summaryrefslogtreecommitdiff
path: root/src/gmi/tpl.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmi/tpl.go')
-rw-r--r--src/gmi/tpl.go33
1 files changed, 4 insertions, 29 deletions
diff --git a/src/gmi/tpl.go b/src/gmi/tpl.go
index d4c6b00..fb62a17 100644
--- a/src/gmi/tpl.go
+++ b/src/gmi/tpl.go
@@ -9,9 +9,7 @@ import (
"io"
"io/fs"
"mime"
- "net/url"
"path"
- "path/filepath"
"strings"
"text/template"
@@ -36,26 +34,6 @@ var tplFS embed.FS
func (a *api) tplHandler() (gemini.Handler, error) {
- blogURL := func(base *url.URL, path string, abs bool) string {
-
- // filepath.Join strips trailing slash, but we want to keep it
- trailingSlash := strings.HasSuffix(path, "/")
-
- path = filepath.Join("/", base.Path, path)
-
- if trailingSlash && path != "/" {
- path += "/"
- }
-
- if !abs {
- return path
- }
-
- u := *base
- u.Path = path
- return u.String()
- }
-
preprocessFuncs := post.PreprocessFunctions{
Image: func(args ...string) (string, error) {
var (
@@ -67,10 +45,9 @@ func (a *api) tplHandler() (gemini.Handler, error) {
descr = args[1]
}
- path := filepath.Join("assets", id)
- path = blogURL(a.params.PublicURL, path, false)
-
- return fmt.Sprintf("\n=> %s %s", path, descr), nil
+ return fmt.Sprintf(
+ "\n=> %s %s", a.urlBuilder.Asset(id), descr,
+ ), nil
},
}
@@ -140,9 +117,7 @@ func (a *api) tplHandler() (gemini.Handler, error) {
err := tpl.Execute(buf, render.NewMethods(
ctx,
r.URL,
- a.params.PublicURL,
- a.params.HTTPPublicURL,
- a.params.PublicURL, // geminiURL
+ a.urlBuilder,
a.params.HTTPGeminiGatewayURL,
a.params.PostStore,
nil, // asset.Store, not supported by gemini endpoint