- [ -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'| sed -e 's/ /-/g'`
- $EDITOR "$data_dir/drafts/$sanitized.draft.html"
-}
-
-sub() {
- cat - |\
- sed "s|{{TITLE}}|$1|g;
- s|{{DATE}}|`date +'%a, %b %d %H:%M'`|g;
- s|{{URL}}|$website_url/$1|g" |\
- sed "/{{BODY}}/r $data_dir/drafts/$1" |\
- sed "/{{BODY}}/d"
-}
-
-# $1 is directory
-choose() { # working on abstraction
- 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