-
- 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 $template_file | sub "$to_publish" \
- > "$data_dir/html/$to_publish.html"
-
- # Add new entry to blog index (do something about indent??)
- sed -i "/<!-- BLOG START -->/ a\
- `cat "$data_dir/templates/$index_entry_template" | sub "$to_publish"`" "$blog_index_file"
- #also clean up this bracket mess ^
-
- mv "$data_dir/drafts/$to_publish.draft.html" "$data_dir/published/"
-