60 lines
1.7 KiB
Bash
Executable File
60 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
domain="$1"
|
|
tagfirst="2021" # see https://validator.w3.org/feed/docs/error/InvalidTAG.html
|
|
|
|
# exit if no public issue found
|
|
ls ../public/issue-*.html >/dev/null 2>&1
|
|
|
|
date_updated=$(env LC_TIME=C TZ=UTC date +%Y-%m-%dT%TZ)
|
|
|
|
cat <<EOF
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
<id>https://${domain}/</id>
|
|
<title>OpenBSD Webzine</title>
|
|
<icon>https://${domain}/favicon-32x32.png</icon>
|
|
<link rel="alternate" type="text/html" href="https://${domain}/" />
|
|
<link rel="self" type="application/atom+xml" href="https://${domain}/atom.xml" />
|
|
<author>
|
|
<name>OpenBSD Webzine contributors</name>
|
|
</author>
|
|
<updated>${date_updated}</updated>
|
|
EOF
|
|
|
|
for page in $(ls -t ../public/issue-*.html) ; do
|
|
|
|
# if it's a special issue, parse the name differently
|
|
if echo "$page" | grep special >/dev/null 2>/dev/null
|
|
then
|
|
issue=$(echo $page | grep -oE "issue-[[:digit:]]+-special-[[:digit:][:alpha:]-]+")
|
|
title=$(echo $issue | cut -d '-' -f 3- | tr '-' ' ')
|
|
else
|
|
issue=$(echo $page | grep -oE "issue\-[0-9]+")
|
|
title=$(echo $issue | awk -F '-' '{ print "Issue #"$NF }')
|
|
fi
|
|
. ./$issue/metadata.sh
|
|
if test -f /bsd # OpenBSD
|
|
then
|
|
tag="$(echo -n ${issue} | sha256)"
|
|
else
|
|
tag="$(echo -n ${issue} | sha256sum | cut -d ' ' -f 1)"
|
|
fi
|
|
|
|
cat <<EOF
|
|
<entry>
|
|
<title type="text">${title}</title>
|
|
<id>tag:${domain},${tagfirst}:${tag}</id>
|
|
<updated>${PUBLISHED_DATE}</updated>
|
|
<link rel="alternate" type="text/html" href="https://${domain}/${issue}.html" />
|
|
<summary type="html">
|
|
<![CDATA[
|
|
$(sed "1d;2d;$d" $issue/10_HEADLINES.html)
|
|
]]>
|
|
</summary>
|
|
</entry>
|
|
EOF
|
|
done
|
|
|
|
echo "</feed>"
|