From eb9a842a40d7cb9c8017e9637392cc21ae614bef Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Fri, 11 Jun 2021 08:24:41 +0200 Subject: [PATCH] Fix --- activityPub.go | 2 +- http.go | 7 ++++--- posts.go | 2 +- postsDb.go | 2 +- sitemap.go | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/activityPub.go b/activityPub.go index b50bbf6..a475a95 100644 --- a/activityPub.go +++ b/activityPub.go @@ -409,7 +409,7 @@ func (a *goBlog) apNewID(blog *configBlog) (hash string, url string) { } func (a *goBlog) apIri(b *configBlog) string { - return a.getFullAddress(b.Path) + return a.getFullAddress(b.getRelativePath("")) } func apRequestIsSuccess(code int) bool { diff --git a/http.go b/http.go index fbb5405..21cedca 100644 --- a/http.go +++ b/http.go @@ -509,9 +509,10 @@ func (a *goBlog) buildDynamicRouter() (*chi.Mux, error) { r.Group(func(r chi.Router) { r.Use(a.privateModeHandler...) r.Use(sbm) - r.With(a.checkActivityStreamsRequest, a.cache.cacheMiddleware).Get(blogConfig.Path, a.serveHome) - r.With(a.cache.cacheMiddleware).Get(blogConfig.getRelativePath(feedPath), a.serveHome) - r.With(a.cache.cacheMiddleware).Get(blogConfig.getRelativePath(paginationPath), a.serveHome) + blogBasePath := blogConfig.getRelativePath("") + r.With(a.checkActivityStreamsRequest, a.cache.cacheMiddleware).Get(blogBasePath, a.serveHome) + r.With(a.cache.cacheMiddleware).Get(blogBasePath+feedPath, a.serveHome) + r.With(a.cache.cacheMiddleware).Get(blogBasePath+paginationPath, a.serveHome) }) } diff --git a/posts.go b/posts.go index f6e82d1..54fa7af 100644 --- a/posts.go +++ b/posts.go @@ -65,7 +65,7 @@ func (a *goBlog) servePost(w http.ResponseWriter, r *http.Request) { canonical = a.fullPostURL(p) } template := templatePost - if p.Path == a.cfg.Blogs[p.Blog].Path { + if p.Path == a.getRelativePath(p.Blog, "") { template = templateStaticHome } w.Header().Add("Link", fmt.Sprintf("<%s>; rel=shortlink", a.shortPostURL(p))) diff --git a/postsDb.go b/postsDb.go index bc3192f..df65469 100644 --- a/postsDb.go +++ b/postsDb.go @@ -89,7 +89,7 @@ func (a *goBlog) checkPost(p *post) (err error) { } var pathBuffer bytes.Buffer err = pathTmpl.Execute(&pathBuffer, map[string]interface{}{ - "BlogPath": a.cfg.Blogs[p.Blog].Path, + "BlogPath": a.getRelativePath(p.Blog, ""), "Year": published.Year(), "Month": int(published.Month()), "Day": published.Day(), diff --git a/sitemap.go b/sitemap.go index 379d57d..a50564a 100644 --- a/sitemap.go +++ b/sitemap.go @@ -18,7 +18,7 @@ func (a *goBlog) serveSitemap(w http.ResponseWriter, r *http.Request) { for b, bc := range a.cfg.Blogs { // Blog sm.Add(&sitemap.URL{ - Loc: a.getFullAddress(bc.Path), + Loc: a.getFullAddress(bc.getRelativePath("")), }) // Sections for _, section := range bc.Sections {