Skip to content

Commit

Permalink
chore: fixup
Browse files Browse the repository at this point in the history
Signed-off-by: moul <[email protected]>
  • Loading branch information
moul committed Dec 6, 2024
1 parent c40f134 commit bbae09f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
14 changes: 11 additions & 3 deletions examples/gno.land/p/moul/web25/web25.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package web25
import "strings"

type Config struct {
CID string
URL string
CID string
URL string
Text string
}

func (c *Config) SetRemoteFrontendByURL(url string) {
Expand All @@ -26,6 +27,8 @@ func (c Config) GetLink() string {
return c.URL
}

const DefaultText = `Click [here]({link}) to visit the full rendering experience.\n`

// Render displays a frontend link at the top of your realm's Render function in
// a concistent way to help gno visitors to have a consistent experience.
//
Expand All @@ -35,5 +38,10 @@ func (c Config) Render(path string) string {
if strings.Contains(path, "?no-web25") {
return ""
}
return "Checkout the full experience from the [web2.5 frontend](" + c.GetLink() + ")"
text := c.Text
if text == "" {
text = DefaultText
}
text = strings.ReplaceAll(text, "{link}", c.GetLink())
return text
}
16 changes: 13 additions & 3 deletions examples/gno.land/r/moul/home/home.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package home
import (
"strconv"

"gno.land/p/moul/mdtable"
"gno.land/p/moul/txlink"
"gno.land/p/moul/umd"
"gno.land/p/moul/web25"
Expand Down Expand Up @@ -41,19 +42,28 @@ func Render(path string) string {
content += umd.H2("Personal ToDo List")
content += umd.BulletItem("test")
for i, todo := range todos {
deleteLink := umd.Link("del", txlink.Call("DeleteTodo", "idx", strconv.Itoa(i)))
deleteLink := umd.Link("x", txlink.Call("DeleteTodo", "idx", strconv.Itoa(i)))
content += umd.BulletItem(todo + " " + deleteLink)
}
content += umd.Paragraph(
umd.Link("new todo", txlink.Call("AddNewTodo")),
umd.Link("new", txlink.Call("AddTodo")),
)

content += umd.H2("Table Example")
// TODO: replace with a useful example
table := mdtable.Table{
Headers: []string{"foo", "bar"},
}
table.Append([]string{"foo1", "bar1"})
table.Append([]string{"foo2", "bar2"})
content += table.String()

// TODO: my r/boards posts
// TODO: my r/events events
return content
}

func AddNewTodo(todo string) {
func AddTodo(todo string) {
config.AssertIsAdmin()
todos = append(todos, todo)
}
Expand Down
11 changes: 8 additions & 3 deletions examples/gno.land/r/moul/home/z1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ func main() {
}

// Output:
// Checkout the full experience from the [web2.5 frontend](https://ipfs.io/ipfs/12345678)# Manfred's (gn)home Dashboard
// Click [here](https://ipfs.io/ipfs/12345678) to visit the full rendering experience.\n# Manfred's (gn)home Dashboard
// ## Meme
// ![meme](https://i.imgflip.com/7ze8dc.jpg)
// ## Status
// Online
// [update](/r/moul/home$help&func=UpdateStatus)## Personal ToDo List
// - test
// - fill this todo list... [del](/r/moul/home$help&func=DeleteTodo&idx=0)
// [new todo](/r/moul/home$help&func=AddNewTodo)
// - fill this todo list... [x](/r/moul/home$help&func=DeleteTodo&idx=0)
// [new](/r/moul/home$help&func=AddTodo)
// ## Table Example
// | foo | bar |
// | --- | --- |
// | foo1 | bar1 |
// | foo2 | bar2 |
//
29 changes: 17 additions & 12 deletions examples/gno.land/r/moul/home/z2_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,33 @@ import (

func main() {
std.TestSetOrigCaller("g1manfred47kzduec920z88wfr64ylksmdcedlf5")
home.AddNewTodo("aaa")
home.AddNewTodo("bbb")
home.AddNewTodo("ccc")
home.AddNewTodo("ddd")
home.AddNewTodo("eee")
home.AddTodo("aaa")
home.AddTodo("bbb")
home.AddTodo("ccc")
home.AddTodo("ddd")
home.AddTodo("eee")
home.UpdateStatus("Lorem Ipsum")
home.DeleteTodo(3)
println(home.Render(""))
}

// Output:
// Checkout the full experience from the [web2.5 frontend](https://ipfs.io/ipfs/12345678)# Manfred's (gn)home Dashboard
// Click [here](https://ipfs.io/ipfs/12345678) to visit the full rendering experience.\n# Manfred's (gn)home Dashboard
// ## Meme
// ![meme](https://i.imgflip.com/7ze8dc.jpg)
// ## Status
// Lorem Ipsum
// [update](/r/moul/home$help&func=UpdateStatus)## Personal ToDo List
// - test
// - fill this todo list... [del](/r/moul/home$help&func=DeleteTodo&idx=0)
// - aaa [del](/r/moul/home$help&func=DeleteTodo&idx=1)
// - bbb [del](/r/moul/home$help&func=DeleteTodo&idx=2)
// - ddd [del](/r/moul/home$help&func=DeleteTodo&idx=3)
// - eee [del](/r/moul/home$help&func=DeleteTodo&idx=4)
// [new todo](/r/moul/home$help&func=AddNewTodo)
// - fill this todo list... [x](/r/moul/home$help&func=DeleteTodo&idx=0)
// - aaa [x](/r/moul/home$help&func=DeleteTodo&idx=1)
// - bbb [x](/r/moul/home$help&func=DeleteTodo&idx=2)
// - ddd [x](/r/moul/home$help&func=DeleteTodo&idx=3)
// - eee [x](/r/moul/home$help&func=DeleteTodo&idx=4)
// [new](/r/moul/home$help&func=AddTodo)
// ## Table Example
// | foo | bar |
// | --- | --- |
// | foo1 | bar1 |
// | foo2 | bar2 |
//

0 comments on commit bbae09f

Please sign in to comment.