1 | @echo off
|
---|
2 |
|
---|
3 | :: Usage: generate-html.bat [<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
|
---|
5 | if not "%GSDLHOME%" == "" goto generate
|
---|
6 |
|
---|
7 | echo You must run 'setup' in the top level folder of your Greenstone installation before running this script
|
---|
8 | echo Usage: $0 [gs-major-version-number=2]
|
---|
9 | goto exit
|
---|
10 |
|
---|
11 | :generate:
|
---|
12 | setlocal
|
---|
13 | set top_dir=%CD%
|
---|
14 | set source_dir=%CD%\xml-source
|
---|
15 | set processing_dir=%CD%\processing
|
---|
16 | set output_dir=%CD%\html
|
---|
17 | set tmp_dir=%CD%\tmp
|
---|
18 | if not exist "%output_dir%" mkdir %output_dir%
|
---|
19 | if not exist "%tmp_dir%" mkdir %tmp_dir%
|
---|
20 | cd ..
|
---|
21 | cd shared
|
---|
22 | set shared_dir=%CD%
|
---|
23 | cd %output_dir%
|
---|
24 |
|
---|
25 |
|
---|
26 | set GSDL_OR_GSDL3SRC_HOME=%GSDLHOME%
|
---|
27 | :: this environment variable varies for GS3, where GLI is located in GSDL3SRCHOME (GS3) and not in GSDLHOME (gs2build)
|
---|
28 | if not "%GSDL3SRCHOME%" == "" if exist "%GSDL3SRCHOME%" (
|
---|
29 | set GSDL_OR_GSDL3SRC_HOME=%GSDL3SRCHOME%
|
---|
30 | )
|
---|
31 |
|
---|
32 | set CLASSPATH=%shared_dir%;%GSDLHOME%\gli;%GSDL_OR_GSDL3SRC_HOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar;%GSDL_OR_GSDL3SRC_HOME%\web\WEB-INF\classes
|
---|
33 |
|
---|
34 | :: preprocess-tut-xml.xsl removes all the non-matching MajorVersion tags first
|
---|
35 | :: This needs to be done in a separate pass, to ensure NumberedItems nested in
|
---|
36 | :: MajorVersion tags preserve their numbering.
|
---|
37 | echo "processing top level index"
|
---|
38 | java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT "en" "%processing_dir%\preprocess-tut-xml.xsl" "%source_dir%\tutorial_en.xml" %* > "%tmp_dir%\tutorial_en.xml"
|
---|
39 | java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT "en" "%processing_dir%\xml-to-top-index.xsl" "%tmp_dir%\tutorial_en.xml" %* > "%output_dir%\index.html"
|
---|
40 |
|
---|
41 | echo "generating wiki index page"
|
---|
42 | java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT "en" "%processing_dir%\xml-to-wiki-index.xsl" "%tmp_dir%\tutorial_en.xml" %* > "%output_dir%\wiki-index.txt"
|
---|
43 |
|
---|
44 |
|
---|
45 | for %%G IN (en,fr,ru,es) do (
|
---|
46 | if not exist "%output_dir%\%%G" mkdir "%output_dir%\%%G"
|
---|
47 |
|
---|
48 | echo "processing %%G version"
|
---|
49 | cd %output_dir%\%%G
|
---|
50 |
|
---|
51 | if not "%%G" == "en" java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT %%G "%processing_dir%\preprocess-tut-xml.xsl" "%source_dir%\tutorial_%%G.xml" %* > "%tmp_dir%\tutorial_%%G.xml"
|
---|
52 |
|
---|
53 | java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT %%G "%processing_dir%\xml-to-index.xsl" "%tmp_dir%\tutorial_%%G.xml" %* > "index.html"
|
---|
54 | java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT %%G "%processing_dir%\xml-to-one-html.xsl" "%tmp_dir%\tutorial_%%G.xml" %* > "all_tutorials.html"
|
---|
55 | java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" -DGSDL3SRCHOME="%GSDL3SRCHOME%" ApplyXSLT %%G "%processing_dir%\xml-to-many-html.xsl" "%tmp_dir%\tutorial_%%G.xml" %* | perl -S "%GSDL_OR_GSDL3SRC_HOME%\gli\help\splithelpdocument.pl"
|
---|
56 | cd ..
|
---|
57 | )
|
---|
58 |
|
---|
59 | endlocal
|
---|
60 |
|
---|
61 | :exit:
|
---|
62 |
|
---|
63 |
|
---|