]> git.sur5r.net Git - bacula/docs/blob - docs/tools/htmls.sh
1cc8abd5d4adc362274823a5d512d1e65b480e6c
[bacula/docs] / docs / tools / htmls.sh
1 #!/bin/bash
2 #
3 # Philippe Chauvat - BaculaSystems
4 # Last modification 04-dec-2012
5 #
6 # This script fetch all HTML 'manual' directories
7 # to apply a conversion script (translatedoc.pl)
8 # and then produce the final HTML version of the manuals
9 #
10 # args: none
11
12 # vars
13 # SOURCEDIRHEAD:        Where are located the original directories relatively to the
14 #                       current script
15 #                       Default: ../manuals/en
16 #
17 # TRANSLATOR:           The script to apply to each HTML original file
18 #                       Default: ./translatedoc.pl
19 #
20 # DEBUG:                You want some ? Specify -d there
21 #                       Default: ""
22 #
23 # FROMFILEMENUEXTRACT:  We want to extract ako menu. This var give the name of the file
24 #                       from which to extract it
25 #                       Default: index.html
26 #
27 # DIRSTOCREATE:         Specify here which directory(ies) must be created before running the conversion
28 #                       Default: "css js images"
29 #
30 # LIST                  The list of dirs containing the manuals to translate
31 #                       Default: `find ${SOURCEDIRHEAD} -mindepth 1 -maxdepth 1 -name "www-*" -type d`
32 #
33 # ROOTDIR               All HTML files rely on CSS, JS and IMAGES. ROOTDIR specify the relative path to those.
34 #                       Default: "../.."
35 #
36 # CSSDIR                The CSS directory used by HTMLs
37 #                       Default: ${ROOTDIR}/css
38 #
39 # JSDIR                 The JS (javascript) directory used by HTMLs
40 #                       Default: ${ROOTDIR}/js
41 #
42 # IMAGEDIR              The images directory used by HTMLs
43 #                       Default: ${ROOTDIR}/images
44 #
45 # DOSUBFILES            Do we want to generate all subfiles (not only the index.html). Debug and tests purpose
46 #                       Default: yes
47 #
48 SOURCEDIRHEAD="../manuals/en"
49 TRANSLATOR='./translatedoc.pl'
50 DEBUG="" # change to -d if you want some debug there
51 FROMFILEMENUEXTRACT="index.html"
52 DIRSTOCREATE="css js images"
53 LIST=`find ${SOURCEDIRHEAD} -mindepth 1 -maxdepth 1 -name "www-*" -type d`
54 #LIST=${SOURCEDIRHEAD}/www-main
55 ROOTDIR="../.."
56 CSSDIR=${ROOTDIR}/css
57 JSDIR=${ROOTDIR}/js
58 IMAGEDIR=${ROOTDIR}/images
59 SOURCEIMAGEDIR=../images
60 DESTIMAGEDIR=${SOURCEDIRHEAD}/images
61 #
62 # Do we want to generate HTML files for all
63 # files
64 DOSUBFILES=yes
65 #
66 # For each manual
67 for M in ${LIST}
68 do
69     #
70     # Extract the directory name: console, developers, main, etc.
71     thedirname=`echo $M | sed -e 's/.*www-\(.*\)/\1/g'`
72     #
73     # Message to indicate what we are building
74     echo ""
75     echo ""
76     echo "$thedirname Manual"
77     #
78     # Where to find HTML files
79     readdir=$M/$thedirname
80     #
81     # Where to store the result
82     DESTINATION_DIR=$SOURCEDIRHEAD/$thedirname/$thedirname
83     #
84     # Create the desitnation directory if needed
85     mkdir -p $DESTINATION_DIR
86     #
87     # Create otherdirs if needed
88     for D in ${DIRSTOCREATE}
89     do
90         mkdir -p $SOURCEDIRHEAD/$D
91     done
92     #
93     # Building the menu must be done without any existing file
94     rm -f wholemenu_${thedirname}.html
95     echo -n "Building navigation menu from ${readdir}/${FROMFILEMENUEXTRACT} to ${DESTINATION_DIR}/${FROMFILEMENUEXTRACT}..."
96     ./translatedoc.pl ${DEBUG} -i ${readdir}/${FROMFILEMENUEXTRACT} -e -o ${DESTINATION_DIR}/${FROMFILEMENUEXTRACT} -j ${JSDIR} -c ${CSSDIR} -p ${IMAGEDIR} -n ${thedirname} -r ${SOURCEDIRHEAD}
97     echo "Done."
98     if [ ${DOSUBFILES} == "yes" ]
99     then
100         for L in `ls ${readdir}|egrep html$`
101         do
102             echo -n "Translating $L..."
103             ./translatedoc.pl ${DEBUG} -i ${readdir}/${L} -o ${DESTINATION_DIR}/${L} -j ${JSDIR} -c ${CSSDIR} -p ${IMAGEDIR} -n ${thedirname}
104             echo "Done."
105         done
106     fi
107 done
108 #
109 # Anchor management
110 readdir=""
111 for M in ${LIST}
112 do
113     #
114     # Extract the directory name: console, developers, main, etc.
115     thedirname=`echo $M | sed -e 's/.*www-\(.*\)/\1/g'`
116     #
117     # Where to find HTML files
118     readdir="${readdir} $SOURCEDIRHEAD/$thedirname/$thedirname"
119 done
120 echo "./handle-xr-references.pl -m \"${readdir}\" -i list-of-anchors -l en"
121 ./handle-xr-references.pl -m "${readdir}" -i list-of-anchors -l en
122 #
123 # Copy images
124 cp -v ${SOURCEIMAGEDIR}/png/*.png ${DESTIMAGEDIR}/