aboutsummaryrefslogtreecommitdiff
path: root/cmd/site/html.go
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-03-27 07:18:52 -0700
committerChristine Dodrill <me@christine.website>2019-03-27 07:18:52 -0700
commitd0ff1b2d04fc0caf57d99f1d34ce13cf4aae6a1a (patch)
tree29ae006563834338e663452e6f810561596582ac /cmd/site/html.go
parent20c08e68d1218475d6c6f3ca8ae718e1f508c696 (diff)
downloadxesite-d0ff1b2d04fc0caf57d99f1d34ce13cf4aae6a1a.tar.xz
xesite-d0ff1b2d04fc0caf57d99f1d34ce13cf4aae6a1a.zip
reorg: phase 1
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