1package home
2
3import (
4 "std"
5 "strconv"
6
7 "gno.land/p/demo/ufmt"
8
9 "gno.land/r/demo/art/gnoface"
10 "gno.land/r/demo/art/millipede"
11 "gno.land/r/demo/mirror"
12 "gno.land/r/leon/config"
13 "gno.land/r/leon/hof"
14)
15
16var (
17 pfp string // link to profile picture
18 pfpCaption string // profile picture caption
19 abtMe [2]string
20)
21
22func Render(path string) string {
23 out := "# Leon's Homepage\n\n"
24
25 out += renderAboutMe()
26 out += renderBlogPosts()
27 out += "\n\n"
28 out += renderArt()
29 out += "\n\n"
30 out += config.Banner()
31 out += "\n\n"
32
33 return out
34}
35
36func init() {
37 hof.Register()
38 mirror.Register(std.CurrentRealm().PkgPath(), Render)
39
40 pfp = "https://i.imgflip.com/91vskx.jpg"
41 pfpCaption = "[My favourite painting & pfp](https://en.wikipedia.org/wiki/Wanderer_above_the_Sea_of_Fog)"
42 abtMe = [2]string{
43 `### About me
44Hi, I'm Leon, a DevRel Engineer at gno.land. I am a tech enthusiast,
45life-long learner, and sharer of knowledge.`,
46 `### Contributions
47My contributions to gno.land can mainly be found
48[here](https://github.com/gnolang/gno/issues?q=sort:updated-desc+author:leohhhn).
49
50TODO import r/gh`,
51 }
52}
53
54func UpdatePFP(url, caption string) {
55 if !config.IsAuthorized(std.PreviousRealm().Address()) {
56 panic(config.ErrUnauthorized)
57 }
58
59 pfp = url
60 pfpCaption = caption
61}
62
63func UpdateAboutMe(col1, col2 string) {
64 if !config.IsAuthorized(std.PreviousRealm().Address()) {
65 panic(config.ErrUnauthorized)
66 }
67
68 abtMe[0] = col1
69 abtMe[1] = col2
70}
71
72func renderBlogPosts() string {
73 out := ""
74 // out += "## Leon's Blog Posts"
75
76 // todo fetch blog posts authored by @leohhhn
77 // and render them
78 return out
79}
80
81func renderAboutMe() string {
82 out := "<div class='columns-3'>"
83
84 out += "<div>\n\n"
85 out += ufmt.Sprintf("\n\n%s\n\n", pfp, pfpCaption)
86 out += "</div>\n\n"
87
88 out += "<div>\n\n"
89 out += abtMe[0] + "\n\n"
90 out += "</div>\n\n"
91
92 out += "<div>\n\n"
93 out += abtMe[1] + "\n\n"
94 out += "</div>\n\n"
95
96 out += "</div><!-- /columns-3 -->\n\n"
97
98 return out
99}
100
101func renderArt() string {
102 out := `<div class="jumbotron">` + "\n\n"
103 out += "# Gno Art\n\n"
104
105 out += "<div class='columns-3'>"
106
107 out += renderGnoFace()
108 out += renderMillipede()
109 out += "Empty spot :/"
110
111 out += "</div><!-- /columns-3 -->\n\n"
112
113 out += "This art is dynamic; it will change with every new block.\n\n"
114 out += `</div><!-- /jumbotron -->` + "\n"
115
116 return out
117}
118
119func renderGnoFace() string {
120 out := "<div>\n\n"
121 out += gnoface.Render(strconv.Itoa(int(std.ChainHeight())))
122 out += "</div>\n\n"
123
124 return out
125}
126
127func renderMillipede() string {
128 out := "<div>\n\n"
129 out += "Millipede\n\n"
130 out += "```\n" + millipede.Draw(int(std.ChainHeight())%10+1) + "```\n"
131 out += "</div>\n\n"
132
133 return out
134}
home.gno
2.64 Kb ยท 134 lines