home · contact · privacy
73d01249d653473fcc5eb760364aec696fff6b46
[redo-blog] / processor / all.do
1 #!/bin/sh
2
3 metadata_dir=.meta
4
5 # Remove target files for which no sources files can be found.
6 for file in "$metadata_dir"/*.intermediate; do
7   basename=$(basename "$file")
8   if   test -f "$file" &&
9      ! test -f "${basename%.intermediate}.md" &&
10      ! test -f "${basename%.intermediate}.rst"; then
11     rm "$file"
12   fi
13 done
14 for file in "$metadata_dir"/*.uuid; do
15   basename=$(basename "$file")
16   if   test -f "$file" &&
17      ! test -f "${basename%.uuid}.md" &&
18      ! test -f "${basename%.uuid}.rst"; then
19     rm "$file"
20   fi
21 done
22 for file in *.html; do
23   if   test -f "$file" &&
24      ! test "$file" = "index.html" &&
25      ! test -f "${metadata_dir}/${file%.html}.intermediate"; then
26     rm "$file"
27   fi
28 done
29
30 # Determine target files from the sources files present, declare dependencies
31 # of the all.do script on them / build them if necessary.
32 for file in *.rst *.md; do
33   if test -f "$file"; then
34     redo-ifchange "${metadata_dir}/${file%.*}.intermediate"
35   fi
36 done
37 for file in "$metadata_dir"/*.intermediate; do
38   if test -f "$file"; then
39     basename=$(basename "$file")
40     redo-ifchange "${basename%.intermediate}.html"
41   fi
42 done
43
44 # Regenerate feed and index pages. Always.
45 redo "feed.xml"
46 redo "index.html"