summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile9
-rwxr-xr-xfeed.sh25
3 files changed, 32 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 2211df63..37dd51ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 *.txt
+feed.atom
diff --git a/Makefile b/Makefile
index 3b9f83e2..d74df97c 100644
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,11 @@ all: $(TXTS)
 .7.txt:
 	mandoc $< | sed $$'s/.\b//g' > $@
 
+feed.atom: $(TXTS)
+	./feed.sh > feed.atom
+
 clean:
-	rm -f $(TXTS)
+	rm -f $(TXTS) feed.atom
 
-install: $(TXTS)
-	install -p -m 644 $(TXTS) $(WEBROOT)
+install: $(TXTS) feed.atom
+	install -p -m 644 $(TXTS) feed.atom $(WEBROOT)
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>'