3 # Pull in global dependencies.
6 meta_file="${metadata_dir}/${1%.html}.automatic_metadata"
7 redo-ifchange "$meta_file"
8 intermediate_file="${metadata_dir}/${1%.html}.intermediate"
9 redo-ifchange "$intermediate_file"
10 title_file="${metadata_dir}"/title
11 redo-ifchange "$title_file"
12 template_file="${metadata_dir}"/article.tmpl
13 redo-ifchange "$template_file"
16 blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed)
17 title_html=$(cat "$intermediate_file" | head -1)
18 title_plaintext=`echo "$title_html" | html2text`
19 title_html=$(printf "%s" "$title_html" | prep_sed)
20 title_plaintext=$(escape_html "$title_plaintext" | prep_sed)
21 body=$(cat "$intermediate_file" | sed 1d | prep_sed)
22 datetime_created_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
23 datetime_created_rfc3339=$(date -u "+%Y-%m-%dT%TZ" -d "@${datetime_created_unix}")
24 datetime_created_friendly=$(date -u "+%Y-%m-%d %T (UTC)" -d "@${datetime_created_unix}")
26 # Put data into template.
27 template=$(cat "$template_file")
28 printf "%s" "$template" | \
29 sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \
30 sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \
31 sed 's/%ARTICLE_TITLE_HTML%/'"$title_html"'/g' | \
32 sed 's/%DATETIME_CREATED_RFC3339%/'"$datetime_created_rfc3339"'/g' | \
33 sed 's/%DATETIME_CREATED_FRIENDLY%/'"$datetime_created_friendly"'/g' | \
34 sed 's/%BODY%/'"$body"'/g' | \