aboutsummaryrefslogtreecommitdiff
path: root/phlogthis
diff options
context:
space:
mode:
Diffstat (limited to 'phlogthis')
-rwxr-xr-xphlogthis19
1 files changed, 13 insertions, 6 deletions
diff --git a/phlogthis b/phlogthis
index 3a7f045..bed1d7f 100755
--- a/phlogthis
+++ b/phlogthis
@@ -4,6 +4,7 @@
# requires the text formating utility 'par'
root=$HOME/src/gopher/phlog
+remoteroot=/srv/gopher/phlog
mkdir -p $HOME/.tmp
pushd "$(pwd)"
@@ -11,13 +12,16 @@ 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
filetitle=$(echo $title | sed 's/ /-/g' | sed 's/[^A-Za-z0-9._-]//g')
-article=$filedate-$filetitle.txt
+dirname="$filedate-$filetitle"
+
+mkdir $root/$dirname
+#ssh spike mkdir $remoteroot/$dirname
-dest="$root/$article"
micro +4:1 "$editfile"
@@ -25,9 +29,10 @@ micro +4:1 "$editfile"
# non-empty line doesn't contain spaces
cat "$editfile" | par -jw67 > $article
-header="title:$title\ndate:$articledate\n$(printf '%*s' 66 | tr ' ' '-')\n\n"
+header="$title\n$articledate\n+$(printf '%*s' 65 | tr ' ' '-')+\n\n"
sed -i "1s/^/$header/" $article
+dest="$root/$dirname/gophermap"
mv "$article" "$dest"
rm $editfile
echo "Article saved as $dest"
@@ -43,9 +48,11 @@ 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
+dirs=($(ls -dr */))
+for dir in "${dirs[@]}"; do
+ dt=$(echo $dir| cut -c 1-10)
+ tt="$(head -n 1 $dir/gophermap)"
+ echo -e "1$dt $tt\t/phlog/$dir\tspike.nagatha.fr\t70" >> gophermap
done
popd