commit 8ba21a2421b8ab2c2857d56ee119dfc1a3dc9104 (patch)
parent bc5c029b2f19c5caec6573186d82faefa65ccab4
Author: Alex Karle <alex@alexkarle.com>
Date: Sun, 21 Nov 2021 10:58:30 -0500
gopher: Add script to automate phlogging & entry about it
Ah the classic "blog trap" -- it's more fun to automate blogging than to
blog itself! Here's to hoping I can make it so dead simple to phlog that
I don't fall into this trap again...
Diffstat:
3 files changed, 116 insertions(+), 0 deletions(-)
diff --git a/gopher/bin/phlog b/gopher/bin/phlog
@@ -0,0 +1,38 @@
+#!/bin/sh
+# phlog -- lowering the barrier to phlogging
+# see gopher://alexkarle.com/phlog/011.txt
+die() {
+ echo "$*"
+ exit 1
+}
+
+[ -z "$1" ] && die "usage: phlog TITLE"
+
+PHLOG=$(dirname "$(dirname "$(readlink -f "$0")")")/phlog
+
+i=1
+nextfile() {
+ file=$(printf "%03d.txt" $i)
+ : $((i+=1))
+}
+
+title="$*"
+underline="$(echo "$title" | sed 's/./-/g')"
+
+nextfile
+while [ -e "$PHLOG/$file" ]; do
+ nextfile
+done
+
+echo "$title" >"$PHLOG/$file"
+echo "$underline" >>"$PHLOG/$file"
+date >>"$PHLOG/$file"
+
+ed "$PHLOG/index.gph" <<EOM
+/^\[0|Atom Feed/+a
+[0|[$(date +%F)] $title|/phlog/$file|server|port]
+.
+wq
+EOM
+
+exec "${EDITOR:-vi}" "$PHLOG/$file"
diff --git a/gopher/phlog/011.txt b/gopher/phlog/011.txt
@@ -0,0 +1,77 @@
+Lowering Barriers to Writing
+----------------------------
+Sun Nov 21 10:21:16 EST 2021
+
+---
+Sipping coffee and listening to Psychedelic Swamp on the
+turntable while Jennie shops online for plants as presents.
+---
+
+When I moved from mdoc(7) over HTTP to plaintext over Gopher,
+the barrier to writing became much smaller. No longer did I
+have to look up the mdoc man page while writing, nor did I
+have to check how it looked in multiple formats (HTML and
+ASCII). There were also psychological barriers too--a phlog
+has less traffic, and the traffic here is maybe less judgey.
+I feel I can be a bit more open in my writing and worry about
+the phrasing less.
+
+I wanted to make it even easier to "just start writing", so
+I wrote a small shell script "phlog(1)" that:
+
+ 1. Takes a title
+ 2. Starts a new entry at the next NNN.txt file available
+ 3. Prepopulates the entry with the title and date
+ 4. Updates the phlog index to include the entry
+
+It's in gopher://alexkarle.com/1/code, but I wanted to include
+it here too, just because I expect it'll morph over time and
+I want to document the MVP!
+
+Some things learned:
+
+- `$(())` for arithmetic returns the result, so to avoid
+ executing a number, prefix it with the null operation `:`
+
+- ed(1) is awesome for programmatic edits to files
+
+--- phlog(1) ---
+
+#!/bin/sh
+# phlog -- lowering the barrier to phlogging
+# see gopher://alexkarle.com/phlog/011.txt
+die() {
+ echo "$*"
+ exit 1
+}
+
+[ -z "$1" ] && die "usage: phlog TITLE"
+
+PHLOG=$(dirname "$(dirname "$(readlink -f "$0")")")/phlog
+
+i=1
+nextfile() {
+ file=$(printf "%03d.txt" $i)
+ : $((i+=1))
+}
+
+title="$*"
+underline="$(echo "$title" | sed 's/./-/g')"
+
+nextfile
+while [ -e "$PHLOG/$file" ]; do
+ nextfile
+done
+
+echo "$title" >"$PHLOG/$file"
+echo "$underline" >>"$PHLOG/$file"
+date >>"$PHLOG/$file"
+
+ed "$PHLOG/index.gph" <<EOM
+/^\[0|Atom Feed/+a
+[0|[$(date +%F)] $title|/phlog/$file|server|port]
+.
+wq
+EOM
+
+exec "${EDITOR:-vi}" "$PHLOG/$file"
diff --git a/gopher/phlog/index.gph b/gopher/phlog/index.gph
@@ -14,6 +14,7 @@
[0|Atom Feed|/phlog/atom.xml|server|port]
+[0|[2021-11-21] Lowering Barriers to Writing|/phlog/011.txt|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]