Small improvements

This commit is contained in:
Jan-Lukas Else 2021-03-08 18:14:52 +01:00
parent a47a1719eb
commit 4bba5c9a4a
5 changed files with 14 additions and 5 deletions

View File

@ -95,9 +95,9 @@ func cacheKey(r *http.Request) string {
func cacheURLString(u *url.URL) string {
var buf strings.Builder
_, _ = buf.WriteString(u.EscapedPath())
if u.RawQuery != "" {
if q := u.Query(); len(q) > 0 {
_ = buf.WriteByte('?')
_, _ = buf.WriteString(u.RawQuery)
_, _ = buf.WriteString(q.Encode())
}
return buf.String()
}

View File

@ -10,6 +10,7 @@ import (
"strings"
"github.com/go-chi/chi/v5"
"github.com/microcosm-cc/bluemonday"
"github.com/vcraescu/go-paginator"
)
@ -233,6 +234,8 @@ func serveIndex(ic *indexConfig) func(w http.ResponseWriter, r *http.Request) {
} else if search != "" {
title = fmt.Sprintf("%s: %s", appConfig.Blogs[ic.blog].Search.Title, search)
}
// Clean title
title = bluemonday.StrictPolicy().Sanitize(title)
// Check if feed
if ft := feedType(chi.URLParam(r, "feed")); ft != noFeed {
generateFeed(ic.blog, ft, w, r, posts, title, description)

View File

@ -13,9 +13,13 @@
<hr>
{{ end }}
{{ $blog := .Blog }}
{{ $summaryTemplate := .Data.SummaryTemplate }}
{{ range $i, $post := .Data.Posts }}
{{ include $summaryTemplate $blog $post }}
{{ if .Data.Posts }}
{{ $summaryTemplate := .Data.SummaryTemplate }}
{{ range $i, $post := .Data.Posts }}
{{ include $summaryTemplate $blog $post }}
{{ end }}
{{ else }}
<p>{{ string .Blog.Lang "noposts" }}</p>
{{ end }}
{{ if .Data.HasPrev }}
<p><a href="{{ .Data.Prev }}">{{ string .Blog.Lang "prev" }}</a></p>

View File

@ -11,6 +11,7 @@ interactions: "Interaktionen & Kommentare"
interactionslabel: "Hast du eine Antwort hierzu veröffentlicht? Füge hier die URL ein."
likeof: "Gefällt mir von"
next: "Weiter"
noposts: "Hier sind keine Posts."
oldcontent: "⚠️ Dieser Eintrag ist bereits über ein Jahr alt. Er ist möglicherweise nicht mehr aktuell. Meinungen können sich geändert haben."
prev: "Zurück"
publishedon: "Veröffentlicht am"

View File

@ -20,6 +20,7 @@ login: "Login"
logout: "Logout"
nameopt: "Name (optional)"
next: "Next"
noposts: "There are no posts here."
notifications: "Notifications"
oldcontent: "⚠️ This entry is already over one year old. It may no longer be up to date. Opinions may have changed."
password: "Password"