[18754] | 1 | #!/bin/bash
|
---|
[13636] | 2 |
|
---|
[25472] | 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
|
---|
[13636] | 5 | if [ "$GSDLHOME" == "" ]; then
|
---|
[18754] | 6 | echo "You must run 'source setup.bash' in the top level folder of your Greenstone installation before running this script"
|
---|
[25472] | 7 | echo "Usage: $0 [gs-major-version-number=2]"
|
---|
[13636] | 8 | exit
|
---|
| 9 | fi
|
---|
| 10 |
|
---|
[25472] | 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 |
|
---|
[13708] | 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
|
---|
[25767] | 21 | tmp_dir=`pwd`/tmp
|
---|
[13636] | 22 |
|
---|
[18754] | 23 | export CLASSPATH=$shared_dir:$GSDLHOME/gli:$GSDLHOME/gli/classes:$GSDLHOME/perllib:$shared_dir/xalan.jar
|
---|
| 24 |
|
---|
[25472] | 25 | if [ ! -d $output_dir ]; then
|
---|
| 26 | mkdir $output_dir
|
---|
| 27 | fi
|
---|
[13708] | 28 |
|
---|
[25767] | 29 | if [ ! -d $tmp_dir ]; then
|
---|
| 30 | mkdir $tmp_dir
|
---|
| 31 | fi
|
---|
| 32 |
|
---|
[13708] | 33 | langs="en fr es ru"
|
---|
| 34 |
|
---|
[25472] | 35 | # http://tadek.pietraszek.org/blog/2006/01/05/messing-up-with-command-line-arguments-in-bash/
|
---|
| 36 | # is on the difference between $@ and $* and when to add quotes around them
|
---|
| 37 |
|
---|
[25767] | 38 | # preprocess-tut-xml.xsl removes all the non-matching MajorVersion tags first
|
---|
| 39 | # This needs to be done in a separate pass, to ensure NumberedItems nested in
|
---|
| 40 | # MajorVersion tags preserve their numbering.
|
---|
| 41 |
|
---|
[13636] | 42 | echo "processing top level index"
|
---|
[25767] | 43 | java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_en.xml "$@" > $tmp_dir/tutorial_en.xml
|
---|
| 44 | java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-top-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/index.html
|
---|
[13636] | 45 |
|
---|
| 46 | echo "generating wiki index page"
|
---|
[25767] | 47 | java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt
|
---|
[13636] | 48 |
|
---|
[13708] | 49 | for l in $langs; do
|
---|
| 50 | echo "Processing $l version"
|
---|
[25472] | 51 | if [ ! -d $output_dir/$l ]; then
|
---|
| 52 | mkdir $output_dir/$l
|
---|
| 53 | fi
|
---|
[13708] | 54 | cd $output_dir/$l
|
---|
[25767] | 55 |
|
---|
| 56 | if [ "$l" != "en" ]; then
|
---|
| 57 | java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_$l.xml "$@" > $tmp_dir/tutorial_$l.xml
|
---|
| 58 | fi
|
---|
| 59 | java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-index.xsl $tmp_dir/tutorial_$l.xml "$@" > index.html
|
---|
| 60 | java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-one-html.xsl $tmp_dir/tutorial_$l.xml "$@" > all_tutorials.html
|
---|
| 61 | java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-many-html.xsl $tmp_dir/tutorial_$l.xml "$@" | perl -S $GSDLHOME/gli/help/splithelpdocument.pl
|
---|
[13708] | 62 | cd $top_dir
|
---|
| 63 | done
|
---|
[13636] | 64 |
|
---|
[25767] | 65 | # get rid of intermediary directory
|
---|
| 66 | rm -rf $tmp_dir
|
---|