From 01424c7dab5fe42a9f00e3c9bb285924e42136fc Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 21 May 2022 11:34:03 -0600 Subject: Standardize URL generation across the blog --- srv/src/http/posts.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'srv/src/http/posts.go') diff --git a/srv/src/http/posts.go b/srv/src/http/posts.go index c05f3de..2f96c6d 100644 --- a/srv/src/http/posts.go +++ b/srv/src/http/posts.go @@ -25,7 +25,7 @@ type postTplPayload struct { func (a *api) postToPostTplPayload(storedPost post.StoredPost) (postTplPayload, error) { - bodyTpl, err := a.parseTpl(storedPost.Body) + bodyTpl, err := a.parseTpl(storedPost.ID+"-body.html", storedPost.Body) if err != nil { return postTplPayload{}, fmt.Errorf("parsing post body as template: %w", err) } @@ -271,7 +271,7 @@ func (a *api) postPostHandler() http.Handler { if first { a.params.Logger.Info(r.Context(), "publishing blog post to mailing list") - urlStr := a.params.PublicURL.String() + filepath.Join("/posts", p.ID) + urlStr := a.postURL(p.ID, true) if err := a.params.MailingList.Publish(p.Title, urlStr); err != nil { apiutil.InternalServerError( @@ -281,9 +281,7 @@ func (a *api) postPostHandler() http.Handler { } } - redirectPath := fmt.Sprintf("posts/%s?edit", p.ID) - - a.executeRedirectTpl(rw, r, redirectPath) + a.executeRedirectTpl(rw, r, a.postURL(p.ID, false)+"?edit") }) } @@ -310,7 +308,7 @@ func (a *api) deletePostHandler() http.Handler { return } - a.executeRedirectTpl(rw, r, "posts/") + a.executeRedirectTpl(rw, r, a.postsURL(false)) }) } -- cgit v1.2.3