home.gno

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