#!/bin/sh # genatom.sh -- generate atom.xml set -e 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 <
Alex Karle's blog https://alexkarle.com/atom.xml Alex Karle HEADER for post in $POSTS; do p=$(basename $post .html) src="$REPO/www/blog/$p.txt" [ "$p" = "index" ] && continue d=$(parsedate "$(grep '^_Published' "$src" | sed 's/_Published: \([^_]*\)_/\1/')") if [ -z "$printed_update" ]; then printed_update=1 printf " %s\n" "${d}T00:00:00Z" fi title=$(sed -e 's/^# //' -e '1q' "$src") cat < $title https://alexkarle.com/blog/$p.html ${d}T00:00:00Z ${d}T00:00:00Z EOENTRY done printf "\n"