From b9c1ed6a0e99dbfe12a535289444553fa1de120e Mon Sep 17 00:00:00 2001 From: Nemanja Matic <106317308+Nemanya8@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:19:52 +0000 Subject: [PATCH 1/5] Add inital version of followup work --- .../followup-work/Nemanya8/config/conig.gno | 65 ++++++++++++++ .../followup-work/Nemanya8/config/gno.mod | 1 + .../followup-work/Nemanya8/home/gno.mod | 5 ++ .../followup-work/Nemanya8/home/home.gno | 84 +++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 live-coding/2-home-realm/followup-work/Nemanya8/config/conig.gno create mode 100644 live-coding/2-home-realm/followup-work/Nemanya8/config/gno.mod create mode 100644 live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod create mode 100644 live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/config/conig.gno b/live-coding/2-home-realm/followup-work/Nemanya8/config/conig.gno new file mode 100644 index 0000000..0e6d594 --- /dev/null +++ b/live-coding/2-home-realm/followup-work/Nemanya8/config/conig.gno @@ -0,0 +1,65 @@ +package config + +import ( + "errors" + "std" +) + +var ( + main std.Address + backup std.Address +) + +func init() { + main = "g1jqllg8870dcf9xtwjqd6ln9ujla2cvh0e7jwyq" +} + +func Address() std.Address { + return main +} + +func Backup() std.Address { + return backup +} + +func SetAddress(a std.Address) error { + if !a.IsValid(){ + return errors.New("config: invalid address") + } + + if err := checkAuthorized(); err != nil { + return err + } + + main = a + return nil +} + +func SetBackup(a std.Address) error { + if !a.IsValid(){ + return errors.New("config: invalid address") + } + + if err := checkAuthorized(); err != nil { + return err + } + + main = a + return nil +} + +func checkAuthorized() error { + caller := std.PrevRealm().Addr() + if caller != main || caller != backup { + return errors.New("config: unauthorized") + } + + return nil +} + +func AssertAuthorized() { + caller := std.PrevRealm().Addr() + if caller != main || caller != backup { + panic("config: unauthorized") + } +} \ No newline at end of file diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/config/gno.mod b/live-coding/2-home-realm/followup-work/Nemanya8/config/gno.mod new file mode 100644 index 0000000..8ffbc32 --- /dev/null +++ b/live-coding/2-home-realm/followup-work/Nemanya8/config/gno.mod @@ -0,0 +1 @@ +module gno.land/r/nemanya/config \ No newline at end of file diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod b/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod new file mode 100644 index 0000000..4a7d40b --- /dev/null +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod @@ -0,0 +1,5 @@ +module gno.land/r/nemanya/home + +require ( + gno.land/r/nemanya/config v0.0.0-latest +) \ No newline at end of file diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno new file mode 100644 index 0000000..6f16770 --- /dev/null +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno @@ -0,0 +1,84 @@ +package home + +import ( + "gno.land/r/nemanya/config" +) + +var ( + aboutMe string + projects [4]string +) + +func init() { + aboutMe =`### About me +I'm Nemanya 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.` + + projects = [4]string{ + "[Liberty Bridge](https://github.com/Milosevic02/LibertyBridge)", + "[Coming Soon!](#)", + "[Coming Soon!](#)", + "[Coming Soon!](#)", + } +} + +func UpdateAboutMe(newAboutMe string) { + config.AssertAuthorized() + aboutMe = newAboutMe +} + +func UpdateProjects(project1, project2, project3, project4 string) { + config.AssertAuthorized() + projects[0] = project1 + projects[1] = project2 + projects[2] = project3 + projects[3] = project4 +} + +func Render(path string) string { + out := "
\n\n" + + out += renderAboutMe() + out += renderProjects() + out += "\n\n" + + out += "
\n\n" + return out +} + +func renderAboutMe() string { + out := "
" + out += "

Nemanya.

" + out += "
\n\n" + out += aboutMe + "\n\n" + out += "
\n\n" + out += "
\n\n" + out += "Placeholder for links to socials" + out += "
\n\n" + out += "
\n\n" + return out +} + +func renderProjects() string { + out := "
" + out += "

Projects

" + + out += "
\n\n" + out += projects[0] + "\n\n" + out += "
\n\n" + + out += "
\n\n" + out += projects[1] + "\n\n" + out += "
\n\n" + + out += "
\n\n" + out += projects[2] + "\n\n" + out += "
\n\n" + + out += "
\n\n" + out += projects[3] + "\n\n" + out += "
\n\n" + + out += "
\n\n" + return out +} From 11ba28300623f469f0b6f96a7edc6581f4a90211 Mon Sep 17 00:00:00 2001 From: Nemanya21 Date: Wed, 4 Sep 2024 18:34:04 +0200 Subject: [PATCH 2/5] Add styling to borders, text and links --- .../followup-work/Nemanya8/home/gno.mod | 1 + .../followup-work/Nemanya8/home/home.gno | 81 ++++++++++++------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod b/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod index 4a7d40b..0efa597 100644 --- a/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod @@ -1,5 +1,6 @@ module gno.land/r/nemanya/home require ( + gno.land/p/demo/ufmt v0.0.0-latest gno.land/r/nemanya/config v0.0.0-latest ) \ No newline at end of file diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno index 6f16770..dc01d24 100644 --- a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno @@ -7,12 +7,11 @@ import ( var ( aboutMe string projects [4]string + socials [3]string ) func init() { - aboutMe =`### About me -I'm Nemanya 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.` + 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." projects = [4]string{ "[Liberty Bridge](https://github.com/Milosevic02/LibertyBridge)", @@ -20,6 +19,12 @@ I discovered gno.land at the Petnica Web3 Camp and I'm eager to make significant "[Coming Soon!](#)", "[Coming Soon!](#)", } + + socials = [3]string{ + "[GitHub](https://github.com/Nemanya8)", + "[LinkedIn](https://www.linkedin.com/in/nemanjamatic)", + "[Email](matic.nemanya@gmail.com)", + } } func UpdateAboutMe(newAboutMe string) { @@ -36,47 +41,65 @@ func UpdateProjects(project1, project2, project3, project4 string) { } func Render(path string) string { - out := "
\n\n" - - out += renderAboutMe() + out := "
\n\n" + + out += "
" + out += renderAboutMe() + out += "
" + out += "
" + + out += "
" out += renderProjects() - out += "\n\n" - - out += "
\n\n" - return out + out += "
" + out += "
\n\n" + out += "
\n\n" + return out } + + func renderAboutMe() string { - out := "
" - out += "

Nemanya.

" - out += "
\n\n" - out += aboutMe + "\n\n" - out += "
\n\n" - out += "
\n\n" - out += "Placeholder for links to socials" - out += "
\n\n" - out += "
\n\n" - return out + out := "
" + out += "

Nemanya.

" + out += "
" + out += "

" + out += aboutMe + out += "

\n\n" + out += "
\n\n" + out += "
\n\n" + out += "
\n\n" + out += socials[0] + out += "
\n" + out += "
\n\n" + out += socials[1] + out += "
\n" + out += "
\n\n" + out += socials[2] + out += "
\n" + out += "
\n\n" + out += "
\n\n" + return out } + func renderProjects() string { out := "
" - out += "

Projects

" + out += "

Projects

" - out += "
\n\n" - out += projects[0] + "\n\n" + out += "
\n\n" + out += projects[0] out += "
\n\n" - out += "
\n\n" - out += projects[1] + "\n\n" + out += "
\n\n" + out += projects[1] out += "
\n\n" - out += "
\n\n" - out += projects[2] + "\n\n" + out += "
\n\n" + out += projects[2] out += "
\n\n" - out += "
\n\n" - out += projects[3] + "\n\n" + out += "
\n\n" + out += projects[3] out += "
\n\n" out += "
\n\n" From 2efbad4bd73edc688ce481a8fd5e2c27018fced7 Mon Sep 17 00:00:00 2001 From: Nemanya21 Date: Wed, 4 Sep 2024 18:55:53 +0200 Subject: [PATCH 3/5] Fix bug with div overlap --- .../2-home-realm/followup-work/Nemanya8/home/home.gno | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno index dc01d24..de5ba71 100644 --- a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno @@ -43,15 +43,14 @@ func UpdateProjects(project1, project2, project3, project4 string) { func Render(path string) string { out := "
\n\n" - out += "
" + out += "
" out += renderAboutMe() - out += "
" out += "
" - out += "
" + out += "
" out += renderProjects() - out += "
" out += "
\n\n" + out += "
\n\n" return out } From ba44f572db314b6a90e27b3c96ea86c73cdd0d20 Mon Sep 17 00:00:00 2001 From: Nemanya21 Date: Wed, 4 Sep 2024 22:48:19 +0200 Subject: [PATCH 4/5] Add socials and project maps --- .../followup-work/Nemanya8/home/home.gno | 146 ++++++++++-------- 1 file changed, 80 insertions(+), 66 deletions(-) diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno index de5ba71..0d47046 100644 --- a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno @@ -4,103 +4,117 @@ import ( "gno.land/r/nemanya/config" ) +type Project struct { + Name string + URL string +} + +type Social struct { + Name string + URL string +} + var ( - aboutMe string - projects [4]string - socials [3]string + aboutMe string + projects map[int]Project + socials map[int]Social ) -func init() { - 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." +func init() { + 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." - projects = [4]string{ - "[Liberty Bridge](https://github.com/Milosevic02/LibertyBridge)", - "[Coming Soon!](#)", - "[Coming Soon!](#)", - "[Coming Soon!](#)", + projects = map[int]Project{ + 0: {"Liberty Bridge", "https://github.com/Milosevic02/LibertyBridge"}, } - socials = [3]string{ - "[GitHub](https://github.com/Nemanya8)", - "[LinkedIn](https://www.linkedin.com/in/nemanjamatic)", - "[Email](matic.nemanya@gmail.com)", + socials = map[int]Social{ + 0: {"GitHub", "https://github.com/Nemanya8"}, + 1: {"LinkedIn", "https://www.linkedin.com/in/nemanjamatic"}, + 2: {"Email", "mailto:matic.nemanya@gmail.com"}, } } -func UpdateAboutMe(newAboutMe string) { +func UpdateAboutMe(newAboutMe string) { config.AssertAuthorized() aboutMe = newAboutMe } -func UpdateProjects(project1, project2, project3, project4 string) { +func AddProject(index int, name string, url string) { config.AssertAuthorized() - projects[0] = project1 - projects[1] = project2 - projects[2] = project3 - projects[3] = project4 + if index >= 0 && index < 4 { + projects[index] = Project{Name: name, URL: url} + } } -func Render(path string) string { - out := "
\n\n" - - out += "
" - out += renderAboutMe() - out += "
" - - out += "
" - out += renderProjects() - out += "
\n\n" - - out += "
\n\n" - return out +func RemoveProject(index int) { + config.AssertAuthorized() + if index >= 0 && index < 4 { + delete(projects, index) + } } +func AddSocial(index int, name string, url string) { + config.AssertAuthorized() + if index >= 0 && index < 3 { + socials[index] = Social{Name: name, URL: url} + } +} - -func renderAboutMe() string { - out := "
" - out += "

Nemanya.

" - out += "
" - out += "

" - out += aboutMe - out += "

\n\n" - out += "
\n\n" - out += "
\n\n" - out += "
\n\n" - out += socials[0] - out += "
\n" - out += "
\n\n" - out += socials[1] - out += "
\n" - out += "
\n\n" - out += socials[2] - out += "
\n" - out += "
\n\n" - out += "
\n\n" - return out +func RemoveSocial(index int) { + config.AssertAuthorized() + if index >= 0 && index < 3 { + delete(socials, index) + } } +func Render(path string) string { + out := "
\n\n" -func renderProjects() string { - out := "
" - out += "

Projects

" + out += "
" + out += renderAboutMe() + out += "
" - out += "
\n\n" - out += projects[0] + out += "
" + out += renderProjects() out += "
\n\n" - out += "
\n\n" - out += projects[1] out += "
\n\n" + return out +} - out += "
\n\n" - out += projects[2] +func renderAboutMe() string { + out := "
" + out += "

Nemanya.

" + out += "
" + out += "

" + out += aboutMe + out += "

\n\n" out += "
\n\n" - out += "
\n\n" - out += projects[3] + out += renderSocials() + out += "
\n\n" + return out +} + +func renderSocials() string { + out := "
\n\n" + for _, social := range socials { + out += "
" + out += "" + social.Name + "" + out += "
\n" + } out += "
\n\n" + return out +} +func renderProjects() string { + out := "
" + out += "

Projects

" + for _, project := range projects { + out += "
" + out += "" + project.Name + "" + out += "
\n" + } out += "
\n\n" return out } From 839c56bd150256dfa781756238bbc42b3e4690be Mon Sep 17 00:00:00 2001 From: Nemanya21 Date: Wed, 4 Sep 2024 23:10:41 +0200 Subject: [PATCH 5/5] Format html and variables --- .../followup-work/Nemanya8/home/home.gno | 89 ++++++++++--------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno index 0d47046..919dfb3 100644 --- a/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno @@ -5,19 +5,28 @@ import ( ) type Project struct { - Name string - URL string + Name string + URL string } type Social struct { - Name string - URL string + Name string + URL string } var ( - aboutMe string - projects map[int]Project - socials map[int]Social + aboutMe string + projects map[int]Project + socials map[int]Social + + + fontFamily = "Inter, sans-serif" + primaryColor = "#FEFEFE" + borderColor = "#D30000" + fontSizeLarge = "7rem" + fontSizeMedium = "4rem" + fontSizeSmall = "1.5rem" + fontSizeExtraSmall = "1rem" ) func init() { @@ -68,53 +77,47 @@ func RemoveSocial(index int) { } func Render(path string) string { - out := "
\n\n" - - out += "
" - out += renderAboutMe() - out += "
" - - out += "
" - out += renderProjects() - out += "
\n\n" - - out += "
\n\n" - return out + return "
\n" + + "
\n" + + " " + renderAboutMe() + "\n" + + "
\n" + + "
\n" + + " " + renderProjects() + "\n" + + "
\n" + + "
\n" } func renderAboutMe() string { - out := "
" - out += "

Nemanya.

" - out += "
" - out += "

" - out += aboutMe - out += "

\n\n" - out += "
\n\n" - - out += renderSocials() - out += "
\n\n" - return out + return "
\n" + + "

Nemanya.

\n" + + "
\n" + + "

\n" + + " " + aboutMe + "\n" + + "

\n" + + "
\n" + + " " + renderSocials() + "\n" + + "
\n" } func renderSocials() string { - out := "
\n\n" + socialsHTML := "
\n" for _, social := range socials { - out += "
" - out += "" + social.Name + "" - out += "
\n" + socialsHTML += "
\n" + + " " + social.Name + "\n" + + "
\n" } - out += "
\n\n" - return out + socialsHTML += "
\n" + return socialsHTML } func renderProjects() string { - out := "
" - out += "

Projects

" + projectsHTML := "
\n" + + "

Projects

\n" for _, project := range projects { - out += "
" - out += "" + project.Name + "" - out += "
\n" + projectsHTML += "
\n" + + " " + project.Name + "\n" + + "
\n" } - out += "
\n\n" - return out + projectsHTML += "
\n" + return projectsHTML }