2008-06-27 18:13:36 -06:00
|
|
|
#!/usr/bin/env rc
|
|
|
|
|
|
|
|
path=( $PLAN9/bin $path )
|
|
|
|
base=.
|
|
|
|
|
|
|
|
fn die {
|
|
|
|
echo error: $* >[1=2]
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2008-12-20 16:13:53 -07:00
|
|
|
if(~ $#* 0)
|
2008-06-27 18:13:36 -06:00
|
|
|
die 'Missing title'
|
|
|
|
|
|
|
|
if(~ $#user 0)
|
2008-12-20 16:13:53 -07:00
|
|
|
user=`{whoami}
|
2008-06-27 18:13:36 -06:00
|
|
|
|
2008-12-20 16:13:53 -07:00
|
|
|
file=(); title=();
|
|
|
|
bloguser=$user
|
2008-06-27 18:13:36 -06:00
|
|
|
while(! ~ $#* 0) {
|
|
|
|
switch($1) {
|
|
|
|
case -u
|
|
|
|
base=/gsoc/www/people/$user/blog/
|
|
|
|
shift
|
|
|
|
case *
|
2008-12-20 16:13:53 -07:00
|
|
|
title=$"*
|
2008-06-27 18:13:36 -06:00
|
|
|
}
|
|
|
|
shift
|
|
|
|
}
|
|
|
|
|
|
|
|
date=`{/bin/date +%F}
|
|
|
|
|
2008-12-20 16:13:53 -07:00
|
|
|
n=1
|
2008-06-27 18:13:36 -06:00
|
|
|
for(f in $base/$date-*) {
|
2008-12-20 16:13:53 -07:00
|
|
|
i=`{echo $f | sed -n 's|^.*/'$date'-([0-9]+)_.*|\1|p'}
|
2008-06-27 18:13:36 -06:00
|
|
|
if(! ~ $#i 0 && test $i -ge $n)
|
2008-12-20 16:13:53 -07:00
|
|
|
n=`{hoc -e $i'+1'}
|
2008-06-27 18:13:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if(~ $EDITOR '')
|
2008-12-20 16:13:53 -07:00
|
|
|
EDITOR=vi
|
2008-06-27 18:13:36 -06:00
|
|
|
|
2008-12-20 16:13:53 -07:00
|
|
|
file=$home/.blogtmp.$pid
|
2008-06-27 18:13:36 -06:00
|
|
|
rm $file >[2]/dev/null
|
|
|
|
touch $file
|
|
|
|
$EDITOR $file
|
|
|
|
ispell $file
|
|
|
|
rm $file.bak >[2]/dev/null
|
|
|
|
|
|
|
|
|
|
|
|
title = `{ echo $"title | sed 's/ /_/g' }
|
|
|
|
|
|
|
|
title = `{echo $"title | sed 's/[ ]+/_/g; 1q'}
|
|
|
|
|
|
|
|
mv $file $base/$"date^'-'^$"n^_$"title.md
|
|
|
|
|