From cefc5dad1ed855eace8f0452cf8ee5d8de7f9dc2 Mon Sep 17 00:00:00 2001 From: Carlos Fenollosa Date: Thu, 21 Feb 2013 17:06:02 +0100 Subject: [PATCH] Flexibility on the dates --- bb.sh | 63 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/bb.sh b/bb.sh index 23ba6f0..73fe936 100755 --- a/bb.sh +++ b/bb.sh @@ -60,7 +60,7 @@ # ######################################################################################### # -# 1.5 Durad Radojicic refactored some code and added flexibility +# 1.5 Durad Radojicic refactored some code and added flexibility and i18n # 1.4.2 Now issues are handled at Github # 1.4.1 Some code refactoring # 1.4 Using twitter for comments, improved 'rebuild' command @@ -97,30 +97,6 @@ global_variables() { # The public base URL for this blog global_url="http://mmb.pcb.ub.es/~carlesfe/blog" - # blog generated files - # index page of blog (it is usually good to use "index.html" here) - index_file="index.html" - number_of_index_articles="8" - # global archive - archive_index="all_posts.html" - # feed file (rss in this case) - blog_feed="test.rss" - number_of_feed_articles="10" - - # template elements that can be translated - # "Comments?" (used in twitter link after every post) - template_comments="Comments?" - # "View more posts" (used on bottom of index page as link to archive) - template_archive="View more posts" - # "Back to the index page" (used on archive page, it is link to blog index) - template_archive_index_page="Back to the index page" - # "Subscribe" (used on bottom of index page, it is link to RSS feed) - template_subscribe="Subscribe" - # "Subscribe to this page..." (used as text for browser feed button that is embedded to html) - template_subscribe_browser_button="Subscribe to this page..." - # "Tweet" (used as twitter text button for posting to twitter) - template_twitter_button="Tweet" - # Your name global_author="Carles Fenollosa" # You can use twitter or facebook or anything for global_author_url @@ -142,9 +118,36 @@ global_variables() { # Leave these empty if you don't want to use twitter for comments global_twitter="true" global_twitter_username="cfenollosa" -} + # Blog generated files + # index page of blog (it is usually good to use "index.html" here) + index_file="index.html" + number_of_index_articles="8" + # global archive + archive_index="all_posts.html" + # feed file (rss in this case) + blog_feed="test.rss" + number_of_feed_articles="10" + + # Localization and i18n + # "Comments?" (used in twitter link after every post) + template_comments="Comments?" + # "View more posts" (used on bottom of index page as link to archive) + template_archive="View more posts" + # "Back to the index page" (used on archive page, it is link to blog index) + template_archive_index_page="Back to the index page" + # "Subscribe" (used on bottom of index page, it is link to RSS feed) + template_subscribe="Subscribe" + # "Subscribe to this page..." (used as text for browser feed button that is embedded to html) + template_subscribe_browser_button="Subscribe to this page..." + # "Tweet" (used as twitter text button for posting to twitter) + template_twitter_button="Tweet" + # The locale to use for the dates displayed on screen (not for the timestamps) + date_format="%B %d, %Y" + date_locale="C" +} + # Prints the required google analytics code google_analytics() { if [ "$global_analytics" == "" ]; then return; fi @@ -234,9 +237,9 @@ create_html_page() { echo "$title" >> "$filename" echo '' >> "$filename" if [ "$timestamp" == "" ]; then - echo '
'$(date +"%B %d, %Y")' — ' >> "$filename" + echo '
'$(LC_ALL=date_locale date +"$date_format")' — ' >> "$filename" else - echo '
'$(date +"%B %d, %Y" --date="$timestamp") ' — ' >> "$filename" + echo '
'$(LC_ALL=date_locale date +"$date_format" --date="$timestamp") ' — ' >> "$filename" fi echo "$global_author
" >> "$filename" echo '' >> "$filename" # This marks the text body, after the title, date... @@ -367,7 +370,7 @@ all_posts() { title="$(awk '/

/, /<\/a><\/h3>/{if (!/

/ && !/<\/a><\/h3>/) print}' $i)" echo -n '
  • '$title' —' >> "$contentfile" # Date - date="$(date -r "$i" +%B\ %d\,\ %Y)" + date="$(LC_ALL=date_locale date -r "$i" "$date_format")" echo " $date
  • " >> "$contentfile" done echo "" @@ -420,7 +423,7 @@ list_posts() { n=1 for i in $(ls -t *.html); do if [ "$i" == "$index_file" ] || [ "$i" == "$archive_index" ]; then continue; fi - line="$n # $(awk '/

    /, /<\/a><\/h3>/{if (!/

    / && !/<\/a><\/h3>/) print}' $i) # $(date -r $i +%B\ %d\,\ %Y)" + line="$n # $(awk '/

    /, /<\/a><\/h3>/{if (!/

    / && !/<\/a><\/h3>/) print}' $i) # $(LC_ALL=date_locale date -r $i "date_format")" lines="${lines}""$line""\n" # Weird stuff needed for the newlines n=$(( $n + 1 )) done