Skip to content

Commit

Permalink
using helplink
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Oct 22, 2024
1 parent 5f1d73a commit cd2814e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/hof/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ require (
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
gno.land/p/moul/helplink v0.0.0-latest
)
19 changes: 7 additions & 12 deletions examples/gno.land/r/demo/hof/rendering.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
"gno.land/p/demo/fqname"
"gno.land/p/demo/seqid"
"gno.land/p/demo/ufmt"
hl "gno.land/p/moul/helplink"
)

const (
likesBar = "#### [%d 👍](/r/demo/hof?help&__func=Upvote&pkgpath=%s) - [%d 👎](/r/demo/hof?help&__func=Downvote&pkgPath=%s)\n\n"
delBar = "[Delete](/r/demo/hof?help&__func=Delete&pkgpath=%s)\n\n"
pageSize = 20
)

func Render(path string) string {
out := "# Hall of Fame\n\n"

out += exhibition.Render(path, path == "dashboard")

return out
Expand Down Expand Up @@ -56,19 +56,14 @@ func (i Item) Render(dashboard bool) string {
out += ufmt.Sprintf("by %s\n\n", strings.Split(i.pkgpath, "/")[2])
out += ufmt.Sprintf("[View realm](%s)\n\n", fqname.ShortPath(i.pkgpath))
out += ufmt.Sprintf("Published at Block #%d\n\n", i.blockNum)
out += ufmt.Sprintf(
likesBar,
i.upvote.Size(),
i.pkgpath,
i.downvote.Size(),
i.pkgpath,

out += ufmt.Sprintf("#### [%d👍](%s) - [%d👎](%s)\n\n",
i.upvote.Size(), hl.FuncURL("Upvote", "pkgpath", i.pkgpath),
i.downvote.Size(), hl.FuncURL("Downvote", "pkgpath", i.pkgpath),
)

if dashboard {
out += ufmt.Sprintf(
delBar,
i.pkgpath,
)
out += hl.Func("Delete", "Delete", "pkgpath", i.pkgpath)
}

return out
Expand Down

0 comments on commit cd2814e

Please sign in to comment.