blog/src/atom.sh

44 lines
1.6 KiB
Bash

#!/bin/sh
# adapted from https://git.segvallday.org/ass2atom/file/ass2atom.html
# 0BSD License - Full text at the bottom of this file
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
echo "<feed xmlns=\"http://www.w3.org/2005/Atom\">"
echo "<title type=\"text\">dzwdz</title>"
echo "<updated>$(date -Iseconds)</updated>"
echo "<id>urn:uuid:677e5055-07e1-43d6-bd58-fda18d3c5277</id>"
echo '<link rel="self" type="application/atom+xml" href="https://tilde.town/~dzwdz/blog/feed.atom"/>'
to_atom_entry() {
while read line; do
entry_date=$(echo "$line" | cut -f1)
entry_url=$(echo "$line" | cut -f2)
entry_title=$(echo "$line" | cut -f3)
echo "<entry>"
echo "<title>$entry_title</title>"
echo "<link href=\"$entry_url\"/>"
echo "<updated>${entry_date}T00:00:00Z</updated>"
echo "<author><name>dzwdz</name></author>"
echo "<id>${entry_url}?${entry_date}</id>"
echo "</entry>"
done
}
grep -e "^[^#]" | sort -r | to_atom_entry
echo '</feed>'
# BSD Zero Clause License
#
# Copyright (c) 2023 segvallday, adapted by dzwdz
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.