3 # pinosaur's blog script
5 blog_index_file="blogindex.html"
6 rolling_file="rolling.html"
7 template_file="template.html"
11 [ ! -z "$EDITOR" ] && EDITOR="vim"
20 # add a confirmation of sorts here
24 [ -z "$1" ] && echo "please supply a name" && exit 1
27 sanitized=`echo -n "$1" | sed -e 's/[^A-Za-z0-9 _-]//g'| sed -e 's/ /-/g'`
30 $EDITOR "$data_dir/drafts/$sanitized"
35 "Select which post to publish"
36 ls -1 "$data_dir/drafts" | nl
39 to_publish=`ls -1 "$data_dir/drafts/" | sed -n "$choice p"`
40 [ -z "$to_publish" ] && echo "Invalid choice" && exit 1
46 echo "Select which post to delete"
47 ls -1 "$data_dir/published" | nl
50 # check to see if all required files are present
51 [ ! -f $blog_index_file ] && echo "missing $blog_index_file" && exit 1
52 [ ! -f $rolling_file ] && echo "missing $rolling_file" && exit 1
53 [ ! -f $template_file ] && echo "missing $template_file" && exit 1
54 [ ! -f $rss_file ] && echo "missing $rss_file" && exit 1
56 # possibly also check to see if index and rolling have the proper headers
59 # check if blog dir exists
60 [ ! -d $data_dir ] && echo "initing blog" &&\
61 mkdir -p "$data_dir/drafts" &&\
62 mkdir -p "$data_dir/published" &&\
63 touch "$data_dir/database"
69 d|delete) echo "delete";;
70 r|refresh) echo "refresh";;
71 *) echo "helper" && exit 1;;