diff options
author | Alexey Shpakovsky <alexey@shpakovsky.ru> | 2014-02-26 23:04:31 +0100 |
---|---|---|
committer | Alexey Shpakovsky <alexey@shpakovsky.ru> | 2014-03-01 09:59:17 +0100 |
commit | 7e7d1a8688fa73db93566524907c8b0c93fbdfd1 (patch) | |
tree | c10b110b84d1c796d11a4bc315ece1806e9b88a2 | |
parent | c581392bd4d44c98cc9309560d14fdf7714aa33b (diff) |
cut text (leave up to "<!-- text cut -->") 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
-rwxr-xr-x | bb.sh | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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 <!-- text cut --> to <!-- text end --> +# note that this does not remove <!-- text cut --> comment 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}' + awk '/<!-- '$1' begin -->/, /<!-- '$2' end -->/{ + if (!/<!-- '$1' begin -->/ && !/<!-- '$2' end -->/) print + if ("'$3'" == "cut" && /<!-- text cut -->/){ + if ("'$2'" == "text") exit # no need to read further + while (getline > 0 && !/<!-- text end -->/) {} + } + }' } # 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 '<item><title>' >> "$rssfile" echo "$(awk '/<h3><a class="ablack" href=".+">/, /<\/a><\/h3>/{if (!/<h3><a class="ablack" href=".+">/ && !/<\/a><\/h3>/) print}' $i)" >> "$rssfile" echo '</title><description><![CDATA[' >> "$rssfile" - echo "$(get_html_file_content 'text' 'entry' <$i)" >> "$rssfile" + echo "$(get_html_file_content 'text' 'entry' 'cut' <$i)" >> "$rssfile" echo "]]></description><link>$global_url/$i</link>" >> "$rssfile" echo "<guid>$global_url/$i</guid>" >> "$rssfile" echo "<dc:creator>$global_author</dc:creator>" >> "$rssfile" |