move templates to web dir

This commit is contained in:
2025-01-02 15:13:13 +01:00
parent 59222160af
commit 7798930145
5 changed files with 5 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ func (ord articleDateOrder) Weight(a *model.Article) int {
// List the latest articles using the base template.
func Index(w http.ResponseWriter, req *http.Request) {
// retrieve from repo
fds, err := data.NewFileDatastore("./persistence/spiegel100.json")
fds, err := data.NewFileDatastore("persistence/spiegel100.json")
if err != nil { http.Error(w, "Failed to load datastore", http.StatusInternalServerError); return; }
repo, err := data.NewDefaultRepository[*model.Article](fds, "article")
if err != nil { http.Error(w, "Failed to create repository", http.StatusInternalServerError); return; }
@@ -36,7 +36,7 @@ func Index(w http.ResponseWriter, req *http.Request) {
}
// render template
t := template.Must(template.ParseFiles("templates/article.html", "templates/layout.html"))
t := template.Must(template.ParseFiles("web/templates/article.html", "web/templates/layout.html"))
err = t.ExecuteTemplate(w, "base", articleVMs)
if err != nil { http.Error(w, "Failed to render template", http.StatusInternalServerError); return; }
}