Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gnoweb): template and md style #2223

Merged
merged 17 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/gno.land/p/demo/blog/blog.gno
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (b Blog) RenderPost(res *mux.ResponseWriter, req *mux.Request) {
}
p := post.(*Post)

res.Write("<main class='gno-tmpl-page'>" + "\n\n")

res.Write("# " + p.Title + "\n\n")
res.Write(p.Body + "\n\n")
res.Write("---\n\n")
Expand All @@ -86,6 +88,8 @@ func (b Blog) RenderPost(res *mux.ResponseWriter, req *mux.Request) {
})

res.Write("</details>\n")
res.Write("</main>")

}

func (b Blog) RenderTag(res *mux.ResponseWriter, req *mux.Request) {
Expand Down
10 changes: 10 additions & 0 deletions examples/gno.land/p/demo/ui/ui.gno
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type DOM struct {
// metadata
Prefix string
Title string
Kind string
WithComments bool

// elements
Expand All @@ -20,6 +21,10 @@ type DOM struct {
func (dom DOM) String() string {
output := ""

if dom.Kind != "" {
output += "<main class='gno-tmpl-" + dom.Kind + "'>" + "\n\n"
}

if dom.Title != "" {
output += H1(dom.Title).String(dom) + "\n"
}
Expand All @@ -43,6 +48,7 @@ func (dom DOM) String() string {
output += "<!-- /body -->"
}
}


if footer := dom.Footer.String(dom); footer != "" {
if dom.WithComments {
Expand All @@ -54,6 +60,10 @@ func (dom DOM) String() string {
}
}

if dom.Kind != "" {
output += "</main>"
}

// TODO: cleanup double new-lines.

return output
Expand Down
thehowl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
package gnopages
package events

func init() {
var (
path = "events"
title = "Gno.land Core Team Attends Industry Events & Meetups"
// XXX: description = "If you’re interested in learning more about Gno.land, you can join us at major blockchain industry events throughout the year either in person or virtually."
body = `
If you’re interested in building web3 with us, catch up with Gno.land in person at one of our industry events.
We’re looking to connect with developers and like-minded thinkers who can contribute to the growth of our platform.
import (
"gno.land/p/demo/ui"
)

---
// XXX: p/demo/ui API is crappy, we need to make it more idiomatic
// XXX: use an updatable block system to update content from a DAO
// XXX: var blocks avl.Tree

## Upcoming Events
func Render(_ string) string {
dom := ui.DOM{Prefix: "r/gnoland/events:"}
dom.Title = "Gno.land Core Team Attends Industry Events & Meetups"
dom.Kind = "section"

<div class="columns-3">
// body
dom.Body.Append(introSection()...)
dom.Body.Append(ui.HR{})
dom.Body.Append(upcomingEvents()...)
dom.Body.Append(ui.HR{})
dom.Body.Append(pastEvents()...)

return dom.String()
}


func introSection() ui.Element {
return ui.Element{
ui.Paragraph("If you’re interested in building web3 with us, catch up with Gno.land in person at one of our industry events. We’re looking to connect with developers and like-minded thinkers who can contribute to the growth of our platform."),
}
}


func upcomingEvents() ui.Element {
return ui.Element{
ui.H2("Upcoming Events"),
ui.Text(`<div class="columns-3">
<div class="column">

### Gno @ Golang Serbia
Expand Down Expand Up @@ -60,13 +80,13 @@ We’re looking to connect with developers and like-minded thinkers who can cont
<div class="column">

</div><!-- end column-->
</div><!-- end columns-3-->

---

## Past Events
</div><!-- end columns-3-->`), }
}

<div class="columns-3">
func pastEvents() ui.Element {
return ui.Element{
ui.H2("Past Events"),
ui.Text(`<div class="columns-3">
<div class="column">

### GopherCon US
Expand Down Expand Up @@ -193,7 +213,5 @@ We’re looking to connect with developers and like-minded thinkers who can cont
[Watch the talk](https://www.youtube.com/watch?v=hCLErPgnavI)

</div><!-- end column-->
</div><!-- end columns-3-->`
)
_ = b.NewPost("", path, title, body, "2022-05-20T13:17:24Z", nil, nil)
</div><!-- end columns-3-->`), }
}
7 changes: 7 additions & 0 deletions examples/gno.land/r/gnoland/events/events_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "gno.land/r/gnoland/events"

func main() {
println(events.Render(""))
}
5 changes: 5 additions & 0 deletions examples/gno.land/r/gnoland/events/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/gnoland/events

require (
gno.land/p/demo/ui v0.0.0-latest
)
3 changes: 3 additions & 0 deletions examples/gno.land/r/gnoland/home/home.gno
thehowl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func Render(_ string) string {
dom := ui.DOM{Prefix: "r/gnoland/home:"}
dom.Title = "Welcome to Gno.land"
dom.Kind = "section"

// body
dom.Body.Append(introSection()...)
Expand Down Expand Up @@ -54,6 +55,8 @@ func Render(_ string) string {
return dom.String()
}



func lastBlogposts(limit int) ui.Element {
posts := blog.RenderLastPostsWidget(limit)
return ui.Element{
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/gnoland/pages/page_about.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ making it trivial to verify the contract or fork it into an improved version. Wi
libraries on-chain, Gno.land serves as the “GitHub” of the ecosystem, with realms built using fully transparent,
auditable code that anyone can inspect and reuse.

- test 1
- test 2

Gno.land addresses many pressing issues in the blockchain space, starting with the ease of use and intuitiveness of
alexiscolin marked this conversation as resolved.
Show resolved Hide resolved
smart contract platforms. Developers can write smart contracts without having to learn a new language that’s exclusive
to a single ecosystem or limited by design. Go developers can easily port their existing web apps to Gno.land or build
Expand Down
4 changes: 2 additions & 2 deletions gno.land/pkg/gnoweb/gnoweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func MakeApp(logger *slog.Logger, cfg Config) gotuna.App {
"/testnets": "/r/gnoland/pages:p/testnets",
"/start": "/r/gnoland/pages:p/start",
"/license": "/r/gnoland/pages:p/license",
"/game-of-realms": "/r/gnoland/pages:p/gor", // XXX: replace with gor realm
"/events": "/r/gnoland/pages:p/events", // XXX: replace with events realm
"/game-of-realms": "/r/gnoland/pages:p/gor", // XXX: replace with gor realm
"/events": "/r/gnoland/events", // XXX: replace with events realm
}

for from, to := range aliases {
Expand Down
20 changes: 17 additions & 3 deletions gno.land/pkg/gnoweb/static/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,22 @@ a[href="#"] {
color: var(--muted-color, #757575);
}

ul {
.gno-tmpl-section ul {
padding: 0;
}

li {
.gno-tmpl-section li ,
#header li ,
.footer li {
list-style: none;
margin-bottom: 0.4rem;
}

.gno-tmpl-section blockquote {
margin-inline: 0;
}
thehowl marked this conversation as resolved.
Show resolved Hide resolved

li {
margin-bottom: 0.4rem;
}

li > * {
Expand Down Expand Up @@ -303,6 +312,11 @@ code {
.container p > img:only-child {
max-width: 100%;
}
.gno-tmpl-page p img:only-child {
margin-inline: auto;
display: block;
max-width: 100%;
}

.inline-list {
padding: 1rem;
Expand Down
Loading
Loading