diff options
Diffstat (limited to 'src/feed')
-rwxr-xr-x | src/feed | 60 |
1 files changed, 30 insertions, 30 deletions
@@ -1,52 +1,52 @@ #!/bin/sh -set -eu +set -euo pipefail + usage() { - echo 'Usage: feed FILENAME' + echo 'Usage: feed BASECONF GLOBALCONF FILENAME.sortdata...' } -FILENAME="${1:-}" -eval "$(assert-arg -- "$FILENAME" 'FILENAME')" - +BASECONF="${1:-}" +GLOBALCONF="${2:-}" +FILES="${3:-}" +eval "$(assert-arg -- "$BASECONF" 'BASECONF')" +eval "$(assert-arg -- "$GLOBALCONF" 'GLOBALCONF')" +eval "$(assert-arg -- "$FILES" 'FILENAME.sortdata...')" +. "$(realpath -- "$BASECONF")" +. "$(realpath -- "$GLOBALCONF")" +shift +shift -absolute() { - printf 'https://domain-here.com/%s' "$(cat -)" -} -feed_article_title='' -site_name=' ' -lang=en -now="$(date -uIs)" -url_absolute="$(printf '%s' "${FILENAME#src/}" | absolute)" -site_name_html="$(htmlesc "${site_name:?}")" -collection=article -collection_url_absolute="$(printf '%s' ${lang:?}/ | absolute)" -feed_title_html="$(eval "echo \"\$feed_${collection}_title\"" | htmlesc)" -export now url_absolute site_name_html collection_url_absolute feed_title_html - -DIR="$(dirname "$FILENAME")" - -author= -email= -cat <<EOF +pre() { + cat <<EOF | sed '/^$/d' <feed xmlns="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" - xml:lang="$lang"> - <link href="$url_absolute" rel="self" type="application/atom+xml" /> - <link href="$collection_url_absolute" rel="alternate" type="text/html" hreflang="$lang" /> + xml:lang="en"> + <link rel="self" type="application/atom+xml" href="$feed_url_absolute" /> + <link rel="alternate" type="text/html" href="$feed_alternate_url_absolute" hreflang="en" /> <title>$site_name_html</title> <subtitle>$feed_title_html</subtitle> - <id>$url_absolute</id> - <updated>$now</updated> + <id>$feed_url_absolute</id> + <updated>$now_iso</updated> <author> <name>$author</name> <email>$email</email> </author> EOF +} + +post() { + printf '</feed>\n' +} + +pre find "$@" | xargs cat | sort -nr | + xargs cat | + sed 's/\.conf$/.feedentry/' | xargs cat -printf '</feed>\n' +post |