diff --git a/lib/all_posts.sh b/lib/all_posts.sh index 20a4a0c..234f2e3 100644 --- a/lib/all_posts.sh +++ b/lib/all_posts.sh @@ -1,16 +1,16 @@ #!/usr/bin/env bash # Create an index page with all the posts +declare archive_index +declare template_archive_index_page +declare template_archive_title +declare date_allposts_header +declare date_format +declare date_locale +declare index_file +declare global_title +declare global_author all_posts() { - declare archive_index - declare template_archive_index_page - declare template_archive_title - declare date_allposts_header - declare date_format - declare date_locale - declare index_file - declare global_title - declare global_author echo -n "Creating an index page with all the posts " contentfile=$archive_index.$RANDOM while [[ -f $contentfile ]]; do diff --git a/lib/all_tags.sh b/lib/all_tags.sh index 0090c17..7d72710 100644 --- a/lib/all_tags.sh +++ b/lib/all_tags.sh @@ -1,17 +1,17 @@ #!/usr/bin/env bash # Create an index page with all the tags +declare tags_index +declare template_tags_posts +declare template_tags_posts_singular +declare template_tags_posts_2_4 +declare template_tags_title +declare prefix_tags +declare index_file +declare template_archive_index_page +declare global_author +declare global_title all_tags() { - declare tags_index - declare template_tags_posts - declare template_tags_posts_singular - declare template_tags_posts_2_4 - declare template_tags_title - declare prefix_tags - declare index_file - declare template_archive_index_page - declare global_author - declare global_title echo -n "Creating an index page with all the tags " contentfile=$tags_index.$RANDOM while [[ -f $contentfile ]]; do diff --git a/lib/create_html_page.sh b/lib/create_html_page.sh index 51759bd..11d8ee8 100644 --- a/lib/create_html_page.sh +++ b/lib/create_html_page.sh @@ -12,14 +12,14 @@ # $4 title for the html header # $5 original blog timestamp # $6 post author +declare body_begin_file +declare date_inpost +declare date_locale +declare date_format +declare date_format_timestamp +declare global_url +declare body_end_file create_html_page() { - declare body_begin_file - declare date_inpost - declare date_locale - declare date_format - declare date_format_timestamp - declare global_url - declare body_end_file content=$1 filename=$2 index=$3 diff --git a/lib/create_includes.sh b/lib/create_includes.sh index 6c2dceb..afd275a 100644 --- a/lib/create_includes.sh +++ b/lib/create_includes.sh @@ -1,21 +1,21 @@ #!/usr/bin/env bash # generate headers, footers, etc +declare global_author +declare global_author_url +declare global_description +declare global_email +declare global_feedburner +declare global_license +declare global_title +declare global_url +declare index_file +declare header_file +declare css_include +declare template_subscribe_browser_button +declare blog_feed +declare footer_file create_includes() { - declare global_author - declare global_author_url - declare global_description - declare global_email - declare global_feedburner - declare global_license - declare global_title - declare global_url - declare index_file - declare header_file - declare css_include - declare template_subscribe_browser_button - declare blog_feed - declare footer_file { echo "
The rest of the text file is an html blog post. The process will continue as soon -as you exit your editor.
- -$template_tags_line_header keep-this-tag-format, tags-are-optional, example
-EOF - - [[ $fmt == md ]] && cat << EOF >> "$TMPFILE" + cat << EOF >> "$TMPFILE" The rest of the text file is a **Markdown** blog post. The process will continue as soon as you exit your editor. @@ -54,21 +34,29 @@ EOF filename="" while [[ $post_status != "p" && $post_status != "P" ]]; do [[ -n $filename ]] && rm "$filename" # Delete the generated html file, if any + $EDITOR "$TMPFILE" - if [[ $fmt == md ]]; then - html_from_md=$(mrkdwn "$TMPFILE") - parse_file "$html_from_md" - rm "$html_from_md" - else - parse_file "$TMPFILE" # this command sets $filename as the html processed file - fi + + html_from_md=$(mrkdwn "$TMPFILE") + + parse_file "$html_from_md" + rm "$html_from_md" + chmod 644 "$filename" [[ -n $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) " + echo -n "[P]ost this entry, [E]dit again, [D]raft for later, [C]ancel and quit? (p/e/d/c) " read -r post_status + #Case user cancelled + if [[ $post_status == c || $post_status == C ]]; then + rm "$TMPFILE" + delete_includes + echo "Your draft was erased. Nothing was changed in your blog." + exit + fi + #Case User choose post if [[ $post_status == d || $post_status == D ]]; then mkdir -p "drafts/" chmod 700 "drafts/" @@ -87,11 +75,7 @@ EOF fi done - if [[ $fmt == md && -n $save_markdown ]]; then - mv "$TMPFILE" "${filename%%.*}.md" - else - rm "$TMPFILE" - fi + mv "$TMPFILE" "${filename%%.*}.md" chmod 644 "$filename" echo "Posted $filename" relevant_tags=$(tags_in_post "$filename")