diff options
Diffstat (limited to 'src/html')
-rwxr-xr-x | src/html | 57 |
1 files changed, 50 insertions, 7 deletions
@@ -3,9 +3,29 @@ set -euo pipefail usage() { - echo 'Usage: html FILENAME.htmlbody' + echo 'Usage: html [ -H | -F ] FILENAME.htmlbody' } + +HEADER_ONLY=false +FOOTER_ONLY=false +while getopts 'HF' flag; do + case "$flag" in + (H) + HEADER_ONLY=true + ;; + (F) + FOOTER_ONLY=true + ;; + (*) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + FILENAME="${1:-}" eval "$(assert-arg -- "$FILENAME" 'FILENAME.htmlbody')" . "$(realpath -- "${FILENAME%.*}.conf")" @@ -56,6 +76,7 @@ comments() { cat <<EOF <section> <hr /> + <!-- Use <address> here? --> <footer> <p id="comment"> <a href="$comment_url">Comment</a> @@ -99,7 +120,9 @@ EOF collection_head_prev_html= collection_head_post_html= -cat <<EOF | sed '/^$/d' + +header() { + cat <<EOF | sed '/^$/d' <!DOCTYPE html> <html lang="en"> <head> @@ -131,14 +154,18 @@ $(headlinks) <article> EOF -h1 -dates + h1 + dates +} -cat "$FILENAME" +body() { + cat "${FILENAME%.*}.htmlbody" +} -comments +footer() { + comments -cat <<EOF + cat <<EOF </article> </main> <footer> @@ -163,3 +190,19 @@ cat <<EOF </body> </html> EOF +} + + +if [ "$HEADER_ONLY" = true ]; then + header + exit +fi + +if [ "$FOOTER_ONLY" = true ]; then + footer + exit +fi + +header +body +footer |