Search Apps Documentation Source Content File Folder Download Copy

home.gno

8.20 Kb · 298 lines
  1package home
  2
  3import (
  4	"std"
  5
  6	"gno.land/p/demo/ownable"
  7	"gno.land/p/demo/ufmt"
  8	"gno.land/p/demo/ui"
  9	blog "gno.land/r/gnoland/blog"
 10	events "gno.land/r/gnoland/events"
 11	"gno.land/r/leon/hof"
 12)
 13
 14// XXX: p/demo/ui API is crappy, we need to make it more idiomatic
 15// XXX: use an updatable block system to update content from a DAO
 16// XXX: var blocks avl.Tree
 17
 18var (
 19	override string
 20	admin    = ownable.NewWithAddress("g1manfred47kzduec920z88wfr64ylksmdcedlf5") // @moul
 21)
 22
 23func Render(_ string) string {
 24	if override != "" {
 25		return override
 26	}
 27
 28	dom := ui.DOM{Prefix: "r/gnoland/home:"}
 29	dom.Title = "Welcome to gno.land"
 30	dom.Classes = []string{"gno-tmpl-section"}
 31
 32	// body
 33	dom.Body.Append(introSection()...)
 34
 35	dom.Body.Append(ui.Jumbotron(discoverLinks()))
 36
 37	dom.Body.Append(
 38		ui.Columns{3, []ui.Element{
 39			lastBlogposts(4),
 40			upcomingEvents(),
 41			latestHOFItems(5),
 42		}},
 43	)
 44
 45	dom.Body.Append(ui.HR{})
 46	dom.Body.Append(playgroundSection()...)
 47	dom.Body.Append(ui.HR{})
 48	dom.Body.Append(packageStaffPicks()...)
 49	dom.Body.Append(ui.HR{})
 50	dom.Body.Append(worxDAO()...)
 51	dom.Body.Append(ui.HR{})
 52	// footer
 53	dom.Footer.Append(
 54		ui.Columns{2, []ui.Element{
 55			socialLinks(),
 56			quoteOfTheBlock(),
 57		}},
 58	)
 59
 60	// Testnet disclaimer
 61	dom.Footer.Append(
 62		ui.HR{},
 63		ui.Bold("This is a testnet."),
 64		ui.Text("Package names are not guaranteed to be available for production."),
 65	)
 66
 67	return dom.String()
 68}
 69
 70func lastBlogposts(limit int) ui.Element {
 71	posts := blog.RenderLastPostsWidget(limit)
 72	return ui.Element{
 73		ui.H2("[Latest Blogposts](/r/gnoland/blog)"),
 74		ui.Text(posts),
 75	}
 76}
 77
 78func lastContributions(limit int) ui.Element {
 79	return ui.Element{
 80		ui.H2("Latest Contributions"),
 81		// TODO: import r/gh to
 82		ui.Link{Text: "View latest contributions", URL: "https://github.com/gnolang/gno/pulls"},
 83	}
 84}
 85
 86func upcomingEvents() ui.Element {
 87	out, _ := events.RenderEventWidget(events.MaxWidgetSize)
 88	return ui.Element{
 89		ui.H2("[Latest Events](/r/gnoland/events)"),
 90		ui.Text(out),
 91	}
 92}
 93
 94func latestHOFItems(num int) ui.Element {
 95	submissions := hof.RenderExhibWidget(num)
 96
 97	return ui.Element{
 98		ui.H2("[Hall of Fame](/r/leon/hof)"),
 99		ui.Text(submissions),
100	}
101}
102
103func introSection() ui.Element {
104	return ui.Element{
105		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.**"),
106		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."),
107		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."),
108	}
109}
110
111func worxDAO() ui.Element {
112	// WorxDAO
113	// XXX(manfred): please, let me finish a v0, then we can iterate
114	// highest level == highest responsibility
115	// teams are responsible for components they don't owne
116	// flag : realm maintainers VS facilitators
117	// teams
118	// committee of trustees to create the directory
119	// each directory is a name, has a parent and have groups
120	// homepage team - blocks aggregating events
121	// XXX: TODO
122	/*`
123	# Directory
124
125	* gno.land (owned by group)
126	  *
127	* gnovm
128	  * gnolang (language)
129	  * gnovm
130	    - current challenges / concerns / issues
131	* tm2
132	  * amino
133	  *
134
135	## Contributors
136	``*/
137	return ui.Element{
138		ui.H2("Contributions (WorxDAO & GoR)"),
139		// TODO: GoR dashboard + WorxDAO topics
140		ui.Text(`coming soon`),
141	}
142}
143
144func quoteOfTheBlock() ui.Element {
145	quotes := []string{
146		"Gno is for Truth.",
147		"Gno is for Social Coordination.",
148		"Gno is _not only_ for DeFi.",
149		"Now, you Gno.",
150		"Come for the Go, Stay for the Gno.",
151	}
152	height := std.GetHeight()
153	idx := int(height) % len(quotes)
154	qotb := quotes[idx]
155
156	return ui.Element{
157		ui.H2(ufmt.Sprintf("Quote of the ~Day~ Block#%d", height)),
158		ui.Quote(qotb),
159	}
160}
161
162func socialLinks() ui.Element {
163	return ui.Element{
164		ui.H2("Socials"),
165		ui.BulletList{
166			// XXX: improve UI to support a nice GO api for such links
167			ui.Text("Check out our [community projects](https://github.com/gnolang/awesome-gno)"),
168			ui.Text("[Discord](https://discord.gg/S8nKUqwkPn)"),
169			ui.Text("[Twitter](https://twitter.com/_gnoland)"),
170			ui.Text("[Youtube](https://www.youtube.com/@_gnoland)"),
171			ui.Text("[Telegram](https://t.me/gnoland)"),
172		},
173	}
174}
175
176func playgroundSection() ui.Element {
177	return ui.Element{
178		ui.H2("[Gno Playground](https://play.gno.land)"),
179		ui.Paragraph(`Gno Playground is a web application designed for building, running, testing, and interacting
180with your Gno code, enhancing your understanding of the Gno language. With Gno Playground, you can share your code,
181execute tests, deploy your realms and packages to gno.land, and explore a multitude of other features.`),
182		ui.Paragraph("Experience the convenience of code sharing and rapid experimentation with [Gno Playground](https://play.gno.land)."),
183	}
184}
185
186func packageStaffPicks() ui.Element {
187	// XXX: make it modifiable from a DAO
188	return ui.Element{
189		ui.H2("Explore New Packages and Realms"),
190		ui.Columns{
191			3,
192			[]ui.Element{
193				{
194					ui.H3("[r/gnoland](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/gnoland)"),
195					ui.BulletList{
196						ui.Link{URL: "r/gnoland/blog"},
197						ui.Link{URL: "r/gnoland/dao"},
198						ui.Link{URL: "r/gnoland/faucet"},
199						ui.Link{URL: "r/gnoland/home"},
200						ui.Link{URL: "r/gnoland/pages"},
201					},
202					ui.H3("[r/sys](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/sys)"),
203					ui.BulletList{
204						ui.Link{URL: "r/sys/names"},
205						ui.Link{URL: "r/sys/rewards"},
206						ui.Link{URL: "/r/sys/validators/v2"},
207					},
208				}, {
209					ui.H3("[r/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/r/demo)"),
210					ui.BulletList{
211						ui.Link{URL: "r/demo/boards"},
212						ui.Link{URL: "r/demo/users"},
213						ui.Link{URL: "r/demo/banktest"},
214						ui.Link{URL: "r/demo/foo20"},
215						ui.Link{URL: "r/demo/foo721"},
216						ui.Link{URL: "r/demo/microblog"},
217						ui.Link{URL: "r/demo/nft"},
218						ui.Link{URL: "r/demo/types"},
219						ui.Link{URL: "r/demo/art/gnoface"},
220						ui.Link{URL: "r/demo/art/millipede"},
221						ui.Link{URL: "r/demo/groups"},
222						ui.Text("..."),
223					},
224				}, {
225					ui.H3("[p/demo](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/demo)"),
226					ui.BulletList{
227						ui.Link{URL: "p/demo/avl"},
228						ui.Link{URL: "p/demo/blog"},
229						ui.Link{URL: "p/demo/ui"},
230						ui.Link{URL: "p/demo/ufmt"},
231						ui.Link{URL: "p/demo/merkle"},
232						ui.Link{URL: "p/demo/bf"},
233						ui.Link{URL: "p/demo/flow"},
234						ui.Link{URL: "p/demo/gnode"},
235						ui.Link{URL: "p/demo/grc/grc20"},
236						ui.Link{URL: "p/demo/grc/grc721"},
237						ui.Text("..."),
238					},
239				},
240			},
241		},
242	}
243}
244
245func discoverLinks() ui.Element {
246	return ui.Element{
247		ui.Text(`<div class="columns-3">
248<div class="column">
249
250## Learn about gno.land
251
252- [About](/about)
253- [GitHub](https://github.com/gnolang)
254- [Blog](/blog)
255- [Events](/events)
256- Tokenomics (soon)
257- [Partners, Fund, Grants](/partners)
258- [Explore the Ecosystem](/ecosystem)
259- [Careers](https://jobs.ashbyhq.com/allinbits)
260
261</div><!-- end column-->
262
263<div class="column">
264
265## Build with Gno
266
267- [Write Gno in the browser](https://play.gno.land)
268- [Read about the Gno Language](/gnolang)
269- [Visit the official documentation](https://docs.gno.land)
270- [Gno by Example](https://gno-by-example.com/)
271- [Efficient local development for Gno](https://docs.gno.land/gno-tooling/cli/gno-tooling-gnodev)
272- [Get testnet GNOTs](https://faucet.gno.land)
273
274</div><!-- end column-->
275<div class="column">
276
277## Explore the universe
278
279- [Discover demo packages](https://github.com/gnolang/gno/tree/master/examples)
280- [Gnoscan](https://gnoscan.io)
281- [Portal Loop](https://docs.gno.land/concepts/portal-loop)
282- [Testnet 4](https://test4.gno.land/)
283- [Faucet Hub](https://faucet.gno.land)
284
285</div><!-- end column-->
286</div><!-- end columns-3-->`),
287	}
288}
289
290func AdminSetOverride(content string) {
291	admin.AssertCallerIsOwner()
292	override = content
293}
294
295func AdminTransferOwnership(newAdmin std.Address) {
296	admin.AssertCallerIsOwner()
297	admin.TransferOwnership(newAdmin)
298}