summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2023-01-22 14:12:54 +0100
committerBrian Picciano <mediocregopher@gmail.com>2023-01-22 14:12:54 +0100
commitacec797048301c7d8713d9c914d776929c51b088 (patch)
tree5339ede42c5f07760b2d4a27f4b920bdbf27f328 /src
parent5b5a0438682ecb69bbc8d7cb9904ad4b049033a3 (diff)
Final fleshing out of gemini content
Diffstat (limited to 'src')
-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
-rw-r--r--src/http/tpl/index.html20
-rw-r--r--src/http/tpl/posts.html4
8 files changed, 117 insertions, 24 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" . }}
diff --git a/src/http/tpl/index.html b/src/http/tpl/index.html
index f19b550..c9eb45b 100644
--- a/src/http/tpl/index.html
+++ b/src/http/tpl/index.html
@@ -1,20 +1,19 @@
{{ define "body" }}
<p>
- Hi! I'm Brian, and this here's my little corner of the web. Here I write
+ This here's my little corner of the web, where I publish
<a href="{{ BlogURL "posts" }}">posts</a>
about projects I'm working on and things that interest me (which you can
<a href="{{ BlogURL "follow" }}">follow</a>,
- if you like). Beyond that I've listed various links related to me below.
+ if you like).
</p>
<h2>Social</h2>
+ <p>Feel free to hmu on any of these if you'd like to get in touch.</p>
<ul>
- <li><a href="https://matrix.to/#/@mediocregopher:waffle.farm">@mediocregopher:waffle.farm</a> is my matrix handle.</li>
- <li><a href="https://social.cryptic.io/@mediocregopher">@mediocregopher@social.cryptic.io</a> is my mastodon handle.</li>
- <li><a href="https://bgpicciano.com">bgpicciano.com</a> is my cover site/resume.</li>
- <li><a href="mailto:mediocregopher@gmail.com">mediocregopher@gmail.com</a> is my email.</li>
- <li><a href="https://news.cryptic.io">Cryptic News</a> aggregates interesting blogs.</li>
+ <li>Matrix: <a href="https://matrix.to/#/@mediocregopher:waffle.farm">@mediocregopher:waffle.farm</a></li>
+ <li>Mastodon: <a href="https://social.cryptic.io/@mediocregopher">@mediocregopher@social.cryptic.io</a></li>
+ <li>Email: <a href="mailto:mediocregopher@gmail.com">mediocregopher@gmail.com</a></li>
</ul>
<h2>Dev</h2>
@@ -36,12 +35,17 @@
<li><a href="https://exchange.art/artists/mediocregopher/series">Exchange.art</a> lists others.</li>
</ul>
+ <h2>Other</h2>
+ <ul>
+ <li><a href="https://bgpicciano.com">bgpicciano.com</a> is my cover site/resume.</li>
+ <li><a href="https://news.cryptic.io">Cryptic News</a> aggregates interesting blogs.</li>
+ </ul>
+
<hr/>
<p>I'm not affiliated with these, but they're worth listing.</p>
<ul>
<li><a href="https://search.marginalia.nu/">Marginalia</a> reminds me of the old internet.</li>
- <li><a href="https://drewdevault.com/2020/11/01/What-is-Gemini-anyway.html">Gemini</a> is a protocol I soon hope to add to this site.</li>
<li><a href="https://www.nts.live/">NTS</a> is a great internet radio station.</li>
<li><a href="https://yamakan.place/palestine/#">Radio alHara</a> is another great internet radio station.</li>
</ul>
diff --git a/src/http/tpl/posts.html b/src/http/tpl/posts.html
index ef94ffb..e6d226b 100644
--- a/src/http/tpl/posts.html
+++ b/src/http/tpl/posts.html
@@ -6,8 +6,8 @@
</p>
{{ else }}
<p>
- Posts are listed in chronological order. If you aren't sure of where to
- start I recommend picking at random.
+ Here you'll find an archive of all published posts. The content varies
+ almost as much as the quality!
</p>
{{ end }}