aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-10-05 23:20:10 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-10-05 23:20:10 +0200
commitf023c7d28624c77712973ad65eb51434b35ce086 (patch)
treed85c5e8342837fce3fff92b9737586065a4eed72
parentac4f5eab34ab8a95cd35beed498bb1d7bac854a7 (diff)
downloadscripts-f023c7d28624c77712973ad65eb51434b35ce086.tar.gz
scripts-f023c7d28624c77712973ad65eb51434b35ce086.tar.bz2
scripts-f023c7d28624c77712973ad65eb51434b35ce086.zip
update
-rwxr-xr-xphlogmap6
-rwxr-xr-xphlogrss8
-rwxr-xr-xphlogthis31
3 files changed, 21 insertions, 24 deletions
diff --git a/phlogmap b/phlogmap
index 211eb28..b6ecabc 100755
--- a/phlogmap
+++ b/phlogmap
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# build gophermap
-cd $HOME/src/gopher/phlog
+cd "$HOME/src/gopher/phlog"
echo "+-----------------------------------+" > gophermap
echo "| Phil's Phlog |" >> gophermap
@@ -12,8 +12,8 @@ echo "" >> gophermap
dirs=($(ls -dr */))
for dir in "${dirs[@]}"; do
- dt=$(echo $dir| cut -c 1-10)
- title="$(head -n 1 $dir/gophermap)"
+ dt=$(echo "$dir" | cut -c 1-10)
+ title="$(head -n 1 "$dir/gophermap")"
echo -e "1$dt $title\t/phlog/$dir\tspike.nagatha.fr\t70" >> gophermap
done
diff --git a/phlogrss b/phlogrss
index e42acb0..a7c9d94 100755
--- a/phlogrss
+++ b/phlogrss
@@ -2,13 +2,12 @@
# create a gopher rss feed
-cd $HOME/src/gopher/phlog
+cd "$HOME/src/gopher/phlog" || exit
phloglink="gopher://spike.nagatha.fr/1/phlog"
description="Phil&#39;s Phlog"
-rsslink=gopher://spike.nagatha.fr/0/phlog/rss.xml
-filename=$HOME/src/gopher/phlog/rss.xml
-phlogroot=$HOME/src/gopher/phlog
+rsslink="gopher://spike.nagatha.fr/0/phlog/rss.xml"
+filename="$HOME/src/gopher/phlog/rss.xml"
builddate=$(date --iso-8601=ns)
buildyear=$(date +%Y)
@@ -69,7 +68,6 @@ for dir in "${dir_array[@]}"; do
post="${dir//\//}"
title=$(head -n1 "$post/gophermap")
postdate=$(cat "$post/gophermap" | sed -n '2p')
- postname=${post##*/}
linkadd="$phloglink/$post"
description="$(cat "$post/gophermap" | sed -n "/^$/,/^$/p" | head --lines 3) …"
build_item "$post"
diff --git a/phlogthis b/phlogthis
index b080b34..e5fc496 100755
--- a/phlogthis
+++ b/phlogthis
@@ -4,27 +4,27 @@
# requires the text formating utility 'par'
# editor is micro
-pushd "$(pwd)"
+pushd "$(pwd)" || exit
-root=$HOME/src/gopher/phlog
-remoteroot=/srv/gopher/phlog
+root="$HOME/src/gopher/phlog"
+remoteroot="/srv/gopher/phlog"
-mkdir -p $HOME/.tmp
-cd $HOME/.tmp || exit
+mkdir -p "$HOME/.tmp"
+cd "$HOME/.tmp" || exit
editfile="phlogtmp.txt"
articledate="$(date -R)"
filedate="$(date +%Y-%m-%d-%H-%I)"
article="/tmp/gophermap.tmp"
-read -r -p "Enter title: " title
+read -rp "Enter title: " title
-filetitle=$(echo $title | sed 's/ /-/g' | sed 's/[^A-Za-z0-9._-]//g')
+filetitle=$(echo "$title" | sed "s/ /-/g" | sed "s/[^A-Za-z0-9._-]//g")
dirname="$filedate-$filetitle"
# make local and remote dirs
-mkdir $root/$dirname
+mkdir "$root/$dirname"
echo "creating remote directory..."
-ssh spike mkdir $remoteroot/$dirname
+ssh spike mkdir "$remoteroot/$dirname"
# edit text
micro +4:1 "$editfile"
@@ -33,7 +33,7 @@ micro +4:1 "$editfile"
# non-empty line doesn't contain spaces
cat "$editfile" | par -jw67 > $article || cat "$editfile" > $article
-header="$title\n$articledate\n+$(printf '%*s' 65 | tr ' ' '-')+\n\n"
+header="$title\n$articledate\n+$(printf "%*s" 65 | tr " " "-")+\n\n"
sed -i "1s/^/$header/" $article
dest="$root/$dirname/gophermap"
@@ -41,23 +41,22 @@ mv "$article" "$dest"
rm $editfile
clear
-cat $dest
+cat "$dest"
echo " "
-read -p "Do you want to edit this text? : " choix1
+read -rp "Do you want to edit this text? : " choix1
if [ "$choix1" != "n" ] ; then
clear
- micro $dest
+ micro "$dest"
fi
echo "Article saved as $dest"
-read -p "Run phlogmap & phlogrss & gosend? ; " choix2
+read -rp "Run phlogmap & phlogrss & gosend? ; " choix2
if [ "$choix2" != "n" ] ; then
phlogmap; phlogrss ; gosend
fi
-popd
-exit 0
+popd || exit