diff --git a/cache.go b/cache.go index 4a2918a..b225782 100644 --- a/cache.go +++ b/cache.go @@ -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() } diff --git a/posts.go b/posts.go index cf16ddc..700e0cb 100644 --- a/posts.go +++ b/posts.go @@ -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) diff --git a/templates/index.gohtml b/templates/index.gohtml index 44f595a..d660fa7 100644 --- a/templates/index.gohtml +++ b/templates/index.gohtml @@ -13,9 +13,13 @@
{{ 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 }} +

{{ string .Blog.Lang "noposts" }}

{{ end }} {{ if .Data.HasPrev }}

{{ string .Blog.Lang "prev" }}

diff --git a/templates/strings/de.yaml b/templates/strings/de.yaml index cfbdc5d..f0a8b0b 100644 --- a/templates/strings/de.yaml +++ b/templates/strings/de.yaml @@ -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" diff --git a/templates/strings/default.yaml b/templates/strings/default.yaml index 40c1d4c..0bd2fec 100644 --- a/templates/strings/default.yaml +++ b/templates/strings/default.yaml @@ -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"