-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add Trust Factor app #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nezketsu
wants to merge
19
commits into
gnoverse:main
Choose a base branch
from
Nezketsu:feat_add_realm_TrustFactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
31a7f31
add: adding the realm HitTheZone
Nezketsu 41b4c40
add: add some test to my realm
Nezketsu bcf2234
add: add TrustFactor realm
Nezketsu 725b171
add: add TrustFactor realm
Nezketsu 478298e
fix: remove Trust factor
Nezketsu 7d8f21e
add: add TrustFactor realm
Nezketsu 4a9fa29
refactor: improve code quality per PR review feedback
Nezketsu 76a631c
add: widget and comment section
Nezketsu 81ae662
fix: modify std import
Nezketsu fc0bba1
rm: remove .md
Nezketsu 5731942
add: render name with sys/users and add some test
Nezketsu 391b45d
fix: remove hitthezone realm
Nezketsu b699819
fix: fix gno fmt output
Nezketsu 0c9d450
refacto: split logic.gno and - Add txlink import to render.gno
Nezketsu cb20391
fix: fix fmt
Nezketsu 30a25b4
fix: replace useless code by existing package
Nezketsu 40542fb
fix: fmt
Nezketsu 07fcf45
fix: use avl tree for filtering
Nezketsu 0a34fc4
fix comment
Nezketsu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module = "gno.land/r/greg007/trustfactor" | ||
| gno = "0.9" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package trustfactor | ||
|
|
||
| import ( | ||
| "strconv" | ||
| "time" | ||
|
|
||
| "gno.land/r/sys/users" | ||
| ) | ||
|
|
||
| // formatTimeAgo converts a Unix timestamp into a human-readable relative time string. | ||
| // The format varies based on the time elapsed: "Today", "N days ago", "N week(s) ago", etc. | ||
| func formatTimeAgo(timestamp int64) string { | ||
| now := time.Now().Unix() | ||
| daysSince := (now - timestamp) / 86400 | ||
|
|
||
| if daysSince == 0 { | ||
| return "Today" | ||
| } | ||
| if daysSince == 1 { | ||
| return "1 day ago" | ||
| } | ||
| if daysSince < 7 { | ||
| return strconv.FormatInt(daysSince, 10) + " days ago" | ||
| } | ||
| if daysSince < 30 { | ||
| weeks := daysSince / 7 | ||
| return strconv.FormatInt(weeks, 10) + " week(s) ago" | ||
| } | ||
| if daysSince < 365 { | ||
| months := daysSince / 30 | ||
| return strconv.FormatInt(months, 10) + " month(s) ago" | ||
| } | ||
|
|
||
| years := daysSince / 365 | ||
| return strconv.FormatInt(years, 10) + " year(s) ago" | ||
| } | ||
|
|
||
| // getDisplayName returns the registered username from sys/users, or a shortened | ||
| // address if no username is registered for the given address. | ||
| func getDisplayName(addr address) string { | ||
| userData := users.ResolveAddress(addr) | ||
|
|
||
| if userData != nil { | ||
| name := userData.Name() | ||
| if name != "" { | ||
| return name | ||
| } | ||
| } | ||
|
|
||
| return shortenAddress(string(addr), 12, 4) | ||
| } | ||
|
|
||
| // shortenAddress truncates a long address string to show only the prefix and suffix, | ||
| // separated by "..." for display purposes. | ||
| func shortenAddress(addr string, prefixLen, suffixLen int) string { | ||
| if len(addr) <= prefixLen+suffixLen { | ||
| return addr | ||
| } | ||
| return addr[:prefixLen] + "..." + addr[len(addr)-suffixLen:] | ||
| } | ||
|
|
||
| // getConfidenceIcon returns an emoji icon representing the confidence level: | ||
| // 🟢 for high (≥0.8), 🟡 for medium (≥0.5), 🔴 for low (<0.5). | ||
| func getConfidenceIcon(confidence float64) string { | ||
| if confidence >= 0.8 { | ||
| return "🟢" | ||
| } | ||
| if confidence >= 0.5 { | ||
| return "🟡" | ||
| } | ||
| return "🔴" | ||
| } | ||
|
|
||
| // getConfidenceColor returns a hex color code based on confidence level for SVG rendering: | ||
| // black for high confidence, dark gray for medium, light gray for low. | ||
| func getConfidenceColor(confidence float64) string { | ||
| if confidence >= 0.8 { | ||
| return "#000000" | ||
| } | ||
| if confidence >= 0.5 { | ||
| return "#666666" | ||
| } | ||
| return "#CCCCCC" | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.