From 652e5f8053f5e00875f10fdf0757b106a4504b0a Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Thu, 27 Feb 2014 22:40:11 +0100 Subject: [PATCH] make cut_line confugurable --- bb.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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='
' # 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 to -# note that this does not remove comment itself, +# $3 "cut" to remove text from
to +# note that this does not remove
line itself, # so you can see if text was cut or not get_html_file_content() { awk '//, //{ if (!// && !//) print - if ("'$3'" == "cut" && //){ + if ("'$3'" == "cut" && /'"$cut_line"'/){ if ("'$2'" == "text") exit # no need to read further while (getline > 0 && !//) {} } @@ -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 -->|

$template_read_more

|" >> "$contentfile" + get_html_file_content 'entry' 'entry' 'cut' <$i | awk '/'"$cut_line"'/ { print "

'"$template_read_more"'

" ; next } 1' >> "$contentfile" echo -n "." n=$(( $n + 1 )) done