From 77b8914d9f233321430f9a9a9947c52de9239a72 Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Sun, 31 May 2026 12:28:54 +0200 Subject: update --- blogarticledate | 17 ++++++++++++ blogrss | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ blogsend | 26 +++++++++++++++++++ blogsitemap | 33 ++++++++++++++++++++++++ blogsitemap.options | 12 +++++++++ blogthis | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 227 insertions(+) create mode 100755 blogarticledate create mode 100755 blogrss create mode 100755 blogsend create mode 100755 blogsitemap create mode 100755 blogsitemap.options create mode 100755 blogthis diff --git a/blogarticledate b/blogarticledate new file mode 100755 index 0000000..6eb73a1 --- /dev/null +++ b/blogarticledate @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# resets blog articles file date to the date indicated +# in the article +postDir=/home/philip/web/articles/2025 + +mapfile -t postArray < <(ls -t "$postDir"/*.html) +for posts in "${postArray[@]}"; do + post="$posts" + postdate=$(grep -o '>.*' "$post" | sed 's/\(>\|<\/h5>\)//g') + echo "$postdate" + #[[CC]YY]MMDDhhmm[.ss] + postdate="${postdate//-}0000" + echo Date="$postdate" + echo Item="$post" + touch -a -m -t "$postdate" "$post" +done diff --git a/blogrss b/blogrss new file mode 100755 index 0000000..5e83aeb --- /dev/null +++ b/blogrss @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +link=https://wittamore.fr/articles/2026 +description='Ramblings from Brittany, France' +rsslink=https://wittamore.fr/rss.xml +feedname=/home/philip/web/rss.xml +postDir=/home/philip/web/articles/2026 +updated=$(date --iso-8601=ns) + +# Build RSS header & footer +header () { +echo " +" > ~/feedtop +echo " + +Bloggings - wittamore.fr +https://wittamore.com +Ramblings from Brittany, France +$updated + +" >> ~/feedtop +} + +footer () { +echo " + + + +" >> ~/feedbottom +} + +# Function: Build Item add to feed + +item () { + echo " + $fullTitle$postdate + $linkadd + $linkadd + + $description +" >> ~/feed +} + +# Function: Concatenate everything + +combine () { + header + footer + cat ~/feedtop ~/feed > ~/feedtb + cat ~/feedtb ~/feedbottom > $feedname + rm ~/feedtop ~/feed ~/feedtb ~/feedbottom +} + +# Run through files and create rss.xml + +if [[ -f $feedname ]]; then + rm $feedname +fi +touch $feedname +mapfile -t postArray < <(ls -t "$postDir"/*.html) +postNum=0 +for posts in "${postArray[@]}"; do + ((postNum+=1)) + post=$posts + fullTitle=$(grep -o '>.*' "$post" | sed 's/\(>\|<\/h2>\)//g') + postdate=$(grep -o '>.*' "$post" | sed 's/\(>\|<\/h5>\)//g') + postname=${post##*/} + linkadd="$link"/"$postname" + description=$(sed -n '/

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

||g' -e 's|

||g' -e 's|"||g') + item "$post" +done + combine +exit + diff --git a/blogsend b/blogsend new file mode 100755 index 0000000..905857e --- /dev/null +++ b/blogsend @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# blogsend + +# folders +localdir=~/web + +# update git +echo "-- Updating git" +cd $localdir || exit +git add * +git commit -m 'file update' +git push origin master + +# update remote http root +echo "-- Updating remote web root" +ssh -q soc << EOF +cd /srv/http/wittamore.fr || exit +pwd +git pull +EOF + +printf "Done.\n" + +exit 0 + diff --git a/blogsitemap b/blogsitemap new file mode 100755 index 0000000..8924287 --- /dev/null +++ b/blogsitemap @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +cd /home/philip/web + +# url configuration +URL="https://wittamore.fr/" + +# values: always hourly daily weekly monthly yearly never +FREQ="weekly" + +# begin new sitemap +exec 1> sitemap.xml + +# print head +echo '' +echo '' +echo '' + +# print urls +IFS=$'\r\n' GLOBIGNORE='*' command eval "OPTIONS=($(cat $0.options))" +find . -type f "${OPTIONS[@]}" -printf "%TY-%Tm-%Td%p\n" | \ +while read -r line; do + DATE=${line:0:10} + FILE=${line:12} + echo "" + echo " ${URL}${FILE}" + echo " $DATE" + echo " $FREQ" + echo "" +done + +# print foot +echo "" diff --git a/blogsitemap.options b/blogsitemap.options new file mode 100755 index 0000000..ed34f09 --- /dev/null +++ b/blogsitemap.options @@ -0,0 +1,12 @@ +-prune +! -iname robots.txt +! -iname sitemap.\* +! -iname favicon.\* +! -iname rss.\* +! -iname style.\* +! -iname .\* +! -path ./images/\* +! -path ./fonts/\* + + + diff --git a/blogthis b/blogthis new file mode 100755 index 0000000..ec0eaf5 --- /dev/null +++ b/blogthis @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# create text, assemble html file, add to articles, upload + +#web is a symlink to $HOME/src/web/example.com +ROOT="$HOME/web" + +mkdir -p $ROOT/.tmp +cd $ROOT/.tmp || exit +EDITFILE="middle.html" +DATE=$(date +%Y-%m-%d) + +read -r -p "Enter title: " TITLE +read -r -e -i "$DATE" -p "Enter date: " input +read -r -p "Enter description: " DESCRIPTION + +ARTICLEDATE="${input:-$DATE}" +YEAR=$(echo "$ARTICLEDATE" | cut -c 1-4) +DEST="$ROOT/articles/$YEAR" + +echo "

$TITLE

" > $EDITFILE +echo "
$ARTICLEDATE
" >> $EDITFILE +echo "

$DESCRIPTION

" >> $EDITFILE + +micro +4:1 "$EDITFILE" + +FIXEDTITLE=${TITLE// /-} +ARTICLE="$FIXEDTITLE.html" + +echo " + + + + + + + $TITLE + + +
+

Bloggings

+ Back +
+
+
" > "$ARTICLE" + +cat "$EDITFILE" >> "$ARTICLE" + +echo "
+
+ + +" >> "$ARTICLE" +mv "$ARTICLE" "$DEST" +echo "saved as $DEST/$ARTICLE" + +echo "--------------------------" +read -rp "Update the sitemap and rss feed, then upload to your server? ; " choix + +if [ "$choix" != "n" ] ; then + blogsitemap; blogrss ; blogsend +fi + -- cgit v1.3.1