home.gno

5.61 Kb · 206 lines
  1package home
  2
  3import (
  4	"std"
  5	"strconv"
  6
  7	"gno.land/p/demo/ownable"
  8	"gno.land/p/demo/ui"
  9	"gno.land/p/moul/dynreplacer"
 10	blog "gno.land/r/gnoland/blog"
 11	events "gno.land/r/gnoland/events"
 12	"gno.land/r/leon/hof"
 13)
 14
 15// XXX: p/demo/ui API is crappy, we need to make it more idiomatic
 16// XXX: use an updatable block system to update content from a DAO
 17// XXX: var blocks avl.Tree
 18
 19var (
 20	override string
 21	Admin    = ownable.NewWithAddress("g1manfred47kzduec920z88wfr64ylksmdcedlf5") // @moul
 22)
 23
 24func Render(_ string) string {
 25	r := dynreplacer.New()
 26	r.RegisterCallback(":latest-blogposts:", func() string {
 27		return blog.RenderLastPostsWidget(4)
 28	})
 29	r.RegisterCallback(":upcoming-events:", func() string {
 30		out, _ := events.RenderEventWidget(events.MaxWidgetSize)
 31		return out
 32	})
 33	r.RegisterCallback(":latest-hof:", func() string {
 34		return hof.RenderExhibWidget(5)
 35	})
 36	r.RegisterCallback(":qotb:", quoteOfTheBlock)
 37	r.RegisterCallback(":chain-height:", func() string {
 38		return strconv.Itoa(int(std.ChainHeight()))
 39	})
 40
 41	template := `# Welcome to gno.land
 42
 43We’re building gno.land, set to become the leading open-source smart contract
 44platform, using Gno, an interpreted and fully deterministic variation of the
 45Go programming language for succinct and composable smart contracts.
 46
 47With transparent and timeless code, gno.land is the next generation of smart
 48contract platforms, serving as the “GitHub” of the ecosystem, with realms built
 49using fully transparent, auditable code that anyone can inspect and reuse.
 50
 51Intuitive and easy to use, gno.land lowers the barrier to web3 and makes
 52censorship-resistant platforms accessible to everyone. If you want to help lay
 53the foundations of a fairer and freer world, join us today. 
 54
 55## Learn about gno.land
 56
 57- [About](/about)
 58- [GitHub](https://github.com/gnolang)
 59- [Blog](/blog)
 60- [Events](/events)
 61- Tokenomics (soon)
 62- [Partners, Fund, Grants](/partners)
 63- [Explore the Ecosystem](/ecosystem)
 64- [Careers](https://jobs.ashbyhq.com/allinbits)
 65
 66## Build with Gno
 67
 68- [Write Gno in the browser](https://play.gno.land)
 69- [Read about the Gno Language](/gnolang)
 70- [Visit the official documentation](https://docs.gno.land)
 71- [Gno by Example](https://gno-by-example.com/)
 72- [Efficient local development for Gno](https://docs.gno.land/gno-tooling/cli/gno-tooling-gnodev)
 73- [Get testnet GNOTs](https://faucet.gno.land)
 74
 75## Explore the universe
 76
 77- [Discover demo packages](https://github.com/gnolang/gno/tree/master/examples)
 78- [Gnoscan](https://gnoscan.io)
 79- [Portal Loop](https://docs.gno.land/concepts/portal-loop)
 80- [Testnet 4](https://test4.gno.land/)
 81- [Faucet Hub](https://faucet.gno.land)
 82
 83## [Latest Blogposts](/r/gnoland/blog)
 84
 85:latest-blogposts:
 86
 87## [Latest Events](/r/gnoland/events)
 88
 89:upcoming-events:
 90
 91## [Hall of Fame](/r/leon/hof)
 92
 93:latest-hof:
 94
 95---
 96
 97## [Gno Playground](https://play.gno.land)
 98
 99
100Gno Playground is a web application designed for building, running, testing, and
101interacting with your Gno code, enhancing your understanding of the Gno
102language. With Gno Playground, you can share your code, execute tests, deploy
103your realms and packages to gno.land, and explore a multitude of other features.
104
105Experience the convenience of code sharing and rapid experimentation with
106[Gno Playground](https://play.gno.land).
107
108## Explore New Packages and Realms
109
110### [r/gnoland](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/gnoland)
111
112- [r/gnoland/blog](r/gnoland/blog)
113- [r/gnoland/dao](r/gnoland/dao)
114- [r/gnoland/faucet](r/gnoland/faucet)
115- [r/gnoland/home](r/gnoland/home)
116- [r/gnoland/pages](r/gnoland/pages)
117
118### [r/sys](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/sys)
119
120- [r/sys/names](r/sys/names)
121- [r/sys/rewards](r/sys/rewards)
122- [/r/sys/validators/v2](/r/sys/validators/v2)
123
124### [r/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/demo)
125
126- [r/demo/boards](r/demo/boards)
127- [r/demo/users](r/demo/users)
128- [r/demo/banktest](r/demo/banktest)
129- [r/demo/foo20](r/demo/foo20)
130- [r/demo/foo721](r/demo/foo721)
131- [r/demo/microblog](r/demo/microblog)
132- [r/demo/nft](r/demo/nft)
133- [r/demo/types](r/demo/types)
134- [r/demo/art/gnoface](r/demo/art/gnoface)
135- [r/demo/art/millipede](r/demo/art/millipede)
136- [r/demo/groups](r/demo/groups)
137- ...
138
139### [p/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/demo)
140
141- [p/demo/avl](p/demo/avl)
142- [p/demo/blog](p/demo/blog)
143- [p/demo/ui](p/demo/ui)
144- [p/demo/ufmt](p/demo/ufmt)
145- [p/demo/merkle](p/demo/merkle)
146- [p/demo/bf](p/demo/bf)
147- [p/demo/flow](p/demo/flow)
148- [p/demo/gnode](p/demo/gnode)
149- [p/demo/grc/grc20](p/demo/grc/grc20)
150- [p/demo/grc/grc721](p/demo/grc/grc721)
151- ...
152
153---
154
155## Socials
156
157- Check out our [community projects](https://github.com/gnolang/awesome-gno)
158- [Discord](https://discord.gg/S8nKUqwkPn)
159- [Twitter](https://twitter.com/_gnoland)
160- [Youtube](https://www.youtube.com/@_gnoland)
161- [Telegram](https://t.me/gnoland)
162
163## Quote of the ~Day~ Block#:chain-height:
164
165> :qotb:
166
167---
168
169**This is a testnet.**
170Package names are not guaranteed to be available for production.
171`
172
173	if override != "" {
174		template = override
175	}
176	result := r.Replace(template)
177	return result
178}
179
180func latestHOFItems(num int) ui.Element {
181	submissions := hof.RenderExhibWidget(num)
182
183	return ui.Element{
184		ui.H2("[Hall of Fame](/r/leon/hof)"),
185		ui.Text(submissions),
186	}
187}
188
189func quoteOfTheBlock() string {
190	quotes := []string{
191		"Gno is for Truth.",
192		"Gno is for Social Coordination.",
193		"Gno is _not only_ for DeFi.",
194		"Now, you Gno.",
195		"Come for the Go, Stay for the Gno.",
196	}
197	height := std.ChainHeight()
198	idx := int(height) % len(quotes)
199	qotb := quotes[idx]
200	return qotb
201}
202
203func AdminSetOverride(content string) {
204	Admin.AssertCallerIsOwner()
205	override = content
206}