-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: moul <[email protected]>
- Loading branch information
Showing
5 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
examples/gno.land/r/moul/present/present_miami23_filetest.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |