Skip to content

Commit

Permalink
start sections
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Dec 19, 2024
1 parent a8e9af3 commit 744b2c4
Showing 1 changed file with 83 additions and 15 deletions.
98 changes: 83 additions & 15 deletions examples/gno.land/r/gnoland/home/home.gno
Original file line number Diff line number Diff line change
@@ -1,10 +1,68 @@
package home

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

var sections []string
"gno.land/p/demo/ufmt"
"gno.land/p/moul/md"
)

var (
sections []Section
Ownable = ownable.NewWithAddress("g1manfred47kzduec920z88wfr64ylksmdcedlf5") // @moul
)

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

func init() {
sections = []Section{
{
text: intro,
ordinal: 0,
enabled: true,
},
{
text: networkBanner,
ordinal: 1,
enabled: true,
},
}
}

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

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

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

}

func Render(_ string) string {

var out string
for _, section := range sections {
if section.enabled {
out += section.text()
}
}

return out

// what is gnoland & gno
// Latest in gno.land:
// registered users, blogs, hof items, new pkgs (maybe registry pattern)
Expand All @@ -20,21 +78,31 @@ func Render(_ string) string {

func intro() string {
out := md.H1("Welcome to gno.land")
out += md.H2("We're building gno.land, xyz")
out += md.Paragraph(`gno.land is a blockchain platform that allows users
to have full transparency over the applications they are using`)

text := `
# Welcome to gno.land
gno.land is xyz bla bla
out += md.Paragraph("gno.land is xyz bla bla")
out += md.H2("What is this website?")
out += md.Paragraph(`
You're looking at the universal web frontend for gno.land - ` + "`gnoweb`" + `. Gnoweb queries the gno.land blockchain in
order to get data from smart contracts called realms. This text, and everything on this page is a smart contract
that represents gno.land's home page.`,
)

return out
}

func networkBanner() string {
chain := "Local"
chainid := std.GetChainID()

## What is this website?
You're looking at the universal web frontend for gno.land - ` + "`gnoweb`" + `. Gnoweb queries the gno.land blockchain in
order to get data from smart contracts called realms. This text, and everything on this page is a smart contract
that represents gno.land's home page.`
switch chainid {
case "portal-loop":
chain = "the Portal Loop"
case "dev":
chain = "Local"
default:
if strings.HasPrefix(chainid, "test") {
chain = "Test" + strings.TrimPrefix(chainid, "test")
}
}

return out
return md.H2(ufmt.Sprintf("You're on network `%s`!", chain))
}

0 comments on commit 744b2c4

Please sign in to comment.