From dc6be223c376c7494eda8bbc6130ef01d3891a19 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Sun, 8 May 2022 14:25:10 +0200 Subject: [PATCH] Absolute URLs for feeds --- go.mod | 6 +++--- go.sum | 12 ++++++------ httpRouters.go | 8 ++++---- paths.go | 6 ------ ui.go | 22 +++++++++++----------- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 8293e3e..beae4f2 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/jlelse/feeds v1.2.1-0.20210704161900-189f94254ad4 github.com/justinas/alice v1.2.0 github.com/kaorimatz/go-opml v0.0.0-20210201121027-bc8e2852d7f9 - github.com/klauspost/compress v1.15.2 + github.com/klauspost/compress v1.15.3 github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/lopezator/migrator v0.3.0 github.com/mattn/go-sqlite3 v1.14.12 @@ -43,7 +43,7 @@ require ( github.com/paulmach/go.geojson v1.4.0 github.com/posener/wstest v1.2.0 github.com/pquerna/otp v1.3.0 - github.com/samber/lo v1.18.0 + github.com/samber/lo v1.20.0 github.com/schollz/sqlite3dump v1.3.1 github.com/snabb/sitemap v1.0.0 github.com/spf13/cast v1.4.1 @@ -57,7 +57,7 @@ require ( github.com/yuin/goldmark v1.4.12 // master github.com/yuin/goldmark-emoji v1.0.2-0.20210607094911-0487583eca38 - golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f + golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/text v0.3.7 diff --git a/go.sum b/go.sum index e722958..acfbdb5 100644 --- a/go.sum +++ b/go.sum @@ -321,8 +321,8 @@ github.com/kaorimatz/go-opml v0.0.0-20210201121027-bc8e2852d7f9 h1:+9REu9CK9D1AQ github.com/kaorimatz/go-opml v0.0.0-20210201121027-bc8e2852d7f9/go.mod h1:OvY5ZBrAC9kOvM2PZs9Lw0BH+5K7tjrT6T7SFhn27OA= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.15.2 h1:3WH+AG7s2+T8o3nrM/8u2rdqUEcQhmga7smjrT41nAw= -github.com/klauspost/compress v1.15.2/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.15.3 h1:wmfu2iqj9q22SyMINp1uQ8C2/V4M1phJdmH9fG4nba0= +github.com/klauspost/compress v1.15.3/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -416,8 +416,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1-0.20211023094830-115ce09fd6b4 h1:Ha8xCaq6ln1a+R91Km45Oq6lPXj2Mla6CRJYcuV2h1w= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/samber/lo v1.18.0 h1:Us2BxtWXMLfIHm7lOJ3FnsSz1pzYAI7yfRZPV/5nBPU= -github.com/samber/lo v1.18.0/go.mod h1:2I7tgIv8Q1SG2xEIkRq0F2i2zgxVpnyPOP0d3Gj2r+A= +github.com/samber/lo v1.20.0 h1:20FtphdORvp4yxklurzZv2HX+g+0urEMQziODC5bV70= +github.com/samber/lo v1.20.0/go.mod h1:2I7tgIv8Q1SG2xEIkRq0F2i2zgxVpnyPOP0d3Gj2r+A= github.com/schollz/sqlite3dump v1.3.1 h1:QXizJ7XEJ7hggjqjZ3YRtF3+javm8zKtzNByYtEkPRA= github.com/schollz/sqlite3dump v1.3.1/go.mod h1:mzSTjZpJH4zAb1FN3iNlhWPbbdyeBpOaTW0hukyMHyI= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= @@ -517,8 +517,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc= -golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 h1:NvGWuYG8dkDHFSKksI1P9faiVJ9rayE6l0+ouWVIDs8= +golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/httpRouters.go b/httpRouters.go index 17a51ad..13db881 100644 --- a/httpRouters.go +++ b/httpRouters.go @@ -426,9 +426,9 @@ func (a *goBlog) blogContactRouter(conf *configBlog) func(r chi.Router) { func (a *goBlog) blogSitemapRouter(conf *configBlog) func(r chi.Router) { return func(r chi.Router) { r.Use(a.privateModeHandler, cacheLoggedIn, a.cacheMiddleware) - r.Get(conf.RelativePath(sitemapBlogPath), a.serveSitemapBlog) - r.Get(conf.RelativePath(sitemapBlogFeaturesPath), a.serveSitemapBlogFeatures) - r.Get(conf.RelativePath(sitemapBlogArchivesPath), a.serveSitemapBlogArchives) - r.Get(conf.RelativePath(sitemapBlogPostsPath), a.serveSitemapBlogPosts) + r.Get(conf.getRelativePath(sitemapBlogPath), a.serveSitemapBlog) + r.Get(conf.getRelativePath(sitemapBlogFeaturesPath), a.serveSitemapBlogFeatures) + r.Get(conf.getRelativePath(sitemapBlogArchivesPath), a.serveSitemapBlogArchives) + r.Get(conf.getRelativePath(sitemapBlogPostsPath), a.serveSitemapBlogPosts) } } diff --git a/paths.go b/paths.go index 3896d76..7f821a7 100644 --- a/paths.go +++ b/paths.go @@ -47,9 +47,3 @@ func (cfg *configServer) getFullAddress(path string) string { } return pa + path } - -// Rendering funcs - -func (blog *configBlog) RelativePath(path string) string { - return blog.getRelativePath(path) -} diff --git a/ui.go b/ui.go index 36f8ba8..8d927be 100644 --- a/ui.go +++ b/ui.go @@ -43,11 +43,11 @@ func (a *goBlog) renderBase(hb *htmlBuilder, rd *renderData, title, main func(hb // Feeds renderedBlogTitle := a.renderMdTitle(rd.Blog.Title) // RSS - hb.writeElementOpen("link", "rel", "alternate", "type", "application/rss+xml", "title", fmt.Sprintf("RSS (%s)", renderedBlogTitle), "href", rd.Blog.Path+".rss") + hb.writeElementOpen("link", "rel", "alternate", "type", "application/rss+xml", "title", fmt.Sprintf("RSS (%s)", renderedBlogTitle), "href", a.getFullAddress(rd.Blog.Path+".rss")) // ATOM - hb.writeElementOpen("link", "rel", "alternate", "type", "application/atom+xml", "title", fmt.Sprintf("ATOM (%s)", renderedBlogTitle), "href", rd.Blog.Path+".atom") + hb.writeElementOpen("link", "rel", "alternate", "type", "application/atom+xml", "title", fmt.Sprintf("ATOM (%s)", renderedBlogTitle), "href", a.getFullAddress(rd.Blog.Path+".atom")) // JSON Feed - hb.writeElementOpen("link", "rel", "alternate", "type", "application/feed+json", "title", fmt.Sprintf("JSON Feed (%s)", renderedBlogTitle), "href", rd.Blog.Path+".json") + hb.writeElementOpen("link", "rel", "alternate", "type", "application/feed+json", "title", fmt.Sprintf("JSON Feed (%s)", renderedBlogTitle), "href", a.getFullAddress(rd.Blog.Path+".json")) // Webmentions hb.writeElementOpen("link", "rel", "webmention", "href", a.getFullAddress("/webmention")) // Micropub @@ -364,11 +364,11 @@ func (a *goBlog) renderIndex(hb *htmlBuilder, rd *renderData) { feedTitle = " (" + renderedIndexTitle + ")" } // RSS - hb.writeElementOpen("link", "rel", "alternate", "type", "application/rss+xml", "title", "RSS"+feedTitle, "href", id.first+".rss") + hb.writeElementOpen("link", "rel", "alternate", "type", "application/rss+xml", "title", "RSS"+feedTitle, "href", a.getFullAddress(id.first+".rss")) // ATOM - hb.writeElementOpen("link", "rel", "alternate", "type", "application/atom+xml", "title", "ATOM"+feedTitle, "href", id.first+".atom") + hb.writeElementOpen("link", "rel", "alternate", "type", "application/atom+xml", "title", "ATOM"+feedTitle, "href", a.getFullAddress(id.first+".atom")) // JSON Feed - hb.writeElementOpen("link", "rel", "alternate", "type", "application/feed+json", "title", "JSON Feed"+feedTitle, "href", id.first+".json") + hb.writeElementOpen("link", "rel", "alternate", "type", "application/feed+json", "title", "JSON Feed"+feedTitle, "href", a.getFullAddress(id.first+".json")) }, func(hb *htmlBuilder) { hb.writeElementOpen("main", "class", "h-feed") @@ -920,20 +920,20 @@ func (a *goBlog) renderPost(hb *htmlBuilder, rd *renderData) { if rd.LoggedIn() { hb.writeElementOpen("div", "class", "actions") // Update - hb.writeElementOpen("form", "method", "post", "action", rd.Blog.RelativePath("/editor")+"#update") + hb.writeElementOpen("form", "method", "post", "action", rd.Blog.getRelativePath("/editor")+"#update") hb.writeElementOpen("input", "type", "hidden", "name", "editoraction", "value", "loadupdate") hb.writeElementOpen("input", "type", "hidden", "name", "path", "value", p.Path) hb.writeElementOpen("input", "type", "submit", "value", a.ts.GetTemplateStringVariant(rd.Blog.Lang, "update")) hb.writeElementClose("form") // Delete - hb.writeElementOpen("form", "method", "post", "action", rd.Blog.RelativePath("/editor")) + hb.writeElementOpen("form", "method", "post", "action", rd.Blog.getRelativePath("/editor")) hb.writeElementOpen("input", "type", "hidden", "name", "action", "value", "delete") hb.writeElementOpen("input", "type", "hidden", "name", "url", "value", rd.Canonical) hb.writeElementOpen("input", "type", "submit", "value", a.ts.GetTemplateStringVariant(rd.Blog.Lang, "delete"), "class", "confirm", "data-confirmmessage", a.ts.GetTemplateStringVariant(rd.Blog.Lang, "confirmdelete")) hb.writeElementClose("form") // Undelete if p.Deleted() { - hb.writeElementOpen("form", "method", "post", "action", rd.Blog.RelativePath("/editor")) + hb.writeElementOpen("form", "method", "post", "action", rd.Blog.getRelativePath("/editor")) hb.writeElementOpen("input", "type", "hidden", "name", "action", "value", "undelete") hb.writeElementOpen("input", "type", "hidden", "name", "url", "value", rd.Canonical) hb.writeElementOpen("input", "type", "submit", "value", a.ts.GetTemplateStringVariant(rd.Blog.Lang, "undelete")) @@ -941,7 +941,7 @@ func (a *goBlog) renderPost(hb *htmlBuilder, rd *renderData) { } // TTS if a.ttsEnabled() { - hb.writeElementOpen("form", "method", "post", "action", rd.Blog.RelativePath("/editor")) + hb.writeElementOpen("form", "method", "post", "action", rd.Blog.getRelativePath("/editor")) hb.writeElementOpen("input", "type", "hidden", "name", "editoraction", "value", "tts") hb.writeElementOpen("input", "type", "hidden", "name", "url", "value", rd.Canonical) hb.writeElementOpen("input", "type", "submit", "value", a.ts.GetTemplateStringVariant(rd.Blog.Lang, "gentts")) @@ -990,7 +990,7 @@ func (a *goBlog) renderStaticHome(hb *htmlBuilder, rd *renderData) { // Update if rd.LoggedIn() { hb.writeElementOpen("div", "class", "actions") - hb.writeElementOpen("form", "method", "post", "action", rd.Blog.RelativePath("/editor")+"#update") + hb.writeElementOpen("form", "method", "post", "action", rd.Blog.getRelativePath("/editor")+"#update") hb.writeElementOpen("input", "type", "hidden", "name", "editoraction", "value", "loadupdate") hb.writeElementOpen("input", "type", "hidden", "name", "path", "value", p.Path) hb.writeElementOpen("input", "type", "submit", "value", a.ts.GetTemplateStringVariant(rd.Blog.Lang, "update"))