-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): add mason realm to examples + md project (#3726)
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
1 parent
041f56d
commit 2e49141
Showing
4 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module gno.land/p/mason/md |
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,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") | ||
} |
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 @@ | ||
module gno.land/r/mason/home |
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,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() | ||
} |