-
Notifications
You must be signed in to change notification settings - Fork 387
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: Manfred Touron <[email protected]>
- Loading branch information
Showing
11 changed files
with
194 additions
and
12 deletions.
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
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
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
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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
# Gnolang examples | ||
|
||
Folder contains Gnolang realms and libraries demos. | ||
Share contracts here to improve engine testing, although it's not required. | ||
Consider separate repository for contracts, but this may limit experience due to ongoing gnomod support work. | ||
Main repository can't reference separate code, causing potential development issues. | ||
This folder showcases Gnolang realms and library demos. These examples not only aid in engine testing but also provide a glimpse into the potential of Gnolang's capabilities. | ||
|
||
While sharing contracts here can enhance engine testing, it's not mandatory. If considering a separate repository for contracts, be aware that this might restrict the experience due to the continuous efforts around `gno mod` support. A key point to note is that the main repository cannot reference separate code, which might pose developmental challenges. | ||
|
||
## Personal Realms & Shared Content | ||
|
||
**Prioritizing Shared Content:** As we expand our examples and use-cases, it's essential to prioritize shared content that benefits the broader community. These examples serve as a foundation and reference for all users. | ||
|
||
**Accepting Personal Realms:** We're now open to accepting personal realms. However, with the vision of maintaining a streamlined and universally helpful main repository, personal realms should pave the way for others. They should act as exemplary models and encourage best practices. | ||
|
||
**Recommended Approach:** | ||
- Use `r/demo` and `p/demo` for generic examples and components that can be imported by others. These are meant to be easily referenced and utilized by the community. | ||
- Personal realms are welcomed if they are easily maintainable with the Continuous Integration (CI) system. If a personal realm becomes cumbersome to maintain or doesn't align with the CI's checks, it might be relocated to a less prominent location or even removed. | ||
|
||
## Usage | ||
|
||
Our recommendation is to use the [gno](../gnovm/cmd/gno) utility to develop contracts locally before publishing them on-chain. | ||
This approach offers a faster and streamlined workflow, along with additional debugging features. | ||
Simply fork or create new contracts and refer to the Makefile. | ||
Once everything looks good locally, you can then publish it on a localnet or testnet. | ||
Our recommendation is to use the [gno](../gnovm/cmd/gno) utility to develop contracts locally before publishing them on-chain. This approach offers a faster and streamlined workflow, along with additional debugging features. Simply fork or create new contracts and refer to the Makefile. Once everything looks good locally, you can then publish it on a localnet or testnet. | ||
|
||
See [`awesome-gno` tutorials](https://github.com/gnolang/awesome-gno#tutorials). | ||
For further guidance and insights, please refer to the [`awesome-gno` tutorials](https://github.com/gnolang/awesome-gno#tutorials). |
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,41 @@ | ||
# Manfred's Personal Realms on gno.land | ||
|
||
## Introduction | ||
|
||
Welcome to the root directory of Manfred's personal realms on `gno.land`. Each | ||
realm within this directory serves a specific purpose and offers a glimpse into | ||
Manfred's interests, projects, and more. | ||
|
||
## ⚠️ Disclaimer | ||
|
||
This is a very early iteration and is subject to change frequently. The | ||
structure and content of these realms are still in the experimental phase. The | ||
concept was inspired by Jae Kwon's idea to manage his to-do list in | ||
`jaekwon/home`. If you're using or referencing these realms, be prepared for | ||
regular updates and modifications. | ||
|
||
## Structure | ||
|
||
- `manfred/home`: This is the main realm where Manfred lists items and topics of | ||
interest to him. | ||
`manfred/config`: Configuration used by other realms. | ||
- `manfred/...`: Coming soon. | ||
|
||
## Usage | ||
|
||
Each realm can be accessed and interacted with individually. Typically, realms | ||
implement a `Render()` function which presents the main content or functionality | ||
of that realm. | ||
|
||
## Access Control | ||
|
||
All realms in this directory have a built-in security check to ensure that only | ||
Manfred can interact with the contents in a meaningful way. Unauthorized access | ||
attempts might be able to see the content but will not be able to make | ||
modifications or access certain functionalities. | ||
|
||
## Contributions & Collaboration | ||
|
||
These realms are personal by nature. If you've stumbled upon them and have | ||
suggestions or want to collaborate on a particular topic, please reach out | ||
directly to Manfred. |
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,19 @@ | ||
package config | ||
|
||
import "std" | ||
|
||
var addr = std.Address("g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq") | ||
|
||
func Addr() std.Address { | ||
return addr | ||
} | ||
|
||
func UpdateAddr(newAddr std.Address) { | ||
addr = newAddr | ||
} | ||
|
||
func AssertIsAdmin() { | ||
if std.GetOrigCaller() != addr { | ||
panic("restricted area") | ||
} | ||
} |
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 @@ | ||
module gno.land/r/manfred/config |
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 @@ | ||
module gno.land/r/manfred/home |
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,60 @@ | ||
package home | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/manfred/config" | ||
) | ||
|
||
var ( | ||
todos []string | ||
status string | ||
memeImgURL string | ||
) | ||
|
||
func init() { | ||
todos = append(todos, "fill this todo list...") | ||
status = "Online" // Initial status set to "Online" | ||
memeImgURL = "https://i.imgflip.com/7ze8dc.jpg" | ||
} | ||
|
||
func Render(path string) string { | ||
content := "# Manfred's (gn)home Dashboard\n\n" | ||
|
||
content += "## Meme\n" | ||
content += "![](" + memeImgURL + ")\n\n" | ||
|
||
content += "## Status\n" | ||
content += status + "\n\n" | ||
|
||
content += "## Personal ToDo List\n" | ||
for _, todo := range todos { | ||
content += "- [ ] " + todo + "\n" | ||
} | ||
content += "\n" | ||
|
||
// TODO: Implement a feature to list replies on r/boards on my posts | ||
// TODO: Maybe integrate a calendar feature for upcoming events? | ||
|
||
return content | ||
} | ||
|
||
func AddNewTodo(todo string) { | ||
config.AssertIsAdmin() | ||
todos = append(todos, todo) | ||
} | ||
|
||
func DeleteTodo(todoIndex int) { | ||
config.AssertIsAdmin() | ||
if todoIndex >= 0 && todoIndex < len(todos) { | ||
// Remove the todo from the list by merging slices from before and after the todo | ||
todos = append(todos[:todoIndex], todos[todoIndex+1:]...) | ||
} else { | ||
panic("Invalid todo index") | ||
} | ||
} | ||
|
||
func UpdateStatus(newStatus string) { | ||
config.AssertIsAdmin() | ||
status = newStatus | ||
} |
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,19 @@ | ||
package main | ||
|
||
import "gno.land/r/manfred/home" | ||
|
||
func main() { | ||
println(home.Render("")) | ||
} | ||
|
||
// Output: | ||
// # Manfred's (gn)home Dashboard | ||
// | ||
// ## Meme | ||
// ![](https://i.imgflip.com/7ze8dc.jpg) | ||
// | ||
// ## Status | ||
// Online | ||
// | ||
// ## Personal ToDo List | ||
// - [ ] fill this todo list... |
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,35 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/manfred/home" | ||
) | ||
|
||
func main() { | ||
std.TestSetOrigCaller("g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq") | ||
home.AddNewTodo("aaa") | ||
home.AddNewTodo("bbb") | ||
home.AddNewTodo("ccc") | ||
home.AddNewTodo("ddd") | ||
home.AddNewTodo("eee") | ||
home.UpdateStatus("Lorem Ipsum") | ||
home.DeleteTodo(3) | ||
println(home.Render("")) | ||
} | ||
|
||
// Output: | ||
// # Manfred's (gn)home Dashboard | ||
// | ||
// ## Meme | ||
// ![](https://i.imgflip.com/7ze8dc.jpg) | ||
// | ||
// ## Status | ||
// Lorem Ipsum | ||
// | ||
// ## Personal ToDo List | ||
// - [ ] fill this todo list... | ||
// - [ ] aaa | ||
// - [ ] bbb | ||
// - [ ] ddd | ||
// - [ ] eee |