diff options
author | Alexey Shpakovsky <alexey@shpakovsky.ru> | 2014-02-27 22:40:11 +0100 |
---|---|---|
committer | Alexey Shpakovsky <alexey@shpakovsky.ru> | 2014-03-01 10:05:48 +0100 |
commit | 652e5f8053f5e00875f10fdf0757b106a4504b0a (patch) | |
tree | c854f353b2a13e19297387e0802c66226fca4450 | |
parent | ff36737c128d838109798b50312f692ec75cd263 (diff) |
make cut_line confugurable
-rwxr-xr-x | bb.sh | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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 |