home · contact · privacy
Add page URL title template field.
[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 meta_file="${1%.index_snippet}.automatic_metadata"
7 redo-ifchange "$meta_file"
8 intermediate_file="${1%.index_snippet}.intermediate"
9 redo-ifchange "$intermediate_file"
10 template_file=index_snippet.tmpl
11 redo-ifchange "$template_file"
12
13 # Build entry data.
14 title=$(cat "$intermediate_file" | head -1 | prep_sed)
15 link=$(escape_url "${1%.index_snippet}.html" | prep_sed)
16 datetime_created_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
17 date_created_human=$(date -u "+%Y-%m-%d" -d "@${datetime_created_unix}")
18
19 # Put data into template.
20 template=$(cat "$template_file")
21 printf "%s\n" "$template" | \
22 sed 's/%TITLE%/'"$title"'/g' | \
23 sed 's/%LINK%/'"$link"'/g' | \
24 sed 's/%DATE_CREATED%/'"$date_created_human"'/g' | \
25 tr '\a' '%'