home · contact · privacy
Display creation dates in index.html and article html files.
[redo-blog] / processor / metadata / default.index_snippet.do
index e332350f23fe81f6b1b27dd5ac1208e5d4930053..a1ff6f966cb6bc6c155be184058e140909439ab1 100644 (file)
@@ -3,12 +3,25 @@
 # Pull in dependencies.
 . ../helpers.sh
 src_file=$(get_source_file "$1")
+uuid_file="${1%.index_snippet}.uuid"
+redo-ifchange "$uuid_file"
 intermediate_file="${1%.index_snippet}.intermediate"
 redo-ifchange "$intermediate_file"
 html_file="${src_file%.*}.html"
 redo-ifchange "$html_file"
+template_file=index_snippet.tmpl
+redo-ifchange "$template_file"
 
-# Get variables, write entry.
-title_html=$(cat "$intermediate_file" | head -1)
-html_file_escaped=$(escape_url "${1%.index_snippet}.html")
-printf "<li><a href=\"%s\" />%s</a></li>\n" "$html_file_escaped" "$title_html"
+# Build entry data.
+title=$(cat "$intermediate_file" | head -1 | prep_sed)
+link=$(escape_url "${1%.index_snippet}.html" | prep_sed)
+datetime_created_unix=$(stat -c%y "${uuid_file}")
+date_created=$(date -u "+%Y-%m-%d" -d "${datetime_created_unix}")
+
+# Put data into template.
+template=$(cat "$template_file")
+printf "%s\n" "$template" | \
+sed 's/%TITLE%/'"$title"'/g' | \
+sed 's/%LINK%/'"$link"'/g' | \
+sed 's/%DATE_CREATED%/'"$date_created"'/g' | \
+tr '\a' '%'