chore: Refactor storia.go into its own module.

This commit is contained in:
2022-08-28 11:16:07 +02:00
parent 3d0bd18aef
commit 5decb85552
4 changed files with 8 additions and 6 deletions
+3 -2
View File
@@ -9,6 +9,7 @@ import (
"git.phc.dm.unipi.it/phc/website/config"
"git.phc.dm.unipi.it/phc/website/handler"
"git.phc.dm.unipi.it/phc/website/server"
"git.phc.dm.unipi.it/phc/website/storia"
"git.phc.dm.unipi.it/phc/website/templates"
)
@@ -24,10 +25,10 @@ func main() {
),
NewsArticlesRegistry: articles.NewRegistry("./_content/news"),
GuideArticlesRegistry: articles.NewRegistry("./_content/guide"),
ListaUtenti: &website.JsonFileListUtenti{
ListaUtenti: &website.JsonFileListaUtenti{
Path: "./utenti-poisson-2022.local.json",
},
Storia: &website.JsonFileStoria{
Storia: &storia.JsonFileStoria{
Path: "./storia.json",
},
}
+2 -1
View File
@@ -10,6 +10,7 @@ import (
"git.phc.dm.unipi.it/phc/website/auth"
"git.phc.dm.unipi.it/phc/website/model"
"git.phc.dm.unipi.it/phc/website/rss"
"git.phc.dm.unipi.it/phc/website/storia"
"git.phc.dm.unipi.it/phc/website/templates"
"git.phc.dm.unipi.it/phc/website/util"
)
@@ -51,7 +52,7 @@ type DefaultHandler struct {
NewsArticlesRegistry *articles.Registry
GuideArticlesRegistry *articles.Registry
ListaUtenti website.ListaUtentiService
Storia website.StoriaService
Storia storia.StoriaService
}
func (h *DefaultHandler) HandleStaticPage(w io.Writer, view string, ctx Context) error {
+1 -1
View File
@@ -1,4 +1,4 @@
package website
package storia
import (
"encoding/json"
+2 -2
View File
@@ -19,11 +19,11 @@ type ListaUtentiService interface {
GetUtenti() ([]UserInfo, error)
}
type JsonFileListUtenti struct {
type JsonFileListaUtenti struct {
Path string
}
func (j *JsonFileListUtenti) GetUtenti() ([]UserInfo, error) {
func (j *JsonFileListaUtenti) GetUtenti() ([]UserInfo, error) {
var users []UserInfo
usersJsonData, err := os.ReadFile(j.Path)