alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit bc5c029b2f19c5caec6573186d82faefa65ccab4 (patch)
parent 02970857475d2afc2257035718255b2e2c6c01b7
Author: Alex Karle <alex@alexkarle.com>
Date:   Wed, 17 Nov 2021 00:33:07 -0500

gophe: Add a phlog feed and a post about it

Exciting times in Gopherville. Now just to find a feed reader that
supports gopher :)

Diffstat:
M.gitignore | 1+
MMakefile | 8+++++++-
Agopher/bin/gophatom.sh | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Agopher/phlog/010.txt | 33+++++++++++++++++++++++++++++++++
Mgopher/phlog/index.gph | 3+++
5 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore @@ -4,6 +4,7 @@ # atom feed is generated by ./bin/genatom.sh atom.xml +gopher.atom # obj directory on OpenBSD for out-of-tree builds obj/ diff --git a/Makefile b/Makefile @@ -24,12 +24,14 @@ HTML != echo $(DIR)/*.[1-9] | sed 's@$(DIR)/\([^\.]*\)\.[1-9]@\1.html@g' TEXT != echo $(DIR)/*.[1-9] | sed 's@$(DIR)/\([^\.]*\)\.[1-9]@\1.txt@g' SETS != find $(DIR)/jam-tuesday -name '[0-9][0-9][0-9][0-9]-*' NOTES != find $(DIR)/gopher/notes/all +PHLOG != find $(DIR)/gopher/phlog BUILT = $(HTML) \ $(TEXT) \ atom.xml \ index.html \ - gopher/notes/index.gph + gopher/notes/index.gph \ + gopher.atom # Top level targets @@ -63,6 +65,7 @@ install: build $(DIR)/gopher/bin/dirlist $(DESTDIR)/gopher/$$d)\ > $(DESTDIR)/gopher/$$d/index.gph; \ done + install -m 444 gopher.atom $(DESTDIR)/gopher/phlog/atom.xml .PHONY: clean clean: @@ -91,6 +94,9 @@ bin/fixlinks: LINKS gopher/notes/index.gph: $(NOTES) (cd $(DIR)/gopher/notes && $(DIR)/gopher/bin/notetag) > $@ +gopher.atom: $(PHLOG) gopher/bin/gophatom.sh + $(DIR)/gopher/bin/gophatom.sh > $@ + # Inference rules (*.txt and *.html) $(HTML): bin/genpost.sh bin/fixlinks diff --git a/gopher/bin/gophatom.sh b/gopher/bin/gophatom.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# gophatom.sh -- Atom feeds for gopher +set -e + +REPO=$(dirname "$(dirname "$(dirname "$0")")") + +cat <<HEADER +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title>Alex Karle's phlog</title> + <id>gopher://alexkarle.com/1/phlog</id> + <link rel="self" type="application/atom+xml" href="gopher://alexkarle.com/0/phlog/atom.xml"/> + <link rel="alternate" href="gopher://alexkarle.com/1/phlog"/> + <author> + <name>Alex Karle</name> + </author> +HEADER + +IFS=' +' +for p in $(grep '^\[0|\[' "$REPO/gopher/phlog/index.gph"); do + stripped=${p#\[0\|\[} + date=${stripped%%\]*} + if [ -z "$printed_update" ]; then + printed_update=1 + printf " %s\n" "<updated>${date}T00:00:00Z</updated>" + fi + stripped=${stripped#*\] } + title=${stripped%%\|*} + stripped=${stripped#*\|} + file=$(basename "${stripped%%\|*}") + cat <<ENTRY + <entry> + <title>${title}</title> + <link rel="alternate" href="gopher://alexkarle.com/0/phlog/${file}"/> + <id>gopher://alexkarle.com/0/phlog/${file}</id> + <updated>${date}T00:00:00Z</updated> + <published>${date}T00:00:00Z</published> + <content type="text"> + <![CDATA[ +ENTRY + cat "$REPO/gopher/phlog/${file}" + cat <<EOENTRY + ]]> + </content> + </entry> +EOENTRY +done +printf "</feed>\n" diff --git a/gopher/phlog/010.txt b/gopher/phlog/010.txt @@ -0,0 +1,33 @@ +Adding a Feed to the Phlog +-------------------------- +Wed Nov 17 00:21:20 EST 2021 + +Quick entry to mark a new milestone for the phlog +--an atom feed! + +This was a pretty simple adaptation of my genatom +script originally described on the blog post +use-feeds(7) [1]. It just parses index.gph for +lines that have the [[Date] Title|path...] format +and spits out the right XML. + +Potentially the most interesting decision here +wasn't actually the crafting of the feed, but +rather whether to serve the feed over Gopher +exclusively or HTTP and Gopher. + +The argument for HTTP is that most feed +reader clients can't handle gopher://--I know for +sure newsboat doesn't. So by putting it on HTTP, +it could at least be read by a wider audience... + +I ended up choosing to keep it gopher-only, since +this is, after all, "gopher exclusive content" :) +I'll find or build a feed reader that can handle +it! + +The source for the gophatom.sh generator can be +found in the "code" section of this gopherhole [2] + +[1]: https://alexkarle.com/use-feeds.html +[2]: gopher://alexkarle.com/1/code diff --git a/gopher/phlog/index.gph b/gopher/phlog/index.gph @@ -12,6 +12,9 @@ just a collection of thoughts.. +[0|Atom Feed|/phlog/atom.xml|server|port] + +[0|[2021-11-17] Adding a Feed for the Phlog|/phlog/010.txt|server|port] [0|[2021-11-15] Going Live on the Weblog|/phlog/009.txt|server|port] [0|[2021-11-11] Choosing a Phormat pt. 4|/phlog/008.txt|server|port] [0|[2021-11-11] Choosing a Phormat pt. 3|/phlog/007.txt|server|port]