diff options
Diffstat (limited to 'api/handlers')
| -rw-r--r-- | api/handlers/html.go | 36 | ||||
| -rw-r--r-- | api/handlers/pong.go | 31 |
2 files changed, 67 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)) } diff --git a/api/handlers/pong.go b/api/handlers/pong.go new file mode 100644 index 0000000..ee0d445 --- /dev/null +++ b/api/handlers/pong.go @@ -0,0 +1,31 @@ +package handlers + +import ( + "net/http" +) + +const pong = `<!DOCTYPE html> +<html> +<head> +<title>Pong!</title> +</head> +<body> +<pre> + _______ +< Pong! > + ------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || +</pre> +</body> +</html>` + +func Pong() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html") + w.Write([]byte(pong)) + } +} |
