home.gno

1.29 Kb ยท 82 lines
 1package home
 2
 3import (
 4	"std"
 5	"strconv"
 6	"time"
 7
 8	"gno.land/r/leon/hof"
 9)
10
11const (
12	gnomeArt1 = `   /\
13  /  \
14 ,,,,,
15(o.o)
16(\_/)
17-"-"-`
18
19	gnomeArt2 = `   /\
20  /  \
21 ,,,,,
22(^.^)
23(\_/)
24 -"-`
25
26	gnomeArt3 = `   /\
27  /  \
28 ,,,,,
29(*.*)
30(\_/)
31"-"-"`
32
33	gnomeArt4 = `   /\
34  /  \
35 ,,,,,
36(o.~)
37(\_/)
38 -"-`
39)
40
41var creation time.Time
42
43func getGnomeArt(height int64) string {
44	var art string
45	switch {
46	case height%7 == 0:
47		art = gnomeArt4 // winking gnome
48	case height%5 == 0:
49		art = gnomeArt3 // starry-eyed gnome
50	case height%3 == 0:
51		art = gnomeArt2 // happy gnome
52	default:
53		art = gnomeArt1 // regular gnome
54	}
55	return "```\n" + art + "\n```\n"
56}
57
58func init() {
59	creation = time.Now()
60	hof.Register()
61}
62
63func Render(path string) string {
64	height := std.GetHeight()
65
66	output := "# " + config.Title + "\n\n"
67
68	output += "## About Me\n"
69	output += "- ๐Ÿ‘‹ Hi, I'm JJOptimist\n"
70	output += getGnomeArt(height)
71	output += "- ๐ŸŒฑ " + config.Description + "\n"
72
73	output += "## Contact\n"
74	output += "- ๐Ÿ“ซ GitHub: [" + config.Github + "](https://github.com/" + config.Github + ")\n"
75
76	output += "\n---\n"
77	output += "_Realm created: " + creation.Format("2006-01-02 15:04:05 UTC") + "_\n"
78	output += "_Owner: " + Ownable.Owner().String() + "_\n"
79	output += "_Current Block Height: " + strconv.Itoa(int(height)) + "_"
80
81	return output
82}