From 82ace66544caf929f3e424ea17d1013e2317276b Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Mon, 15 Feb 2021 21:35:05 +0100 Subject: [PATCH] Small improvements --- config.go | 1 + http.go | 2 ++ search.go | 7 ++++--- templates/assets/css/styles.css | 8 ++++++++ templates/assets/css/styles.scss | 8 ++++++++ templates/blogstats.gohtml | 12 ++++++------ 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index be2180e..ef1ef77 100644 --- a/config.go +++ b/config.go @@ -31,6 +31,7 @@ type configServer struct { PublicAddress string `mapstructure:"publicAddress"` ShortPublicAddress string `mapstructure:"shortPublicAddress"` PublicHTTPS bool `mapstructure:"publicHttps"` + SecurityHeaders bool `mapstructure:"securityHeaders"` LetsEncryptMail string `mapstructure:"letsEncryptMail"` JWTSecret string `mapstructure:"jwtSecret"` publicHostname string diff --git a/http.go b/http.go index b934c0c..86e1cd6 100644 --- a/http.go +++ b/http.go @@ -54,6 +54,8 @@ func startServer() (err error) { hosts = append(hosts, appConfig.Server.shortPublicHostname) } err = certmagic.HTTPS(hosts, securityHeaders(d)) + } else if appConfig.Server.SecurityHeaders { + err = http.ListenAndServe(localAddress, securityHeaders(d)) } else { err = http.ListenAndServe(localAddress, d) } diff --git a/search.go b/search.go index d9302e4..05a4db4 100644 --- a/search.go +++ b/search.go @@ -4,12 +4,13 @@ import ( "encoding/base64" "net/http" "net/url" + "path" "strings" ) const searchPlaceholder = "{search}" -func serveSearch(blog string, path string) func(w http.ResponseWriter, r *http.Request) { +func serveSearch(blog string, servePath string) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { @@ -17,12 +18,12 @@ func serveSearch(blog string, path string) func(w http.ResponseWriter, r *http.R return } if q := r.Form.Get("q"); q != "" { - http.Redirect(w, r, path+"/"+searchEncode(q), http.StatusFound) + http.Redirect(w, r, path.Join(servePath, searchEncode(q)), http.StatusFound) return } render(w, templateSearch, &renderData{ BlogString: blog, - Canonical: appConfig.Server.PublicAddress + path, + Canonical: appConfig.Server.PublicAddress + servePath, }) } } diff --git a/templates/assets/css/styles.css b/templates/assets/css/styles.css index c70495d..e4a5b1a 100644 --- a/templates/assets/css/styles.css +++ b/templates/assets/css/styles.css @@ -158,6 +158,14 @@ footer * { background-color: white; } +.tal { + text-align: left; +} + +.tar { + text-align: right; +} + /* Print */ @media print { html { diff --git a/templates/assets/css/styles.scss b/templates/assets/css/styles.scss index f8b0b11..78fb61b 100644 --- a/templates/assets/css/styles.scss +++ b/templates/assets/css/styles.scss @@ -185,6 +185,14 @@ footer { background-color: white; } +.tal { + text-align: left; +} + +.tar { + text-align: right; +} + /* Print */ @media print { html { diff --git a/templates/blogstats.gohtml b/templates/blogstats.gohtml index c8e495d..67c2beb 100644 --- a/templates/blogstats.gohtml +++ b/templates/blogstats.gohtml @@ -9,21 +9,21 @@ - - + + {{ $counts := .Data.counts }} {{ range $i, $year := .Data.years }} - - + + {{ end }} - - + +
{{ string .Blog.Lang "year" }}{{ string .Blog.Lang "count" }}{{ string .Blog.Lang "year" }}{{ string .Blog.Lang "count" }}
{{ $year }}{{ index $counts $i }}{{ $year }}{{ index $counts $i }}
{{ string .Blog.Lang "total" }}{{ .Data.total }}{{ string .Blog.Lang "total" }}{{ .Data.total }}