update to use new css filtering
Ted Unangst tedu@tedunangst.com
Fri, 27 Sep 2019 22:00:35 -0400
M
go.mod
→
go.mod
@@ -7,5 +7,5 @@ github.com/mattn/go-runewidth v0.0.4
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/net v0.0.0-20190620200207-3b0461eec859 humungus.tedunangst.com/r/go-sqlite3 v1.1.3 - humungus.tedunangst.com/r/webs v0.6.6 + humungus.tedunangst.com/r/webs v0.6.7 )
M
go.sum
→
go.sum
@@ -23,3 +23,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= humungus.tedunangst.com/r/webs v0.6.6 h1:qepe+N9waCqLzOwhSws5pxpwSxNxdYRktJB1gY8Q3NQ= humungus.tedunangst.com/r/webs v0.6.6/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE= +humungus.tedunangst.com/r/webs v0.6.7 h1:VE556AXIwCVQRraVc36ild+b7ET30aoJNCVykDLqMPo= +humungus.tedunangst.com/r/webs v0.6.7/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE=
M
web.go
→
web.go
@@ -21,7 +21,6 @@ "fmt"
"html" "html/template" "io" - "io/ioutil" "log" notrand "math/rand" "net/http"@@ -1355,11 +1354,17 @@ w.Write(a)
} func servecss(w http.ResponseWriter, r *http.Request) { - data, _ := ioutil.ReadFile("views" + r.URL.Path) - s := css.Process(string(data)) - w.Header().Set("Cache-Control", "max-age=7776000") + fd, err := os.Open("views" + r.URL.Path) + if err != nil { + http.NotFound(w, r) + return + } + w.Header().Set("Cache-Control", "max-age=0") w.Header().Set("Content-Type", "text/css; charset=utf-8") - w.Write([]byte(s)) + err = css.Filter(fd, w) + if err != nil { + log.Printf("error filtering css: %s", err) + } } func serveasset(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "max-age=7776000")