update to use new css filtering

This commit is contained in:
Ted Unangst 2019-09-27 22:00:35 -04:00
parent eacfaa2288
commit b25fb94be2
3 changed files with 13 additions and 6 deletions

2
go.mod
View File

@ -7,5 +7,5 @@ require (
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/net v0.0.0-20190620200207-3b0461eec859
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 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
) )

2
go.sum
View File

@ -23,3 +23,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= 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 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.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=

15
web.go
View File

@ -21,7 +21,6 @@ import (
"html" "html"
"html/template" "html/template"
"io" "io"
"io/ioutil"
"log" "log"
notrand "math/rand" notrand "math/rand"
"net/http" "net/http"
@ -1355,11 +1354,17 @@ func avatate(w http.ResponseWriter, r *http.Request) {
} }
func servecss(w http.ResponseWriter, r *http.Request) { func servecss(w http.ResponseWriter, r *http.Request) {
data, _ := ioutil.ReadFile("views" + r.URL.Path) fd, err := os.Open("views" + r.URL.Path)
s := css.Process(string(data)) if err != nil {
w.Header().Set("Cache-Control", "max-age=7776000") http.NotFound(w, r)
return
}
w.Header().Set("Cache-Control", "max-age=0")
w.Header().Set("Content-Type", "text/css; charset=utf-8") 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) { func serveasset(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=7776000") w.Header().Set("Cache-Control", "max-age=7776000")