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
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
23export CLASSPATH=$shared_dir:$GSDLHOME/gli:$GSDLHOME/gli/classes:$GSDLHOME/perllib:$shared_dir/xalan.jar
24
25if [ ! -d $output_dir ]; then
26 mkdir $output_dir
27fi
28
29if [ ! -d $tmp_dir ]; then
30 mkdir $tmp_dir
31fi
32
33langs="en fr es ru"
34
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
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
42echo "processing top level index"
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
45
46echo "generating wiki index page"
47java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt
48
49for l in $langs; do
50 echo "Processing $l version"
51 if [ ! -d $output_dir/$l ]; then
52 mkdir $output_dir/$l
53 fi
54 cd $output_dir/$l
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
62 cd $top_dir
63done
64
65# get rid of intermediary directory
66rm -rf $tmp_dir
Note: See TracBrowser for help on using the repository browser.