summary refs log tree commit diff
path: root/feed.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-09-18 00:14:04 -0400
committerJune McEnroe <june@causal.agency>2018-09-18 00:14:04 -0400
commit0b101f5b9d98f972ab9f72e983534412a53dc102 (patch)
tree3861b906c499572c274c72b2c2b221ed37f650cf /feed.sh
parentUse install(1) to install (diff)
downloadsrc-0b101f5b9d98f972ab9f72e983534412a53dc102.tar.gz
src-0b101f5b9d98f972ab9f72e983534412a53dc102.zip
Add atom feed generator
Diffstat (limited to '')
-rwxr-xr-xfeed.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/feed.sh b/feed.sh
new file mode 100755
index 00000000..4a45ce45
--- /dev/null
+++ b/feed.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -e -u
+
+updated=$(date -u '+%FT%TZ')
+echo '<?xml version="1.0" encoding="utf-8"?>'
+echo '<feed xmlns="http://www.w3.org/2005/Atom">'
+echo '<title>Causal Agency</title>'
+echo '<author><name>June</name><email>june@causal.agency</email></author>'
+echo '<link href="https://text.causal.agency"/>'
+echo '<id>https://text.causal.agency/</id>'
+echo "<updated>${updated}</updated>"
+for entry in *.7; do
+	url="https://text.causal.agency/${entry%.7}.txt"
+	title=$(grep '^\.Nm' "$entry" | cut -c 5-)
+	summary=$(grep '^\.Nd' "$entry" | cut -c 5-)
+	updated=$(date -j -u -f '%s' "$(stat -f '%m' "$entry")" '+%FT%TZ')
+	echo '<entry>'
+	echo "<title>${title}</title>"
+	echo "<summary>${summary}</summary>"
+	echo "<link href=\"https://text.causal.agency/${entry%.7}.txt\"/>"
+	echo "<id>${url}</id>"
+	echo "<updated>${updated}</updated>"
+	echo '</entry>'
+done
+echo '</feed>'