Skip to content

Commit

Permalink
admin dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Dec 19, 2024
1 parent 744b2c4 commit 86b5e9d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions examples/gno.land/r/gnoland/home/home.gno
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package home

import (
"github.com/gnolang/gno/examples/gno.land/p/demo/ownable"
"std"
"strings"

"gno.land/p/demo/ownable"
"gno.land/p/demo/ufmt"
"gno.land/p/moul/md"
)
Expand All @@ -16,7 +16,7 @@ var (

type Section struct {
text func() string
ordinal uint8
ordinal uint
enabled bool
}

Expand All @@ -35,26 +35,40 @@ func init() {
}
}

func UpdateSection(ord1, ord2 uint8) error {
func UpdateSection(ord1, ord2 uint) error {
if !Ownable.CallerIsOwner() {
return ownable.ErrUnauthorized
}

if ord1 != ord2 {
sections[ord1], sections[ord2] = sections[ord2], sections[ord1]
}

// sort by ord at the end
return nil
}

func AddSection(text string, ordinal uint8, enabled bool) error {
func AddSection(text func() string, ordinal uint8, enabled bool) error {
if !Ownable.CallerIsOwner() {
return ownable.ErrUnauthorized
}

return nil
}

func Render(_ string) string {

func Render(path string) string {
var out string

if path == "admin" {
for _, section := range sections {
out += md.H3(ufmt.Sprintf("Section Ordinal: %d, enabled: %t", section.ordinal, section.enabled))
out += section.text()
out += "---\n\n"
}

return out
}

for _, section := range sections {
if section.enabled {
out += section.text()
Expand Down

0 comments on commit 86b5e9d

Please sign in to comment.