aboutsummaryrefslogtreecommitdiff
path: root/phlogthis
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-09-25 22:35:10 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-09-25 22:35:10 +0200
commite19f6298c7256972f9175bc2c9e1bb7c22d6249e (patch)
tree0691a8b2132f046426d0e783495e23ab2eca6c1d /phlogthis
parent503f8bd3eac1848cd2b472f64ab76c1bb8a41cb1 (diff)
downloadscripts-e19f6298c7256972f9175bc2c9e1bb7c22d6249e.tar.gz
scripts-e19f6298c7256972f9175bc2c9e1bb7c22d6249e.tar.bz2
scripts-e19f6298c7256972f9175bc2c9e1bb7c22d6249e.zip
update
Diffstat (limited to 'phlogthis')
-rwxr-xr-xphlogthis51
1 files changed, 51 insertions, 0 deletions
diff --git a/phlogthis b/phlogthis
new file mode 100755
index 0000000..cef6049
--- /dev/null
+++ b/phlogthis
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# create text, assemble html file, add to articles
+
+root=$HOME/src/gopher/phlog
+
+mkdir -p $HOME/.tmp
+pushd "$(pwd)"
+cd $HOME/.tmp || exit
+editfile="phlogtmp.txt"
+articledate="$(date -R)"
+filedate="$(date +%Y-%m-%d-%H-%I)"
+
+read -r -p "Enter title: " title
+
+filetitle=$(echo $title | sed 's/ /-/g' | sed 's/[^A-Za-z0-9._-]//g')
+article=$filedate-$filetitle.txt
+
+dest="$root/$article"
+
+micro +4:1 "$editfile"
+
+# article
+cat "$editfile" | par -jw67 >> "$article"
+
+header="title:$title\ndate:$articledate\n\n"
+sed -i "1s/^/$header/" $article
+
+mv "$article" "$dest"
+rm $editfile
+echo "Article saved as $dest"
+
+# create gophermap
+
+cd $root
+
+echo "╔═══════════════════════════════════╗" > gophermap
+echo "║ Phil's Phlog ║" >> gophermap
+echo "╚═══════════════════════════════════╝" >> gophermap
+echo "" >> gophermap
+echo "0[Rss feed] /phlog/rss.xml spike.nagatha.fr 70" >> gophermap
+echo "" >> gophermap
+
+
+files=($(ls -1r *.txt))
+for file in "${files[@]}"; do
+ echo -e "0$(head -n 1 $file | sed s/title://g)\t/phlog/$file\tspike.nagatha.fr\t70" >> gophermap
+done
+
+popd
+exit 0