13201c223cd9423e7c6b4580df85420e8f9c009f
[pb.git] / pb
1 #!/bin/sh
2 # pinosaur's blog script v2!
3
4 data_dir="blog"
5 website_url="https://www.youtube.com/watch?v=oHg5SJYRHA0/" 
6 rolling_file="rolling.html"
7 blog_index_file="blogindex.html"
8 rss_file="rss.xml"
9 blog_template="template.html"
10 database_file="$data_dir/database"
11 index_template="$data_dir/templates/index_entry.html"
12 rolling_template="$data_dir/templates/rolling_entry.html"
13 rss_template="$data_dir/templates/rss_entry.html"
14
15 init() {
16     read -p "Initialize blog here? [y/n] " ask
17     [ "$ask" != "y" ] && printf "Initialization cancelled.\n" && exit 0
18
19     mkdir -p "$data_dir/drafts" "$data_dir/published" "$data_dir/html" "$data_dir/templates" 
20
21     printf '<li><a href="{{URL}}">{{DATE}} - {{TITLE}}</a></li>' > "$index_template"
22     printf '<div>\n<h2>{{TITLE}}</h2>\n<p>{{DATE}}</p>\n<p>{{BODY}}</p>\n</div>\n' > "$rolling_template"
23     printf '<item>\n<title>{{TITLE}}</title>\n<link>{{URL}}</link>\n<description></description>\n{{BODY}}\n</item>\n' > "$rss_template"
24     touch "$database_file"
25
26     printf 'Successfully initialized pb.\n'
27 }
28
29 new() {
30     printf 'new\n' 
31 }
32
33 publish() {
34     printf 'publish\n' 
35 }
36
37 delete() {
38     printf 'delete\n' 
39 }
40
41 [ -f $blog_index_file ] && [ -f $rolling_file ] && [ -f $rss_file ] && [ -f $blog_template ] || { echo "You are missing a file, please check that you have $blog_index_file, $blog_template, $rolling_file and $rss_file in your home directory" && exit 1; }
42
43 [ -f $blog ]
44
45 [ ! -d $data_dir ] && init && exit 0
46
47 case $1 in
48     n|new) new;;
49     p|publish) publish;;
50     d|delete) delete;;
51     r|refresh) printf 'refresh\n';;
52     h|*) printf 'help\n';;
53 esac
54
55
56