Small improvements

This commit is contained in:
Jan-Lukas Else 2021-02-15 21:35:05 +01:00
parent 478d1dcaac
commit 82ace66544
6 changed files with 29 additions and 9 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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,
})
}
}

View File

@ -158,6 +158,14 @@ footer * {
background-color: white;
}
.tal {
text-align: left;
}
.tar {
text-align: right;
}
/* Print */
@media print {
html {

View File

@ -185,6 +185,14 @@ footer {
background-color: white;
}
.tal {
text-align: left;
}
.tar {
text-align: right;
}
/* Print */
@media print {
html {

View File

@ -9,21 +9,21 @@
<table class="p">
<thead>
<tr>
<th style="text-align:left">{{ string .Blog.Lang "year" }}</th>
<th style="text-align:right">{{ string .Blog.Lang "count" }}</th>
<th class="tal">{{ string .Blog.Lang "year" }}</th>
<th class="tar">{{ string .Blog.Lang "count" }}</th>
</tr>
</thead>
<tbody>
{{ $counts := .Data.counts }}
{{ range $i, $year := .Data.years }}
<tr>
<td style="text-align:left">{{ $year }}</td>
<td style="text-align:right">{{ index $counts $i }}</td>
<td class="tal">{{ $year }}</td>
<td class="tar">{{ index $counts $i }}</td>
</tr>
{{ end }}
<tr>
<td style="text-align:left"><b>{{ string .Blog.Lang "total" }}</b></td>
<td style="text-align:right">{{ .Data.total }}</td>
<td class="tal"><b>{{ string .Blog.Lang "total" }}</b></td>
<td class="tar">{{ .Data.total }}</td>
</tr>
</tbody>
</table>