#!/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