summaryrefslogtreecommitdiff
path: root/src/gmi
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmi')
-rw-r--r--src/gmi/tpl.go18
-rw-r--r--src/gmi/tpl/feed.xml2
-rw-r--r--src/gmi/tpl/footer.gmi8
-rw-r--r--src/gmi/tpl/index.gmi60
-rw-r--r--src/gmi/tpl/posts/index.gmi19
-rw-r--r--src/gmi/tpl/posts/post.gmi10
6 files changed, 103 insertions, 14 deletions
diff --git a/src/gmi/tpl.go b/src/gmi/tpl.go
index edd3a75..8f4c3be 100644
--- a/src/gmi/tpl.go
+++ b/src/gmi/tpl.go
@@ -36,6 +36,7 @@ type rendererGetPostSeriesNextPreviousRes struct {
type renderer struct {
url *url.URL
+ publicURL *url.URL
postStore post.Store
preprocessFuncs post.PreprocessFunctions
}
@@ -124,12 +125,24 @@ func (r renderer) GetQueryIntValue(key string, def int) (int, error) {
return strconv.Atoi(vStr)
}
+func (r renderer) GetPath() (string, error) {
+ basePath := filepath.Join("/", r.publicURL.Path) // in case it's empty
+ return filepath.Rel(basePath, r.url.Path)
+}
+
func (r renderer) Add(a, b int) int { return a + b }
func (a *api) tplHandler() (gemini.Handler, error) {
blogURL := func(path string, abs bool) string {
- path = filepath.Join(a.params.PublicURL.Path, path)
+ // filepath.Join strips trailing slash, but we want to keep it
+ trailingSlash := strings.HasSuffix(path, "/")
+
+ path = filepath.Join("/", a.params.PublicURL.Path, path)
+
+ if trailingSlash && path != "/" {
+ path += "/"
+ }
if !abs {
return path
@@ -170,7 +183,7 @@ func (a *api) tplHandler() (gemini.Handler, error) {
path := blogURL(filepath.Join("assets", id), false)
- return fmt.Sprintf("=> %s %s", path, descr), nil
+ return fmt.Sprintf("\n=> %s %s", path, descr), nil
},
}
@@ -247,6 +260,7 @@ func (a *api) tplHandler() (gemini.Handler, error) {
err := tpl.Execute(buf, renderer{
url: r.URL,
+ publicURL: a.params.PublicURL,
postStore: a.params.PostStore,
preprocessFuncs: preprocessFuncs,
})
diff --git a/src/gmi/tpl/feed.xml b/src/gmi/tpl/feed.xml
index 497fb11..a33e42f 100644
--- a/src/gmi/tpl/feed.xml
+++ b/src/gmi/tpl/feed.xml
@@ -1,4 +1,4 @@
-{{ $getPostsRes := .GetPosts 0 15 -}}
+{{ $getPostsRes := .GetPosts 0 20 -}}
{{ $posts := $getPostsRes.Posts -}}
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
diff --git a/src/gmi/tpl/footer.gmi b/src/gmi/tpl/footer.gmi
new file mode 100644
index 0000000..44782a1
--- /dev/null
+++ b/src/gmi/tpl/footer.gmi
@@ -0,0 +1,8 @@
+================================================================================
+
+{{ if ne .GetPath "index.gmi" -}}
+=> {{ BlogURL "/" }} Home
+
+{{ end -}}
+
+=> {{ BlogURL "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 9f12e0d..8a0dbee 100644
--- a/src/gmi/tpl/index.gmi
+++ b/src/gmi/tpl/index.gmi
@@ -1,3 +1,61 @@
# mediocregopher's lil web corner
-=> /posts/ See all posts
+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
+
+{{ $getPostsRes := .GetPosts 0 1 -}}
+{{ if gt (len $getPostsRes.Posts) 0 -}}
+{{ $post := index $getPostsRes.Posts 0 -}}
+=> {{ PostURL $post.ID }} (Latest post: {{ $post.Title }})
+
+{{ end -}}
+
+Below you'll find other information and links related to me.
+
+## Social
+
+Feel free to hmu on any of these if you'd like to get in touch.
+
+* Matrix: @mediocregopher:waffle.farm
+
+* Mastodon: @mediocregopher@social.cryptic.io
+
+* Email: mediocregopher@gmail.com
+
+## Dev
+
+=> https://code.betamike.com/mediocregopher Gitea is for newer open-source code I've written.
+
+=> https://github.com/mediocregopher Github is for older open-source code I've written.
+
+=> gemini://godocs.io/github.com/mediocregopher/radix/v4 radix is for using redis with go.
+
+=> https://code.betamike.com/cryptic-io/cryptic-net cryptic-net implements the foundation of a community infrastucture.
+
+=> https://code.betamike.com/mediocregopher/mediocre-blog mediocre-blog is the CMS I designed from scratch to run this site.
+
+## Art
+
+=> https://opensea.io/mediocregopher?tab=created OpenSea lists some NFTs I've made.
+
+=> https://exchange.art/artists/mediocregopher/series Exchange.art lists others.
+
+## Other
+
+=> https://bgpicciano.com/ bgpicciano.com is my cover site/resume.
+
+=> https://news.cryptic.io/ Cryptic News aggregates interesting blogs.
+
+--------------------------------------------------------------------------------
+
+I'm not affiliated with these, but they're worth listing.
+
+=> https://search.marginalia.nu/ Marginalia reminds me of the old internet.
+
+=> https://www.nts.live/ NTS is a great internet radio station.
+
+=> https://yamakan.place/palestine/# Radio alHara is another great internet radio station.
+
+{{ template "footer.gmi" . }}
diff --git a/src/gmi/tpl/posts/index.gmi b/src/gmi/tpl/posts/index.gmi
index 9d0f6e2..60a62fd 100644
--- a/src/gmi/tpl/posts/index.gmi
+++ b/src/gmi/tpl/posts/index.gmi
@@ -1,10 +1,17 @@
# mediocregopher's Posts
{{ $page := .GetQueryIntValue "page" 0 -}}
-{{ $getPostsRes := .GetPosts $page 15 -}}
+
+{{ 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 -}}
-=> /posts/?page={{ .Add $page -1 }} Previous Page
+=> {{ BlogURL "posts" }}/?page={{ .Add $page -1 }} Previous Page
{{ end -}}
@@ -14,8 +21,10 @@
{{ end -}}
{{ if $getPostsRes.HasMore -}}
-=> /posts/?page={{ .Add $page 1 }} Next page
+=> {{ BlogURL "posts" }}/?page={{ .Add $page 1 }} Next page
{{ end }}
-================================================================================
+--------------------------------------------------------------------------------
+
+=> {{ BlogURL "feed.xml" }} Subscribe to the RSS feed for updates
-=> / Home
+{{ template "footer.gmi" . }}
diff --git a/src/gmi/tpl/posts/post.gmi b/src/gmi/tpl/posts/post.gmi
index 7d1719b..e95cb53 100644
--- a/src/gmi/tpl/posts/post.gmi
+++ b/src/gmi/tpl/posts/post.gmi
@@ -4,6 +4,7 @@
{{ if ne $post.Description "" -}}
> {{ $post.Description }}
+
{{ end -}}
{{ .PostBody $post }}
@@ -19,15 +20,14 @@ This post is part of a series!
{{ $seriesNextPrev := .GetPostSeriesNextPrevious $post -}}
{{ if $seriesNextPrev.Next -}}
-=> /posts/{{ $seriesNextPrev.Next.ID }}.gmi Next: {{ $seriesNextPrev.Next.Title }}
+=> {{ BlogURL "posts" }}/{{ $seriesNextPrev.Next.ID }}.gmi Next in the series: {{ $seriesNextPrev.Next.Title }}
{{ end -}}
{{ if $seriesNextPrev.Previous -}}
-=> /posts/{{ $seriesNextPrev.Previous.ID }}.gmi Previously: {{ $seriesNextPrev.Previous.Title }}
+=> {{ BlogURL "posts" }}/{{ $seriesNextPrev.Previous.ID }}.gmi Prevous in the series: {{ $seriesNextPrev.Previous.Title }}
{{ end -}}
{{ end }}
-================================================================================
+=> {{ BlogURL "posts/" }} Browse all posts
-=> /posts/ More posts
-=> / Home
+{{ template "footer.gmi" . }}