+
+ drafts=`ls -1 "$data_dir/drafts" | sed -e 's/\.draft\.html$//'`
+ [ -z "$drafts" ] && echo "No drafts to publish" && exit 0
+
+ echo "Select which draft to publish"
+ echo "$drafts" | nl
+
+ read -p '> ' choice
+ to_publish=`ls -1 "$data_dir/drafts/" | sed -n "$choice p"`
+ to_publish=${to_publish%.draft.html}
+ [ -z "$to_publish" ] && echo "Invalid choice" && exit 1
+
+ cat $blog_template | sub "$to_publish" \
+ > "$data_dir/html/$to_publish.html"
+
+ # Add new entry to blog index (do something about indent??)
+ sed -i "/$start_token/ a\
+ <!-- ID:$to_publish START -->\n`cat "$data_dir/templates/$index_template" | sub "$to_publish"`\n<!-- ID:$to_publish END -->" "$blog_index_file"
+
+ sed -i "/$start_token/ a\
+ <!-- ID:$to_publish START -->\n`cat "$data_dir/templates/$rolling_template" | sub "$to_publish"`\n<!-- ID:$to_publish END -->" "$rolling_file"
+
+ mv "$data_dir/drafts/$to_publish.draft.html" "$data_dir/published/"
+