source: documentation/trunk/tutorials/generate-html.sh@ 25767

Last change on this file since 25767 was 25767, checked in by ak19, 12 years ago

Processing of the MajorVersion element is moved into a separate preprocessing pass, in order to ensure that NumberedItems nested in a MajorVersion element continue to have the right numbering on display.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
RevLine 
[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]5if [ "$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
9fi
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]16top_dir=`pwd`
17shared_dir=`pwd`/../shared
18source_dir=`pwd`/xml-source
19processing_dir=`pwd`/processing
20output_dir=`pwd`/html
[25767]21tmp_dir=`pwd`/tmp
[13636]22
[18754]23export CLASSPATH=$shared_dir:$GSDLHOME/gli:$GSDLHOME/gli/classes:$GSDLHOME/perllib:$shared_dir/xalan.jar
24
[25472]25if [ ! -d $output_dir ]; then
26 mkdir $output_dir
27fi
[13708]28
[25767]29if [ ! -d $tmp_dir ]; then
30 mkdir $tmp_dir
31fi
32
[13708]33langs="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]42echo "processing top level index"
[25767]43java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_en.xml "$@" > $tmp_dir/tutorial_en.xml
44java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-top-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/index.html
[13636]45
46echo "generating wiki index page"
[25767]47java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt
[13636]48
[13708]49for 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
63done
[13636]64
[25767]65# get rid of intermediary directory
66rm -rf $tmp_dir
Note: See TracBrowser for help on using the repository browser.