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

Last change on this file was 33783, checked in by kjdon, 4 years ago

only generate english versions for now as ru, fr, es haven't been translated since 2.70

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 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-either-2-or-3>]"
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"
41
42# no point generating all langs as the translations haven't changed since 2.70
43# if they did get retranslated, add these langs back into the langs var above.
44oldlangs="fr es ru"
45
46# http://tadek.pietraszek.org/blog/2006/01/05/messing-up-with-command-line-arguments-in-bash/
47# is on the difference between $@ and $* and when to add quotes around them
48
49# preprocess-tut-xml.xsl removes all the non-matching MajorVersion tags first
50# This needs to be done in a separate pass, to ensure NumberedItems nested in
51# MajorVersion tags preserve their numbering.
52
53echo "processing top level index"
54java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_en.xml "$@" > $tmp_dir/tutorial_en.xml
55java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/xml-to-top-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/index.html
56
57echo "generating wiki index page"
58java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $tmp_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt
59
60for l in $langs; do
61 echo "Processing $l version"
62 if [ ! -d $output_dir/$l ]; then
63 mkdir $output_dir/$l
64 fi
65 cd $output_dir/$l
66
67 if [ "$l" != "en" ]; then
68 java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/preprocess-tut-xml.xsl $source_dir/tutorial_$l.xml "$@" > $tmp_dir/tutorial_$l.xml
69 fi
70 java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/xml-to-index.xsl $tmp_dir/tutorial_$l.xml "$@" > index.html
71 java -DGSDLHOME=$GSDLHOME -DGSDL3SRCHOME=$GSDL3SRCHOME ApplyXSLT $l $processing_dir/xml-to-one-html.xsl $tmp_dir/tutorial_$l.xml "$@" > all_tutorials.html
72 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
73 cd $top_dir
74done
75
76# get rid of intermediary directory
77rm -rf $tmp_dir
Note: See TracBrowser for help on using the repository browser.