mirror of https://github.com/jlelse/GoBlog
Small improvements
This commit is contained in:
parent
a47a1719eb
commit
4bba5c9a4a
4
cache.go
4
cache.go
|
@ -95,9 +95,9 @@ func cacheKey(r *http.Request) string {
|
||||||
func cacheURLString(u *url.URL) string {
|
func cacheURLString(u *url.URL) string {
|
||||||
var buf strings.Builder
|
var buf strings.Builder
|
||||||
_, _ = buf.WriteString(u.EscapedPath())
|
_, _ = buf.WriteString(u.EscapedPath())
|
||||||
if u.RawQuery != "" {
|
if q := u.Query(); len(q) > 0 {
|
||||||
_ = buf.WriteByte('?')
|
_ = buf.WriteByte('?')
|
||||||
_, _ = buf.WriteString(u.RawQuery)
|
_, _ = buf.WriteString(q.Encode())
|
||||||
}
|
}
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
3
posts.go
3
posts.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
|
"github.com/microcosm-cc/bluemonday"
|
||||||
"github.com/vcraescu/go-paginator"
|
"github.com/vcraescu/go-paginator"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -233,6 +234,8 @@ func serveIndex(ic *indexConfig) func(w http.ResponseWriter, r *http.Request) {
|
||||||
} else if search != "" {
|
} else if search != "" {
|
||||||
title = fmt.Sprintf("%s: %s", appConfig.Blogs[ic.blog].Search.Title, search)
|
title = fmt.Sprintf("%s: %s", appConfig.Blogs[ic.blog].Search.Title, search)
|
||||||
}
|
}
|
||||||
|
// Clean title
|
||||||
|
title = bluemonday.StrictPolicy().Sanitize(title)
|
||||||
// Check if feed
|
// Check if feed
|
||||||
if ft := feedType(chi.URLParam(r, "feed")); ft != noFeed {
|
if ft := feedType(chi.URLParam(r, "feed")); ft != noFeed {
|
||||||
generateFeed(ic.blog, ft, w, r, posts, title, description)
|
generateFeed(ic.blog, ft, w, r, posts, title, description)
|
||||||
|
|
|
@ -13,9 +13,13 @@
|
||||||
<hr>
|
<hr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $blog := .Blog }}
|
{{ $blog := .Blog }}
|
||||||
{{ $summaryTemplate := .Data.SummaryTemplate }}
|
{{ if .Data.Posts }}
|
||||||
{{ range $i, $post := .Data.Posts }}
|
{{ $summaryTemplate := .Data.SummaryTemplate }}
|
||||||
{{ include $summaryTemplate $blog $post }}
|
{{ range $i, $post := .Data.Posts }}
|
||||||
|
{{ include $summaryTemplate $blog $post }}
|
||||||
|
{{ end }}
|
||||||
|
{{ else }}
|
||||||
|
<p>{{ string .Blog.Lang "noposts" }}</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if .Data.HasPrev }}
|
{{ if .Data.HasPrev }}
|
||||||
<p><a href="{{ .Data.Prev }}">{{ string .Blog.Lang "prev" }}</a></p>
|
<p><a href="{{ .Data.Prev }}">{{ string .Blog.Lang "prev" }}</a></p>
|
||||||
|
|
|
@ -11,6 +11,7 @@ interactions: "Interaktionen & Kommentare"
|
||||||
interactionslabel: "Hast du eine Antwort hierzu veröffentlicht? Füge hier die URL ein."
|
interactionslabel: "Hast du eine Antwort hierzu veröffentlicht? Füge hier die URL ein."
|
||||||
likeof: "Gefällt mir von"
|
likeof: "Gefällt mir von"
|
||||||
next: "Weiter"
|
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."
|
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"
|
prev: "Zurück"
|
||||||
publishedon: "Veröffentlicht am"
|
publishedon: "Veröffentlicht am"
|
||||||
|
|
|
@ -20,6 +20,7 @@ login: "Login"
|
||||||
logout: "Logout"
|
logout: "Logout"
|
||||||
nameopt: "Name (optional)"
|
nameopt: "Name (optional)"
|
||||||
next: "Next"
|
next: "Next"
|
||||||
|
noposts: "There are no posts here."
|
||||||
notifications: "Notifications"
|
notifications: "Notifications"
|
||||||
oldcontent: "⚠️ This entry is already over one year old. It may no longer be up to date. Opinions may have changed."
|
oldcontent: "⚠️ This entry is already over one year old. It may no longer be up to date. Opinions may have changed."
|
||||||
password: "Password"
|
password: "Password"
|
||||||
|
|
Loading…
Reference in New Issue