diff options
author | EuAndreh <eu@euandre.org> | 2024-08-31 21:01:44 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-08-31 21:05:57 -0300 |
commit | 05903eea532bfd18cfb4a289c9d3c57f62e9d20e (patch) | |
tree | 146cad5d1a92a4b34c165e5eee555756d43c5467 /src/feed | |
parent | Initial empty commit (diff) | |
download | mkwb-05903eea532bfd18cfb4a289c9d3c57f62e9d20e.tar.gz mkwb-05903eea532bfd18cfb4a289c9d3c57f62e9d20e.tar.xz |
Import code from website repository
Diffstat (limited to 'src/feed')
-rwxr-xr-x | src/feed | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/feed b/src/feed new file mode 100755 index 0000000..f202ba6 --- /dev/null +++ b/src/feed @@ -0,0 +1,52 @@ +#!/bin/sh +set -eu + +usage() { + echo 'Usage: feed FILENAME' +} + +FILENAME="${1:-}" +eval "$(assert-arg -- "$FILENAME" 'FILENAME')" + + +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 +<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" /> + <title>$site_name_html</title> + <subtitle>$feed_title_html</subtitle> + <id>$url_absolute</id> + <updated>$now</updated> + + <author> + <name>$author</name> + <email>$email</email> + </author> +EOF +find "$@" | + xargs cat | + sort -nr | + xargs cat +printf '</feed>\n' |