home · contact · privacy
a1ff6f966cb6bc6c155be184058e140909439ab1
[redo-blog] / processor / metadata / default.index_snippet.do
1 #!/bin/sh
2
3 # Pull in dependencies.
4 . ../helpers.sh
5 src_file=$(get_source_file "$1")
6 uuid_file="${1%.index_snippet}.uuid"
7 redo-ifchange "$uuid_file"
8 intermediate_file="${1%.index_snippet}.intermediate"
9 redo-ifchange "$intermediate_file"
10 html_file="${src_file%.*}.html"
11 redo-ifchange "$html_file"
12 template_file=index_snippet.tmpl
13 redo-ifchange "$template_file"
14
15 # Build entry data.
16 title=$(cat "$intermediate_file" | head -1 | prep_sed)
17 link=$(escape_url "${1%.index_snippet}.html" | prep_sed)
18 datetime_created_unix=$(stat -c%y "${uuid_file}")
19 date_created=$(date -u "+%Y-%m-%d" -d "${datetime_created_unix}")
20
21 # Put data into template.
22 template=$(cat "$template_file")
23 printf "%s\n" "$template" | \
24 sed 's/%TITLE%/'"$title"'/g' | \
25 sed 's/%LINK%/'"$link"'/g' | \
26 sed 's/%DATE_CREATED%/'"$date_created"'/g' | \
27 tr '\a' '%'