aboutsummaryrefslogtreecommitdiff
path: root/cmd/site/html.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/site/html.go')
-rw-r--r--cmd/site/html.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/cmd/site/html.go b/cmd/site/html.go
index a645551..ba2b4fa 100644
--- a/cmd/site/html.go
+++ b/cmd/site/html.go
@@ -8,6 +8,8 @@ import (
"path/filepath"
"time"
+ "christine.website/internal"
+ "christine.website/internal/blog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"within.website/ln"
@@ -30,7 +32,7 @@ func logTemplateTime(ctx context.Context, name string, f ln.F, from time.Time) {
func (s *Site) renderTemplatePage(templateFname string, data interface{}) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := opname.With(r.Context(), "renderTemplatePage")
- fetag := "W/" + Hash(templateFname, etag) + "-1"
+ fetag := "W/" + internal.Hash(templateFname, etag) + "-1"
f := ln.F{"etag": fetag, "if_none_match": r.Header.Get("If-None-Match")}
@@ -74,14 +76,16 @@ func (s *Site) showPost(w http.ResponseWriter, r *http.Request) {
}
cmp := r.URL.Path[1:]
- var p *Post
+ var p blog.Post
+ var found bool
for _, pst := range s.Posts {
if pst.Link == cmp {
p = pst
+ found = true
}
}
- if p == nil {
+ if !found {
w.WriteHeader(http.StatusNotFound)
s.renderTemplatePage("error.html", "no such post found: "+r.RequestURI).ServeHTTP(w, r)
return