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"
16 mkdir -p "$data_dir/drafts" &&\
17 mkdir -p "$data_dir/published" &&\
18 touch "$data_dir/database"
23 # add a confirmation of sorts here
27 [ -z "$1" ] && echo "please supply a name" && exit 1
30 sanitized=`echo -n "$1" | sed -e 's/[^A-Za-z0-9 _-]//g'| sed -e 's/ /-/g'`
33 $EDITOR "$data_dir/drafts/$sanitized"
38 echo "Select which post to publish"
39 ls -1 "$data_dir/drafts" | nl
42 to_publish=`ls -1 "$data_dir/drafts/" | sed -n "$choice p"`
43 [ -z "$to_publish" ] && echo "Invalid choice" && exit 1
46 sed -e "s/{{TITLE}}/$to_publish/g" |\
47 sed -e "s/{{DATE}}/`date +'%a, %b %d %H:%M'`/g" |\
48 sed -e "/{{BODY}}/r $data_dir/drafts/$to_publish" |\
49 sed -e "/{{BODY}}/d" # rly ugly for now
54 echo "Select which post to delete"
55 ls -1 "$data_dir/published" | nl
58 # check to see if all required files are present
59 [ ! -f $blog_index_file ] && echo "missing $blog_index_file" && exit 1
60 [ ! -f $rolling_file ] && echo "missing $rolling_file" && exit 1
61 [ ! -f $template_file ] && echo "missing $template_file" && exit 1
62 [ ! -f $rss_file ] && echo "missing $rss_file" && exit 1
64 # possibly also check to see if index and rolling have the proper headers
67 # check if blog dir exists
68 [ ! -d $data_dir ] && init
74 d|delete) echo "delete";;
75 r|refresh) echo "refresh";;
76 *) echo "helper" && exit 1;;