home · contact · privacy
Improve templates.
[redo-blog] / processor / metadata / default.feed_snippet.do
1 #!/bin/sh
2
3 # Pull in dependencies. 
4 . ../helpers.sh
5 src_file=$(get_source_file "$1")
6 meta_file="${1%.feed_snippet}.automatic_metadata"
7 redo-ifchange "$meta_file"
8 intermediate_file="${1%.feed_snippet}.intermediate"
9 redo-ifchange "$intermediate_file"
10
11 # Get variables, write entry.
12 html_file=$(escape_url "${1%.feed_snippet}.html")
13 lastmod=$(get_lastmod_date_from_meta_file "$meta_file")
14 lastmod_rfc3339=$(date -u "+%Y-%m-%dT%TZ" -d "@$lastmod")
15 title=$(read_and_escape_file "$intermediate_file" | head -1)
16 uuid=$(get_uuid_from_meta_file "$meta_file")
17 published_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
18 published_rfc3339=$(date -u "+%Y-%m-%dT%TZ" -d "@${published_unix}")
19 body=$(read_and_escape_file "$intermediate_file" | sed 1d)
20 printf "<entry>\n"
21 printf "<title type=\"html\">%s</title>\n" "$title"
22 printf "<id>urn:uuid:%s</id>\n" "$uuid"
23 printf "<updated>%s</updated>\n" "$lastmod_rfc3339"
24 printf "<published>%s</published>\n" "$published_rfc3339"
25 printf "<link href=\"%s%s\" rel=\"alternate\" type=\"text/html\" />\n" "$(get_basepath)" "${html_file}"
26 printf "<content type=\"html\">\n%s\n</content>\n" "$body"
27 printf "</entry>\n"