#!/usr/bin/env bash
# Makes RSS feed (feed.xml)
# Currently missing description and pubDate
# Based off https://en.wikipedia.org/wiki/RSS, particularly the example
printf "\n\n\n\n askiiart.net\n The feed for askiiart.net, I guess\n https://askiiart.net\n $(TZ='UTC' date --rfc-2822)" >feed.xml
find . -path ./error -prune -o -name '*.html' -print | while read -r item; do
# Skip template.html, wishlist.html, resume.html, and portfolio.html
if [[ ${item} == "./index.html" || ${item} == "./template.html" || ${item} == "./wishlist.html" || ${item} == "./resume.html" || ${item} == "./portfolio.html" || ${item} == "./opx.html" ]]; then
continue
fi
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n \n ${TITLE}\n https://askiiart.net/${item}.html\n " >>feed.xml
done
printf "\n\n\n" >>feed.xml
# same thing, but for TIL only
cd ./til
printf "\n\n\n\n askiiart.net TIL\n The feed for askiiart.net but just TIL, I guess\n https://askiiart.net/til/\n $(TZ='UTC' date --rfc-2822)" >feed.xml
find . -name "*.html" | while read -r item; do
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n \n ${TITLE}\n https://askiiart.net/til/${item}.html\n " >>feed.xml
done
printf "\n\n\n" >>feed.xml
cd ..
# same thing, but for blog only
cd ./blog
printf "\n\n\n\n askiiart.net blog\n The feed for askiiart.net but just the blog, I guess\n https://askiiart.net/blog/\n $(TZ='UTC' date --rfc-2822)" >feed.xml
find . -name "*.html" | while read -r item; do
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n \n ${TITLE}\n https://askiiart.net/til/${item}.html\n " >>feed.xml
done
printf "\n\n\n" >>feed.xml
cd ..