Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: r/gnoland/home #3371

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/gno.land/p/moul/web25/web25.gno
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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" {
Expand Down
340 changes: 82 additions & 258 deletions examples/gno.land/r/gnoland/home/home.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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(`<div class="columns-3">
<div class="column">

## 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)

</div><!-- end column-->

<div class="column">

## 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)

</div><!-- end column-->
<div class="column">

## 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.`,
)

</div><!-- end column-->
</div><!-- end columns-3-->`),
}
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))
}
Loading
Loading