2 # pinosaur's blog script v2!
5 website_url="https://www.youtube.com/watch?v=oHg5SJYRHA0/"
6 rolling_file="rolling.html"
7 blog_index_file="blogindex.html"
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"
16 read -p "Initialize blog here? [y/n] " ask
17 [ "$ask" != "y" ] && printf "Initialization cancelled.\n" && exit 0
19 mkdir -p "$data_dir/drafts" "$data_dir/published" "$data_dir/html" "$data_dir/templates"
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"
26 printf 'Successfully initialized pb.\n'
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; }
45 [ ! -d $data_dir ] && init && exit 0
51 r|refresh) printf 'refresh\n';;
52 h|*) printf 'help\n';;