Skip to content

Commit d34a956

Browse files
Nemanya8Nemanya21
and
Nemanya21
authored
Personal home realm (#85)
* Add inital version of followup work * Add styling to borders, text and links * Fix bug with div overlap * Add socials and project maps * Format html and variables --------- Co-authored-by: Nemanya21 <[email protected]>
1 parent 25d1933 commit d34a956

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package config
2+
3+
import (
4+
"errors"
5+
"std"
6+
)
7+
8+
var (
9+
main std.Address
10+
backup std.Address
11+
)
12+
13+
func init() {
14+
main = "g1jqllg8870dcf9xtwjqd6ln9ujla2cvh0e7jwyq"
15+
}
16+
17+
func Address() std.Address {
18+
return main
19+
}
20+
21+
func Backup() std.Address {
22+
return backup
23+
}
24+
25+
func SetAddress(a std.Address) error {
26+
if !a.IsValid(){
27+
return errors.New("config: invalid address")
28+
}
29+
30+
if err := checkAuthorized(); err != nil {
31+
return err
32+
}
33+
34+
main = a
35+
return nil
36+
}
37+
38+
func SetBackup(a std.Address) error {
39+
if !a.IsValid(){
40+
return errors.New("config: invalid address")
41+
}
42+
43+
if err := checkAuthorized(); err != nil {
44+
return err
45+
}
46+
47+
main = a
48+
return nil
49+
}
50+
51+
func checkAuthorized() error {
52+
caller := std.PrevRealm().Addr()
53+
if caller != main || caller != backup {
54+
return errors.New("config: unauthorized")
55+
}
56+
57+
return nil
58+
}
59+
60+
func AssertAuthorized() {
61+
caller := std.PrevRealm().Addr()
62+
if caller != main || caller != backup {
63+
panic("config: unauthorized")
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module gno.land/r/nemanya/config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module gno.land/r/nemanya/home
2+
3+
require (
4+
gno.land/p/demo/ufmt v0.0.0-latest
5+
gno.land/r/nemanya/config v0.0.0-latest
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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

Comments
 (0)