Skip to content

Commit

Permalink
feat: portal loop's main contracts and gnoweb improvements (gnolang#1176
Browse files Browse the repository at this point in the history
)

Addresses gnolang#1131

## Completed Tasks

-  [x] Completed the home page by adding static content and blocks.
-  [x] Implemented support for redirects and aliases to improve SEO.
- [x] Made some improvements to p/demo/ui, but more work is still
needed.
-  [x] Enhanced p/demo/blog by adding widget support.
-  [x] Transferred previous static webpages to realms.
- [x] Created a new personal realm `p/manfred/present` for a Gno-powered
presentation.
- [x] Refactored gnoweb to remove static pages, improve maintainability
and design consistency, and added optional analytics.

## Next Steps after Merging

- Anyone:
  - Improve r/gnoland/home.
- Create and enhance additional `p/demo/*` pages to simplify maintenance
of `r/gnoland/home`.
- Start writing personal and team realms to incorporate more dynamic
data on-chain. Consider adding these realms as widgets on the homepage.
- Encourage individuals to create dedicated realms, preferably dynamic
ones. Then, import these new realms into the homepage to include widgets
such as "upcoming events."
- Manfred:
- Develop dynamic contracts for Worxdao, including project, team, and
people directories. Also, implement DAO features v0 and contributor
profiles.

---------

Signed-off-by: moul <[email protected]>
  • Loading branch information
moul authored and thehowl committed Oct 21, 2023
1 parent 8c72b4c commit 112ca15
Show file tree
Hide file tree
Showing 37 changed files with 1,603 additions and 290 deletions.
51 changes: 35 additions & 16 deletions examples/gno.land/p/demo/blog/blog.gno
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,28 @@ import (
)

type Blog struct {
Title string
Prefix string // i.e. r/gnoland/blog:
Posts avl.Tree // slug -> Post
Title string
Prefix string // i.e. r/gnoland/blog:
Posts avl.Tree // slug -> Post
NoBreadcrumb bool
}

func (b Blog) RenderLastPostsWidget(limit int) string {
output := ""
i := 0
b.Posts.Iterate("", "", func(key string, value interface{}) bool {
p := value.(*Post)
output += ufmt.Sprintf("- [%s](%s)\n", p.Title, p.URL())
i++
return i >= limit
})
return output
}

func (b Blog) RenderHome(res *mux.ResponseWriter, req *mux.Request) {
res.Write(breadcrumb([]string{b.Title}))
if !b.NoBreadcrumb {
res.Write(breadcrumb([]string{b.Title}))
}

if b.Posts.Size() == 0 {
res.Write("No posts.")
Expand Down Expand Up @@ -47,12 +62,14 @@ func (b Blog) RenderPost(res *mux.ResponseWriter, req *mux.Request) {
}
p := post.(*Post)

breadStr := breadcrumb([]string{
ufmt.Sprintf("[%s](%s)", b.Title, b.Prefix),
"p",
p.Title,
})
res.Write(breadStr)
if !b.NoBreadcrumb {
breadStr := breadcrumb([]string{
ufmt.Sprintf("[%s](%s)", b.Title, b.Prefix),
"p",
p.Title,
})
res.Write(breadStr)
}

// output += ufmt.Sprintf("## [%s](%s)\n", p.Title, p.URL())
res.Write(p.Body + "\n\n")
Expand All @@ -75,12 +92,14 @@ func (b Blog) RenderTag(res *mux.ResponseWriter, req *mux.Request) {
return
}

breadStr := breadcrumb([]string{
ufmt.Sprintf("[%s](%s)", b.Title, b.Prefix),
"t",
slug,
})
res.Write(breadStr)
if !b.NoBreadcrumb {
breadStr := breadcrumb([]string{
ufmt.Sprintf("[%s](%s)", b.Title, b.Prefix),
"t",
slug,
})
res.Write(breadStr)
}

nb := 0
b.Posts.Iterate("", "", func(key string, value interface{}) bool {
Expand Down
44 changes: 43 additions & 1 deletion examples/gno.land/p/demo/ui/ui.gno
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ui

import "strings"
import (
"strconv"
"strings"
)

type DOM struct {
// metadata
Expand Down Expand Up @@ -56,6 +59,17 @@ func (dom DOM) String() string {
return output
}

type Jumbotron []DomStringer

func (j Jumbotron) String(dom DOM) string {
output := `<div class="jumbotron">` + "\n\n"
for _, elem := range j {
output += elem.String(dom) + "\n"
}
output += `</div><!-- /jumbotron -->` + "\n"
return output
}

// XXX: rename Element to Div?
type Element []DomStringer

Expand Down Expand Up @@ -88,6 +102,26 @@ func (b Breadcrumb) String(dom DOM) string {
return output
}

type Columns struct {
MaxWidth int
Columns []Element
}

func (c *Columns) Append(elems ...Element) {
c.Columns = append(c.Columns, elems...)
}

func (c Columns) String(dom DOM) string {
output := `<div class="columns-` + strconv.Itoa(c.MaxWidth) + `">` + "\n"
for _, entry := range c.Columns {
output += `<div class="column">` + "\n\n"
output += entry.String(dom)
output += "</div><!-- /column-->\n"
}
output += "</div><!-- /columns-" + strconv.Itoa(c.MaxWidth) + " -->\n"
return output
}

type Link struct {
Text string
Path string
Expand All @@ -104,8 +138,14 @@ func (l Link) String(dom DOM) string {
case l.Path != "" && l.URL != "":
panic("a link should have a path or a URL, not both.")
case l.Path != "":
if l.Text == "" {
l.Text = l.Path
}
url = dom.Prefix + l.Path
case l.URL != "":
if l.Text == "" {
l.Text = l.URL
}
url = l.URL
}

Expand Down Expand Up @@ -151,6 +191,7 @@ type (
Italic string
Code string
Paragraph string
Quote string
HR struct{}
)

Expand All @@ -160,6 +201,7 @@ func (text H3) String(_ DOM) string { return "### " + string(text) + "\n"
func (text H4) String(_ DOM) string { return "#### " + string(text) + "\n" }
func (text H5) String(_ DOM) string { return "##### " + string(text) + "\n" }
func (text H6) String(_ DOM) string { return "###### " + string(text) + "\n" }
func (text Quote) String(_ DOM) string { return "> " + string(text) + "\n" }
func (text Bold) String(_ DOM) string { return "**" + string(text) + "**" }
func (text Italic) String(_ DOM) string { return "_" + string(text) + "_" }
func (text Paragraph) String(_ DOM) string { return "\n" + string(text) + "\n" }
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/gnoland/blog/gnoblog.gno
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ func AddComment(postSlug, comment string) {
func Render(path string) string {
return b.Render(path)
}

func RenderLastPostsWidget(limit int) string {
return b.RenderLastPostsWidget(limit)
}
8 changes: 8 additions & 0 deletions examples/gno.land/r/gnoland/home/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module gno.land/r/gnoland/home

require (
"gno.land/r/gnoland/blog" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/ui" v0.0.0-latest
)
Loading

0 comments on commit 112ca15

Please sign in to comment.