diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2025-09-10 00:46:42 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2025-09-10 00:46:42 +0100 |
| commit | d122d841e8b7dd7f8942b6f2fa84220f95f2cae4 (patch) | |
| tree | a00734c1109b222f2485bd31c61fdf5e00a6d516 /api/handlers/html.go | |
| parent | baea81484f61fc341634ecf5e144d7ecf18ad42f (diff) | |
Add optional CSS to html
Diffstat (limited to 'api/handlers/html.go')
| -rw-r--r-- | api/handlers/html.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/api/handlers/html.go b/api/handlers/html.go index dd5d4e8..2f6688c 100644 --- a/api/handlers/html.go +++ b/api/handlers/html.go @@ -7,6 +7,28 @@ import ( "git.leonardobishop.net/history/pkg/html" ) +const style = `<style> +.entry { + display: grid; + grid-template: + 'title date' + 'desc desc'; +} + +.entry-title { + grid-area: title; +} + +.entry-date { + grid-area: date; + justify-self: end; +} + +.entry-description { + grid-area: desc; +} +</style>` + func GetEntriesHtml(entriesService entries.Service, htmlService html.Service) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { entries, err := entriesService.GetEntries() @@ -21,6 +43,20 @@ func GetEntriesHtml(entriesService entries.Service, htmlService html.Service) ht return } + if r.URL.Query().Get("css") == "no" { + goto send + } + + html = `<!DOCTYPE html> +<html> +<head> +<title>History</title> +` + style + ` +</head> +<body>` + html + `</body> +</html>` + + send: w.Header().Set("Content-Type", "text/html;charset=UTF-8") w.Write([]byte(html)) } |
