root/documentation/trunk/tutorials/generate-html.sh @ 27035

Revision 27035, 3.0 KB (checked in by ak19, 7 years ago)

1. Bringing Windows script generate-html.bat up to speed with changes to Linux script generate-html.sh that were made in revision 25767. 2. Tested on Windows: important changes to both scripts as well as Dictionary.java to get the tutorials generated when using a GS3 installation (when a gs3-setup file is sourced).

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
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
5if [ "$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
9fi
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
16top_dir=`pwd`
17shared_dir=`pwd`/../shared
18source_dir=`pwd`/xml-source
19processing_dir=`pwd`/processing
20output_dir=`pwd`/html
21tmp_dir=`pwd`/tmp
22
23
24export GSDL_OR_GSDL3SRC_HOME=$GSDLHOME
25# this environment variable varies for GS3, where GLI is located in GSDL3SRCHOME (GS3) and not in GSDLHOME (gs2build)
26if [ "$GSDL3SRCHOME" != "" ] && [ -d $GSDL3SRCHOME ]; then 
27    export GSDL_OR_GSDL3SRC_HOME=$GSDL3SRCHOME 
28fi
29
30export CLASSPATH=$shared_dir:$GSDLHOME/gli:$GSDL_OR_GSDL3SRC_HOME/gli/classes:$GSDLHOME/perllib:$shared_dir/xalan.jar
31
32if [ ! -d $output_dir ]; then
33    mkdir $output_dir
34fi
35
36if [ ! -d $tmp_dir ]; then
37    mkdir $tmp_dir
38fi
39
40langs="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
49echo "processing top level index"
50java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/preprocess-tut-xml.xsl  $source_dir/tutorial_en.xml "$@" > $tmp_dir/tutorial_en.xml
51java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/xml-to-top-index.xsl  $tmp_dir/tutorial_en.xml "$@" > $output_dir/index.html
52
53echo "generating wiki index page"
54java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt
55
56for 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
70done
71
72# get rid of intermediary directory
73rm -rf $tmp_dir
Note: See TracBrowser for help on using the browser.