Browse Source

Use here documents in feed.sh

master
Causal Agent 11 months ago
parent
commit
97df7c4c38
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
1 changed files with 18 additions and 14 deletions
  1. 18
    14
      feed.sh

+ 18
- 14
feed.sh View File

@@ -2,24 +2,28 @@
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>"
cat <<EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Causal Agency</title>
<author><name>June</name><email>june@causal.agency</email></author>
<link href="https://text.causal.agency"/>
<id>https://text.causal.agency/</id>
<updated>${updated}</updated>
EOF
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>'
cat <<EOF
<entry>
<title>${title}</title>
<summary>${summary}</summary>
<link href="${url}"/>
<id>${url}</id>
<updated>${updated}</updated>
</entry>
EOF
done
echo '</feed>'