chore: Refactor storia.go into its own module.

feat/db
Francesco Minnocci 2 years ago
parent 3d0bd18aef
commit 5decb85552
Signed by: BachoSeven
GPG Key ID: 2BE4AB7FDAD828A4

@ -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",
},
}

@ -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,4 +1,4 @@
package website
package storia
import (
"encoding/json"

@ -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)

Loading…
Cancel
Save