From f98f6ed8b23b7f44dd08ec8cc7feed790cbfd9d1 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sun, 8 Dec 2024 23:19:09 +0100 Subject: [PATCH 1/7] save --- examples/gno.land/r/gnoland/home/home.gno | 302 +----------------- .../gno.land/r/gnoland/home/home_filetest.gno | 197 ------------ .../r/gnoland/home/overide_filetest.gno | 24 -- 3 files changed, 10 insertions(+), 513 deletions(-) delete mode 100644 examples/gno.land/r/gnoland/home/home_filetest.gno delete mode 100644 examples/gno.land/r/gnoland/home/overide_filetest.gno diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index facb1817fe2..1e6e56a14cc 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -1,298 +1,16 @@ package home -import ( - "std" - - "gno.land/p/demo/ownable" - "gno.land/p/demo/ufmt" - "gno.land/p/demo/ui" - blog "gno.land/r/gnoland/blog" - events "gno.land/r/gnoland/events" - "gno.land/r/leon/hof" -) - -// XXX: p/demo/ui API is crappy, we need to make it more idiomatic -// XXX: use an updatable block system to update content from a DAO -// XXX: var blocks avl.Tree - -var ( - override string - admin = ownable.NewWithAddress("g1manfred47kzduec920z88wfr64ylksmdcedlf5") // @moul -) - func Render(_ string) string { - if override != "" { - return override - } - - dom := ui.DOM{Prefix: "r/gnoland/home:"} - dom.Title = "Welcome to gno.land" - dom.Classes = []string{"gno-tmpl-section"} - - // body - dom.Body.Append(introSection()...) - - dom.Body.Append(ui.Jumbotron(discoverLinks())) - - dom.Body.Append( - ui.Columns{3, []ui.Element{ - lastBlogposts(4), - upcomingEvents(), - latestHOFItems(5), - }}, - ) - - dom.Body.Append(ui.HR{}) - dom.Body.Append(playgroundSection()...) - dom.Body.Append(ui.HR{}) - dom.Body.Append(packageStaffPicks()...) - dom.Body.Append(ui.HR{}) - dom.Body.Append(worxDAO()...) - dom.Body.Append(ui.HR{}) - // footer - dom.Footer.Append( - ui.Columns{2, []ui.Element{ - socialLinks(), - quoteOfTheBlock(), - }}, - ) - - // Testnet disclaimer - dom.Footer.Append( - ui.HR{}, - ui.Bold("This is a testnet."), - ui.Text("Package names are not guaranteed to be available for production."), - ) - - return dom.String() -} - -func lastBlogposts(limit int) ui.Element { - posts := blog.RenderLastPostsWidget(limit) - return ui.Element{ - ui.H3("[Latest Blogposts](/r/gnoland/blog)"), - ui.Text(posts), - } -} - -func lastContributions(limit int) ui.Element { - return ui.Element{ - ui.H3("Latest Contributions"), - // TODO: import r/gh to - ui.Link{Text: "View latest contributions", URL: "https://github.com/gnolang/gno/pulls"}, - } -} - -func upcomingEvents() ui.Element { - out, _ := events.RenderEventWidget(events.MaxWidgetSize) - return ui.Element{ - ui.H3("[Latest Events](/r/gnoland/events)"), - ui.Text(out), - } -} - -func latestHOFItems(num int) ui.Element { - submissions := hof.RenderExhibWidget(num) - - return ui.Element{ - ui.H3("[Hall of Fame](/r/leon/hof)"), - ui.Text(submissions), - } -} - -func introSection() ui.Element { - return ui.Element{ - ui.H3("We’re building gno.land, set to become the leading open-source smart contract platform, using Gno, an interpreted and fully deterministic variation of the Go programming language for succinct and composable smart contracts."), - ui.Paragraph("With transparent and timeless code, gno.land is the next generation of smart contract platforms, serving as the “GitHub” of the ecosystem, with realms built using fully transparent, auditable code that anyone can inspect and reuse."), - ui.Paragraph("Intuitive and easy to use, gno.land lowers the barrier to web3 and makes censorship-resistant platforms accessible to everyone. If you want to help lay the foundations of a fairer and freer world, join us today."), - } -} - -func worxDAO() ui.Element { - // WorxDAO - // XXX(manfred): please, let me finish a v0, then we can iterate - // highest level == highest responsibility - // teams are responsible for components they don't owne - // flag : realm maintainers VS facilitators - // teams - // committee of trustees to create the directory - // each directory is a name, has a parent and have groups - // homepage team - blocks aggregating events - // XXX: TODO - /*` - # Directory - - * gno.land (owned by group) - * - * gnovm - * gnolang (language) - * gnovm - - current challenges / concerns / issues - * tm2 - * amino - * - ## Contributors - ``*/ - return ui.Element{ - ui.H3("Contributions (WorxDAO & GoR)"), - // TODO: GoR dashboard + WorxDAO topics - ui.Text(`coming soon`), - } -} - -func quoteOfTheBlock() ui.Element { - quotes := []string{ - "Gno is for Truth.", - "Gno is for Social Coordination.", - "Gno is _not only_ for DeFi.", - "Now, you Gno.", - "Come for the Go, Stay for the Gno.", - } - height := std.GetHeight() - idx := int(height) % len(quotes) - qotb := quotes[idx] - - return ui.Element{ - ui.H3(ufmt.Sprintf("Quote of the ~Day~ Block#%d", height)), - ui.Quote(qotb), - } -} - -func socialLinks() ui.Element { - return ui.Element{ - ui.H3("Socials"), - ui.BulletList{ - // XXX: improve UI to support a nice GO api for such links - ui.Text("Check out our [community projects](https://github.com/gnolang/awesome-gno)"), - ui.Text("![Discord](static/img/ico-discord.svg) [Discord](https://discord.gg/S8nKUqwkPn)"), - ui.Text("![Twitter](static/img/ico-twitter.svg) [Twitter](https://twitter.com/_gnoland)"), - ui.Text("![Youtube](static/img/ico-youtube.svg) [Youtube](https://www.youtube.com/@_gnoland)"), - ui.Text("![Telegram](static/img/ico-telegram.svg) [Telegram](https://t.me/gnoland)"), - }, - } -} - -func playgroundSection() ui.Element { - return ui.Element{ - ui.H3("[Gno Playground](https://play.gno.land)"), - ui.Paragraph(`Gno Playground is a web application designed for building, running, testing, and interacting -with your Gno code, enhancing your understanding of the Gno language. With Gno Playground, you can share your code, -execute tests, deploy your realms and packages to gno.land, and explore a multitude of other features.`), - ui.Paragraph("Experience the convenience of code sharing and rapid experimentation with [Gno Playground](https://play.gno.land)."), - } -} - -func packageStaffPicks() ui.Element { - // XXX: make it modifiable from a DAO - return ui.Element{ - ui.H3("Explore New Packages and Realms"), - ui.Columns{ - 3, - []ui.Element{ - { - ui.H4("[r/gnoland](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/gnoland)"), - ui.BulletList{ - ui.Link{URL: "r/gnoland/blog"}, - ui.Link{URL: "r/gnoland/dao"}, - ui.Link{URL: "r/gnoland/faucet"}, - ui.Link{URL: "r/gnoland/home"}, - ui.Link{URL: "r/gnoland/pages"}, - }, - ui.H4("[r/sys](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/sys)"), - ui.BulletList{ - ui.Link{URL: "r/sys/names"}, - ui.Link{URL: "r/sys/rewards"}, - ui.Link{URL: "/r/sys/validators/v2"}, - }, - }, { - ui.H4("[r/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/demo)"), - ui.BulletList{ - ui.Link{URL: "r/demo/boards"}, - ui.Link{URL: "r/demo/users"}, - ui.Link{URL: "r/demo/banktest"}, - ui.Link{URL: "r/demo/foo20"}, - ui.Link{URL: "r/demo/foo721"}, - ui.Link{URL: "r/demo/microblog"}, - ui.Link{URL: "r/demo/nft"}, - ui.Link{URL: "r/demo/types"}, - ui.Link{URL: "r/demo/art/gnoface"}, - ui.Link{URL: "r/demo/art/millipede"}, - ui.Link{URL: "r/demo/groups"}, - ui.Text("..."), - }, - }, { - ui.H4("[p/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/demo)"), - ui.BulletList{ - ui.Link{URL: "p/demo/avl"}, - ui.Link{URL: "p/demo/blog"}, - ui.Link{URL: "p/demo/ui"}, - ui.Link{URL: "p/demo/ufmt"}, - ui.Link{URL: "p/demo/merkle"}, - ui.Link{URL: "p/demo/bf"}, - ui.Link{URL: "p/demo/flow"}, - ui.Link{URL: "p/demo/gnode"}, - ui.Link{URL: "p/demo/grc/grc20"}, - ui.Link{URL: "p/demo/grc/grc721"}, - ui.Text("..."), - }, - }, - }, - }, - } -} - -func discoverLinks() ui.Element { - return ui.Element{ - ui.Text(`
-
- -### Learn about gno.land - -- [About](/about) -- [GitHub](https://github.com/gnolang) -- [Blog](/blog) -- [Events](/events) -- Tokenomics (soon) -- [Partners, Fund, Grants](/partners) -- [Explore the Ecosystem](/ecosystem) -- [Careers](https://jobs.ashbyhq.com/allinbits) - -
- -
- -### Build with Gno - -- [Write Gno in the browser](https://play.gno.land) -- [Read about the Gno Language](/gnolang) -- [Visit the official documentation](https://docs.gno.land) -- [Gno by Example](https://gno-by-example.com/) -- [Efficient local development for Gno](https://docs.gno.land/gno-tooling/cli/gno-tooling-gnodev) -- [Get testnet GNOTs](https://faucet.gno.land) - -
-
- -### Explore the universe - -- [Discover demo packages](https://github.com/gnolang/gno/tree/master/examples) -- [Gnoscan](https://gnoscan.io) -- [Portal Loop](https://docs.gno.land/concepts/portal-loop) -- [Testnet 4](https://test4.gno.land/) -- [Faucet Hub](https://faucet.gno.land) - -
-
`), - } -} - -func AdminSetOverride(content string) { - admin.AssertCallerIsOwner() - override = content -} + // what is gnoland & gno + // Latest in gno.land: + // registered users, blogs, hof items, new pkgs (maybe registry pattern) + // User? view r/ + // Dev? View r/docs + // view: examples (p/ & r/), + // footer: + // looking at X chain's home realm render + // links, other stats + // -func AdminTransferOwnership(newAdmin std.Address) { - admin.AssertCallerIsOwner() - admin.TransferOwnership(newAdmin) } diff --git a/examples/gno.land/r/gnoland/home/home_filetest.gno b/examples/gno.land/r/gnoland/home/home_filetest.gno deleted file mode 100644 index 4825c9fc588..00000000000 --- a/examples/gno.land/r/gnoland/home/home_filetest.gno +++ /dev/null @@ -1,197 +0,0 @@ -package main - -import "gno.land/r/gnoland/home" - -func main() { - println(home.Render("")) -} - -// Output: -//
-// -// # Welcome to gno.land -// -// ### We’re building gno.land, set to become the leading open-source smart contract platform, using Gno, an interpreted and fully deterministic variation of the Go programming language for succinct and composable smart contracts. -// -// -// With transparent and timeless code, gno.land is the next generation of smart contract platforms, serving as the “GitHub” of the ecosystem, with realms built using fully transparent, auditable code that anyone can inspect and reuse. -// -// -// Intuitive and easy to use, gno.land lowers the barrier to web3 and makes censorship-resistant platforms accessible to everyone. If you want to help lay the foundations of a fairer and freer world, join us today. -// -//
-// -//
-//
-// -// ### Learn about gno.land -// -// - [About](/about) -// - [GitHub](https://github.com/gnolang) -// - [Blog](/blog) -// - [Events](/events) -// - Tokenomics (soon) -// - [Partners, Fund, Grants](/partners) -// - [Explore the Ecosystem](/ecosystem) -// - [Careers](https://jobs.ashbyhq.com/allinbits) -// -//
-// -//
-// -// ### Build with Gno -// -// - [Write Gno in the browser](https://play.gno.land) -// - [Read about the Gno Language](/gnolang) -// - [Visit the official documentation](https://docs.gno.land) -// - [Gno by Example](https://gno-by-example.com/) -// - [Efficient local development for Gno](https://docs.gno.land/gno-tooling/cli/gno-tooling-gnodev) -// - [Get testnet GNOTs](https://faucet.gno.land) -// -//
-//
-// -// ### Explore the universe -// -// - [Discover demo packages](https://github.com/gnolang/gno/tree/master/examples) -// - [Gnoscan](https://gnoscan.io) -// - [Portal Loop](https://docs.gno.land/concepts/portal-loop) -// - [Testnet 4](https://test4.gno.land/) -// - [Faucet Hub](https://faucet.gno.land) -// -//
-//
-//
-// -//
-//
-// -// ### [Latest Blogposts](/r/gnoland/blog) -// -// No posts. -//
-//
-// -// ### [Latest Events](/r/gnoland/events) -// -// No events. -//
-//
-// -// ### [Hall of Fame](/r/leon/hof) -// -// -//
-//
-// -// -// --- -// -// ### [Gno Playground](https://play.gno.land) -// -// -// Gno Playground is a web application designed for building, running, testing, and interacting -// with your Gno code, enhancing your understanding of the Gno language. With Gno Playground, you can share your code, -// execute tests, deploy your realms and packages to gno.land, and explore a multitude of other features. -// -// -// Experience the convenience of code sharing and rapid experimentation with [Gno Playground](https://play.gno.land). -// -// -// --- -// -// ### Explore New Packages and Realms -// -//
-//
-// -// #### [r/gnoland](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/gnoland) -// -// - [r/gnoland/blog](r/gnoland/blog) -// - [r/gnoland/dao](r/gnoland/dao) -// - [r/gnoland/faucet](r/gnoland/faucet) -// - [r/gnoland/home](r/gnoland/home) -// - [r/gnoland/pages](r/gnoland/pages) -// -// #### [r/sys](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/sys) -// -// - [r/sys/names](r/sys/names) -// - [r/sys/rewards](r/sys/rewards) -// - [/r/sys/validators/v2](/r/sys/validators/v2) -// -//
-//
-// -// #### [r/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/demo) -// -// - [r/demo/boards](r/demo/boards) -// - [r/demo/users](r/demo/users) -// - [r/demo/banktest](r/demo/banktest) -// - [r/demo/foo20](r/demo/foo20) -// - [r/demo/foo721](r/demo/foo721) -// - [r/demo/microblog](r/demo/microblog) -// - [r/demo/nft](r/demo/nft) -// - [r/demo/types](r/demo/types) -// - [r/demo/art/gnoface](r/demo/art/gnoface) -// - [r/demo/art/millipede](r/demo/art/millipede) -// - [r/demo/groups](r/demo/groups) -// - ... -// -//
-//
-// -// #### [p/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/demo) -// -// - [p/demo/avl](p/demo/avl) -// - [p/demo/blog](p/demo/blog) -// - [p/demo/ui](p/demo/ui) -// - [p/demo/ufmt](p/demo/ufmt) -// - [p/demo/merkle](p/demo/merkle) -// - [p/demo/bf](p/demo/bf) -// - [p/demo/flow](p/demo/flow) -// - [p/demo/gnode](p/demo/gnode) -// - [p/demo/grc/grc20](p/demo/grc/grc20) -// - [p/demo/grc/grc721](p/demo/grc/grc721) -// - ... -// -//
-//
-// -// -// --- -// -// ### Contributions (WorxDAO & GoR) -// -// coming soon -// -// --- -// -// -//
-//
-// -// ### Socials -// -// - Check out our [community projects](https://github.com/gnolang/awesome-gno) -// - ![Discord](static/img/ico-discord.svg) [Discord](https://discord.gg/S8nKUqwkPn) -// - ![Twitter](static/img/ico-twitter.svg) [Twitter](https://twitter.com/_gnoland) -// - ![Youtube](static/img/ico-youtube.svg) [Youtube](https://www.youtube.com/@_gnoland) -// - ![Telegram](static/img/ico-telegram.svg) [Telegram](https://t.me/gnoland) -// -//
-//
-// -// ### Quote of the ~Day~ Block#123 -// -// > Now, you Gno. -// -//
-//
-// -// -// --- -// -// **This is a testnet.** -// Package names are not guaranteed to be available for production. -// -//
diff --git a/examples/gno.land/r/gnoland/home/overide_filetest.gno b/examples/gno.land/r/gnoland/home/overide_filetest.gno deleted file mode 100644 index be7e33501d6..00000000000 --- a/examples/gno.land/r/gnoland/home/overide_filetest.gno +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "std" - - "gno.land/p/demo/testutils" - "gno.land/r/gnoland/home" -) - -func main() { - std.TestSetOrigCaller("g1manfred47kzduec920z88wfr64ylksmdcedlf5") - home.AdminSetOverride("Hello World!") - println(home.Render("")) - home.AdminTransferOwnership(testutils.TestAddress("newAdmin")) - defer func() { - r := recover() - println("r: ", r) - }() - home.AdminSetOverride("Not admin anymore") -} - -// Output: -// Hello World! -// r: ownable: caller is not owner From d40cb830ea64f8801465aa79764c76c3a859680c Mon Sep 17 00:00:00 2001 From: leohhhn Date: Mon, 9 Dec 2024 11:07:41 +0100 Subject: [PATCH 2/7] home, typos --- examples/gno.land/p/moul/web25/web25.gno | 6 +++--- examples/gno.land/r/gnoland/home/home.gno | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/gno.land/p/moul/web25/web25.gno b/examples/gno.land/p/moul/web25/web25.gno index 46d564b70ad..80addd46d2a 100644 --- a/examples/gno.land/p/moul/web25/web25.gno +++ b/examples/gno.land/p/moul/web25/web25.gno @@ -1,4 +1,4 @@ -// Pacakge web25 provides an opinionated way to register an external web2 +// Package web25 provides an opinionated way to register an external web2 // frontend to provide a "better" web2.5 experience. package web25 @@ -34,9 +34,9 @@ func (c Config) GetLink() string { 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. +// a consistent way to help gno visitors to have a consistent experience. // -// if query is not nil, then it will check if it's not disable by ?no-web25, so +// if query is not nil, then it will check if it's not disabled by ?no-web25, so // that you can call the render function from an external point of view. func (c Config) Render(path string) string { if realmpath.Parse(path).Query.Get("no-web25") == "1" { diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index 1e6e56a14cc..fc22b8b7efa 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -1,16 +1,27 @@ package home -func Render(_ string) string { +import "github.com/gnolang/gno/examples/gno.land/p/moul/md" + +var sections []string +func Render(_ string) string { // what is gnoland & gno // Latest in gno.land: // registered users, blogs, hof items, new pkgs (maybe registry pattern) + // learn about gno:pages, github + // // User? view r/ // Dev? View r/docs // view: examples (p/ & r/), // footer: // looking at X chain's home realm render // links, other stats - // +} + +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`) } From a8e9af3f90a01755f6febb516448c2ad9a170e8f Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 19 Dec 2024 12:28:49 +0100 Subject: [PATCH 3/7] add text --- examples/gno.land/r/gnoland/home/home.gno | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index fc22b8b7efa..c4741b9eebc 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -24,4 +24,17 @@ func intro() string { 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 + + + + ## 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.` + + return out } From 744b2c49bcc7bbda0a634b6c2d8a63ee25dd8c37 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 19 Dec 2024 14:16:33 +0100 Subject: [PATCH 4/7] start sections --- examples/gno.land/r/gnoland/home/home.gno | 98 +++++++++++++++++++---- 1 file changed, 83 insertions(+), 15 deletions(-) diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index c4741b9eebc..8667a03c517 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -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) @@ -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)) } From 86b5e9d74c21ce868b07492a9da78bb29b9dd019 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 19 Dec 2024 14:28:27 +0100 Subject: [PATCH 5/7] admin dashboard --- examples/gno.land/r/gnoland/home/home.gno | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index 8667a03c517..636ceb1c2dc 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -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" ) @@ -16,7 +16,7 @@ var ( type Section struct { text func() string - ordinal uint8 + ordinal uint enabled bool } @@ -35,7 +35,7 @@ func init() { } } -func UpdateSection(ord1, ord2 uint8) error { +func UpdateSection(ord1, ord2 uint) error { if !Ownable.CallerIsOwner() { return ownable.ErrUnauthorized } @@ -43,18 +43,32 @@ func UpdateSection(ord1, ord2 uint8) error { 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() From 23aef0bad0800e00c9e52dd831fc4df067b10543 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 19 Dec 2024 14:28:54 +0100 Subject: [PATCH 6/7] func name --- examples/gno.land/r/gnoland/home/home.gno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index 636ceb1c2dc..f5b997f9f52 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -35,7 +35,7 @@ func init() { } } -func UpdateSection(ord1, ord2 uint) error { +func RotateSections(ord1, ord2 uint) error { if !Ownable.CallerIsOwner() { return ownable.ErrUnauthorized } From 03126af57fd7e997ac55103288a0e3f6d62eddea Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 23 Jan 2025 19:17:18 +0100 Subject: [PATCH 7/7] save --- examples/gno.land/r/gnoland/home/home.gno | 56 +++++++++++++++-------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index f5b997f9f52..79d1d662f0f 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -10,25 +10,30 @@ import ( ) var ( - sections []Section + sections []section Ownable = ownable.NewWithAddress("g1manfred47kzduec920z88wfr64ylksmdcedlf5") // @moul ) -type Section struct { - text func() string +type section struct { + text string ordinal uint enabled bool } func init() { - sections = []Section{ + sections = []section{ { - text: intro, + text: introSection(), ordinal: 0, enabled: true, }, { - text: networkBanner, + text: mainSection(), + ordinal: 1, + enabled: true, + }, + { + text: networkBanner(), ordinal: 1, enabled: true, }, @@ -44,11 +49,11 @@ func RotateSections(ord1, ord2 uint) error { sections[ord1], sections[ord2] = sections[ord2], sections[ord1] } - // sort by ord at the end + // todo sort by ord at the end return nil } -func AddSection(text func() string, ordinal uint8, enabled bool) error { +func AddSection(text string, ordinal uint8, enabled bool) error { if !Ownable.CallerIsOwner() { return ownable.ErrUnauthorized } @@ -62,7 +67,7 @@ func Render(path string) 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 += section.text out += "---\n\n" } @@ -71,12 +76,11 @@ func Render(path string) string { for _, section := range sections { if section.enabled { - out += section.text() + out += section.text } } return out - // what is gnoland & gno // Latest in gno.land: // registered users, blogs, hof items, new pkgs (maybe registry pattern) @@ -90,19 +94,26 @@ func Render(path string) string { // links, other stats } -func intro() string { +func introSection() string { out := md.H1("Welcome to gno.land") - 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.`, - ) + out += md.Paragraph(md.Bold(`We’re building gno.land, set to become the leading open-source smart contract platform, +using Gno, an interpreted and fully deterministic variation of the Go programming language for succinct and +composable smart contracts.`)) + + out += md.Paragraph(`With transparent and timeless code, gno.land is the next generation of smart contract platforms, +serving as the “GitHub” of the ecosystem, with realms built using fully transparent, auditable code that anyone can +inspect and reuse.`) + + out += md.Paragraph(`Intuitive and easy to use, gno.land lowers the barrier to web3 and makes censorship-resistant +platforms accessible to everyone. If you want to help lay the foundations of a fairer and freer world, join us today.`) return out } +func mainSection() { + +} + func networkBanner() string { chain := "Local" chainid := std.GetChainID() @@ -120,3 +131,10 @@ func networkBanner() string { return md.H2(ufmt.Sprintf("You're on network `%s`!", chain)) } + +//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.`, +//)