buttons.gno
1.09 Kb ยท 44 lines
1package buttons
2
3import (
4 "std"
5
6 "gno.land/p/demo/ufmt"
7 "gno.land/p/moul/txlink"
8)
9
10var (
11 motd = "The Initial Message\n\n"
12 lastCaller std.Address
13)
14
15func UpdateMOTD(newmotd string) {
16 motd = newmotd
17 lastCaller = std.PreviousRealm().Address()
18}
19
20func Render(path string) string {
21 if path == "motd" {
22 out := "# Message of the Day:\n\n"
23 out += "---\n\n"
24 out += "# " + motd + "\n\n"
25 out += "---\n\n"
26 link := txlink.Call("UpdateMOTD", "newmotd", "Message!") // "/r/docs/buttons$help&func=UpdateMOTD&newmotd=Message!"
27 out += ufmt.Sprintf("Click **[here](%s)** to update the Message of The Day!\n\n", link)
28 out += "[Go back to home page](/r/docs/buttons)\n\n"
29 out += "Last updated by " + lastCaller.String()
30
31 return out
32 }
33
34 out := `# Buttons
35
36Users can create simple hyperlink buttons to view specific realm pages and
37do specific realm actions, such as calling a specific function with some arguments.
38
39The foundation for this functionality are markdown links; for example, you can
40click...
41` + "\n## [here](/r/docs/buttons:motd)\n" + `...to view this realm's message of the day.`
42
43 return out
44}