[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 |
|
---|
[27035] | 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 |
|
---|
[25472] | 32 | if [ ! -d $output_dir ]; then
|
---|
| 33 | mkdir $output_dir
|
---|
| 34 | fi
|
---|
[13708] | 35 |
|
---|
[25767] | 36 | if [ ! -d $tmp_dir ]; then
|
---|
| 37 | mkdir $tmp_dir
|
---|
| 38 | fi
|
---|
| 39 |
|
---|
[13708] | 40 | langs="en fr es ru"
|
---|
| 41 |
|
---|
[25472] | 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 |
|
---|
[25767] | 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 |
|
---|
[13636] | 49 | echo "processing top level index"
|
---|
[27035] | 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
|
---|
[13636] | 52 |
|
---|
| 53 | echo "generating wiki index page"
|
---|
[27035] | 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
|
---|
[13636] | 55 |
|
---|
[13708] | 56 | for l in $langs; do
|
---|
| 57 | echo "Processing $l version"
|
---|
[25472] | 58 | if [ ! -d $output_dir/$l ]; then
|
---|
| 59 | mkdir $output_dir/$l
|
---|
| 60 | fi
|
---|
[13708] | 61 | cd $output_dir/$l
|
---|
[25767] | 62 |
|
---|
| 63 | if [ "$l" != "en" ]; then
|
---|
[27035] | 64 | java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_$l.xml "$@" > $tmp_dir/tutorial_$l.xml
|
---|
[25767] | 65 | fi
|
---|
[27035] | 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
|
---|
[13708] | 69 | cd $top_dir
|
---|
| 70 | done
|
---|
[13636] | 71 |
|
---|
[25767] | 72 | # get rid of intermediary directory
|
---|
| 73 | rm -rf $tmp_dir
|
---|