home · contact · privacy
99d784df28884f9816f08305099b04cc3338211e
[redo-blog] / default.html.do
1 #!/bin/sh
2
3 # Pull in global dependencies.
4 . ./helpers.sh
5 metadata_dir=metadata
6 intermediate_file="${metadata_dir}/${1%.html}.intermediate"
7 redo-ifchange "$intermediate_file"
8 title_file="${metadata_dir}"/title
9 redo-ifchange "$title_file" 
10 template_file="${metadata_dir}"/article.tmpl
11 redo-ifchange "$template_file"
12
13 # Build entry data.
14 blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed)
15 title_html=$(cat "$intermediate_file" | head -1)
16 title_plaintext=`echo "$title_html" | html2text`
17 title_html=$(printf "%s" "$title_html" | prep_sed)
18 title_plaintext=$(escape_html "$title_plaintext" | prep_sed)
19 body=$(cat "$intermediate_file" | sed 1d | prep_sed)
20
21 # Put data into template.
22 template=$(cat "$template_file")
23 printf "%s" "$template" | \
24 sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \
25 sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \
26 sed 's/%ARTICLE_TITLE_HTML%/'"$title_html"'/g' | \
27 sed 's/%BODY%/'"$body"'/g' | \
28 tr '\a' '%'