X-Git-Url: https://plomlompom.com/repos/new_day?a=blobdiff_plain;f=processor%2Fdefault.html.do;h=f0d43a39dca9970f2a9838bff0ddda2f53d0d114;hb=refs%2Fheads%2Fmaster;hp=2a457a5ad2eda05c2f47e9953357da48af5de818;hpb=5a17d0898d72bc8574601f57f26af8d3e0da2288;p=redo-blog diff --git a/processor/default.html.do b/processor/default.html.do index 2a457a5..f0d43a3 100644 --- a/processor/default.html.do +++ b/processor/default.html.do @@ -1,28 +1,57 @@ #!/bin/sh +# Handle URL from .links file. +prep_url() { + url=$(printf "%s" "$(escape_html "$1")" | prep_sed) + template=$(cat "$linkback_tmpl_file") + printf "%s" "$template" | sed 's/%URL%/'"$url"'/g' | tr '\a' '%' | prep_sed +} + # Pull in global dependencies. . ./helpers.sh -intermediate_file="${1%.html}.intermediate" -title_file=title.meta -redo-ifchange "$title_file" +metadata_dir=metadata +captchas_dir=captchas/linkable +mkdir -p "$captchas_dir" +meta_file="${metadata_dir}/${1%.html}.automatic_metadata" +redo-ifchange "$meta_file" +intermediate_file="${metadata_dir}/${1%.html}.intermediate" redo-ifchange "$intermediate_file" +title_file="${metadata_dir}"/title +redo-ifchange "$title_file" +article_tmpl_file="${metadata_dir}"/article.tmpl +redo-ifchange "$article_tmpl_file" +linkback_tmpl_file="${metadata_dir}"/linkback.tmpl +redo-ifchange "$linkback_tmpl_file" +replies_file="${1%.html}.links" +redo-ifchange "$replies_file" +captcha_file="$captchas_dir/${1%.html}" +redo-ifchange "$captcha_file" # Build entry data. -blog_title=`read_and_escape_file "$title_file" | head -1` -title_html=`cat "$intermediate_file" | head -1` +blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed) +title_html=$(cat "$intermediate_file" | head -1) title_plaintext=`echo "$title_html" | html2text` -title_plaintext_escaped=`escape_html "$title_plaintext"` -body=`cat "$intermediate_file" | sed 1d` - -# Write first part of entry head. -cat << EOF - - -
-EOF +title_html=$(printf "%s" "$title_html" | prep_sed) +title_plaintext=$(escape_html "$title_plaintext" | prep_sed) +title_url=$(escape_html "${1%.html}" | prep_sed) +body=$(cat "$intermediate_file" | sed 1d | prep_sed) +datetime_created_unix=$(get_creation_date_from_meta_file_seconds "$meta_file") +date_created=$(date -u "+%Y-%m-%d" -d "@${datetime_created_unix}") +datetime_lastmod_unix=$(get_lastmod_date_from_meta_file "$meta_file") +date_updated=$(date -u "+%Y-%m-%d" -d "@${datetime_lastmod_unix}") +replies=$(while read line; do prep_url "$line"; done < "$replies_file") +captcha=$(escape_html "$(cat "$captcha_file" | sed -n 2p)" | prep_sed) -# Write remaining entry head and body. -printf "