#!/bin/bash

# Updates the RSS feed

# This is the static header
echo '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">

<channel>
   <title>nomadActivist</title>
   <description>This is the nab (not a blog) of Timber</description>
   <link>https://timber.codeberg.page/nomadActivist/</link>
' > nomadActivist.rss

# Iterate over the HTML files
htmlFiles=`ls html`
for file in $htmlFiles
do
    # Extract the title and the content
    title=`basename --suffix=".html" $file`
    titleWithoutDate=`echo "$title" | sed -E "s/^[0-9.]+_(.*)$/\1/"`
    content=`cat html/${file}`
    echo "
  <item>
    <title>${titleWithoutDate}</title>
    <link>https://timber.codeberg.page/nomadActivist/html/${file}</link>
    <description><![CDATA[${content}]]></description>
  </item>
" >> nomadActivist.rss
done

# This is the closing tags, thus the static "footer"
echo "
</channel>
</rss>
" >> nomadActivist.rss

