Files
Website-Scripts/rss.sh

69 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
source "${BASEDIR}/website.conf"
shopt -s extglob
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
DATE="$(date -R)"
LINKS=($(find -P "${WEBROOT}/blog/" | grep 'index\.html' | grep -v 'blog/index\.html' | sed 's|index.html||g; s|.*/blog|blog|g' | sort))
MENU="@(${LINKS[0]}"
for ((i=1;i<${#LINKS[@]};i++)); do
MENU+="|${LINKS[${i}]}"
done
MENU+=")"
printf 'Select the link you wish to use\n'
select LINK in "${LINKS[@]}"
do
case ${LINK} in
${MENU})
break
;;
*)
printf \
'Invalid option\n'
;;
esac
done
printf 'Title of blog post:\n'
read -r TITLE
printf 'Description of blog post:\n'
read -r DESCRIPTION
cat << EOF | tee "${WEBROOT}/blog/feed.rss" &> /dev/null
$(cat "${WEBROOT}/blog/feed.rss" | sed '/<last.*$/Q')
<lastBuildDate>
${DATE}
</lastBuildDate>
<item>
<title>
${TITLE}
</title>
<link>
${WEBSITE_URL}/${LINK}
</link>
<guid>
$(uuidgen)
</guid>
<pubDate>
${DATE}
</pubDate>
<description>
${DESCRIPTION}
</description>
</item>
$(cat "${WEBROOT}/blog/feed.rss" | sed '1,29d')
EOF