aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-03-21 07:55:32 -0700
committerChristine Dodrill <me@christine.website>2019-03-21 07:57:23 -0700
commit368bd244aed0709c8b1bb05464d44f4d0cca07a4 (patch)
treebabc41308d52a97f0f3b50bad57bbb92ece79dc6 /cmd
parent47ddf59c12bc8827dafa80383c6c7b0595fecab1 (diff)
downloadxesite-368bd244aed0709c8b1bb05464d44f4d0cca07a4.tar.xz
xesite-368bd244aed0709c8b1bb05464d44f4d0cca07a4.zip
vendor some dependencies
Diffstat (limited to 'cmd')
-rw-r--r--cmd/site/html.go26
-rw-r--r--cmd/site/main.go4
-rw-r--r--cmd/site/rss.go4
3 files changed, 10 insertions, 24 deletions
diff --git a/cmd/site/html.go b/cmd/site/html.go
index fe8d190..afb0790 100644
--- a/cmd/site/html.go
+++ b/cmd/site/html.go
@@ -19,7 +19,7 @@ func (s *Site) renderTemplatePage(templateFname string, data interface{}) http.H
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fetag := "W/" + Hash(templateFname, etag) + "-1"
- f := ln.F{"etag": fetag, "if-none-match": r.Header.Get("If-None.Match")}
+ f := ln.F{"etag": fetag, "if_none_match": r.Header.Get("If-None-Match")}
if r.Header.Get("If-None-Match") == fetag {
http.Error(w, "Cached data OK", http.StatusNotModified)
@@ -28,29 +28,15 @@ func (s *Site) renderTemplatePage(templateFname string, data interface{}) http.H
}
defer logTemplateTime(templateFname, f, time.Now())
- s.tlock.RLock()
- defer s.tlock.RUnlock()
var t *template.Template
var err error
- if s.templates[templateFname] == nil {
- t, err = template.ParseFiles("templates/base.html", "templates/"+templateFname)
- if err != nil {
- w.WriteHeader(http.StatusInternalServerError)
- ln.Error(context.Background(), err, ln.F{"action": "renderTemplatePage", "page": templateFname})
- fmt.Fprintf(w, "error: %v", err)
- }
-
- ln.Log(context.Background(), ln.F{"action": "loaded_new_template", "fname": templateFname})
-
- s.tlock.RUnlock()
- s.tlock.Lock()
- s.templates[templateFname] = t
- s.tlock.Unlock()
- s.tlock.RLock()
- } else {
- t = s.templates[templateFname]
+ t, err = template.ParseFiles("templates/base.html", "templates/"+templateFname)
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ ln.Error(context.Background(), err, ln.F{"action": "renderTemplatePage", "page": templateFname})
+ fmt.Fprintf(w, "error: %v", err)
}
w.Header().Set("ETag", fetag)
diff --git a/cmd/site/main.go b/cmd/site/main.go
index 1690842..60619c7 100644
--- a/cmd/site/main.go
+++ b/cmd/site/main.go
@@ -12,13 +12,13 @@ import (
"sync"
"time"
- "github.com/Xe/jsonfeed"
+ "christine.website/internal/front"
+ "christine.website/internal/jsonfeed"
"github.com/gorilla/feeds"
"github.com/povilasv/prommod"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
blackfriday "github.com/russross/blackfriday"
- "github.com/tj/front"
"within.website/ln"
)
diff --git a/cmd/site/rss.go b/cmd/site/rss.go
index 935749f..2f319b2 100644
--- a/cmd/site/rss.go
+++ b/cmd/site/rss.go
@@ -16,7 +16,7 @@ const IncrediblySecureSalt = "hunter2"
func (s *Site) createFeed(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/rss+xml")
- w.Header().Set("ETag", Hash(bootTime.String(), IncrediblySecureSalt))
+ w.Header().Set("ETag", "W/"+Hash(bootTime.String(), IncrediblySecureSalt))
err := s.rssFeed.WriteRss(w)
if err != nil {
@@ -32,7 +32,7 @@ func (s *Site) createFeed(w http.ResponseWriter, r *http.Request) {
func (s *Site) createAtom(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/atom+xml")
- w.Header().Set("ETag", Hash(bootTime.String(), IncrediblySecureSalt))
+ w.Header().Set("ETag", "W/"+Hash(bootTime.String(), IncrediblySecureSalt))
err := s.rssFeed.WriteAtom(w)
if err != nil {