#!/bin/bash # gauntlet's micro blog # by Gauntlet O. Manatee # 2016-07-15 if [ -z "$1" ]; then echo "Type your new entry, then hit return." read typed else typed=`cat $1` fi date=`date --utc +%Y-%m-%d\ %H:%M` id=`date --utc +%Y%m%d%H%M%S` entry=' <p><span id="'"$id"'" class="date"><a href="#'"$id"'">'"$date"'</a> </span><span>'"$typed"'</span></p>' sed -i "10i $entry" blog.html # rss from here on # cut the words for the title if the string is too long length=$(echo $typed | wc -w) if [ "$length" -gt "5" ] then title="`echo $typed | cut -d' ' -f-5` ..." else title=$typed fi # cut html tags from title, because this might screw up the feed # plus, it looks terrible title=`echo $title | sed -e 's/<[^>]*>//g'` link='http://ctrl-c.club/~gauntlet/gmb/#'"$id" rss='<item>\n<title>'"$title"'</title>\n<link>'"$link"'</link>\n<guid>'"$link"'</guid>\n<description><![CDATA['"$typed"']]></description>\n</item>' # write the new item to the rss file sed -i "8i $rss" rss.xml