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 2d1aad8a1a0..f5b997f9f52 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -2,297 +2,121 @@ package home import ( "std" + "strings" "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" + "gno.land/p/moul/md" ) -// 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 + sections []Section + Ownable = 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() +type Section struct { + text func() string + ordinal uint + enabled bool } -func lastBlogposts(limit int) ui.Element { - posts := blog.RenderLastPostsWidget(limit) - return ui.Element{ - ui.H2("[Latest Blogposts](/r/gnoland/blog)"), - ui.Text(posts), +func init() { + sections = []Section{ + { + text: intro, + ordinal: 0, + enabled: true, + }, + { + text: networkBanner, + ordinal: 1, + enabled: true, + }, } } -func lastContributions(limit int) ui.Element { - return ui.Element{ - ui.H2("Latest Contributions"), - // TODO: import r/gh to - ui.Link{Text: "View latest contributions", URL: "https://github.com/gnolang/gno/pulls"}, +func RotateSections(ord1, ord2 uint) error { + if !Ownable.CallerIsOwner() { + return ownable.ErrUnauthorized } -} -func upcomingEvents() ui.Element { - out, _ := events.RenderEventWidget(events.MaxWidgetSize) - return ui.Element{ - ui.H2("[Latest Events](/r/gnoland/events)"), - ui.Text(out), + if ord1 != ord2 { + sections[ord1], sections[ord2] = sections[ord2], sections[ord1] } -} - -func latestHOFItems(num int) ui.Element { - submissions := hof.RenderExhibWidget(num) - return ui.Element{ - ui.H2("[Hall of Fame](/r/leon/hof)"), - ui.Text(submissions), - } + // sort by ord at the end + return nil } -func introSection() ui.Element { - return ui.Element{ - ui.Text("**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 AddSection(text func() string, ordinal uint8, enabled bool) error { + if !Ownable.CallerIsOwner() { + return ownable.ErrUnauthorized } -} - -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.H2("Contributions (WorxDAO & GoR)"), - // TODO: GoR dashboard + WorxDAO topics - ui.Text(`coming soon`), - } + return nil } -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] +func Render(path string) string { + var out string - return ui.Element{ - ui.H2(ufmt.Sprintf("Quote of the ~Day~ Block#%d", height)), - ui.Quote(qotb), - } -} + 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" + } -func socialLinks() ui.Element { - return ui.Element{ - ui.H2("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](https://discord.gg/S8nKUqwkPn)"), - ui.Text("[Twitter](https://twitter.com/_gnoland)"), - ui.Text("[Youtube](https://www.youtube.com/@_gnoland)"), - ui.Text("[Telegram](https://t.me/gnoland)"), - }, + return out } -} -func playgroundSection() ui.Element { - return ui.Element{ - ui.H2("[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)."), + for _, section := range sections { + if section.enabled { + out += section.text() + } } -} -func packageStaffPicks() ui.Element { - // XXX: make it modifiable from a DAO - return ui.Element{ - ui.H2("Explore New Packages and Realms"), - ui.Columns{ - 3, - []ui.Element{ - { - ui.H3("[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.H3("[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.H3("[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.H3("[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("..."), - }, - }, - }, - }, - } + return out + + // 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 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 intro() 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.`, + ) -
-
`), - } + return out } -func AdminSetOverride(content string) { - admin.AssertCallerIsOwner() - override = content -} +func networkBanner() string { + chain := "Local" + chainid := std.GetChainID() + + 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") + } + } -func AdminTransferOwnership(newAdmin std.Address) { - admin.AssertCallerIsOwner() - admin.TransferOwnership(newAdmin) + return md.H2(ufmt.Sprintf("You're on network `%s`!", chain)) } 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 5b5ff5740c3..00000000000 --- a/examples/gno.land/r/gnoland/home/home_filetest.gno +++ /dev/null @@ -1,196 +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](https://discord.gg/S8nKUqwkPn) -// - [Twitter](https://twitter.com/_gnoland) -// - [Youtube](https://www.youtube.com/@_gnoland) -// - [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