3 # Handle URL from .links file.
5 url=$(printf "%s" "$(escape_html "$1")" | prep_sed)
6 template=$(cat "$linkback_tmpl_file")
7 printf "%s" "$template" | sed 's/%URL%/'"$url"'/g' | tr '\a' '%' | prep_sed
10 # Pull in global dependencies.
13 meta_file="${metadata_dir}/${1%.html}.automatic_metadata"
14 redo-ifchange "$meta_file"
15 intermediate_file="${metadata_dir}/${1%.html}.intermediate"
16 redo-ifchange "$intermediate_file"
17 title_file="${metadata_dir}"/title
18 redo-ifchange "$title_file"
19 article_tmpl_file="${metadata_dir}"/article.tmpl
20 redo-ifchange "$article_tmpl_file"
21 linkback_tmpl_file="${metadata_dir}"/linkback.tmpl
22 redo-ifchange "$linkback_tmpl_file"
23 replies_file="${1%.html}.links"
26 blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed)
27 title_html=$(cat "$intermediate_file" | head -1)
28 title_plaintext=`echo "$title_html" | html2text`
29 title_html=$(printf "%s" "$title_html" | prep_sed)
30 title_plaintext=$(escape_html "$title_plaintext" | prep_sed)
31 body=$(cat "$intermediate_file" | sed 1d | prep_sed)
32 datetime_created_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
33 date_created=$(date -u "+%Y-%m-%d" -d "@${datetime_created_unix}")
34 datetime_lastmod_unix=$(get_lastmod_date_from_meta_file "$meta_file")
35 date_updated=$(date -u "+%Y-%m-%d" -d "@${datetime_lastmod_unix}")
36 if test -f "$replies_file"; then
37 replies=$(while read line; do prep_url "$line"; done < "$replies_file")
40 # Put data into template.
41 template=$(cat "$article_tmpl_file")
42 printf "%s" "$template" | \
43 sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \
44 sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \
45 sed 's/%ARTICLE_TITLE_HTML%/'"$title_html"'/g' | \
46 sed 's/%DATE_CREATED%/'"$date_created"'/g' | \
47 sed 's/%DATE_UPDATED%/'"$date_updated"'/g' | \
48 sed 's/%BODY%/'"$body"'/g' | \
49 sed 's/%LINKBACKS%/'"$replies"'/g' | \