From 74767807420f4fa91221a30f441c95be6747922c Mon Sep 17 00:00:00 2001
From: Carlos Fenollosa
Date: Thu, 27 Feb 2014 13:59:56 +0100
Subject: Refactored get_post_title and is_boilerplate_file
---
bb.sh | 49 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 9 deletions(-)
(limited to 'bb.sh')
diff --git a/bb.sh b/bb.sh
index 294aa5c..ccda054 100755
--- a/bb.sh
+++ b/bb.sh
@@ -156,6 +156,9 @@ global_variables() {
# feed file (rss in this case)
blog_feed="feed.rss"
number_of_feed_articles="10"
+ # prefix for category/tag files
+ # please make sure that no other html file starts with this prefix
+ prefix_tags="tag_"
# personalized header and footer (only if you know what you're doing)
# DO NOT name them .header.html, .footer.html or they will be overwritten
# leave blank to generate them, recommended
@@ -180,7 +183,6 @@ global_variables() {
template_subscribe_browser_button="Subscribe to this page..."
# "Tweet" (used as twitter text button for posting to twitter)
template_twitter_button="Tweet"
-
template_twitter_comment="<Type your comment here but please leave the URL so that other people can follow the comments>"
# The locale to use for the dates displayed on screen (not for the timestamps)
@@ -329,6 +331,20 @@ twitter() {
echo "
"
}
+# Check if the file is a 'boilerplate' (i.e. not a post)
+# The return values are designed to be used like this inside a loop:
+# is_boilerplate_file && continue
+#
+# $1 the file
+#
+# Return 0 (bash return value 'true') if the input file is am index, feed, etc
+# or 1 (bash return value 'false') if it is a blogpost
+is_boilerplate_file() {
+ if [[ "$i" == "$index_file" ]] || [[ "$i" == "$archive_index" ]] || [[ "$i" == "$footer_file" ]] || [[ "$i" == "$header_file" ]] || [[ "$i" == "global_analytics_file" ]] || [[ "$1" = "$prefix_tags"* ]] ; then return 0
+ else return 1
+ fi
+}
+
# Adds all the bells and whistles to format the html page
# Every blog post is marked with a and
# which is parsed afterwards in the other functions. There is also a marker
@@ -530,10 +546,10 @@ all_posts() {
echo "
$template_archive_title
" >> "$contentfile"
echo "
" >> "$contentfile"
for i in $(ls -t *.html); do
- if [[ "$i" == "$index_file" ]] || [[ "$i" == "$archive_index" ]]; then continue; fi
+ is_boilerplate_file "$i" && continue
echo -n "."
# Title
- title="$(awk '/