home · contact · privacy
Add uuid.meta test.
[redo-blog] / processor / index.html.do
1 #!/bin/sh
2
3 # Pull in global dependencies.
4 . ./helpers.sh
5 title_file=title.meta
6 redo-ifchange "$title_file"
7
8 # Write index head.
9 cat << EOF
10 <!DOCTYPE html>
11 <html>
12 <head>
13 EOF
14 blog_title=`read_and_escape_file "$title_file" | head -1`
15 printf "<title>%s</title>\n</head>\n<body>\n" "$blog_title"
16 printf "<h1>%s</h1>\n<ul>\n" "$blog_title"
17
18 # Iterate through entries sorted by lastmod of their source files, write entry
19 # list. 
20 first_run=0
21 files=`ls -1t *.rst *.md | tr '\n' $'\0'`
22 oldIFS="$IFS"
23 IFS=$'\0'
24 for file in $files; do
25   if [ "$first_run" -lt "1" ]; then
26     IFS="$oldIFS"
27     first_run=1
28   fi
29   intermediate_file="${file%.*}.intermediate"
30   html_file="${file%.*}.html"
31   redo-ifchange "$intermediate_file"
32   redo-ifchange "$html_file"
33   title_html=`cat "$intermediate_file" | head -1`
34   html_file_escaped=`escape_url "$html_file"`
35   printf "<li><a href=\"%s\" />%s</a></li>\n" "$html_file_escaped" "$title_html"
36 done
37
38 printf "</ul>\n</body>\n</html>"