+ choose "$data_dir/drafts"
+ to_publish=${chosen%.draft.html}
+
+ cat $blog_template | sub "$to_publish" > "$data_dir/html/$to_publish.html"
+
+ # make this part less horrendous
+ temp_index="$(mktemp)"
+ cat "$data_dir/templates/$index_template" | sub "$to_publish" >> $temp_index
+ temp_rolling="$(mktemp)"
+ cat "$data_dir/templates/$rolling_template" | sub "$to_publish" >> $temp_rolling
+ temp_rss="$(mktemp)"
+ cat "$data_dir/templates/$rss_template" | sub "$to_publish" >> $temp_rss
+
+ # Add new entry to blog index (do something about indent??)
+ sed -i "/<!-- BLOG START -->/r $temp_index" "$blog_index_file"
+ sed -i "/<!-- BLOG START -->/r $temp_rolling" "$rolling_file"
+ sed -i "/<!-- BLOG START -->/r $temp_rss" "$rss_file"
+
+ mv "$data_dir/drafts/$to_publish.draft.html" "$data_dir/published/"
+ echo "Successfully published $to_publish"