diff --git a/bb.sh b/bb.sh
index 2659346..96d410a 100755
--- a/bb.sh
+++ b/bb.sh
@@ -160,6 +160,13 @@ global_variables() {
# feed file (rss in this case)
blog_feed="feed.rss"
number_of_feed_articles="10"
+ # "cut" blog entry when putting it to index page
+ # i.e. include only up to first
(---- in markdown)
+ # possible values: "cut", ""
+ cut_do="cut"
+ # 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_"
@@ -175,6 +182,8 @@ global_variables() {
# Localization and i18n
# "Comments?" (used in twitter link after every post)
template_comments="Comments?"
+ # "Read more..." (link under cut article on index page)
+ template_read_more="Read more..."
# "View more posts" (used on bottom of index page as link to archive)
template_archive="View more posts"
# "All posts" (title of archive page)
@@ -309,6 +318,22 @@ 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 line itself,
+# so you can see if text was cut or not
+get_html_file_content() {
+ awk '//, //{
+ if (!// && !//) print
+ if ("'$3'" == "cut" && /'"$cut_line"'/){
+ if ("'$2'" == "text") exit # no need to read further
+ while (getline > 0 && !//) {}
+ }
+ }'
+}
+
# Edit an existing, published .html file while keeping its original timestamp
# Please note that this function does not automatically republish anything, as
# it is usually called from 'main'.
@@ -641,7 +666,11 @@ 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 '//, //' "$i" >> "$contentfile"
+ if [ "$cut_do" ]; then
+ get_html_file_content 'entry' 'entry' 'cut' <$i | awk '/'"$cut_line"'/ { print "