Sfoglia il codice sorgente

Add atom feed generator

master
Causal Agent 11 mesi fa
parent
commit
e4bc90be5c
Firmato da: Curtis McEnroe <june@causal.agency> ID Chiave GPG: CEA2F97ADCFCD77C
3 ha cambiato i file con 32 aggiunte e 3 eliminazioni
  1. 1
    0
      .gitignore
  2. 6
    3
      Makefile
  3. 25
    0
      feed.sh

+ 1
- 0
.gitignore Vedi File

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

+ 6
- 3
Makefile Vedi File

@@ -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)

+ 25
- 0
feed.sh Vedi File

@@ -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>'