#!/bin/sh # gophatom.sh -- Atom feeds for gopher set -e REPO=$(dirname "$(dirname "$0")") if [ -z "$1" ] || [ ! -d "$REPO/$1" ]; then echo "usage: gophatom.sh phlog|yis" 1>&2 exit 1 fi dir=$1 case "$dir" in phlog) title="Alex Karle's phlog" prefix="" ;; yis) title="This Year in Songs" prefix="Song of the Week: " ;; esac cat <
$title gopher://alexkarle.com/1/$dir Alex Karle HEADER IFS=' ' for p in $(grep '^\[0|\[' "$REPO/$dir/index.gph"); do if [ -z "$printed_update" ]; then printed_update=1 last=$(git log --pretty="%aI" -- $dir/*.txt | head -n 1) printf " %s\n" "${last}" fi stripped=${p#\[0\|\[} stripped=${stripped#*\] } title=${stripped%%\|*} stripped=${stripped#*\|} file=$(basename "${stripped%%\|*}") updated=$(git log --pretty="%aI" -- $dir/$file | head -n 1) published=$(git log --pretty="%aI" -- $dir/$file | tail -n 1) cat < ${prefix}${title} gopher://alexkarle.com/0/$dir/${file} ${updated} ${published} EOENTRY done printf "\n"