From 9fdc7ba32a624c91b808e39605137afd254a6fa0 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 6 Mar 2024 14:04:09 +0100 Subject: [PATCH 1/4] sort widget, add condition, change title slightly --- examples/gno.land/p/demo/blog/blog.gno | 6 +++++- examples/gno.land/r/gnoland/blog/admin.gno | 2 +- examples/gno.land/r/gnoland/home/home.gno | 2 +- examples/gno.land/r/gnoland/home/home_filetest.gno | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/gno.land/p/demo/blog/blog.gno b/examples/gno.land/p/demo/blog/blog.gno index 6be11336b0c..2c9c0e89359 100644 --- a/examples/gno.land/p/demo/blog/blog.gno +++ b/examples/gno.land/p/demo/blog/blog.gno @@ -21,9 +21,13 @@ type Blog struct { } func (b Blog) RenderLastPostsWidget(limit int) string { + if b.PostsPublished.Size() == 0 { + return "No posts." + } + output := "" i := 0 - b.Posts.Iterate("", "", func(key string, value interface{}) bool { + b.PostsPublished.ReverseIterate("", "", func(key string, value interface{}) bool { p := value.(*Post) output += ufmt.Sprintf("- [%s](%s)\n", p.Title, p.URL()) i++ diff --git a/examples/gno.land/r/gnoland/blog/admin.gno b/examples/gno.land/r/gnoland/blog/admin.gno index f615e26e491..16129774329 100644 --- a/examples/gno.land/r/gnoland/blog/admin.gno +++ b/examples/gno.land/r/gnoland/blog/admin.gno @@ -16,7 +16,7 @@ var ( func init() { // adminAddr = std.GetOrigCaller() // FIXME: find a way to use this from the main's genesis. - adminAddr = "g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq" + adminAddr = "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" } func AdminSetAdminAddr(addr std.Address) { diff --git a/examples/gno.land/r/gnoland/home/home.gno b/examples/gno.land/r/gnoland/home/home.gno index a33c312e572..93b3229da44 100644 --- a/examples/gno.land/r/gnoland/home/home.gno +++ b/examples/gno.land/r/gnoland/home/home.gno @@ -54,7 +54,7 @@ func Render(_ string) string { func lastBlogposts(limit int) ui.Element { posts := blog.RenderLastPostsWidget(limit) return ui.Element{ - ui.H3("Last Blogposts"), + ui.H3("Latest Blogposts"), ui.Text(posts), } } diff --git a/examples/gno.land/r/gnoland/home/home_filetest.gno b/examples/gno.land/r/gnoland/home/home_filetest.gno index 97796a5947d..2cc6adc5e29 100644 --- a/examples/gno.land/r/gnoland/home/home_filetest.gno +++ b/examples/gno.land/r/gnoland/home/home_filetest.gno @@ -64,7 +64,7 @@ func main() { //
//
// -//### Last Blogposts +//### Latest Blogposts // // //
From 512167b9a1167a9588418c2b040130264139a6d7 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 6 Mar 2024 14:05:59 +0100 Subject: [PATCH 2/4] bring back original admin --- examples/gno.land/r/gnoland/blog/admin.gno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gno.land/r/gnoland/blog/admin.gno b/examples/gno.land/r/gnoland/blog/admin.gno index 16129774329..f615e26e491 100644 --- a/examples/gno.land/r/gnoland/blog/admin.gno +++ b/examples/gno.land/r/gnoland/blog/admin.gno @@ -16,7 +16,7 @@ var ( func init() { // adminAddr = std.GetOrigCaller() // FIXME: find a way to use this from the main's genesis. - adminAddr = "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" + adminAddr = "g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq" } func AdminSetAdminAddr(addr std.Address) { From f4f9341cd7a1304c8deafd284899500bbe535a36 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 6 Mar 2024 14:49:31 +0100 Subject: [PATCH 3/4] fix test --- examples/gno.land/r/gnoland/home/home_filetest.gno | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/gno.land/r/gnoland/home/home_filetest.gno b/examples/gno.land/r/gnoland/home/home_filetest.gno index 2cc6adc5e29..4d1d3b840cf 100644 --- a/examples/gno.land/r/gnoland/home/home_filetest.gno +++ b/examples/gno.land/r/gnoland/home/home_filetest.gno @@ -66,6 +66,7 @@ func main() { // //### Latest Blogposts // +// No posts. // //
//
From f46dd2cbd36f5a5aadda531c24be0cd58b4c9ea7 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 6 Mar 2024 14:52:58 +0100 Subject: [PATCH 4/4] fix test, again --- examples/gno.land/r/gnoland/home/home_filetest.gno | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/gno.land/r/gnoland/home/home_filetest.gno b/examples/gno.land/r/gnoland/home/home_filetest.gno index 4d1d3b840cf..a612efc26fd 100644 --- a/examples/gno.land/r/gnoland/home/home_filetest.gno +++ b/examples/gno.land/r/gnoland/home/home_filetest.gno @@ -66,8 +66,7 @@ func main() { // //### Latest Blogposts // -// No posts. -// +//No posts. //
//
//