home · contact · privacy
Move snippet generation for index/feed into separate .do files.
[redo-blog] / processor / default.feed_snippet.do
1 #!/bin/sh
2
3 # Pull in dependencies. 
4 . ./helpers.sh
5 src_file=$(get_source_file "$1")
6 uuid_file="${1%.feed_snippet}.uuid"
7 redo-ifchange "$uuid_file"
8 intermediate_file="${src_file%.*}.intermediate"
9 redo-ifchange "$intermediate_file"
10
11 # Get variables, write entry.
12 html_file=`escape_url "${src_file%.*}.html"`
13 lastmod=`stat -c%y "$src_file"`
14 lastmod_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$lastmod"`
15 published=`stat -c%y "$uuid_file"`
16 published_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "${published}"`
17 title=`read_and_escape_file "$intermediate_file" | head -1`
18 uuid=`read_and_escape_file "$uuid_file" | head -1`
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\" />\n" "$(get_basepath)" "${html_file#\./}"
26 printf "<content type=\"html\">\n%s\n</content>\n" "$body"
27 printf "</entry>\n"