|
| 1 | +// Package home is Leon's personal home realm, deployed under gno.land/r/leon/home |
| 2 | +// It is meant to act as Leon's profile page on gno.land |
| 3 | +package home |
| 4 | + |
| 5 | +import ( |
| 6 | + "std" |
| 7 | + "strconv" |
| 8 | + |
| 9 | + "gno.land/p/demo/ufmt" |
| 10 | + "gno.land/r/demo/art/gnoface" |
| 11 | + "gno.land/r/demo/art/millipede" |
| 12 | + "gno.land/r/leon/config" |
| 13 | +) |
| 14 | + |
| 15 | +var ( |
| 16 | + pfp string // link to my profile pic |
| 17 | + pfpCaption string |
| 18 | + abtMe [2]string |
| 19 | +) |
| 20 | + |
| 21 | +func init() { |
| 22 | + pfp = "https://i.imgflip.com/91vskx.jpg" |
| 23 | + pfpCaption = "[My favourite painting & pfp](https://en.wikipedia.org/wiki/Wanderer_above_the_Sea_of_Fog)" |
| 24 | + abtMe = [2]string{ |
| 25 | + `### About me |
| 26 | +Hi, I'm Leon, a DevRel Engineer at gno.land. I am a tech enthusiast, |
| 27 | +life-long learner, and sharer of knowledge.`, |
| 28 | + `### Contributions |
| 29 | +My contributions to gno.land can mainly be found |
| 30 | +[here](https://github.com/gnolang/gno/issues?q=sort:updated-desc+author:leohhhn). |
| 31 | + |
| 32 | +TODO import r/gh`, |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +// Updating |
| 37 | + |
| 38 | +func UpdateAbtMe(col1, col2 string) { |
| 39 | + config.AssertAuthorized() |
| 40 | + abtMe[0] = col1 |
| 41 | + abtMe[1] = col2 |
| 42 | +} |
| 43 | + |
| 44 | +// Todo: make setters for all pkg-level variables |
| 45 | + |
| 46 | +// Rendering |
| 47 | + |
| 48 | +func Render(_ string) string { |
| 49 | + output := "# Leon's Homepage\n\n" |
| 50 | + |
| 51 | + output += renderAboutMe() |
| 52 | + output += "\n\n" |
| 53 | + output += renderArt() |
| 54 | + |
| 55 | + return output |
| 56 | +} |
| 57 | + |
| 58 | +func renderAboutMe() string { |
| 59 | + out := "<div class='columns-3'>" |
| 60 | + |
| 61 | + out += "<div>\n\n" |
| 62 | + out += ufmt.Sprintf("\n\n%s\n\n", pfp, pfpCaption) |
| 63 | + out += "</div>\n\n" |
| 64 | + |
| 65 | + out += "<div>\n\n" |
| 66 | + out += abtMe[0] + "\n\n" |
| 67 | + out += "</div>\n\n" |
| 68 | + |
| 69 | + out += "<div>\n\n" |
| 70 | + out += abtMe[1] + "\n\n" |
| 71 | + out += "</div>\n\n" |
| 72 | + |
| 73 | + out += "</div>" |
| 74 | + return out |
| 75 | +} |
| 76 | + |
| 77 | +func renderArt() string { |
| 78 | + out := `<div class=jumbotron>` + "\n\n" |
| 79 | + out += "## Gno Art\n\n" |
| 80 | + out += "<div class='columns-3'>" |
| 81 | + |
| 82 | + out += renderGnoFace() |
| 83 | + out += renderMillipede() |
| 84 | + out += renderGnoFace() |
| 85 | + |
| 86 | + out += "</div><!-- /columns-3 -->" |
| 87 | + out += "</div><!-- /jumbotron -->" |
| 88 | + |
| 89 | + return out |
| 90 | +} |
| 91 | + |
| 92 | +func renderGnoFace() string { |
| 93 | + out := "<div>\n\n" |
| 94 | + out += gnoface.Render(strconv.Itoa(int(std.GetHeight()))) |
| 95 | + out += "</div>\n\n" |
| 96 | + |
| 97 | + return out |
| 98 | +} |
| 99 | + |
| 100 | +func renderMillipede() string { |
| 101 | + out := "<div>\n\n" |
| 102 | + out += "Millipede\n\n" |
| 103 | + out += "```\n" + millipede.Draw(int(std.GetHeight()%10+1)) + "```\n" |
| 104 | + out += "</div>\n\n" |
| 105 | + |
| 106 | + return out |
| 107 | +} |
0 commit comments