diff options
-rwxr-xr-x | bb.sh | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -310,8 +310,10 @@ 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") get_html_file_content() { - awk '/<!-- text begin -->/, /<!-- text end -->/{if (!/<!-- text begin -->/ && !/<!-- text end -->/) print}' + awk '/<!-- '$1' begin -->/, /<!-- '$2' end -->/{if (!/<!-- '$1' begin -->/ && !/<!-- '$2' end -->/) print}' } # Edit an existing, published .html file while keeping its original timestamp @@ -646,7 +648,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 - awk '/<!-- entry begin -->/, /<!-- entry end -->/' "$i" >> "$contentfile" + get_html_file_content 'entry' 'entry' <$1 >> "$contentfile" echo -n "." n=$(( $n + 1 )) done @@ -745,8 +747,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 "$(awk '/<!-- text begin -->/, /<!-- entry end -->/{if (!/<!-- text begin -->/ && !/<!-- entry end -->/) print}' $i)" >> "$rssfile" - + echo "$(get_html_file_content 'text' 'entry' <$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" @@ -852,7 +853,7 @@ rebuild_all_entries() { echo -n "." # Get the title and entry, and rebuild the html structure from scratch (divs, title, description...) title="$(get_post_title "$i")" - get_html_file_content <$i >> "$contentfile" + get_html_file_content 'text' 'text' <$i >> "$contentfile" # Original post timestamp timestamp="$(LC_ALL=$date_locale date -r $i +"%a, %d %b %Y %H:%M:%S %z" )" |