From 3d9e9a08476fe12aaf5f5564df0f7d6646e7e984 Mon Sep 17 00:00:00 2001 From: Caleb Gardner Date: Wed, 3 Jan 2024 05:40:11 -0600 Subject: [PATCH] Fix portfolio and files pages --- internal/darkstormtech/app.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/darkstormtech/app.go b/internal/darkstormtech/app.go index afa5cf9..9caa36c 100644 --- a/internal/darkstormtech/app.go +++ b/internal/darkstormtech/app.go @@ -53,6 +53,17 @@ func notFoundPage() pageOut { } } +func pageWith(content string, title string) pageOut { + if title == "" { + title = "Darkstorm.Tech" + } + return pageOut{ + Content: content, + Title: title, + Favicon: "https://darkstorm.tech/favicon.png", + } +} + func (p pageOut) json() []byte { out, _ := json.Marshal(p) return out @@ -132,7 +143,7 @@ func (d *DarkstormTech) handleFiles(req *stupid.Request) bool { } out += "

" + f.Name() + " " + inf.ModTime().Round(time.Minute).String() + "

\n" } - _, err = req.Resp.Write([]byte(out)) + _, err = req.Resp.Write(pageWith(out, "Files").json()) if err != nil { log.Println("Error while writing output:", err) req.Resp.WriteHeader(http.StatusInternalServerError) @@ -195,7 +206,7 @@ func (d *DarkstormTech) handlePortfolio(req *stupid.Request) bool { } out += "

" + p.Description + "

" } - _, err = req.Resp.Write([]byte(out)) + _, err = req.Resp.Write(pageWith(out, "Portfolio").json()) if err != nil { log.Println("Error while writing output:", err) req.Resp.WriteHeader(http.StatusInternalServerError)