1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # Usage: ./generate-html.sh [<gs-major-version-number]
|
---|
4 | # The optional parameter major version number, which can be 2 or 3, will be assumed to be (Greenstone) "2" if none is provided
|
---|
5 | if [ "$GSDLHOME" == "" ]; then
|
---|
6 | echo "You must run 'source setup.bash' in the top level folder of your Greenstone installation before running this script"
|
---|
7 | echo "Usage: $0 [gs-major-version-number=2]"
|
---|
8 | exit
|
---|
9 | fi
|
---|
10 |
|
---|
11 | #ApplyXSLT.java will take care of setting the default of the major Greenstone version if none is provided
|
---|
12 | #if [ "$1" != "" ]; then
|
---|
13 | # $major_version="2"
|
---|
14 | #fi
|
---|
15 |
|
---|
16 | top_dir=`pwd`
|
---|
17 | shared_dir=`pwd`/../shared
|
---|
18 | source_dir=`pwd`/xml-source
|
---|
19 | processing_dir=`pwd`/processing
|
---|
20 | output_dir=`pwd`/html
|
---|
21 | tmp_dir=`pwd`/tmp
|
---|
22 |
|
---|
23 |
|
---|
24 | export GSDL_OR_GSDL3SRC_HOME=$GSDLHOME
|
---|
25 | # this environment variable varies for GS3, where GLI is located in GSDL3SRCHOME (GS3) and not in GSDLHOME (gs2build)
|
---|
26 | if [ "$GSDL3SRCHOME" != "" ] && [ -d $GSDL3SRCHOME ]; then
|
---|
27 | export GSDL_OR_GSDL3SRC_HOME=$GSDL3SRCHOME
|
---|
28 | fi
|
---|
29 |
|
---|
30 | export CLASSPATH=$shared_dir:$GSDLHOME/gli:$GSDL_OR_GSDL3SRC_HOME/gli/classes:$GSDLHOME/perllib:$shared_dir/xalan.jar
|
---|
31 |
|
---|
32 | if [ ! -d $output_dir ]; then
|
---|
33 | mkdir $output_dir
|
---|
34 | fi
|
---|
35 |
|
---|
36 | if [ ! -d $tmp_dir ]; then
|
---|
37 | mkdir $tmp_dir
|
---|
38 | fi
|
---|
39 |
|
---|
40 | langs="en fr es ru"
|
---|
41 |
|
---|
42 | # http://tadek.pietraszek.org/blog/2006/01/05/messing-up-with-command-line-arguments-in-bash/
|
---|
43 | # is on the difference between $@ and $* and when to add quotes around them
|
---|
44 |
|
---|
45 | # preprocess-tut-xml.xsl removes all the non-matching MajorVersion tags first
|
---|
46 | # This needs to be done in a separate pass, to ensure NumberedItems nested in
|
---|
47 | # MajorVersion tags preserve their numbering.
|
---|
48 |
|
---|
49 | echo "processing top level index"
|
---|
50 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_en.xml "$@" > $tmp_dir/tutorial_en.xml
|
---|
51 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/xml-to-top-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/index.html
|
---|
52 |
|
---|
53 | echo "generating wiki index page"
|
---|
54 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt
|
---|
55 |
|
---|
56 | for l in $langs; do
|
---|
57 | echo "Processing $l version"
|
---|
58 | if [ ! -d $output_dir/$l ]; then
|
---|
59 | mkdir $output_dir/$l
|
---|
60 | fi
|
---|
61 | cd $output_dir/$l
|
---|
62 |
|
---|
63 | if [ "$l" != "en" ]; then
|
---|
64 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_$l.xml "$@" > $tmp_dir/tutorial_$l.xml
|
---|
65 | fi
|
---|
66 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/xml-to-index.xsl $tmp_dir/tutorial_$l.xml "$@" > index.html
|
---|
67 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/xml-to-one-html.xsl $tmp_dir/tutorial_$l.xml "$@" > all_tutorials.html
|
---|
68 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/xml-to-many-html.xsl $tmp_dir/tutorial_$l.xml "$@" | perl -S $GSDL_OR_GSDL3SRC_HOME/gli/help/splithelpdocument.pl
|
---|
69 | cd $top_dir
|
---|
70 | done
|
---|
71 |
|
---|
72 | # get rid of intermediary directory
|
---|
73 | rm -rf $tmp_dir
|
---|