💾 Archived View for friendo.monster › log › added_rss_to_script.gmi captured on 2022-04-29 at 11:43:33. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

Added RSS to my .gmi to .html script

25 Apr 2021

I'm currently generating my website from my gemini pod using a *very ugly* script. The script didn't do RSS because I don't care about RSS and kinda find it to be an offensively ugly technology (an XML document to outline another XML document, seriously?).

I can get away with it on my site because barely anyone reads it. But people actually read Hex's site so he was getting complaints. So I added RSS generation.

# make rss
url="https://friendo.monster"
cat head.rss > rss.xml
rss=""
while read i;do
	rss="$rss\n<item>\n<title>$(awk -F' ‒ ' '{ print $2 }' <<<$i)</title>\n<link>$url$(awk '{ print  $2 }' <<<$i | sed 's/\.gmi/.html/g')</link>\n<pubDate>$(date -d $(awk '{ print $3 }' <<<$i) +'%a, %d %b %Y %H:%M:%S %z')</pubDate>\n<description><![CDATA[$(cat $(awk '{ print $2 }' <<<$i | sed -e 's/\.gmi/.html/g' -e 's/^\///') | sed -e '1,/<section>/d' -e '/<footer>/,$d')]]></description>\n</item>\n\n"
done<<<$(sed -n '/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/p' index.gmi)
echo -e "$rss" >> rss.xml
cat tail.rss >> rss.xml &&
if ! grep "<a href=\"rss.xml\">rss</a>" index.html >/dev/null 2>&1;then
	sed -i '19 a <p><a href="rss.xml">rss</a></p>' index.html
fi

It's another big nasty mess of awk and sed, but it does the trick.

It just loops through links-in-the-right-format, extracts the information, and squirts it into an rss file. Then it schomps a link to the rss into index.html.

I've also added auto-differentiation between web and gemini links into the original big ugly sed command as a courtesy to those still holding-out on the legacy internet.

Full script is here:

https://gitlab.com/uoou/dotfiles/-/blob/master/stow/bin/home/drew/.local/bin/upgem

..