New "all tags" index page
This commit is contained in:
parent
3d73749f1a
commit
8b5ed42a2a
1 changed files with 44 additions and 12 deletions
56
bb.sh
56
bb.sh
|
@ -24,16 +24,17 @@
|
||||||
# Files that this script generates:
|
# Files that this script generates:
|
||||||
# - main.css (inherited from my web page) and blog.css (blog-specific stylesheet)
|
# - main.css (inherited from my web page) and blog.css (blog-specific stylesheet)
|
||||||
# - one .html for each post
|
# - one .html for each post
|
||||||
|
# - one tag_*.html file for each tag
|
||||||
# - index.html (regenerated each run)
|
# - index.html (regenerated each run)
|
||||||
# - feed.rss (regenerated each run)
|
# - feed.rss (idem)
|
||||||
# - all_posts.html (regenerated each run)
|
# - all_posts.html (idem)
|
||||||
|
# - all_tags.html (idem)
|
||||||
# - it also generates temporal files, which are removed afterwards
|
# - it also generates temporal files, which are removed afterwards
|
||||||
#
|
#
|
||||||
# It generates valid html and rss files, so keep care to use valid xhtml when editing a post
|
# It generates valid html and rss files, so keep care to use valid xhtml when editing a post
|
||||||
#
|
#
|
||||||
# There are many loops which iterate on '*.html' so make sure that the only html files
|
# There are many loops which iterate on '*.html' so make sure not to manually put other
|
||||||
# on this folder are the blog entries and index.html and all_posts.html. Drafts must go
|
# html files on this folder.
|
||||||
# into drafts/ and any other *.html file should be moved out of the way
|
|
||||||
#
|
#
|
||||||
# Read more: https://github.com/cfenollosa/bashblog
|
# Read more: https://github.com/cfenollosa/bashblog
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
#
|
#
|
||||||
# 2.1 Support for tags/categories
|
# 2.1 Support for tags/categories
|
||||||
|
# 'delete' command
|
||||||
# 2.0.3 Support for other analytics code, via external file
|
# 2.0.3 Support for other analytics code, via external file
|
||||||
# 2.0.2 Fixed bug when $body_begin_file was empty
|
# 2.0.2 Fixed bug when $body_begin_file was empty
|
||||||
# Added extra line in the footer linking to the github project
|
# Added extra line in the footer linking to the github project
|
||||||
|
@ -154,6 +156,7 @@ global_variables() {
|
||||||
number_of_index_articles="8"
|
number_of_index_articles="8"
|
||||||
# global archive
|
# global archive
|
||||||
archive_index="all_posts.html"
|
archive_index="all_posts.html"
|
||||||
|
tags_index="all_tags.html"
|
||||||
# feed file (rss in this case)
|
# feed file (rss in this case)
|
||||||
blog_feed="feed.rss"
|
blog_feed="feed.rss"
|
||||||
number_of_feed_articles="10"
|
number_of_feed_articles="10"
|
||||||
|
@ -176,6 +179,8 @@ global_variables() {
|
||||||
template_archive="View more posts"
|
template_archive="View more posts"
|
||||||
# "All posts" (title of archive page)
|
# "All posts" (title of archive page)
|
||||||
template_archive_title="All posts"
|
template_archive_title="All posts"
|
||||||
|
# "All tags"
|
||||||
|
template_tags_title="All tags"
|
||||||
# "Back to the index page" (used on archive page, it is link to blog index)
|
# "Back to the index page" (used on archive page, it is link to blog index)
|
||||||
template_archive_index_page="Back to the index page"
|
template_archive_index_page="Back to the index page"
|
||||||
# "Subscribe" (used on bottom of index page, it is link to RSS feed)
|
# "Subscribe" (used on bottom of index page, it is link to RSS feed)
|
||||||
|
@ -341,7 +346,7 @@ twitter() {
|
||||||
# Return 0 (bash return value 'true') if the input file is am index, feed, etc
|
# Return 0 (bash return value 'true') if the input file is am index, feed, etc
|
||||||
# or 1 (bash return value 'false') if it is a blogpost
|
# or 1 (bash return value 'false') if it is a blogpost
|
||||||
is_boilerplate_file() {
|
is_boilerplate_file() {
|
||||||
if [[ "$1" == "$index_file" ]] || [[ "$1" == "$archive_index" ]] || [[ "$1" == "$footer_file" ]] || [[ "$1" == "$header_file" ]] || [[ "$1" == "$global_analytics_file" ]] || [[ "$1" = "$prefix_tags"* ]] ; then return 0
|
if [[ "$1" == "$index_file" ]] || [[ "$1" == "$archive_index" ]] || [[ "$1" == "$tags_index" ]] || [[ "$1" == "$footer_file" ]] || [[ "$1" == "$header_file" ]] || [[ "$1" == "$global_analytics_file" ]] || [[ "$1" = "$prefix_tags"* ]] ; then return 0
|
||||||
else return 1
|
else return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -589,6 +594,32 @@ all_posts() {
|
||||||
rm "$contentfile"
|
rm "$contentfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create an index page with all the tags
|
||||||
|
all_tags() {
|
||||||
|
echo -n "Creating an index page with all the tags "
|
||||||
|
contentfile="$tags_index.$RANDOM"
|
||||||
|
while [ -f "$contentfile" ]; do
|
||||||
|
contentfile="$tags_index.$RANDOM"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "<h3>$template_tags_title</h3>" >> "$contentfile"
|
||||||
|
echo "<ul>" >> "$contentfile"
|
||||||
|
for i in $(ls tag_*.html); do
|
||||||
|
echo -n "."
|
||||||
|
nposts="$(grep -c "^<\!-- entry begin -->$" $i)"
|
||||||
|
tagname="$(echo $i | cut -c $((${#prefix_tags}+1))- | sed 's/\.html//g')"
|
||||||
|
echo "<li><a href="$i">$tagname</a> — $nposts posts</li>" >> "$contentfile"
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
echo "</ul>" >> "$contentfile"
|
||||||
|
echo '<div id="all_posts"><a href="'./'">'$template_archive_index_page'</a></div>' >> "$contentfile"
|
||||||
|
|
||||||
|
create_html_page "$contentfile" "$tags_index.tmp" yes "$global_title — $template_tags_title"
|
||||||
|
mv "$tags_index.tmp" "$tags_index"
|
||||||
|
chmod 644 "$tags_index"
|
||||||
|
rm "$contentfile"
|
||||||
|
}
|
||||||
|
|
||||||
# Generate the index.html with the content of the latest posts
|
# Generate the index.html with the content of the latest posts
|
||||||
rebuild_index() {
|
rebuild_index() {
|
||||||
echo -n "Rebuilding the index "
|
echo -n "Rebuilding the index "
|
||||||
|
@ -609,11 +640,9 @@ rebuild_index() {
|
||||||
n=$(( $n + 1 ))
|
n=$(( $n + 1 ))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$global_feedburner" == "" ]]; then
|
feed="$blog_feed"
|
||||||
echo '<div id="all_posts"><a href="'$archive_index'">'$template_archive'</a> — <a href="'$blog_feed'">'$template_subscribe'</a></div>' >> "$contentfile"
|
if [[ "$global_feedburner" != "" ]]; then feed="$global_feedburner"; fi
|
||||||
else
|
echo '<div id="all_posts"><a href="'$archive_index'">'$template_archive'</a> — <a href="'$tags_index'">'$template_tags_title'</a> — <a href="'$feed'">'$template_subscribe'</a></div>' >> "$contentfile"
|
||||||
echo '<div id="all_posts"><a href="'$archive_index'">'$template_archive'</a> — <a href="'$global_feedburner'">Subscribe</a></div>' >> "$contentfile"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
@ -837,6 +866,7 @@ echo "Commands:"
|
||||||
echo " post [-m] [filename] insert a new blog post, or the FILENAME of a draft to continue editing it"
|
echo " post [-m] [filename] insert a new blog post, or the FILENAME of a draft to continue editing it"
|
||||||
echo " use '-m' to edit the post as Markdown text"
|
echo " use '-m' to edit the post as Markdown text"
|
||||||
echo " edit [filename] edit an already published .html file. Never edit manually a published .html file,"
|
echo " edit [filename] edit an already published .html file. Never edit manually a published .html file,"
|
||||||
|
echo " delete [filename] deletes the post"
|
||||||
echo " always use this function as it keeps the original timestamp "
|
echo " always use this function as it keeps the original timestamp "
|
||||||
echo " and rebuilds whatever indices are needed"
|
echo " and rebuilds whatever indices are needed"
|
||||||
echo " rebuild regenerates all the pages and posts, preserving the content of the entries"
|
echo " rebuild regenerates all the pages and posts, preserving the content of the entries"
|
||||||
|
@ -906,7 +936,7 @@ do_main() {
|
||||||
echo "Please set your \$EDITOR environment variable" && exit
|
echo "Please set your \$EDITOR environment variable" && exit
|
||||||
|
|
||||||
# Check for validity of argument
|
# Check for validity of argument
|
||||||
[[ "$1" != "reset" ]] && [[ "$1" != "post" ]] && [[ "$1" != "rebuild" ]] && [[ "$1" != "list" ]] && [[ "$1" != "edit" ]] &&
|
[[ "$1" != "reset" ]] && [[ "$1" != "post" ]] && [[ "$1" != "rebuild" ]] && [[ "$1" != "list" ]] && [[ "$1" != "edit" ]] && [[ "$1" != "delete" ]] &&
|
||||||
usage && exit
|
usage && exit
|
||||||
|
|
||||||
[[ "$1" == "list" ]] &&
|
[[ "$1" == "list" ]] &&
|
||||||
|
@ -938,8 +968,10 @@ do_main() {
|
||||||
[[ "$1" == "post" ]] && write_entry "$@"
|
[[ "$1" == "post" ]] && write_entry "$@"
|
||||||
[[ "$1" == "rebuild" ]] && rebuild_all_entries
|
[[ "$1" == "rebuild" ]] && rebuild_all_entries
|
||||||
[[ "$1" == "edit" ]] && edit "$2"
|
[[ "$1" == "edit" ]] && edit "$2"
|
||||||
|
[[ "$1" == "delete" ]] && rm "$2" &> /dev/null
|
||||||
rebuild_index
|
rebuild_index
|
||||||
all_posts
|
all_posts
|
||||||
|
all_tags
|
||||||
make_rss
|
make_rss
|
||||||
rebuild_tags
|
rebuild_tags
|
||||||
delete_includes
|
delete_includes
|
||||||
|
|
Loading…
Reference in a new issue