Skip to content

Commit

Permalink
feat(examples): add mason realm to examples + md project (#3726)
Browse files Browse the repository at this point in the history
Hi I'm putting this here so I can be added into the examples folder. I
will also be making a md implementation that's slightly different than
moul and sunspirits but in the same spirit as them.
  • Loading branch information
masonmcbride authored Feb 13, 2025
1 parent 041f56d commit 2e49141
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/gno.land/p/mason/md/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/mason/md
48 changes: 48 additions & 0 deletions examples/gno.land/p/mason/md/md.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package md

import (
"strings"
)

type MD struct {
elements []string
}

func New() *MD {
return &MD{elements: []string{}}
}

func (m *MD) H1(text string) {
m.elements = append(m.elements, "# "+text)
}

func (m *MD) H3(text string) {
m.elements = append(m.elements, "### "+text)
}

func (m *MD) P(text string) {
m.elements = append(m.elements, text)
}

func (m *MD) Code(text string) {
m.elements = append(m.elements, " ```\n"+text+"\n```\n")
}

func (m *MD) Im(path string, caption string) {
m.elements = append(m.elements, "!["+caption+"]("+path+" \""+caption+"\")")
}

func (m *MD) Bullet(point string) {
m.elements = append(m.elements, "- "+point)
}

func Link(text, url string, title ...string) string {
if len(title) > 0 && title[0] != "" {
return "[" + text + "](" + url + " \"" + title[0] + "\")"
}
return "[" + text + "](" + url + ")"
}

func (m *MD) Render() string {
return strings.Join(m.elements, "\n\n")
}
1 change: 1 addition & 0 deletions examples/gno.land/r/mason/home/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/mason/home
77 changes: 77 additions & 0 deletions examples/gno.land/r/mason/home/home.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package home

import (
"gno.land/p/mason/md"
)

const (
gnomeArt1 = ` /\
/ \
,,,,,
(o.o)
(\_/)
-"-"-`
dgnonut = `
#$$$$$$$$*
#$$@@@@@@@@@@$$$#
#$$@@@@@@@@@@@@@$$$$#
#$$$@@@@$$$$$$$$$$$$$$$$*
#$$$$$$$$$$$$$$$$$$$$$$$$$#!
#$$$$$$$$$############$$$$$##*
!##$$$$$$####**********#####$###*
=##$$$$$###****!!!!!!!!!***######*!
*##$$$###***!!!!!!==!!!!!!**######*=
!*#######***!!!=;;;;;====!!!!**####**
!*#######**!!!==;;::::::;;==!!!**###**!
!*######***!==;::~~~~~~:::;;=!!!***#***=
=**#####**!!==;::~-,,,,,--~:;;=!!!******!
!**####***!==;:~-,.. ..,,-~:;==!!******!;
;!**###***!!=;:~-,. ..-~:;==!!*****!=
=!*******!!==::-. .,-::==!!*****!=
=!*******!!=;:~, .-~:;=!!!****!=:
~=!*******!==;:-. .,-:;=!!!****!=;
:=!*******!==;~,. ,-:;==!!!***!=;
:=!******!!==:~, ,-:;=!!!***!!=;
:=!!*****!!=;:~, ,~:;=!!****!!=;-
:=!!!****!!==;~, -~;==!!****!!=;-
:;=!!*****!!=;:- -:;=!!*****!!=:-
~;=!!!****!!==;~ :;=!!*****!!!;:-
~;==!!****!!!==: ;=!!******!!=;:,
~:==!!!****!!!=;~ :=!********!!=;:.
-:;==!!*****!!!!; =!*********!==;:
,~;==!!*******!!== =**#####****!==:~
,~:;=!!!!*********! **#######***!!=;~-
-~;;=!!!!**********! *##$$$$$###***!!=:~.
,~:;==!!!****##########$$$$$$$$###****!=;:~
-~:;==!!!***####$$$$$$@@@@@$$$###**!!=;:~,
,-~:;=!!!***####$$$$@@@@@@$$$$##**!!!=;:-.
-~:;;=!!!***###$$$$$@@@@$$$$##***!!=;:-.
.-~:;;=!!!***###$$$$$$$$$$$##***!==;:~-
.-~:;==!!!!**####$$$$$$$###**!!==;:~-
,-~::;==!!!!***########****!!==;:~-.
,-~:;;==!!!!!***********!!!==;:~,.
,,~~::;====!!!!!!!!!!!!!==;::~,.
.,-~::;;;===!!!!!!!!===;::~-,.
,--~~:;;;;========;;::~--.
.,,-~~:::::::::::~~~-,,.
..,---~~~~~~~~~--,..
..,,,,,,,,,...
...`
)

func Render(path string) string {
home := md.New()
home.H1("Mason's Realm")

home.Im("https://cdn.esawebb.org/archives/images/screen/weic2428a.jpg", "Placeholder")
home.P("Welcome to my realm. " + md.Link("github", "https://github.com/masonmcbride"))

home.H3("Dgnonut")
home.Code(dgnonut)

home.H3("More")
home.Code(gnomeArt1)
home.Bullet("Credit to " + md.Link("JJOptimist", "https://gno.land/r/jjoptimist/home") + " for this gnome art.")
home.Bullet("I'm testing out my markdown system.")
return home.Render()
}

0 comments on commit 2e49141

Please sign in to comment.