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..0efa597 --- /dev/null +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/gno.mod @@ -0,0 +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 new file mode 100644 index 0000000..919dfb3 --- /dev/null +++ b/live-coding/2-home-realm/followup-work/Nemanya8/home/home.gno @@ -0,0 +1,123 @@ +package home + +import ( + "gno.land/r/nemanya/config" +) + +type Project struct { + Name string + URL string +} + +type Social struct { + Name string + URL string +} + +var ( + 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() { + 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 = map[int]Project{ + 0: {"Liberty Bridge", "https://github.com/Milosevic02/LibertyBridge"}, + } + + 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) { + config.AssertAuthorized() + aboutMe = newAboutMe +} + +func AddProject(index int, name string, url string) { + config.AssertAuthorized() + if index >= 0 && index < 4 { + projects[index] = Project{Name: name, URL: url} + } +} + +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 RemoveSocial(index int) { + config.AssertAuthorized() + if index >= 0 && index < 3 { + delete(socials, index) + } +} + +func Render(path string) string { + return "
\n" + + " " + aboutMe + "\n" + + "
\n" + + "