cutephrase cleanup squad
Jes Olson j3s@c3f.net
Thu, 25 May 2023 17:03:50 -0700
4 files changed,
10 insertions(+),
25 deletions(-)
M
files/head.tmpl.html
→
files/head.tmpl.html
@@ -9,6 +9,7 @@ <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel='shortcut icon' href='/favicon.ico'> + <link rel="stylesheet" href="/static/style.css"> <link rel="manifest" href="/manifest.json"> <script>@@ -18,8 +19,5 @@ }
</script> <title>{{ .Title }}</title> -<style> -{{ .StyleSheet }} -</style> </head> {{end}}
M
site.go
→
site.go
@@ -3,7 +3,6 @@
import ( "errors" "fmt" - "io/ioutil" "log" "net/http" "net/url"@@ -314,33 +313,22 @@
tmplFiles := filepath.Join("files", "*.tmpl.html") tmpl := template.Must(template.New("whatever").Funcs(funcMap).ParseGlob(tmplFiles)) - // we read the stylesheet in order to render it inline - cssFile := filepath.Join("files", "style.css") - stylesheet, err := ioutil.ReadFile(cssFile) - if err != nil { - panic(err) - } - // fields on this anon struct are generally // pulled out of Data when they're globally required // callers should jam anything they want into Data pageData := struct { - Title string - Username string - LoggedIn bool - StyleSheet string - CutePhrase string - Data any + Title string + Username string + LoggedIn bool + Data any }{ - Title: page + " | " + s.title, - Username: s.username(r), - LoggedIn: s.loggedIn(r), - StyleSheet: string(stylesheet), - CutePhrase: s.randomCutePhrase(), - Data: data, + Title: page + " | " + s.title, + Username: s.username(r), + LoggedIn: s.loggedIn(r), + Data: data, } - err = tmpl.ExecuteTemplate(w, page, pageData) + err := tmpl.ExecuteTemplate(w, page, pageData) if err != nil { s.renderErr(w, err.Error(), http.StatusInternalServerError) return