#!/bin/bash ## # Generate html page with blog article excerpts from ./posts.txt. Post file names should # be added to ./posts.txt in the exact order that they are supposed to appear on the blog # page. # Check if required executables can be found if ! type readlink dirname html2text mv; then echo 'One or more required executables are not present. Generation cancelled' >&2 exit 1 fi # Determine script directory (requires GNU readlink) here="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" printf 'Changing directory: ' pushd "$here" || exit $? posts_file="$here/posts.txt" if ! [[ -f "$posts_file" ]]; then printf 'Posts file "%s" not found. Generation cancelled.\n' "$posts_file" >&2 exit 1 fi escape-html() { sed 's/&/\&/g; s/\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g' } html-to-text() { html2text -nobs -style compact "$@" } blog_html="$here/blog.html" { echo '
%s