diff options
Diffstat (limited to 'update-feed.sh')
-rwxr-xr-x | update-feed.sh | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/update-feed.sh b/update-feed.sh deleted file mode 100755 index 5b0785b..0000000 --- a/update-feed.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash -set -ex - -# static info -## tokens -TKN_BUILDDATE='#BUILDDATE' -TKN_PUBDATE='#PUBDATE' -TKN_TITLE='#TITLE' -TKN_LINK='#LINK' -TKN_PERMALINK='#PERMALINK' - -URL_PREFIX="https://www.senders.io" -TKN_URL_STRIP="./www" # remove www file prefix for URL/LINK -TKN_INDEX_STRIP="index.html" # remove index.html for LINK - -FILE_RSS_HEADER=./templates/rss/rss-header.xml -FILE_RSS_FOOTER=./templates/rss/rss-footer.xml -FILE_RSS_ITEM_HEADER=./templates/rss/rss-item-header.xml -FILE_RSS_ITEM_FOOTER=./templates/rss/rss-item-footer.xml -FILE_ITEM_OUTPUT=./rss/items.xml -FILE_RSS_OUTPUT=./www/blog/feed.rss - - -# dynamic info -FILE_TMP_FEED=$(mktemp --suffix=.xml) -FILE_TMP_ITEM=$(mktemp --suffix=.xml) -BUILDDATE=$(date -R) - -# user input - -if [ $# -ne 3 ]; then - echo "./update-feed.sh PUBDATE TITLE FILE_PATH - Examples: - ./update-feed.sh 2022-12-31 \"Generating RSS feeds with bash\" ./www/blog/2022-12-31/index.html" - exit 1 -fi - -PUBDATE=$(date -d "$1" -R) -TITLE=$2 -FILE_PATH=$3 -PERMALINK=$(echo "${FILE_PATH}" | sed -e "s,${TKN_URL_STRIP},${URL_PREFIX},g") -LINK=$(echo "${PERMALINK}" | sed -e "s,${TKN_INDEX_STRIP},,g") - -# Generate TMP FEED File Header - -cat -s $FILE_RSS_HEADER > $FILE_TMP_FEED -sed -i -E "s/${TKN_BUILDDATE}/${BUILDDATE}/g" $FILE_TMP_FEED -sed -i -E "s/${TKN_PUBDATE}/${PUBDATE}/g" $FILE_TMP_FEED - -# Generate TMP Item File - -cat -s $FILE_RSS_ITEM_HEADER > $FILE_TMP_ITEM -sed -i -E "s~${TKN_TITLE}~${TITLE}~g" $FILE_TMP_ITEM -sed -i -E "s/${TKN_PUBDATE}/${PUBDATE}/g" $FILE_TMP_ITEM -sed -i -E "s,${TKN_PERMALINK},${PERMALINK},g" $FILE_TMP_ITEM -sed -i -E "s,${TKN_LINK},${LINK},g" $FILE_TMP_ITEM -sed -n "/<article>/,/<\/article>/p" $FILE_PATH >> $FILE_TMP_ITEM -cat -s $FILE_RSS_ITEM_FOOTER >> $FILE_TMP_ITEM - -# Prepend Item to items list and overwrite items file w/ prepended item -## In order to "prepend" the item (so it's on top of the others) -## We need to concat the tmp item file with the existing list, then -## we can push the contents over the existing file -## We use cat -s to squeeze the blank lines -cat -s $FILE_ITEM_OUTPUT >> $FILE_TMP_ITEM -cat -s $FILE_TMP_ITEM > $FILE_ITEM_OUTPUT - -# Push items to TMP FEED -cat -s $FILE_ITEM_OUTPUT >> $FILE_TMP_FEED - -# Push RSS footer to TMP FEED -cat -s $FILE_RSS_FOOTER >> $FILE_TMP_FEED -echo $FILE_TMP_FEED - -# Publish feed -cat -s $FILE_TMP_FEED > $FILE_RSS_OUTPUT - -echo "Finished generating feed" - |