From ab6479dcb30299271c043dce268cffe229d0f039 Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Wed, 1 Jul 2026 17:16:17 +0200 Subject: update --- blogrss | 68 ++++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'blogrss') diff --git a/blogrss b/blogrss index 2c98b59..36c90e3 100755 --- a/blogrss +++ b/blogrss @@ -1,24 +1,32 @@ #!/usr/bin/env bash -YEAR="$(date +%Y)" -YLINK="https://wittamore.fr/articles/$YEAR" -DESC="Ramblings from Brittany, France" -RSSLINK="https://wittamore.fr/rss.xml" -FEEDNAME="/home/philip/web/rss.xml" -POSTDIR="/home/philip/web/articles/$YEAR" -UPDATED="$(date --iso-8601=ns)" +# settings +TYEAR="$(date +%Y)" +TITLE="Bloggings" +YLINK="https://wittamore.fr/articles/$TYEAR" +FDESC="Ramblings from Brittany" +WSITE="https://wittamore.fr" +RLINK="$WSITE/rss.xml" +FEEDN="/home/philip/web/rss.xml" +ARTDR="/home/philip/web/articles/$TYEAR" +UPDAT="$(date --iso-8601=ns)" + +# convert tring to htmlentities +htmlentities () { + echo $1 | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' +} # Build RSS header & footer header () { echo " -Bloggings - wittamore.fr -https://wittamore.com -Ramblings from Brittany, France -$UPDATED - +$TITLE +$WSITE +$FDESC +$UPDAT + " >> ~/feedtop } @@ -33,11 +41,13 @@ echo " builditem () { echo " - $FULLTITLE$POSTDATE - $LINKADDR - $LINKADDR + $POSTTIT + $POSTDAT + Philip A. Wittamore + $POSTADD + $POSTADD - $DESC + " >> ~/feed } @@ -47,27 +57,29 @@ combine () { header footer cat ~/feedtop ~/feed > ~/feedtb - cat ~/feedtb ~/feedbottom > $FEEDNAME + cat ~/feedtb ~/feedbottom > $FEEDN rm ~/feedtop ~/feed ~/feedtb ~/feedbottom } # Run through files and create rss.xml -if [[ -f $FEEDNAME ]]; then - rm $FEEDNAME +if [[ -f $FEEDN ]]; then + rm $FEEDN fi -touch $FEEDNAME -mapfile -t POSTARRAY < <(ls -t "$POSTDIR"/*.html) +touch $FEEDN +mapfile -t ARTICLEARRAY < <(ls -t "$ARTDR"/*.html) postNum=0 -for POSTS in "${POSTARRAY[@]}"; do +for POSTS in "${ARTICLEARRAY[@]}"; do ((postNum+=1)) POST=$POSTS - FULLTITLE=$(grep -o '>.*' "$POST" | sed 's/\(>\|<\/h2>\)//g') - POSTDATE=$(grep -o '>.*' "$POST" | sed 's/\(>\|<\/h3>\)//g') - POSTNAME=${POST##*/} - LINKADDR="$YLINK/$POSTNAME" - DESC="$(sed -n '/

.*/,/*.<\/h4>/{p;q;}' "$POST" | - sed -e 's/<[^>]\+>/ /g' -e 's|

||g' -e 's|

||g' -e 's|"||g' -e 's/^[ \t]*//;s/[ \t]*$//')" + POSTTIT="$(grep -o '

.*

' $POST | sed 's/\(

\|<\/h2>\)//g')" + POSTDAT="$(grep -o '

.*

' $POST | sed 's/\(

\|<\/h3>\)//g')" + # extract from first

to last

+ POSTDES="$(awk '/

/,/<\/p>/' $POST)" + POSTNAM="$(htmlentities "${POST##*/}")" + POSTTIT="$(htmlentities "$POSTTIT")" + POSTDES="$(htmlentities "$POSTDES")" + POSTADD="$YLINK/$POSTNAM" builditem "$POST" done combine -- cgit v1.3.1