favicon test
[www_nobug/.git] / build_website.sh
1 #!/bin/bash
2 DEFAULT_CONF=xhtml11
3
4 run_menugen=no
5
6 umask 003
7
8 # first pass, poor man dependency tracking over all .txt files
9 if [[ ! "$1" ]]; then
10         echo -n "finding dependencies "
11         find -L -name '*.txt' |
12                 while read file; do
13                         echo -n "."
14                         sed 's/include::\([^[]*\).*/\1/p;d' "$file" | while read prerequisite; do
15                                 if [[ "${prerequisite}" -nt "${file}" ]]; then
16                                         echo -n ":"
17                                         touch "$file"
18                                 fi
19                         done
20                 done
21 echo
22 fi
23
24 # second pass for every .txt file
25 echo -n "processing files "
26 case "$1" in
27 --all|'')
28         find -L -name '*.txt'
29         ;;
30 *)
31         echo "$1"
32         ;;
33 esac |
34         { while read file; do
35                 echo -n "."
36                 # when the .txt is newer than an existing .html
37                 if [[ "$file" -nt "${file%*.txt}.html" || "$1" ]]; then
38                         # use the default config file
39                         conf="${DEFAULT_CONF}.conf"
40                         # or if there is a .conf file with the same basename as the .txt file use that instead
41                         if [[ -e "${file%*.txt}.conf" ]]; then
42                                 conf="${file%*.txt}.conf"
43                         fi
44                         # run asciidoc over it
45                         echo "asciidocing $file"
46                         python /usr/bin/asciidoc --unsafe --backend=xhtml11 \
47                                 --attribute icons --attribute \
48                                 iconsdir=./images/icons --attribute=badges! \
49                                 --attribute=revision="$VERS"  --attribute=date="$DATE" \
50                                 --attribute quirks! --attribute toc \
51                                 --conf-file="${conf}" \
52                                 "$file"
53                         echo
54
55                         run_menugen=yes
56                 fi
57         done
58 #       if [[ $run_menugen=yes ]]; then
59 #               ./menugen.py -p -s -w >menu.html.tmp
60 #               if cmp -s menu.html.tmp menu.html; then
61 #                       rm menu.html.tmp
62 #               else
63 #                       echo
64 #                       echo "regenerate menus"
65 #                       mv menu.html.tmp menu.html
66 #               fi
67 #       fi
68         }
69 echo
70