summaryrefslogtreecommitdiff
path: root/src/http/posts.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2023-01-24 12:40:32 +0100
committerBrian Picciano <mediocregopher@gmail.com>2023-01-24 12:45:10 +0100
commit6b3933282e3aa9803636b2ba580aced5c202eaa9 (patch)
treeafee0d9661e964a3f6f2f782bd959333c4cdaa09 /src/http/posts.go
parent63cc6cb217dadc2fa5aa8d55e054cdbad14df60a (diff)
Refactor URL construction a bit
BlogHTTPURL and BlogGeminiURL are now used specifically to construct absolute URLs to their respective endpoints.
Diffstat (limited to 'src/http/posts.go')
-rw-r--r--src/http/posts.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/http/posts.go b/src/http/posts.go
index 8cb8472..2c6f896 100644
--- a/src/http/posts.go
+++ b/src/http/posts.go
@@ -66,14 +66,16 @@ type postTplPayload struct {
Body template.HTML
}
-func (a *api) postToPostTplPayload(storedPost post.StoredPost) (postTplPayload, error) {
-
- preprocessFuncs := post.PreprocessFunctions{
+func (a *api) postPreprocessFuncs() post.PreprocessFunctions {
+ return post.PreprocessFunctions{
BlogURL: func(path string) string {
- return a.blogURL(path, false)
+ return a.blogURL(a.params.PublicURL, path, false)
},
BlogHTTPURL: func(path string) string {
- return a.blogURL(path, false)
+ return a.blogURL(a.params.PublicURL, path, true)
+ },
+ BlogGeminiURL: func(path string) string {
+ return a.blogURL(a.params.GeminiPublicURL, path, true)
},
AssetURL: func(id string) string {
return a.assetURL(id, false)
@@ -83,10 +85,15 @@ func (a *api) postToPostTplPayload(storedPost post.StoredPost) (postTplPayload,
},
StaticURL: func(path string) string {
path = filepath.Join("static", path)
- return a.blogURL(path, false)
+ return a.blogURL(a.params.PublicURL, path, false)
},
Image: a.postPreprocessFuncImage,
}
+}
+
+func (a *api) postToPostTplPayload(storedPost post.StoredPost) (postTplPayload, error) {
+
+ preprocessFuncs := a.postPreprocessFuncs()
bodyBuf := new(bytes.Buffer)