chore: Rimosso file utenti.go e spostati file .json in _content/
This commit is contained in:
@@ -33,7 +33,7 @@ func main() {
|
|||||||
NewsArticlesRegistry: articles.NewRegistry("./_content/news"),
|
NewsArticlesRegistry: articles.NewRegistry("./_content/news"),
|
||||||
GuideArticlesRegistry: articles.NewRegistry("./_content/guide"),
|
GuideArticlesRegistry: articles.NewRegistry("./_content/guide"),
|
||||||
Storia: &storia.JsonFileStoria{
|
Storia: &storia.JsonFileStoria{
|
||||||
Path: "./storia.json",
|
Path: "./_content/storia.json",
|
||||||
},
|
},
|
||||||
ListaUtenti: listaUtentiService,
|
ListaUtenti: listaUtentiService,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func New(authService auth.Service, config string) (Service, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadMacchinisti() (util.Set[string], error) {
|
func loadMacchinisti() (util.Set[string], error) {
|
||||||
f, err := os.Open("macchinisti.json")
|
f, err := os.Open("_content/macchinisti.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ func withSpacers(events []*GenericEvent) []*GenericEvent {
|
|||||||
func getDateYear(date string) int {
|
func getDateYear(date string) int {
|
||||||
year, err := strconv.Atoi(strings.Split(date, "/")[0])
|
year, err := strconv.Atoi(strings.Split(date, "/")[0])
|
||||||
if err != nil {
|
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
|
return year
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user