From 192d8ea944e250e39f446ce754c1262d4bb09dbe Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Sun, 28 Aug 2022 18:11:08 +0200 Subject: [PATCH] chore: Rimosso file utenti.go e spostati file .json in _content/ --- macchinisti.json => _content/macchinisti.json | 0 storia.json => _content/storia.json | 0 cmd/phc-website-server/main.go | 2 +- lista_utenti/lista_utenti.go | 2 +- storia/storia.go | 2 +- utenti.go | 41 ------------------- 6 files changed, 3 insertions(+), 44 deletions(-) rename macchinisti.json => _content/macchinisti.json (100%) rename storia.json => _content/storia.json (100%) delete mode 100644 utenti.go diff --git a/macchinisti.json b/_content/macchinisti.json similarity index 100% rename from macchinisti.json rename to _content/macchinisti.json diff --git a/storia.json b/_content/storia.json similarity index 100% rename from storia.json rename to _content/storia.json diff --git a/cmd/phc-website-server/main.go b/cmd/phc-website-server/main.go index a11ec27..81ded2c 100644 --- a/cmd/phc-website-server/main.go +++ b/cmd/phc-website-server/main.go @@ -33,7 +33,7 @@ func main() { NewsArticlesRegistry: articles.NewRegistry("./_content/news"), GuideArticlesRegistry: articles.NewRegistry("./_content/guide"), Storia: &storia.JsonFileStoria{ - Path: "./storia.json", + Path: "./_content/storia.json", }, ListaUtenti: listaUtentiService, } diff --git a/lista_utenti/lista_utenti.go b/lista_utenti/lista_utenti.go index 94deab9..ada229d 100644 --- a/lista_utenti/lista_utenti.go +++ b/lista_utenti/lista_utenti.go @@ -23,7 +23,7 @@ func New(authService auth.Service, config string) (Service, error) { } func loadMacchinisti() (util.Set[string], error) { - f, err := os.Open("macchinisti.json") + f, err := os.Open("_content/macchinisti.json") if err != nil { return nil, err } diff --git a/storia/storia.go b/storia/storia.go index e163b35..1505607 100644 --- a/storia/storia.go +++ b/storia/storia.go @@ -133,7 +133,7 @@ func withSpacers(events []*GenericEvent) []*GenericEvent { func getDateYear(date string) int { year, err := strconv.Atoi(strings.Split(date, "/")[0]) if err != nil { - panic(err) // Tanto nel caso si nota in fase di sviluppo visto che "storia.json" è statico + panic(err) // Tanto nel caso si nota in fase di sviluppo visto che "_content/storia.json" è statico } return year diff --git a/utenti.go b/utenti.go deleted file mode 100644 index c87e721..0000000 --- a/utenti.go +++ /dev/null @@ -1,41 +0,0 @@ -package website - -import ( - "encoding/json" - "log" - "os" -) - -type UserInfo struct { - Uid string `json:"uid"` - Nome string `json:"nome"` - Cognome string `json:"cognome"` - - Tags []string `json:"tags"` - IsMacchinista bool `json:"macchinista,omitempty"` -} - -type ListaUtentiService interface { - GetUtenti() ([]UserInfo, error) -} - -type JsonFileListaUtenti struct { - Path string -} - -func (j *JsonFileListaUtenti) GetUtenti() ([]UserInfo, error) { - var users []UserInfo - - usersJsonData, err := os.ReadFile(j.Path) - if err != nil { - return nil, err - } - - if err := json.Unmarshal(usersJsonData, &users); err != nil { - return nil, err - } - - log.Printf("Loaded list utenti with %d users", len(users)) - - return users, nil -}