askiiart-net/generate-rss.sh

44 lines
2.6 KiB
Bash
Raw Normal View History

2023-10-09 15:31:24 +00:00
#!/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 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<rss version=\"2.0\">\n\n<channel>\n <title>askiiart.net</title>\n <description>The feed for askiiart.net, I guess</description>\n <link>https://askiiart.net</link>\n <lastBuildDate>$(TZ='UTC' date --rfc-2822)</lastBuildDate>" >feed.xml
2023-11-20 17:08:03 +00:00
find . -path ./error -prune -o -name '*.html' -print | while read -r item; do
2023-10-09 15:31:24 +00:00
# Skip template.html, wishlist.html, resume.html, and portfolio.html
2025-01-07 15:31:01 +00:00
if [[ ${item} == "./index.html" || ${item} == "./template.html" || ${item} == "./wishlist.html" || ${item} == "./resume.html" || ${item} == "./portfolio.html" || ${item} == "./opx.html" || ${item} == "./blog/this-page-is-actually-portable.html" ]]; then
2023-10-09 15:31:24 +00:00
continue
fi
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n <item>\n <title>${TITLE}</title>\n <link>https://askiiart.net/${item}.html</link>\n </item>" >>feed.xml
done
2023-10-15 17:38:53 +00:00
printf "\n\n</channel>\n</rss>" >>feed.xml
# same thing, but for TIL only
cd ./til
printf "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<rss version=\"2.0\">\n\n<channel>\n <title>askiiart.net TIL</title>\n <description>The feed for askiiart.net but just TIL, I guess</description>\n <link>https://askiiart.net/til/</link>\n <lastBuildDate>$(TZ='UTC' date --rfc-2822)</lastBuildDate>" >feed.xml
find . -name "*.html" | while read -r item; do
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n <item>\n <title>${TITLE}</title>\n <link>https://askiiart.net/til/${item}.html</link>\n </item>" >>feed.xml
done
printf "\n\n</channel>\n</rss>" >>feed.xml
cd ..
# same thing, but for blog only
cd ./blog
printf "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<rss version=\"2.0\">\n\n<channel>\n <title>askiiart.net blog</title>\n <description>The feed for askiiart.net but just the blog, I guess</description>\n <link>https://askiiart.net/blog/</link>\n <lastBuildDate>$(TZ='UTC' date --rfc-2822)</lastBuildDate>" >feed.xml
find . -name "*.html" | while read -r item; do
2025-01-07 15:31:01 +00:00
if [[ ${item} == "./this-page-is-actually-portable.html" ]]; then
continue
fi
2023-10-15 17:38:53 +00:00
item="${item%.*}"
item="${item#./}"
TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)
printf "\n <item>\n <title>${TITLE}</title>\n <link>https://askiiart.net/til/${item}.html</link>\n </item>" >>feed.xml
done
printf "\n\n</channel>\n</rss>" >>feed.xml
cd ..