diff options
Diffstat (limited to 'backend/data.go')
| -rw-r--r-- | backend/data.go | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/backend/data.go b/backend/data.go index adf5db3..e1a8478 100644 --- a/backend/data.go +++ b/backend/data.go @@ -1,11 +1,41 @@ package backend +import ( + "fmt" + "html/template" + "net/http" +) + type data struct { - title string - Article bool + title string + Article bool + Domain string + URL string + Image string + Description string +} + +func (d *data) handleGeneric(w http.ResponseWriter, name string) { + t, err := template.New("").Funcs(template.FuncMap{ + "static": func(path string) string { + return fmt.Sprintf("/static/%s", path) + }, + "assets": func(path string) string { + return fmt.Sprintf("/assets/%s", path) + }, + }).ParseFS(templates, fmt.Sprintf("templates/%s.html", name), "templates/base.html") + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + err = t.ExecuteTemplate(w, "base.html", d) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } } -func (d data) Title() string { +func (d *data) Title() string { title := "anhgelus" if d.Article { title += " - log entry" |
