#!/bin/sh blogtitle="ben's space" urlroot="https://bvnf.space/blog" urlblog="https://bvnf.space/blog/" # HEADER cat << EOF $blogtitle $urlblog CC-BY 4.0 en $(date "+%a, %e %b %Y %H:%M:%S %z") EOF ls -r -- *.txt *.gmi *.html | while read -r f; do unset date title desc link in # hack for same-day posts case "$f" in 007*) time="01" ;; *) time="00" ;; esac case "$f" in index.html) continue ;; *.txt) link="$urlroot/$f" in="${f%.txt}.7" date="$(grep '^[.]Dd' "$in" | cut -c 5-)" date="$(date -ju -f "%B %d, %Y" +"%a, %d %b %Y 00:00:${time:-00} %z" "$date")" title="$(grep '^[.]Nm' "$in" | cut -c 5-)" desc=" - $(grep '^[.]Nd' "$in" | cut -c 5-)" ;; *.gmi) link="gemini://gemini.bvnf.space/blog/${f#[0-9][0-9][0-9]-}" title="$(sed 1q "$f")" date="$(date -ju -f "%B %d, %Y" +"%a, %d %b %Y 00:00:${time:-00} %z" "$(sed 1d "$f")")" ;; *.html) link="$urlroot/$f" title="$(sed -n 's/.*\(.*\)<\/title>.*/\1/p' "$f")" date="$(date -ju +"%a, %d %b %Y 00:00:${time:-00} %z" "$(sed -n 's/^.*written \([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\).*$/\1\2\30000/p' "$f")")" ;; *) continue ;; esac cat <<EOF <item> <title>$title $link $date EOF done # FOOTER cat << EOF EOF