X-Git-Url: https://plomlompom.com/repos/?p=redo-blog;a=blobdiff_plain;f=processor%2Fdefault.html.do;h=99d784df28884f9816f08305099b04cc3338211e;hp=3ff413230f8babfdd13d5ab3569f741327abd435;hb=6b5631096b03f1c985bc40c4d2e244315280c686;hpb=dfdd193cf3f2f215fd26bae06ada013a14422581 diff --git a/processor/default.html.do b/processor/default.html.do index 3ff4132..99d784d 100644 --- a/processor/default.html.do +++ b/processor/default.html.do @@ -2,26 +2,27 @@ # Pull in global dependencies. . ./helpers.sh -intermediate_file="${1%.html}.intermediate" -redo-ifchange title +metadata_dir=metadata +intermediate_file="${metadata_dir}/${1%.html}.intermediate" redo-ifchange "$intermediate_file" +title_file="${metadata_dir}"/title +redo-ifchange "$title_file" +template_file="${metadata_dir}"/article.tmpl +redo-ifchange "$template_file" # Build entry data. -blog_title=`read_and_escape_file title | 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` +title_html=$(printf "%s" "$title_html" | prep_sed) +title_plaintext=$(escape_html "$title_plaintext" | prep_sed) +body=$(cat "$intermediate_file" | sed 1d | prep_sed) -# Write first part of entry head. -cat << EOF - - - -EOF - -# Write remaining entry head and body. -printf "%s – %s\n\n\n" "$blog_title" "$title_plaintext_escaped" -#printf "%s – %s\n\n\n" "$blog_title" "$entry_title" -printf "

%s

\n" "$title_html" -printf "
\n%s\n
\n\n" "$body" +# Put data into template. +template=$(cat "$template_file") +printf "%s" "$template" | \ +sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \ +sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \ +sed 's/%ARTICLE_TITLE_HTML%/'"$title_html"'/g' | \ +sed 's/%BODY%/'"$body"'/g' | \ +tr '\a' '%'