3 # Pull in global dependencies.
10 # Build some variables. XML-escape even file contents that should not contain
11 # dangerous characters, just to avoid any XML trouble.
12 base_url=`cat url | head -1`
13 url_protocol=`echo $base_url | cut -d ':' -f 1`
14 url_basepath=`echo $base_url | cut -d '/' -f 3-`
15 url_basepath_escaped=`escape_url "$url_basepath"`
16 basepath="$url_protocol""://""$url_basepath_escaped"
17 title=`read_and_escape_file title | head -1`
18 author=`read_and_escape_file author | head -1`
19 uuid=`read_and_escape_file uuid | head -1`
21 # Write majority of feed head.
23 <?xml version="1.0" encoding="utf-8"?>
24 <feed xmlns="http://www.w3.org/2005/Atom">
26 printf "<link href=\"%s\" />\n" "$basepath"
27 printf "<link href=\"%sfeed.xml\" rel=\"self\" />\n" "$basepath"
28 printf "<title type=\"html\">%s</title>\n" "$title"
29 printf "<author><name>%s</name></author>\n" "$author"
30 printf "<id>urn:uuid:%s</id>\n" "$uuid"
32 # Iterate through most recent entries (go by lastmod date of source files) to
33 # build feed head "updated" element, and individual entries.
35 files=`ls -1t *.rst *.md | head -10 | tr '\n' $'\0'`
38 for file in $files; do
39 lastmod=`stat -c%y "$file"`
40 lastmod_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$lastmod"`
41 if [ "$first_run" -lt "1" ]; then
43 printf "<updated>%s</updated>\n\n" "$lastmod_rfc3339"
47 # Build some variables and dependencies.
48 intermediate_file="${file%.*}.intermediate"
49 htmlfile=`escape_url "${file%.*}.html"`
50 redo-ifchange "$intermediate_file"
51 redo-ifchange "$uuidfile"
52 title=`read_and_escape_file "$intermediate_file" | head -1`
53 uuidfile="${file%.*}.uuid"
54 uuid=`read_and_escape_file "$uuidfile" | head -1`
55 body=`read_and_escape_file "$intermediate_file" | sed 1d`
56 published=`stat -c%y "$uuidfile"`
57 published_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$published"`
61 printf "<title type=\"html\">%s</title>\n" "$title"
62 printf "<id>urn:uuid:%s</id>\n" "$uuid"
63 printf "<updated>%s</updated>\n" "$lastmod_rfc3339"
64 printf "<published>%s</published>\n" "$published_rfc3339"
65 printf "<link href=\"%s%s\" />\n" "$basepath" "$htmlfile"
66 printf "<content type=\"html\">\n%s\n</content>\n" "$body"