|
| 1 | +package home |
| 2 | + |
| 3 | +import ( |
| 4 | + "gno.land/r/nemanya/config" |
| 5 | +) |
| 6 | + |
| 7 | +type Project struct { |
| 8 | + Name string |
| 9 | + URL string |
| 10 | +} |
| 11 | + |
| 12 | +type Social struct { |
| 13 | + Name string |
| 14 | + URL string |
| 15 | +} |
| 16 | + |
| 17 | +var ( |
| 18 | + aboutMe string |
| 19 | + projects map[int]Project |
| 20 | + socials map[int]Social |
| 21 | + |
| 22 | + |
| 23 | + fontFamily = "Inter, sans-serif" |
| 24 | + primaryColor = "#FEFEFE" |
| 25 | + borderColor = "#D30000" |
| 26 | + fontSizeLarge = "7rem" |
| 27 | + fontSizeMedium = "4rem" |
| 28 | + fontSizeSmall = "1.5rem" |
| 29 | + fontSizeExtraSmall = "1rem" |
| 30 | +) |
| 31 | + |
| 32 | +func init() { |
| 33 | + aboutMe = "I'm Nemanja Matic from Serbia, an IT student and aspiring Web3 developer. I discovered gno.land at the Petnica Web3 Camp and I'm eager to make significant contributions to this project." |
| 34 | + |
| 35 | + projects = map[int]Project{ |
| 36 | + 0: {"Liberty Bridge", "https://github.com/Milosevic02/LibertyBridge"}, |
| 37 | + } |
| 38 | + |
| 39 | + socials = map[int]Social{ |
| 40 | + 0: {"GitHub", "https://github.com/Nemanya8"}, |
| 41 | + 1: {"LinkedIn", "https://www.linkedin.com/in/nemanjamatic"}, |
| 42 | + 2: {"Email", "mailto: [email protected]"}, |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +func UpdateAboutMe(newAboutMe string) { |
| 47 | + config.AssertAuthorized() |
| 48 | + aboutMe = newAboutMe |
| 49 | +} |
| 50 | + |
| 51 | +func AddProject(index int, name string, url string) { |
| 52 | + config.AssertAuthorized() |
| 53 | + if index >= 0 && index < 4 { |
| 54 | + projects[index] = Project{Name: name, URL: url} |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +func RemoveProject(index int) { |
| 59 | + config.AssertAuthorized() |
| 60 | + if index >= 0 && index < 4 { |
| 61 | + delete(projects, index) |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +func AddSocial(index int, name string, url string) { |
| 66 | + config.AssertAuthorized() |
| 67 | + if index >= 0 && index < 3 { |
| 68 | + socials[index] = Social{Name: name, URL: url} |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +func RemoveSocial(index int) { |
| 73 | + config.AssertAuthorized() |
| 74 | + if index >= 0 && index < 3 { |
| 75 | + delete(socials, index) |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +func Render(path string) string { |
| 80 | + return "<div style='display: flex;'>\n" + |
| 81 | + " <div style='flex: 8; margin-right: 20px; padding: 2rem; border: 2px solid transparent; border-image: linear-gradient(166deg, " + borderColor + " 0%, rgba(0,0,0,0) 20%); border-image-slice: 1;'>\n" + |
| 82 | + " " + renderAboutMe() + "\n" + |
| 83 | + " </div>\n" + |
| 84 | + " <div style='flex: 2; padding: 2rem; border: 2px solid transparent; border-image: linear-gradient(324deg, " + borderColor + " 0%, rgba(0,0,0,0) 20%); border-image-slice: 1;'>\n" + |
| 85 | + " " + renderProjects() + "\n" + |
| 86 | + " </div>\n" + |
| 87 | + "</div>\n" |
| 88 | +} |
| 89 | + |
| 90 | +func renderAboutMe() string { |
| 91 | + return "<div class='rows-3'>\n" + |
| 92 | + " <h1 style='font-family: " + fontFamily + "; font-weight: 100; color: " + primaryColor + "; text-align: left; font-size: " + fontSizeLarge + ";'>Nemanya.</h1>\n" + |
| 93 | + " <div style='border-left: 1px solid " + borderColor + "; padding-left: 1rem;'>\n" + |
| 94 | + " <p style='font-family: " + fontFamily + "; color: " + primaryColor + "; font-size: " + fontSizeSmall + "; margin-bottom: 5rem;'>\n" + |
| 95 | + " " + aboutMe + "\n" + |
| 96 | + " </p>\n" + |
| 97 | + " </div>\n" + |
| 98 | + " " + renderSocials() + "\n" + |
| 99 | + "</div><!-- /rows-3 -->\n" |
| 100 | +} |
| 101 | + |
| 102 | +func renderSocials() string { |
| 103 | + socialsHTML := "<div class='socials-container' style='display: flex; justify-content: center; align-items: center; gap: 20px;'>\n" |
| 104 | + for _, social := range socials { |
| 105 | + socialsHTML += " <div style='display: flex; justify-content: center; align-items: center;'>\n" + |
| 106 | + " <a href='" + social.URL + "' style='color: " + primaryColor + "; font-family: " + fontFamily + "; font-size: " + fontSizeExtraSmall + "; display: flex; justify-content: center; align-items: center; width: 100%; height: 100%;'>" + social.Name + "</a>\n" + |
| 107 | + " </div>\n" |
| 108 | + } |
| 109 | + socialsHTML += "</div>\n" |
| 110 | + return socialsHTML |
| 111 | +} |
| 112 | + |
| 113 | +func renderProjects() string { |
| 114 | + projectsHTML := "<div class='rows-5'>\n" + |
| 115 | + " <h2 style='font-family: " + fontFamily + "; font-weight: 200; color: " + primaryColor + "; text-align: left; font-size: " + fontSizeMedium + ";'>Projects</h2>\n" |
| 116 | + for _, project := range projects { |
| 117 | + projectsHTML += " <div style='margin-bottom: 1rem; border-left: 1px solid " + borderColor + "; padding-left: 1rem;'>\n" + |
| 118 | + " <a href='" + project.URL + "' style='color: " + primaryColor + "; font-family: " + fontFamily + "; font-size: " + fontSizeSmall + ";'>" + project.Name + "</a>\n" + |
| 119 | + " </div>\n" |
| 120 | + } |
| 121 | + projectsHTML += "</div><!-- /rows-5 -->\n" |
| 122 | + return projectsHTML |
| 123 | +} |
0 commit comments