#!/usr/bin/env bash echo() { printf '%s\n' "$*"; } html() { : "${LIMIT:=1}" aside="$(mktemp /tmp/sfeed_html_aside.XXXXXX)" cat <

mars, but with eyes Planet ACDW

last updated at

$(html_main "$@")
EOF rm "$aside" } html_head() { cat < Planet ACDW EOF } html_main() { cat < $(for file in "$@"; do html_feed "$file"; done) EOF } filter_invidious() { # Convert youtube links to invidious links host="$(cat /tmp/invidious.host)" sed "s@https://www\.youtube\.com@${host}@" } html_feed() { # html_feed FEED(file) => HTML filename="$(basename "$1")" now="$(date +%s)" fresh_days=1 fresh_secs="$((fresh_days * 24 * 60 * 60))" ## ENTRIES entries="$(awk -v NOW="$now" -v FRESH_SECS="$fresh_secs" \ -v NAME="$filename" -v ASIDE="$aside" -v limit="$LIMIT" \ 'BEGIN { FS="\t"; fresh_feed = 0; FRESH = (NOW - FRESH_SECS); } function unescape(t) { t = html_escape(t); gsub(/\\\t/,"\t",t); gsub(/\\\n/,"\n",t); gsub(/\\\\/,"\\",t); return t } function html_escape(t) { gsub(//,"\\>",t); gsub(/&/,"\\&",t); return t } { timestamp=$1; title=$2; link=$3; content=unescape($4); content_type=$5; id=$6; author=$7; enclosure=$8; category=$9; if (limit && (timestamp < (NOW - (FRESH_SECS * 3)))) next; show_in_sidebar = 1; #print timestamp, title, link > "/dev/stderr"; date_cmd = "date -d \"@" timestamp "\" +\"%F %R\"" if (timestamp) { date_cmd | getline ts; close(date_cmd); } fresh = (timestamp >= FRESH) if (fresh) fresh_feed = 1; print "" print "" ts "" printf "%s", "" if (enclosure) { stamp = "@" printf "%s", "" stamp "" } if ((link != id) && (id != enclosure) && (id ~ /^https?:/)) { stamp = "#" printf "%s", "" stamp "" } print "" printf "" title "" print "" } END { if (show_in_sidebar) { printf "", (fresh_feed?" class=\"fresh\"":"") >> ASIDE printf "%s\n", NAME, NAME >> ASIDE } printf "%s", (stamp ? stamp : ".") > "/dev/stderr" }' "$1" | filter_invidious)" if [ -z "$entries" ]; then return 1; fi echo "
" # TODO: Include a link back to the website printf '

# %s

\n' "$filename" "$filename" printf '%s
' "[back to top]" echo "" echo "$entries" echo "
" echo "
" } if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then html "$@" fi