diff options
author | Philip Wittamore <philip@wittamore.com> | 2025-05-08 22:20:43 +0200 |
---|---|---|
committer | Philip Wittamore <philip@wittamore.com> | 2025-05-08 22:20:43 +0200 |
commit | 43f1bb6b8b2c80a68d332fb887a35b10d89a626e (patch) | |
tree | b6829a05f05f7efe01b3b3a1748755148a5dc325 /blogrss | |
parent | 0f415a8f3521504b26feba9ddafa6f2264e3f2f1 (diff) | |
download | blog-43f1bb6b8b2c80a68d332fb887a35b10d89a626e.tar.gz blog-43f1bb6b8b2c80a68d332fb887a35b10d89a626e.tar.bz2 blog-43f1bb6b8b2c80a68d332fb887a35b10d89a626e.zip |
update
Diffstat (limited to 'blogrss')
-rwxr-xr-x | blogrss | 46 |
1 files changed, 20 insertions, 26 deletions
@@ -1,6 +1,5 @@ #!/bin/bash -title=Bloggings link=https://wittamore.com/articles/2025 description='Ramblings from Brittany, France' rsslink=https://wittamore.com/rss.xml @@ -23,40 +22,36 @@ updated=$(date --iso-8601=ns) # Build RSS header & footer header () { -echo """<?xml version='1.0' encoding='UTF-8' ?> -<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'> -""" > ~/feedtop -echo """ +echo "<?xml version='1.0' encoding='UTF-8' ?> +<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>" > ~/feedtop +echo " <channel> <title>Bloggings - wittamore.com</title> <link>https://wittamore.com</link> <description>Ramblings from Brittany, France</description> <lastBuildDate>$updated</lastBuildDate> <atom:link href='$rsslink' rel='self' type='application/rss+xml' /> -""" >> ~/feedtop +" >> ~/feedtop } footer () { -echo """ +echo " </channel> </rss> -""" >> ~/feedbottom +" >> ~/feedbottom } # Function: Build Item add to feed item () { - echo """<item> - <title>$fullTitle</title> - <pubDate>$postdate</pubDate> - <link>$linkadd</link> - <guid>$linkadd</guid> - <category> </category> - <description>$description</description> - <enclosure> </enclosure> - </item> - """ >> ~/feed + echo "<item> + <title>$fullTitle</title><pubDate>$postdate</pubDate> + <link>$linkadd</link> + <guid>$linkadd</guid> + <category> </category> + <description>$description</description> +</item>" >> ~/feed } # Function: Concatenate everything @@ -75,19 +70,18 @@ if [[ -f $feedname ]]; then rm $feedname fi touch $feedname -postArray=( $(ls -t "$postDir"/*.html) ) -numPosts=$(ls "$postDir"/*.html | wc -l) +#postArray=( $(ls -t "$postDir"/*.html) ) +mapfile -t postArray < <(ls -t "$postDir"/*.html) postNum=0 for posts in "${postArray[@]}"; do - let postNum+=1 + ((postNum+=1)) post=$posts - fullTitle=$(grep -o '>.*</h2>' $post | sed 's/\(>\|<\/h2>\)//g') - postdate=$(grep -o '>.*</h5>' $post | sed 's/\(>\|<\/h5>\)//g') + fullTitle=$(grep -o '>.*</h2>' "$post" | sed 's/\(>\|<\/h2>\)//g') + postdate=$(grep -o '>.*</h5>' "$post" | sed 's/\(>\|<\/h5>\)//g') postname=${post##*/} linkadd="$link"/"$postname" - guid=$postNum - description=$(sed -n '/<h4>.*/,/*.<\/h4>/{p;q;}' $post | sed -e 's/<[^>]\+>/ /g' -e 's|<h4>||g' -e 's|</h4>||g' -e 's|"||g') - item $post + description=$(sed -n '/<h4>.*/,/*.<\/h4>/{p;q;}' "$post" | sed -e 's/<[^>]\+>/ /g' -e 's|<h4>||g' -e 's|</h4>||g' -e 's|"||g') + item "$post" done combine exit |