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