From 652e5f8053f5e00875f10fdf0757b106a4504b0a Mon Sep 17 00:00:00 2001
From: Alexey Shpakovsky <alexey@shpakovsky.ru>
Date: Thu, 27 Feb 2014 22:40:11 +0100
Subject: make cut_line confugurable

---
 bb.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'bb.sh')

diff --git a/bb.sh b/bb.sh
index 39d7c2e..2176108 100755
--- a/bb.sh
+++ b/bb.sh
@@ -160,6 +160,9 @@ global_variables() {
     # feed file (rss in this case)
     blog_feed="feed.rss"
     number_of_feed_articles="10"
+    # Regexp matching the HTML line where to do the cut
+    # note that slash is regexp separator so you need to prepend it with backslash
+    cut_line='<hr ?\/?>'
     # prefix for tags/categories files
     # please make sure that no other html file starts with this prefix
     prefix_tags="tag_"
@@ -314,13 +317,13 @@ disqus_footer() {
 # Reads HTML file from stdin, prints its content to stdout
 # $1    where to start ("text" or "entry")
 # $2    where to stop ("text" or "entry")
-# $3    "cut" to remove text from <!-- text cut --> to <!-- text end -->
-#       note that this does not remove <!-- text cut --> comment itself,
+# $3    "cut" to remove text from <hr /> to <!-- text end -->
+#       note that this does not remove <hr /> line itself,
 #       so you can see if text was cut or not
 get_html_file_content() {
     awk '/<!-- '$1' begin -->/, /<!-- '$2' end -->/{
         if (!/<!-- '$1' begin -->/ && !/<!-- '$2' end -->/) print
-        if ("'$3'" == "cut" && /<!-- text cut -->/){
+        if ("'$3'" == "cut" && /'"$cut_line"'/){
             if ("'$2'" == "text") exit # no need to read further
             while (getline > 0 && !/<!-- text end -->/) {}
         }
@@ -659,7 +662,7 @@ rebuild_index() {
     for i in $(ls -t *.html); do # sort by date, newest first
         is_boilerplate_file "$i" && continue;
         if [[ "$n" -ge "$number_of_index_articles" ]]; then break; fi
-        get_html_file_content 'entry' 'entry' 'cut' <$i | sed "s|<.-- text cut -->|<p class=\"readmore\"><a href=\"$i\">$template_read_more</a></p>|" >> "$contentfile"
+        get_html_file_content 'entry' 'entry' 'cut' <$i | awk '/'"$cut_line"'/ { print "<p class=\"readmore\"><a href=\"'$i'\">'"$template_read_more"'</a></p>" ; next } 1' >> "$contentfile"
         echo -n "."
         n=$(( $n + 1 ))
     done
-- 
cgit v1.2.3