home · contact · privacy
Add workaround for redo-ifcreate not working as expected.
[redo-blog] / processor / metadata / default.feed_snippet.do
1 #!/bin/sh
2
3 # Handle URL from .links file.
4 prep_url() {
5   url=$(escape_html "$1")
6   printf "\n<link href=\"%s\" rel=\"replies\" />" "$url"
7 }
8
9 # Pull in dependencies. 
10 . ../helpers.sh
11 src_file=$(get_source_file "$1")
12 meta_file="${1%.feed_snippet}.automatic_metadata"
13 redo-ifchange "$meta_file"
14 intermediate_file="${1%.feed_snippet}.intermediate"
15 redo-ifchange "$intermediate_file"
16 replies_file="${src_file%.*}.links"
17 redo-ifchange "$replies_file"
18
19 # Get variables, write entry.
20 html_file=$(escape_url "${1%.feed_snippet}.html")
21 lastmod=$(get_lastmod_date_from_meta_file "$meta_file")
22 lastmod_rfc3339=$(date -u "+%Y-%m-%dT%TZ" -d "@$lastmod")
23 title=$(read_and_escape_file "$intermediate_file" | head -1)
24 uuid=$(get_uuid_from_meta_file "$meta_file")
25 published_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
26 published_rfc3339=$(date -u "+%Y-%m-%dT%TZ" -d "@${published_unix}")
27 body=$(read_and_escape_file "$intermediate_file" | sed 1d)
28 replies=$(while read line; do prep_url "$line"; done < "$replies_file")
29 printf "<entry>\n"
30 printf "<title type=\"html\">%s</title>\n" "$title"
31 printf "<id>urn:uuid:%s</id>\n" "$uuid"
32 printf "<updated>%s</updated>\n" "$lastmod_rfc3339"
33 printf "<published>%s</published>\n" "$published_rfc3339"
34 printf "<link href=\"%s%s\" rel=\"alternate\" type=\"text/html\" />" "$(get_basepath)" "${html_file}"
35 printf "%s" "$replies"
36 printf "\n<content type=\"html\">\n%s\n</content>\n" "$body"
37 printf "</entry>\n"