From 2ca8e59bd0e11dd47734bce3ebe0794c9ba72383 Mon Sep 17 00:00:00 2001 From: Carlos Bautista Date: Tue, 2 Apr 2013 23:35:33 +0200 Subject: [PATCH] Configuration settings for disqus variables --- bb.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/bb.sh b/bb.sh index fa308f3..961eda9 100755 --- a/bb.sh +++ b/bb.sh @@ -90,10 +90,10 @@ global_config=".config" global_variables() { - if [[ -z $EDITOR ]]; then EDITOR=vim; fi + echo Loading inline configuration global_software_name="BashBlog" - global_software_version="1.5.1" + global_software_version="1.6.0" # Blog title global_title="My fancy blog" @@ -124,6 +124,10 @@ global_variables() { global_twitter="true" global_twitter_username="example" + # Leave these empty if you don't want to use disqus for comments + global_disqus="true" + global_disqus_username="disqus_undefined" + # Blog generated files # index page of blog (it is usually good to use "index.html" here) @@ -175,6 +179,45 @@ google_analytics() { " } +# Prints the required code for disqus comments +disqus_body() { +if [ "$global_disqus" != "" ]; then + echo '
+ + + comments powered by Disqus' +fi + +} +# Prints the required code for disqus in the footer +disqus_footer() { +if [ "$global_disqus" != "" ]; then + echo '' + + fi +} + # Edit an existing, published .html file while keeping its original timestamp # Please note that this function does not automatically republish anything, as # it is usually called from 'main'. @@ -266,13 +309,13 @@ create_html_page() { echo '' >> "$filename" # content echo ${filename%.*.*} if [[ ${filename%.*.*} != "index" && ${filename%.*.*} != "all_posts" ]]; then - cat disqus >> "$filename" + disqus_body >> "$filename" fi # page footer cat .footer.html >> "$filename" # close divs echo '' >> "$filename" # divbody and divbodyholder - cat disqus_footer >> "$filename" + disqus_footer >> "$filename" echo '' >> "$filename" } @@ -623,7 +666,7 @@ date_version_detect() { if !(date --version >/dev/null 2>&1) ; then # date utility is BSD. Test if gdate is installed if gdate --version >/dev/null 2>&1 ; then - alias date=gdate + DATE_COMMAND=gdate echo Using gdate. else echo ERROR: Not GNU date found. @@ -631,9 +674,14 @@ date_version_detect() { echo Exiting... exit fi + + else + DATE_COMMAND=date fi } - +date() { +$DATE_COMMAND "$@" +} # Main function # Encapsulated on its own function for readability purposes # @@ -643,6 +691,7 @@ do_main() { # Detect if using BSD date or GNU date date_version_detect # Use config file or fallback to inline configuration + echo Loading configuration source "$global_config" &> /dev/null || global_variables # Check for $EDITOR