summaryrefslogtreecommitdiff
path: root/srv/src/http/posts.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-21 11:34:03 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-21 11:34:03 -0600
commit01424c7dab5fe42a9f00e3c9bb285924e42136fc (patch)
treeffca7063daab3b71a65171d080d9abc93bd27128 /srv/src/http/posts.go
parente269b111a18c8822b0c16f1567548bc598b25997 (diff)
Standardize URL generation across the blog
Diffstat (limited to 'srv/src/http/posts.go')
-rw-r--r--srv/src/http/posts.go10
1 files changed, 4 insertions, 6 deletions
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))
})
}