mirror of https://github.com/jlelse/GoBlog
Small improvements
This commit is contained in:
parent
478d1dcaac
commit
82ace66544
|
@ -31,6 +31,7 @@ type configServer struct {
|
||||||
PublicAddress string `mapstructure:"publicAddress"`
|
PublicAddress string `mapstructure:"publicAddress"`
|
||||||
ShortPublicAddress string `mapstructure:"shortPublicAddress"`
|
ShortPublicAddress string `mapstructure:"shortPublicAddress"`
|
||||||
PublicHTTPS bool `mapstructure:"publicHttps"`
|
PublicHTTPS bool `mapstructure:"publicHttps"`
|
||||||
|
SecurityHeaders bool `mapstructure:"securityHeaders"`
|
||||||
LetsEncryptMail string `mapstructure:"letsEncryptMail"`
|
LetsEncryptMail string `mapstructure:"letsEncryptMail"`
|
||||||
JWTSecret string `mapstructure:"jwtSecret"`
|
JWTSecret string `mapstructure:"jwtSecret"`
|
||||||
publicHostname string
|
publicHostname string
|
||||||
|
|
2
http.go
2
http.go
|
@ -54,6 +54,8 @@ func startServer() (err error) {
|
||||||
hosts = append(hosts, appConfig.Server.shortPublicHostname)
|
hosts = append(hosts, appConfig.Server.shortPublicHostname)
|
||||||
}
|
}
|
||||||
err = certmagic.HTTPS(hosts, securityHeaders(d))
|
err = certmagic.HTTPS(hosts, securityHeaders(d))
|
||||||
|
} else if appConfig.Server.SecurityHeaders {
|
||||||
|
err = http.ListenAndServe(localAddress, securityHeaders(d))
|
||||||
} else {
|
} else {
|
||||||
err = http.ListenAndServe(localAddress, d)
|
err = http.ListenAndServe(localAddress, d)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,13 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const searchPlaceholder = "{search}"
|
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) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
err := r.ParseForm()
|
err := r.ParseForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -17,12 +18,12 @@ func serveSearch(blog string, path string) func(w http.ResponseWriter, r *http.R
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if q := r.Form.Get("q"); q != "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
render(w, templateSearch, &renderData{
|
render(w, templateSearch, &renderData{
|
||||||
BlogString: blog,
|
BlogString: blog,
|
||||||
Canonical: appConfig.Server.PublicAddress + path,
|
Canonical: appConfig.Server.PublicAddress + servePath,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,14 @@ footer * {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tal {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tar {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* Print */
|
/* Print */
|
||||||
@media print {
|
@media print {
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -185,6 +185,14 @@ footer {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tal {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tar {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* Print */
|
/* Print */
|
||||||
@media print {
|
@media print {
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -9,21 +9,21 @@
|
||||||
<table class="p">
|
<table class="p">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="text-align:left">{{ string .Blog.Lang "year" }}</th>
|
<th class="tal">{{ string .Blog.Lang "year" }}</th>
|
||||||
<th style="text-align:right">{{ string .Blog.Lang "count" }}</th>
|
<th class="tar">{{ string .Blog.Lang "count" }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{ $counts := .Data.counts }}
|
{{ $counts := .Data.counts }}
|
||||||
{{ range $i, $year := .Data.years }}
|
{{ range $i, $year := .Data.years }}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align:left">{{ $year }}</td>
|
<td class="tal">{{ $year }}</td>
|
||||||
<td style="text-align:right">{{ index $counts $i }}</td>
|
<td class="tar">{{ index $counts $i }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align:left"><b>{{ string .Blog.Lang "total" }}</b></td>
|
<td class="tal"><b>{{ string .Blog.Lang "total" }}</b></td>
|
||||||
<td style="text-align:right">{{ .Data.total }}</td>
|
<td class="tar">{{ .Data.total }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue