bpst.rc (1188B)
1 #!/bin/rc 2 3 path=( $PLAN9/bin $path ) 4 base=. 5 6 if(~ $#user 0) 7 user=`{whoami} 8 9 file=(); title=(); 10 bloguser=$user 11 while(! ~ $#* 0) { 12 switch($1) { 13 case -u 14 base=/gsoc/www/people/$user/blog/ 15 case -b 16 shift 17 base=$1 18 case -f 19 shift 20 file=$1 21 } 22 shift 23 } 24 25 if(~ $"EDITOR '') 26 EDITOR=vi 27 28 if(~ $#file 0 || ! test -f $file) { 29 file=/tmp/blogtmp.$pid 30 rm $file >[2]/dev/null 31 touch $file 32 } 33 34 $EDITOR $file 35 ispell $file 36 rm $file.bak >[2]/dev/null 37 38 fn mkbpost { 39 umask 002 # Let group write 40 bptext=$1 41 if(! ~ $#2 0) 42 bpid=`{echo -n '-'^$"bpid | sed 's/'$forbidden_uri_chars'+/_/g; 1q'} 43 d=`{/bin/date +%F|sed 's,-,/,g'} 44 45 ddir=$blagh_root^$d^'/' 46 n=`{ls $ddir >[2]/dev/null |wc -l} 47 48 mkdir -p $ddir/$"n^$"bpid/ 49 { 50 # TODO: Enable metadata 51 #echo '* Posted:' `{date} 52 #if(! ~ $#logged_user 0) 53 # echo '* Author: '$logged_user 54 cat $bptext 55 }> $ddir/$"n^$"bpid/index.md 56 } 57 58 forbidden_uri_chars='[^a-zA-Z0-9_+\-\/\.]' 59 blagh_root=$base 60 61 if(test -s $file) 62 mkbpost $file 63 if not 64 echo Empty file!