- [ -z "$1" ] && echo "Please give your blog post a name (you should put it inside quotations)" && exit 1
- sanitized=`echo -n "$1" | sed -e 's/[^A-Za-z0-9 _-]//g'`
- [ -f "$data_dir/drafts/$sanitized.draft.html" ] && echo "Blog of that name already exists." && exit 1
- $EDITOR "$data_dir/drafts/$sanitized.draft.html"
-}
-
-sub() {
- cat - |\
- sed "1i <!-- ID:$1 START -->" |\
- sed "\$a <!-- ID:$1 END -->" |\
- sed "s|{{TITLE}}|$1|g;
- s|{{DATE}}|`date +'%a, %b %d %H:%M'`|g;
- s|{{URL}}|$website_url/blog/html/$1.html|g" |\
- sed "/{{BODY}}/r $data_dir/drafts/$1.draft.html" |\
- sed "/{{BODY}}/d"
-}
-
-# $1 is directory
-choose() {
- options=`ls -1 "$1" | sed 's/\.draft\.html$//;s/\.html$//'`
- [ -z "$options" ] && echo "No drafts to publish" && exit 0
- echo "$options" | nl
- read -p 'Choose an entry by number > ' choice
- chosen=`ls -1 "$1" | sed -n "$choice p"`
- [ -z "$chosen" ] && echo "Invalid choice" && exit 1