From 7e7d1a8688fa73db93566524907c8b0c93fbdfd1 Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Wed, 26 Feb 2014 23:04:31 +0100 Subject: [PATCH] cut text (leave up to "") in index and RSS note that when requested to cut entry, it keeps stuff between text end and entry end, so twitter button will still find its way into RSS feed also fix indentation --- bb.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bb.sh b/bb.sh index 35d46d4..cffa105 100755 --- a/bb.sh +++ b/bb.sh @@ -310,10 +310,19 @@ 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") +# $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, +# so you can see if text was cut or not get_html_file_content() { - awk '//, //{if (!// && !//) print}' + awk '//, //{ + if (!// && !//) print + if ("'$3'" == "cut" && //){ + if ("'$2'" == "text") exit # no need to read further + while (getline > 0 && !//) {} + } + }' } # Edit an existing, published .html file while keeping its original timestamp @@ -648,7 +657,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' <$1 >> "$contentfile" + get_html_file_content 'entry' 'entry' 'cut' <$i >> "$contentfile" echo -n "." n=$(( $n + 1 )) done @@ -747,7 +756,7 @@ make_rss() { echo '' >> "$rssfile" echo "$(awk '/<h3><a class="ablack" href=".+">/, /<\/a><\/h3>/{if (!/<h3><a class="ablack" href=".+">/ && !/<\/a><\/h3>/) print}' $i)" >> "$rssfile" echo '> "$rssfile" - echo "$(get_html_file_content 'text' 'entry' <$i)" >> "$rssfile" + echo "$(get_html_file_content 'text' 'entry' 'cut' <$i)" >> "$rssfile" echo "]]>$global_url/$i" >> "$rssfile" echo "$global_url/$i" >> "$rssfile" echo "$global_author" >> "$rssfile"