diff options
-rwxr-xr-x | phlogthis | 32 |
1 files changed, 9 insertions, 23 deletions
@@ -1,13 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash -# create phlog entry, rebuild gophermap +# create phlog entry # requires the text formating utility 'par' +# editor is micro + +pushd "$(pwd)" root=$HOME/src/gopher/phlog remoteroot=/srv/gopher/phlog mkdir -p $HOME/.tmp -pushd "$(pwd)" cd $HOME/.tmp || exit editfile="phlogtmp.txt" articledate="$(date -R)" @@ -19,15 +21,16 @@ read -r -p "Enter title: " title filetitle=$(echo $title | sed 's/ /-/g' | sed 's/[^A-Za-z0-9._-]//g') dirname="$filedate-$filetitle" +# make local and remote dirs mkdir $root/$dirname #ssh spike mkdir $remoteroot/$dirname - +# edit text micro +4:1 "$editfile" # Justify article. This may fail if a # non-empty line doesn't contain spaces -cat "$editfile" | par -jw67 > $article +cat "$editfile" | par -jw67 > $article || cat "$editfile" > $article header="$title\n$articledate\n+$(printf '%*s' 65 | tr ' ' '-')+\n\n" sed -i "1s/^/$header/" $article @@ -36,24 +39,7 @@ dest="$root/$dirname/gophermap" mv "$article" "$dest" rm $editfile echo "Article saved as $dest" - -# build 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 - -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 +echo "Run phlogmap to update the main gophermap" popd exit 0 |