From 41ea1757508169957d0ff91ccd94ffea5cc676be Mon Sep 17 00:00:00 2001 From: Mohit Agarwal Date: Fri, 14 Mar 2025 18:37:19 +0000 Subject: Initial commit. --- feed.sh | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 feed.sh (limited to 'feed.sh') diff --git a/feed.sh b/feed.sh new file mode 100755 index 0000000..44df5fb --- /dev/null +++ b/feed.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +# taken from https://github.com/maxhebditch/rss-roller/ +# modified by Mohit Agarwal + + +# Configuration +title="Unorthodox Monologues" +link="https://mohit.uk/blogs/unmono" +description="Abby's Blog" +rsslink="$link/feed.xml" +feedname="./feed.xml" +postDir="./unmono/" + + +echo "./feed.sh------------------------------------------------" +echo " Feed builder RSS/ATOM" +echo " Written by Mohit Agarwal" +echo " INTERNAL USE ONLY" +echo "---------------------------------------------------------" + +echo "" +echo "TITLE" $title +echo "LINK " $link +echo "RSS L" $rsslink +echo "RSS F" $feedname +echo "DESCR" $description +echo "POSTD" $postDir + + +header () { +echo """ + + +""" > ~/feedtop +echo """ + +$title +$link +$description + +""" >> ~/feedtop +} + +footer () { +echo """ + + +""" >> ~/feedbottom +} + +item () { + echo """ + $fullTitle + $linkadd + $guid + + $fullText + + + + $fullText + + + """ >> ~/feed + echo """ + $fullTitle + $linkadd + $guidadd + + """ >> ~/feed +} + +combine () { + header + footer + cat ~/feedtop ~/feed > ~/feedtb + cat ~/feedtb ~/feedbottom > $feedname + rm ~/feedtop ~/feed ~/feedtb ~/feedbottom +} + + + +if [[ ! -f $feedname ]]; then + touch $feedname +fi + +echo "" +echo "BUILDING FEED" +#Do the bad thing +if [[ -f $feedname ]]; then + rm $feedname +fi +touch $feedname +postArray=( $(ls -r "$postDir"/*.html | grep -v index.html) ) +numPosts=$(ls -r "$postDir"/*.html | grep -v index.html | wc -l) +echo "numPosts is $numPosts" +postNum=0 +guidadd=$linkadd +for posts in "${postArray[@]}"; do + let postNum+=1 + post=$posts + echo " adding post $postNum/$numPosts : $post" + fullTitle=$(grep -o '>.*' $post | sed 's/\(>\|<\/h1>\)//g') + postname=${post##*/} + linkadd="$link"/"$postname" + fullText=$(pandoc ../${post/%html/md} -t html) + item $post +done +combine +exit -- cgit v1.2.3