tweaks
[pb.git] / pb
1 #!/bin/sh
2
3 # pinosaur's blog script
4
5 blog_index_file="blogindex.html"
6 rolling_file="rolling.html"
7 template_file="template.html"
8 rss_file="rss.xml"
9 data_dir="blog"
10
11 [ ! -z "$EDITOR" ] && EDITOR="vim"
12
13
14 init() {
15     echo 1
16 }
17
18 purge() {
19     echo 1
20     # add a confirmation of sorts here
21 }
22
23 new() {
24     [ -z $1 ] && echo "please supply a name" && exit 1 
25
26     # do some sed stuff here
27     cp $template_file "$data_dir/drafts/$1"
28
29 }
30
31 publish() {
32     echo "Select which post to publish"
33     ls -1 "$data_dir/drafts" | nl 
34 }
35
36 delete() {
37     echo "Select which post to delete"
38     ls -1 "$data_dir/published" | nl 
39 }
40
41 # check to see if all required files are present
42 [ ! -f $blog_index_file ] && echo "missing $blog_index_file" && exit 1
43 [ ! -f $rolling_file ] && echo "missing $rolling_file" && exit 1
44 [ ! -f $template_file ] && echo "missing $template_file" && exit 1
45 [ ! -f $rss_file ] && echo "missing $rss_file" && exit 1
46
47 # possibly also check to see if index and rolling have the proper headers
48
49
50 # check if blog dir exists
51 [ ! -d $data_dir ] && echo "initing blog" &&\
52     mkdir -p "$data_dir/drafts" &&\
53     mkdir -p "$data_dir/published" &&\
54     touch "$data_dir/database" 
55
56 case $1 in
57     i|init) echo "init";;
58     n|new) new $2;;
59     p|publish) publish;;
60     d|delete) echo "delete";;
61     D|purge) echo "purge";;
62     *) echo "helper" && exit 1;;
63 esac
64