summaryrefslogtreecommitdiff
path: root/src/gmi
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmi')
-rw-r--r--src/gmi/gmi.go4
-rw-r--r--src/gmi/tpl.go2
-rw-r--r--src/gmi/tpl/feed.xml8
-rw-r--r--src/gmi/tpl/footer.gmi4
-rw-r--r--src/gmi/tpl/index.gmi8
-rw-r--r--src/gmi/tpl/posts/index.gmi11
-rw-r--r--src/gmi/tpl/posts/post.gmi10
7 files changed, 25 insertions, 22 deletions
diff --git a/src/gmi/gmi.go b/src/gmi/gmi.go
index e37ca74..89c35bc 100644
--- a/src/gmi/gmi.go
+++ b/src/gmi/gmi.go
@@ -58,7 +58,9 @@ func (p *Params) SetupCfg(cfg *cfg.Cfg) {
var err error
- *publicURLStr = strings.TrimSuffix(*publicURLStr, "/")
+ if !strings.HasSuffix(*publicURLStr, "/") {
+ *publicURLStr += "/"
+ }
if p.PublicURL, err = url.Parse(*publicURLStr); err != nil {
return fmt.Errorf("parsing -gemini-public-url: %w", err)
diff --git a/src/gmi/tpl.go b/src/gmi/tpl.go
index f6c1754..cdf9535 100644
--- a/src/gmi/tpl.go
+++ b/src/gmi/tpl.go
@@ -175,6 +175,8 @@ func (a *api) tplHandler() (gemini.Handler, error) {
ctx,
r.URL,
a.params.PublicURL,
+ a.params.HTTPPublicURL,
+ a.params.PublicURL, // geminiURL
a.params.HTTPGeminiGatewayURL,
a.params.PostStore,
nil, // asset.Store, not supported by gemini endpoint
diff --git a/src/gmi/tpl/feed.xml b/src/gmi/tpl/feed.xml
index aa596b7..2935327 100644
--- a/src/gmi/tpl/feed.xml
+++ b/src/gmi/tpl/feed.xml
@@ -3,11 +3,11 @@
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>mediocregopher's lil web corner</title>
- <id>{{ BlogGeminiURL "/" }}</id>
+ <id>{{ .RootURL.Absolute }}</id>
{{ if gt (len $posts) 0 -}}
<updated>{{ (index $posts 0).PublishedAt.Format "2006-01-02T15:04:05Z07:00" }}</updated>
{{ end -}}
- <link href="{{ BlogGeminiURL "/" }}"></link>
+ <link href="{{ .RootURL.Absolute }}"></link>
<author>
<name>mediocregopher</name>
</author>
@@ -15,8 +15,8 @@
<entry>
<title>{{ .Title }}</title>
<updated>{{ .PublishedAt.Format "2006-01-02T15:04:05Z07:00" }}</updated>
- <id>{{ PostURLAbs .ID }}</id>
- <link href="{{ PostURLAbs .ID }}" rel="alternate"></link>
+ <id>{{ $.RootURL.Absolute.Post .ID }}</id>
+ <link href="{{ $.RootURL.Absolute.Post .ID }}" rel="alternate"></link>
{{ if .Description -}}
<summary type="html">{{ .Description }}</summary>
{{ end -}}
diff --git a/src/gmi/tpl/footer.gmi b/src/gmi/tpl/footer.gmi
index 15ee7b6..04a6562 100644
--- a/src/gmi/tpl/footer.gmi
+++ b/src/gmi/tpl/footer.gmi
@@ -1,10 +1,10 @@
========================================
{{ if ne .GetPath "index.gmi" -}}
-=> {{ BlogURL "/" }} Home
+=> {{ .RootURL }} Home
{{ end -}}
=> https://dev.mediocregopher.com/mediocre-blog.git Source
-=> {{ BlogURL "wtfpl.txt" }} License for all content, if you must have one
+=> {{ .RootURL.Path "wtfpl.txt" }} License for all content, if you must have one
diff --git a/src/gmi/tpl/index.gmi b/src/gmi/tpl/index.gmi
index b854481..6a70607 100644
--- a/src/gmi/tpl/index.gmi
+++ b/src/gmi/tpl/index.gmi
@@ -2,16 +2,16 @@
This here's my little corner of the web, where I publish posts about projects I'm working on and things that interest me (which you can follow, if you like).
-=> {{ BlogURL "posts/" }} Browse all posts
+=> {{ .RootURL.Posts }} Browse all posts
{{ $getPostsRes := .GetPosts 0 1 -}}
{{ if gt (len $getPostsRes.Posts) 0 -}}
{{ $post := index $getPostsRes.Posts 0 -}}
-=> {{ PostURL $post.ID }} (Latest post: {{ $post.Title }})
+=> {{ .RootURL.Post $post.ID }} (Latest post: {{ $post.Title }})
{{ end -}}
-=> {{ BlogURL "feed.xml" }} RSS feed
+=> {{ .RootURL.Path "feed.xml" }} RSS feed
Below you'll find other information and links related to me.
@@ -21,7 +21,7 @@ Feel free to hmu over email or Signal if you'd like to get in touch.
=> mailto:me@mediocregopher Email: me@mediocregopher.com
-=> {{ BlogURL "me@mediocregopher.com.gpg" }} GPG Key
+=> {{ .RootURL.Path "me@mediocregopher.com.gpg" }} GPG Key
=> https://signal.me/#eu/x5psueq2E3WfFwwEgFDoWeSZx9k4u8vFBaiMSa4Lo0cvluHkb-dIpJp1wfdJsdie Signal: mediocregopher.01
diff --git a/src/gmi/tpl/posts/index.gmi b/src/gmi/tpl/posts/index.gmi
index 2ff296a..873222b 100644
--- a/src/gmi/tpl/posts/index.gmi
+++ b/src/gmi/tpl/posts/index.gmi
@@ -1,29 +1,28 @@
# 👻 mediocregopher's Posts
{{ $page := .GetQueryIntValue "page" 0 -}}
+{{ $getPostsRes := .GetPosts $page 20 -}}
{{ if eq $page 0 -}}
Here you'll find an archive of all published posts. The content varies almost as much as the quality!
{{ end -}}
-{{ $getPostsRes := .GetPosts $page 20 -}}
-
{{ if gt $page 0 -}}
-=> {{ BlogURL "posts" }}/?page={{ .Add $page -1 }} Previous Page
+=> {{ .RootURL.Posts.Page (.Add $page -1) }} Previous Page
{{ end -}}
{{ range $getPostsRes.Posts -}}
-=> {{ PostURL .ID }} {{ .PublishedAt.Format "2006-01-02" }} - {{ .Title }}
+=> {{ $.RootURL.Post .ID }} {{ .PublishedAt.Format "2006-01-02" }} - {{ .Title }}
{{ end -}}
{{ if $getPostsRes.HasMore -}}
-=> {{ BlogURL "posts" }}/?page={{ .Add $page 1 }} Next page
+=> {{ .RootURL.Posts.Page (.Add $page 1) }} Next page
{{ end }}
========================================
-=> {{ BlogURL "feed.xml" }} RSS feed
+=> {{ .RootURL.Path "feed.xml" }} RSS feed
{{ template "footer.gmi" . }}
diff --git a/src/gmi/tpl/posts/post.gmi b/src/gmi/tpl/posts/post.gmi
index b568044..eafa76c 100644
--- a/src/gmi/tpl/posts/post.gmi
+++ b/src/gmi/tpl/posts/post.gmi
@@ -3,7 +3,7 @@
{{ if eq $post.Format "md" -}}
This post has been translated from it's original markdown format, if it seems busted it might appear better over HTTP:
-=> {{ PostHTTPURL $post.ID }}
+=> {{ .RootURL.HTTP.Post $post.ID }}
{{ end -}}
@@ -26,18 +26,18 @@ Published {{ $post.PublishedAt.Format "2006-01-02" }} by mediocregopher
This post is part of a series!
{{ if $seriesNextPrev.Next -}}
-=> {{ BlogURL "posts" }}/{{ $seriesNextPrev.Next.ID }}.gmi Next in the series: {{ $seriesNextPrev.Next.Title }}
+=> {{ .RootURL.Post $seriesNextPrev.Next.ID }} Next in the series: {{ $seriesNextPrev.Next.Title }}
{{ end -}}
{{ if $seriesNextPrev.Previous -}}
-=> {{ BlogURL "posts" }}/{{ $seriesNextPrev.Previous.ID }}.gmi Prevous in the series: {{ $seriesNextPrev.Previous.Title }}
+=> {{ .RootURL.Post $seriesNextPrev.Previous.ID }} Prevous in the series: {{ $seriesNextPrev.Previous.Title }}
{{ end -}}
{{ end -}}
{{ else }}{{/* newline */}}
{{ end }}
-=> {{ BlogURL "posts/" }} Browse all posts
+=> {{ .RootURL.Posts }} Browse all posts
-=> {{ BlogURL "feed.xml" }} RSS feed
+=> {{ .RootURL.Path "feed.xml" }} RSS feed
{{ template "footer.gmi" . }}