#!/bin/sh # SHATOM: generate a feed from a directory of files # Copyright (C) 2020--2022 Case Duckworth # Licensed under the Good Choices License. See COPYING for details. ### Entry point usage() { cat < $FEED_TITLE $FEED_SUBTITLE $FEED_ID shatom $FEED_COPYRIGHT $FEED_UPDATED END } feed_footer() { cat < END } feed_item() { ITEM_URL="$(item_url "$1")" cat < $ITEM_URL $(item_title "$1") $(item_summary "$1") $(item_updated "$1") $(item_author) END } ## Item-level functions # These can all be, and in fact should be, changed in the configuration file. skip_item() { return 1 } item_url() { basename="${1#$DIRECTORY}" echo "$FEED_URL/$basename" } item_title() { basename="${1#$DIRECTORY}" echo "$basename" } item_summary() { return 1 } item_author() { echo "$FEED_AUTHOR" } item_content() { cat "$1" } item_updated() { # requires stat(1) stat -c %y "$1" } ### Execution section test -n "$DEBUG" && set -x test -n "$SOURCE" || main "$@"