-
- 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"`
- [ -z "$to_publish" ] && echo "Invalid choice" && exit 1
-
- cat $template_file |\
- sed -e "s/{{TITLE}}/$to_publish/g;
- s/{{DATE}}/`date +'%a, %b %d %H:%M'`/g" |\
- sed -e "/{{BODY}}/r $data_dir/drafts/$to_publish" |\
- sed -e "/{{BODY}}/d" \
- > "$data_dir/html/${to_publish%.draft.html}.html"
-
- mv "$data_dir/drafts/$to_publish" "$data_dir/published/"
-
- # Add new entry to blog index (do something about indent??)
- sed -i "/<!-- BLOG START -->/ a <h3>$to_publish<\\/h3>" "$blog_index_file"
-