-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev/aeddi/gnokms-gnokey-adapter
- Loading branch information
Showing
29 changed files
with
1,629 additions
and
158 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package config | ||
|
||
import ( | ||
"strconv" | ||
|
||
p "gno.land/p/demo/avl/pager" | ||
"gno.land/p/demo/ufmt" | ||
"gno.land/p/moul/md" | ||
"gno.land/p/moul/realmpath" | ||
"gno.land/p/moul/txlink" | ||
) | ||
|
||
var ( | ||
banner = "---\n[[Leon's Home page]](/r/leon/home) | [[Leon's snippets]](/r/leon/config) | [[GitHub: @leohhhn]](https://github.com/leohhhn)\n\n---" | ||
pager = p.NewPager(configs, 10, true) | ||
) | ||
|
||
func Banner() string { | ||
return banner | ||
} | ||
|
||
func Render(path string) (out string) { | ||
req := realmpath.Parse(path) | ||
if req.Path == "" { | ||
out += md.H1("Leon's configs & snippets") | ||
|
||
out += ufmt.Sprintf("Leon's main address: %s\n\n", OwnableMain.Owner().String()) | ||
out += ufmt.Sprintf("Leon's backup address: %s\n\n", OwnableBackup.Owner().String()) | ||
|
||
out += md.H2("Snippets") | ||
|
||
if configs.Size() == 0 { | ||
out += "No configs yet :c\n\n" | ||
} else { | ||
page := pager.MustGetPageByPath(path) | ||
for _, item := range page.Items { | ||
out += ufmt.Sprintf("- [%s](%s:%s)\n\n", item.Value.(Config).name, absPath, item.Key) | ||
} | ||
|
||
out += page.Picker() | ||
out += "\n\n" | ||
out += "Page " + strconv.Itoa(page.PageNumber) + " of " + strconv.Itoa(page.TotalPages) + "\n\n" | ||
} | ||
|
||
out += Banner() | ||
|
||
return out | ||
} | ||
|
||
return renderConfPage(req.Path) | ||
} | ||
|
||
func renderConfPage(id string) (out string) { | ||
raw, ok := configs.Get(id) | ||
if !ok { | ||
out += md.H1("404") | ||
out += "That config does not exist :/" | ||
return out | ||
} | ||
|
||
conf := raw.(Config) | ||
out += md.H1(conf.name) | ||
out += ufmt.Sprintf("```\n%s\n```\n\n", conf.lines) | ||
out += ufmt.Sprintf("_Last updated on %s_\n\n", conf.updated.Format("02 Jan, 2006")) | ||
out += md.HorizontalRule() | ||
out += ufmt.Sprintf("[[EDIT]](%s) - [[DELETE]](%s)", txlink.Call("EditConfig", "id", conf.id.String()), txlink.Call("RemoveConfig", "id", conf.id.String())) | ||
|
||
return out | ||
} |
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
Oops, something went wrong.