pub / newsplanet

Planet-Style Newsfeed generated with perlanet
git clone https://src.jayvii.de/pub/newsplanet.git
Home | Log | Files | Exports | Refs | README | RSS

commit 9d6b13416539cecf9a4add1ffcbf54f6d5870016
parent ab6eb461e04ebd46424a14651cb5cf3e75de250d
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sat, 30 Nov 2024 16:32:15 +0100

fix: restructure run script

Diffstat:
Mrun.sh | 47+++++++++++++++++++++++------------------------
1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/run.sh b/run.sh @@ -7,28 +7,18 @@ else CONFIG="$1" fi -# Generate site -printf "Fetching feeds and generating html...\n" -perlanet "$CONFIG" - -# fetch name of resulting html file +# Gather various information from config file +printf "Gather information from config file...\n" HTML=`grep -E '^\s+file:.*?\.html\s*$' "$CONFIG" | awk '{ print $NF }'` - -# fetch name of resulting xml file XML=`grep -E '^\s+file:.*?\.xml\s*$' "$CONFIG" | awk '{ print $NF }'` +TITLES=`grep -E "^\s*-*\ title:" "$CONFIG" | sed -e 's/^.*title:\ //g'` +# URLS=`grep -E "^\s*-*\ url:" "$CONFIG" | sed -e 's/^.*url:\ //g'` +WEBS=`grep -E "^\s*-*\ web:" "$CONFIG" | sed -e 's/^.*web:\ //g'` +NFEEDS=`echo "$TITLES" | wc -l` -# fetch feedi formation from config file -FEED_TITLE=`grep -E "^\s*-*\ title:" "$CONFIG"` -# FEED_URL=`grep -E "^\s*-*\ url:" "$CONFIG"` -FEED_WEB=`grep -E "^\s*-*\ web:" "$CONFIG"` -FEED_NUM=`echo "$FEED_TITLE" | wc -l` - -# insert link to rss/xml file -sed -E -e "s/<!--XML-->/\"$XML\"/" -i "$HTML" - -# insert link to manifest JSON file -MANIFEST=`echo "$HTML" | sed -e 's/html/json/'` -sed -E -e "s/<!--MANIFEST-->/\"$MANIFEST\"/" -i "$HTML" +# Generate site +printf "Fetching feeds and generating html...\n" +perlanet "$CONFIG" # remove images and iframes from article previews printf "Removing images and iframes...\n" @@ -39,19 +29,28 @@ sed -E -e 's/<img[^>]*>//g' -e 's/<iframe[^>]*>//g' \ printf "Clean up HTML...\n" sed -E -e 's/<br[^a-z]*[^>]*>//g' -e 's/<p[^a-z]*[^>]*><\/p>//g' -i "$HTML" +# insert link to rss/xml file +printf "Inserting RSS feed file...\n" +sed -E -e "s/<!--XML-->/\"$XML\"/" -i "$HTML" + +# insert link to manifest JSON file +printf "Inserting manifest file...\n" +MANIFEST=`echo "$HTML" | sed -e 's/html/json/'` +sed -E -e "s/<!--MANIFEST-->/\"$MANIFEST\"/" -i "$HTML" + # insert favicon image buttons -printf "Insert favicons...\n" +printf "Inserting favicons...\n" sed -E -e 's/<!--IMG\ src=\"(https:\/\/[^\/]*)[^\"]*(\"[^>]*>)-->/<img src=\"\1\/favicon.ico\2/g' -i "$HTML" # Insert feeds list printf "Inserting feeds list...\n" FEEDS="" -for i in `seq 1 1 $FEED_NUM`; do - TITLE=`echo "$FEED_TITLE" | sed -n "${i},${i}p" | sed -e 's/^.*title:\ //'` - WEB=`echo "$FEED_WEB" | sed -n "${i},${i}p" | sed -e 's/^.*web:\ //'` +for i in `seq 1 1 $NFEEDS`; do + TITLE=`echo "$TITLES" | sed -n "${i},${i}p"` + WEB=`echo "$WEBS" | sed -n "${i},${i}p"` FEEDS="$FEEDS<a href=\"$WEB\">$TITLE</a><br>" done -FEEDS=`echo "$FEEDS" | sed -e 's/\//\\\\\//g' -ze's/\n//g'` +FEEDS=`echo "$FEEDS" | sed -e 's/\//\\\\\//g' -ze 's/\n//g'` sed -E -e "s/<!--FEEDS-->/$FEEDS/" -i "$HTML" # Insert Update time