From 840d24c4acdcee3f79ea771f7caf4b2eecd6bee2 Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Thu, 26 Jun 2014 03:53:09 +0200 Subject: [PATCH 1/4] Don't ask for preview - just show URL for preview --- bb.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/bb.sh b/bb.sh index a4f33f7..fcb6d99 100755 --- a/bb.sh +++ b/bb.sh @@ -635,15 +635,10 @@ EOF else parse_file "$TMPFILE" # this command sets $filename as the html processed file fi - chmod 600 "$filename" - echo -n "Preview? (Y/n) " - read p - if [[ "$p" != "n" ]] && [[ "$p" != "N" ]]; then - chmod 644 "$filename" - [ $preview_url ] || preview_url="$global_url" - echo "Open $preview_url/$filename in your browser" - fi + chmod 644 "$filename" + [ "$preview_url" ] || preview_url="$global_url" + echo "To preview the entry, open $preview_url/$filename in your browser" echo -n "[P]ost this entry, [E]dit again, [D]raft for later? (p/E/d) " read post_status From 555db3167f49fffdfe8a394a50c7e0c10db2bd84 Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Thu, 26 Jun 2014 04:08:31 +0200 Subject: [PATCH 2/4] use markdown by default (if available) when posting with `bb.sh post` --- bb.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/bb.sh b/bb.sh index fcb6d99..3a72441 100755 --- a/bb.sh +++ b/bb.sh @@ -583,16 +583,9 @@ parse_file() { # Manages the creation of the text file and the parsing to html file # also the drafts write_entry() { - fmt="html"; f="$2" - [[ "$2" == "-m" ]] && fmt="md" && f="$3" - if [[ "$fmt" == "md" ]]; then - test_markdown - if [[ "$?" -ne 0 ]]; then - echo "Markdown is not working, please use HTML. Press a key to continue..." - fmt="html" - read - fi - fi + test_markdown && fmt="md" || fmt="html" + f="$2" + [[ "$2" == "-html" ]] && fmt="html" && f="$3" if [[ "$f" != "" ]]; then TMPFILE="$f" From 7d67da7b27fe70c52002d9599669bb2f00c8d79b Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Thu, 26 Jun 2014 04:13:29 +0200 Subject: [PATCH 3/4] use file extension when posting with `bb.sh post file.ext` but let users override it with `bb.sh post -html file.md` --- bb.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bb.sh b/bb.sh index 3a72441..86f0824 100755 --- a/bb.sh +++ b/bb.sh @@ -594,9 +594,11 @@ write_entry() { delete_includes exit fi - # check if TMPFILE is markdown even though the user didn't specify it + # guess format from TMPFILE extension="${TMPFILE##*.}" - [[ "$extension" == "md" ]] && fmt="md" + [[ "$extension" == "md" || "$extension" == "html" ]] && fmt="$extension" + # but let user override it (`bb.sh post -html file.md`) + [[ "$2" == "-html" ]] && fmt="html" else TMPFILE=".entry-$RANDOM.$fmt" echo -e "Title on this line\n" >> "$TMPFILE" From 773bcc1f8558647d1e3d33f324e146e1e055ccff Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Thu, 26 Jun 2014 04:23:38 +0200 Subject: [PATCH 4/4] help text --- bb.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bb.sh b/bb.sh index 86f0824..3cf58b8 100755 --- a/bb.sh +++ b/bb.sh @@ -975,8 +975,9 @@ usage() { echo "Usage: $0 command [filename]" echo "" echo "Commands:" - echo " post [-m] [filename] insert a new blog post, or the filename of a draft to continue editing it" - echo " use '-m' to edit the post as Markdown text" + echo " post [-html] [filename] insert a new blog post, or the filename of a draft to continue editing it" + echo " it tries to use markdown by default, and falls back to HTML if it's not available." + echo " use '-html' to override it and edit the post as HTML even when markdown is available" echo " edit [-n|-f] [filename] edit an already published .html or .md file. **NEVER** edit manually a published .html file," echo " always use this function as it keeps internal data and rebuilds the blog" echo " use '-n' to give the file a new name, if title was changed"