From bc5c029b2f19c5caec6573186d82faefa65ccab4 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 17 Nov 2021 00:33:07 -0500 Subject: [PATCH] gophe: Add a phlog feed and a post about it Exciting times in Gopherville. Now just to find a feed reader that supports gopher :) --- .gitignore | 1 + Makefile | 8 +++++++- gopher/bin/gophatom.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ gopher/phlog/010.txt | 33 +++++++++++++++++++++++++++++++++ gopher/phlog/index.gph | 3 +++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100755 gopher/bin/gophatom.sh create mode 100644 gopher/phlog/010.txt diff --git a/.gitignore b/.gitignore index e6fab47..2162783 100644 --- 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 index 9bcf157..4c1e808 100644 --- 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 new file mode 100755 index 0000000..f1d4c3a --- /dev/null +++ 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 <
+ + Alex Karle's phlog + gopher://alexkarle.com/1/phlog + + + + Alex Karle + +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" "${date}T00:00:00Z" + fi + stripped=${stripped#*\] } + title=${stripped%%\|*} + stripped=${stripped#*\|} + file=$(basename "${stripped%%\|*}") + cat < + ${title} + + gopher://alexkarle.com/0/phlog/${file} + ${date}T00:00:00Z + ${date}T00:00:00Z + + + + +EOENTRY +done +printf "\n" diff --git a/gopher/phlog/010.txt b/gopher/phlog/010.txt new file mode 100644 index 0000000..8b6d596 --- /dev/null +++ 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 index 043c94b..bfa4da8 100644 --- 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] -- libgit2 1.1.1