alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit 5d751eb7d828d6104ec543e92672c0efaa51bb6e (patch)
parent 424b8c4a0828d8d5d8f45ce3955c921b8c5e94f8
Author: Alex Karle <alex@alexkarle.com>
Date:   Mon,  3 Jan 2022 18:01:52 -0500

atom: Add support for Linux atom.xml generation

Turns out `date` is rather different between BSD and GNU... RIP.
This is a half-hearted attempt (I mean Linux != GNU) to support Linux
(all my Linux systems use GNU coreutils).

Diffstat:
Mbin/genatom.sh | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bin/genatom.sh b/bin/genatom.sh @@ -6,6 +6,14 @@ REPO=$(dirname "$(dirname "$0")") POSTS=$(grep '^- ../..' "$REPO/www/blog/index.txt" | sed 's#.*/blog/\([^)]*\).*#\1#') +ARCH="$(uname)" +parsedate() { + case "$ARCH" in + Linux) date +%F --date="$1" ;; + *) date -juf"%b %d, %Y" +%F "$1" ;; # assume *BSD + esac +} + cat <<HEADER <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> @@ -23,8 +31,7 @@ for post in $POSTS; do src="$REPO/www/blog/$p.txt" [ "$p" = "index" ] && continue - d=$(date -juf"%b %d, %Y" +%F \ - "$(grep '^_Published' "$src" | sed 's/_Published: \([^_]*\)_/\1/')") + d=$(parsedate "$(grep '^_Published' "$src" | sed 's/_Published: \([^_]*\)_/\1/')") if [ -z "$printed_update" ]; then printed_update=1 printf " %s\n" "<updated>${d}T00:00:00Z</updated>"