Browse Source

Add atom feed generator

June 2 months ago
parent
commit
e4bc90be5c
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
3 changed files with 32 additions and 3 deletions
  1. 1
    0
      .gitignore
  2. 6
    3
      Makefile
  3. 25
    0
      feed.sh

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
1 1
 *.txt
2
+feed.atom

+ 6
- 3
Makefile View File

@@ -9,8 +9,11 @@ all: $(TXTS)
9 9
 .7.txt:
10 10
 	mandoc $< | sed $$'s/.\b//g' > $@
11 11
 
12
+feed.atom: $(TXTS)
13
+	./feed.sh > feed.atom
14
+
12 15
 clean:
13
-	rm -f $(TXTS)
16
+	rm -f $(TXTS) feed.atom
14 17
 
15
-install: $(TXTS)
16
-	install -p -m 644 $(TXTS) $(WEBROOT)
18
+install: $(TXTS) feed.atom
19
+	install -p -m 644 $(TXTS) feed.atom $(WEBROOT)

+ 25
- 0
feed.sh View File

@@ -0,0 +1,25 @@
1
+#!/bin/sh
2
+set -e -u
3
+
4
+updated=$(date -u '+%FT%TZ')
5
+echo '<?xml version="1.0" encoding="utf-8"?>'
6
+echo '<feed xmlns="http://www.w3.org/2005/Atom">'
7
+echo '<title>Causal Agency</title>'
8
+echo '<author><name>June</name><email>june@causal.agency</email></author>'
9
+echo '<link href="https://text.causal.agency"/>'
10
+echo '<id>https://text.causal.agency/</id>'
11
+echo "<updated>${updated}</updated>"
12
+for entry in *.7; do
13
+	url="https://text.causal.agency/${entry%.7}.txt"
14
+	title=$(grep '^\.Nm' "$entry" | cut -c 5-)
15
+	summary=$(grep '^\.Nd' "$entry" | cut -c 5-)
16
+	updated=$(date -j -u -f '%s' "$(stat -f '%m' "$entry")" '+%FT%TZ')
17
+	echo '<entry>'
18
+	echo "<title>${title}</title>"
19
+	echo "<summary>${summary}</summary>"
20
+	echo "<link href=\"https://text.causal.agency/${entry%.7}.txt\"/>"
21
+	echo "<id>${url}</id>"
22
+	echo "<updated>${updated}</updated>"
23
+	echo '</entry>'
24
+done
25
+echo '</feed>'

Loading…
Cancel
Save