summaryrefslogtreecommitdiff
path: root/src/gmi/tpl.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2023-01-21 19:38:59 +0100
committerBrian Picciano <mediocregopher@gmail.com>2023-01-21 19:38:59 +0100
commit0d420f70d89281320d95e92db01b240a40c6e2f7 (patch)
tree57e4fafdd67bfad2cff8df3dc1b53365bdcb6176 /src/gmi/tpl.go
parent2ca44b60d4cdbd6158604b5c25f80a9139f8c716 (diff)
Fix StaticURL in gemini
Diffstat (limited to 'src/gmi/tpl.go')
-rw-r--r--src/gmi/tpl.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gmi/tpl.go b/src/gmi/tpl.go
index 3022fe2..8220a49 100644
--- a/src/gmi/tpl.go
+++ b/src/gmi/tpl.go
@@ -33,8 +33,9 @@ type rendererGetPostSeriesNextPreviousRes struct {
}
type renderer struct {
- url *url.URL
- postStore post.Store
+ url *url.URL
+ postStore post.Store
+ httpPublicURL *url.URL
}
func (r renderer) GetPosts(page, count int) (rendererGetPostsRes, error) {
@@ -98,7 +99,9 @@ func (r renderer) PostBody(p post.StoredPost) (string, error) {
return filepath.Join("/posts", id)
},
StaticURL: func(path string) string {
- return filepath.Join("/static", path)
+ httpPublicURL := *r.httpPublicURL
+ httpPublicURL.Path = filepath.Join(httpPublicURL.Path, "/static", path)
+ return httpPublicURL.String()
},
Image: func(args ...string) (string, error) {
@@ -207,8 +210,9 @@ func (a *api) tplHandler() (gemini.Handler, error) {
buf := new(bytes.Buffer)
err := tpl.Execute(buf, renderer{
- url: r.URL,
- postStore: a.params.PostStore,
+ url: r.URL,
+ postStore: a.params.PostStore,
+ httpPublicURL: a.params.HTTPPublicURL,
})
if err != nil {