Skip to content

Commit

Permalink
chore: fixup
Browse files Browse the repository at this point in the history
Signed-off-by: moul <[email protected]>
  • Loading branch information
moul committed Feb 4, 2025
1 parent 66bf936 commit a9f9fad
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 1 deletion.
96 changes: 96 additions & 0 deletions examples/gno.land/r/moul/present/admin.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package present

import (
"std"
"strings"

"gno.land/p/demo/avl"
)

var (
adminAddr std.Address
moderatorList avl.Tree
inPause bool
)

func init() {
// adminAddr = std.GetOrigCaller() // FIXME: find a way to use this from the main's genesis.
adminAddr = "g1manfred47kzduec920z88wfr64ylksmdcedlf5"
}

func AdminSetAdminAddr(addr std.Address) {
assertIsAdmin()
adminAddr = addr
}

func AdminSetInPause(state bool) {
assertIsAdmin()
inPause = state
}

func AdminAddModerator(addr std.Address) {
assertIsAdmin()
moderatorList.Set(addr.String(), true)
}

func AdminRemoveModerator(addr std.Address) {
assertIsAdmin()
moderatorList.Set(addr.String(), false) // XXX: delete instead?
}

func ModAddPost(slug, title, body, publicationDate, authors, tags string) {
assertIsModerator()

caller := std.GetOrigCaller()
tagList := strings.Split(tags, ",")
authorList := strings.Split(authors, ",")

err := b.NewPost(caller, slug, title, body, publicationDate, authorList, tagList)
checkErr(err)
}

func ModEditPost(slug, title, body, publicationDate, authors, tags string) {
assertIsModerator()

tagList := strings.Split(tags, ",")
authorList := strings.Split(authors, ",")

err := b.GetPost(slug).Update(title, body, publicationDate, authorList, tagList)
checkErr(err)
}

func isAdmin(addr std.Address) bool {
return addr == adminAddr
}

func isModerator(addr std.Address) bool {
_, found := moderatorList.Get(addr.String())
return found
}

func assertIsAdmin() {
caller := std.GetOrigCaller()
if !isAdmin(caller) {
panic("access restricted.")
}
}

func assertIsModerator() {
caller := std.GetOrigCaller()
if isAdmin(caller) || isModerator(caller) {
return
}
panic("access restricted")
}

func assertNotInPause() {
if inPause {
panic("access restricted (pause)")
}
}

func checkErr(err error) {
if err != nil {
panic(err)
}
}
1 change: 0 additions & 1 deletion examples/gno.land/r/moul/present/gno.mod

This file was deleted.

42 changes: 42 additions & 0 deletions examples/gno.land/r/moul/present/present_miami23.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package present

func init() {
path := "miami23"
title := "Portal Loop Demo (Miami 2023)"
body := `
Rendered by Gno.
[Source (WIP)](https://github.com/gnolang/gno/pull/1176)
## Portal Loop
- DONE: Dynamic homepage, key pages, aliases, and redirects.
- TODO: Deploy with history, complete worxdao v0.
- Will replace the static gno.land site.
- Enhances local development.
[GitHub Issue](https://github.com/gnolang/gno/issues/1108)
## Roadmap
- Crafting the roadmap this week, open to collaboration.
- Combining onchain (portal loop) and offchain (GitHub).
- Next week: Unveiling the official v0 roadmap.
## Teams, DAOs, Projects
- Developing worxDAO contracts for directories of projects and teams.
- GitHub teams and projects align with this structure.
- CODEOWNER file updates coming.
- Initial teams announced next week.
## Tech Team Retreat Plan
- Continue Portal Loop.
- Consider dApp development.
- Explore new topics [here](https://github.com/orgs/gnolang/projects/15/).
- Engage in workshops.
- Connect and have fun with colleagues.
`
_ = b.NewPost(adminAddr, path, title, body, "2023-10-15T13:17:24Z", []string{"moul"}, []string{"demo", "portal-loop", "miami"})
}
11 changes: 11 additions & 0 deletions examples/gno.land/r/moul/present/present_miami23_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"gno.land/r/moul/present"
)

func main() {
println(present.Render(""))
println("------------------------------------")
println(present.Render("p/miami23"))
}
17 changes: 17 additions & 0 deletions examples/gno.land/r/moul/present/presentations.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package present

import (
"gno.land/p/demo/blog"
)

// TODO: switch from p/blog to p/present

var b = &blog.Blog{
Title: "Manfred's Presentations",
Prefix: "/r/moul/present:",
NoBreadcrumb: true,
}

func Render(path string) string {
return b.Render(path)
}

0 comments on commit a9f9fad

Please sign in to comment.