Skip to content

Commit d1a84d6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents a674ec5 + 9ac5989 commit d1a84d6

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ As a guideline, pull requests should:
128128
Changelog
129129
---------
130130

131+
- 2.6 Support for multiple authors, use a different `.config` for each one
131132
- 2.5 Massive code cleanup by Martijn Dekker<br/>
132133
'tags' command<br/>
133134
The word 'posts' in the tag list (both website and command) now has a singular form, check out `template_tags_posts_singular`

bb.sh

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ global_config=".config"
1717
# by the 'global_config' file contents
1818
global_variables() {
1919
global_software_name="BashBlog"
20-
global_software_version="2.5"
20+
global_software_version="2.6"
2121

2222
# Blog title
2323
global_title="My fancy blog"
@@ -52,8 +52,7 @@ global_variables() {
5252
# Set this to false for a Twitter button with share count. The cookieless version
5353
# is just a link.
5454
global_twitter_cookieless="true"
55-
# Set to "topsy" which can search tweets way early in time, or "twitter"
56-
# for the default search page, where tweets more than a week old are hidden
55+
# Default search page, where tweets more than a week old are hidden
5756
global_twitter_search="twitter"
5857

5958
# Change this to your disqus username to use disqus for comments
@@ -343,8 +342,7 @@ twitter() {
343342
id=$RANDOM
344343
345344
search_engine="https://twitter.com/search?q="
346-
[[ $global_twitter_search == topsy ]] && search_engine="http://topsy.com/trackback?url="
347-
345+
348346
echo "<p id='twitter'><a href='http://twitter.com/intent/tweet?url=$1&text=$template_twitter_comment&via=$global_twitter_username'>$template_comments $template_twitter_button</a> "
349347
echo "<a href='$search_engine""$1'><span id='count-$id'></span></a>&nbsp;</p>"
350348
# Get current tweet count
@@ -396,12 +394,14 @@ is_boilerplate_file() {
396394
# "no" to insert new blog posts
397395
# $4 title for the html header
398396
# $5 original blog timestamp
397+
# $6 post author
399398
create_html_page() {
400399
content=$1
401400
filename=$2
402401
index=$3
403402
title=$4
404403
timestamp=$5
404+
author=$6
405405
406406
# Create the actual blog post
407407
# html, head
@@ -438,7 +438,7 @@ create_html_page() {
438438
else
439439
echo "<div class=\"subtitle\">$(LC_ALL=$date_locale date +"$date_format" --date="$timestamp") &mdash; "
440440
fi
441-
echo "$global_author</div>"
441+
echo "$author</div>"
442442
echo '<!-- text begin -->' # This marks the text body, after the title, date...
443443
fi
444444
cat "$content" # Actual content
@@ -511,7 +511,7 @@ parse_file() {
511511
done < "$1"
512512
513513
# Create the actual html page
514-
create_html_page "$content" "$filename" no "$title" "$2"
514+
create_html_page "$content" "$filename" no "$title" "$2" "$global_author"
515515
rm "$content"
516516
}
517517
@@ -643,10 +643,10 @@ all_posts() {
643643
done < <(ls -t ./*.html)
644644
echo "" 1>&3
645645
echo "</ul>"
646-
echo "<div id=\"all_posts\"><a href=\"./\">$template_archive_index_page</a></div>"
646+
echo "<div id=\"all_posts\"><a href=\"./$index_file\">$template_archive_index_page</a></div>"
647647
} 3>&1 >"$contentfile"
648648
649-
create_html_page "$contentfile" "$archive_index.tmp" yes "$global_title &mdash; $template_archive_title"
649+
create_html_page "$contentfile" "$archive_index.tmp" yes "$global_title &mdash; $template_archive_title" "$global_author"
650650
mv "$archive_index.tmp" "$archive_index"
651651
chmod 644 "$archive_index"
652652
rm "$contentfile"
@@ -674,10 +674,10 @@ all_tags() {
674674
done
675675
echo "" 1>&3
676676
echo "</ul>"
677-
echo "<div id=\"all_posts\"><a href=\"./\">$template_archive_index_page</a></div>"
677+
echo "<div id=\"all_posts\"><a href=\"./$index_file\">$template_archive_index_page</a></div>"
678678
} 3>&1 > "$contentfile"
679679
680-
create_html_page "$contentfile" "$tags_index.tmp" yes "$global_title &mdash; $template_tags_title"
680+
create_html_page "$contentfile" "$tags_index.tmp" yes "$global_title &mdash; $template_tags_title" "$global_author"
681681
mv "$tags_index.tmp" "$tags_index"
682682
chmod 644 "$tags_index"
683683
rm "$contentfile"
@@ -715,7 +715,7 @@ rebuild_index() {
715715
716716
echo ""
717717
718-
create_html_page "$contentfile" "$newindexfile" yes "$global_title"
718+
create_html_page "$contentfile" "$newindexfile" yes "$global_title" "$global_author"
719719
rm "$contentfile"
720720
mv "$newindexfile" "$index_file"
721721
chmod 644 "$index_file"
@@ -795,7 +795,7 @@ rebuild_tags() {
795795
while IFS='' read -r i; do
796796
tagname=${i#./"$prefix_tags"}
797797
tagname=${tagname%.tmp.html}
798-
create_html_page "$i" "$prefix_tags$tagname.html" yes "$global_title &mdash; $template_tag_title \"$tagname\""
798+
create_html_page "$i" "$prefix_tags$tagname.html" yes "$global_title &mdash; $template_tag_title \"$tagname\"" "$global_author"
799799
rm "$i"
800800
done < <(ls -t ./"$prefix_tags"*.tmp.html 2>/dev/null)
801801
echo
@@ -808,6 +808,13 @@ get_post_title() {
808808
awk '/<h3><a class="ablack" href=".+">/, /<\/a><\/h3>/{if (!/<h3><a class="ablack" href=".+">/ && !/<\/a><\/h3>/) print}' "$1"
809809
}
810810
811+
# Return the post author
812+
#
813+
# $1 the html file
814+
get_post_author() {
815+
awk '/<div class="subtitle">.+/, /<!-- text begin -->/{if (!/<div class="subtitle">.+/ && !/<!-- text begin -->/) print}' "$1" | sed 's/<\/div>//g'
816+
}
817+
811818
# Displays a list of the tags
812819
#
813820
# $2 if "-n", tags will be sorted by number of posts
@@ -863,7 +870,7 @@ make_rss() {
863870
pubdate=$(LC_ALL=C date +"%a, %d %b %Y %H:%M:%S %z")
864871
echo '<?xml version="1.0" encoding="UTF-8" ?>'
865872
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">'
866-
echo "<channel><title>$global_title</title><link>$global_url</link>"
873+
echo "<channel><title>$global_title</title><link>$global_url/$index_file</link>"
867874
echo "<description>$global_description</description><language>en</language>"
868875
echo "<lastBuildDate>$pubdate</lastBuildDate>"
869876
echo "<pubDate>$pubdate</pubDate>"
@@ -880,7 +887,7 @@ make_rss() {
880887
get_html_file_content 'text' 'entry' $cut_do <"$i"
881888
echo "]]></description><link>$global_url/${i#./}</link>"
882889
echo "<guid>$global_url/$i</guid>"
883-
echo "<dc:creator>$global_author</dc:creator>"
890+
echo "<dc:creator>$(get_post_author "$i")</dc:creator>"
884891
echo "<pubDate>$(LC_ALL=C date -r "$i" +"%a, %d %b %Y %H:%M:%S %z")</pubDate></item>"
885892
886893
n=$(( n + 1 ))
@@ -897,7 +904,7 @@ make_rss() {
897904
# generate headers, footers, etc
898905
create_includes() {
899906
{
900-
echo "<h1 class=\"nomargin\"><a class=\"ablack\" href=\"$global_url\">$global_title</a></h1>"
907+
echo "<h1 class=\"nomargin\"><a class=\"ablack\" href=\"$global_url/$index_file\">$global_title</a></h1>"
901908
echo "<div id=\"description\">$global_description</div>"
902909
} > ".title.html"
903910
@@ -990,12 +997,13 @@ rebuild_all_entries() {
990997
echo -n "."
991998
# Get the title and entry, and rebuild the html structure from scratch (divs, title, description...)
992999
title=$(get_post_title "$i")
1000+
9931001
get_html_file_content 'text' 'text' <"$i" >> "$contentfile"
9941002
9951003
# Original post timestamp
9961004
timestamp=$(LC_ALL=C date -r "$i" +"%a, %d %b %Y %H:%M:%S %z" )
9971005
998-
create_html_page "$contentfile" "$i.rebuilt" no "$title" "$timestamp"
1006+
create_html_page "$contentfile" "$i.rebuilt" no "$title" "$timestamp" "$(get_post_author "$i")"
9991007
# keep the original timestamp!
10001008
timestamp=$(LC_ALL=C date -r "$i" +'%Y%m%d%H%M')
10011009
mv "$i.rebuilt" "$i"

0 commit comments

Comments
 (0)