#!/usr/bin/env bash # Adds all the bells and whistles to format the html page # Every blog post is marked with a and # which is parsed afterwards in the other functions. There is also a marker # to determine just the beginning of the text body of the post # # $1 a file with the body of the content # $2 the output file # $3 "yes" if we want to generate the index.html, # "no" to insert new blog posts # $4 title for the html header # $5 original blog timestamp # $6 post author declare body_begin_file declare date_inpost declare date_locale declare date_format declare date_format_timestamp declare global_url declare body_end_file create_html_page() { content=$1 filename=$2 index=$3 title=$4 timestamp=$5 author=$6 # Create the actual blog post # html, head { cat ".header.html" echo "$title" twitter_card "$content" "$title" echo "" # stuff to add before the actual body content [[ -n $body_begin_file ]] && cat "$body_begin_file" # body divs echo '
' echo '
' # blog title echo '
' cat .title.html echo '
' # title, header, headerholder echo '
' file_url=${filename#./} file_url=${file_url%.rebuilt} # Get the correct URL when rebuilding file_url=${file_url%.html} file_url=${file_url%.md}.html # Get the correct link # one blog entry if [[ $index == no ]]; then echo '' # marks the beginning of the whole post echo "

" # remove possible

's on the title because of markdown conversion title=${title//

/} title=${title//<\/p>/} echo "$title" echo '

' if [[ -z $timestamp ]]; then echo "" else echo "" fi if [[ -z $timestamp ]]; then echo -n "
$(LC_ALL=$date_locale date +"$date_format")" else echo -n "
$(LC_ALL=$date_locale date +"$date_format" --date="$timestamp")" fi [[ -n $author ]] && echo -e " — \n$author" echo "
" echo '' # This marks the text body, after the title, date... fi cat "$content" # Actual content if [[ $index == no ]]; then echo -e '\n' twitter "$global_url/$file_url" echo '' # absolute end of the post fi echo '
' # content # page footer cat .footer.html # close divs echo '
' # divbody and divbodyholder [[ -n $body_end_file ]] && cat "$body_end_file" echo '' } > "$filename" }