blob: 0cccfb03fdf780dc6223aa9c92f6cded5a5aeb94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/env bash
# 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
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')
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" > $article
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"
echo "Run phlogmap to update the main gophermap"
popd
exit 0
|