[Libreoffice-commits] help.git: help3xsl/get_bookmark.sh help3xsl/get_hid2file.sh help3xsl/get_html.sh help3xsl/get_media.sh help3xsl/get_tree.sh help3xsl/index2.html help3xsl/makelocal.sh help3xsl/makeonline.sh help3xsl/online_transform.xsl

Olivier Hallot olivier.hallot at libreoffice.org
Wed Nov 1 16:19:30 UTC 2017


 help3xsl/get_bookmark.sh      |   75 +++++++++++++++---------
 help3xsl/get_hid2file.sh      |   40 +++++++++++++
 help3xsl/get_html.sh          |   49 ++++++++++++++++
 help3xsl/get_media.sh         |   42 +++++++++++++
 help3xsl/get_tree.sh          |  128 ++++++++++++++++++++++++++++++++++++++++++
 help3xsl/index2.html          |    4 -
 help3xsl/makelocal.sh         |   24 +++++++
 help3xsl/makeonline.sh        |   24 +++++++
 help3xsl/online_transform.xsl |   18 ++---
 9 files changed, 363 insertions(+), 41 deletions(-)

New commits:
commit 788f70916eaa53d89775c5998a4d19235ed19f4a
Author: Olivier Hallot <olivier.hallot at libreoffice.org>
Date:   Tue Oct 31 11:14:57 2017 -0200

    Refactor new help builder script into smaller pieces
    
    Add 4 smaller bash scripts for building new help, for
    better management
    
    Scripts use the following parameters
    
    workDir: $(WORKDIR)
    lang: $(LANG)
    productVersion: 6.0
    
    and put results in
    $(WORKDIR)/HelpTargetHTML
    
    ./get_hid2file.sh $productVersion $workDir
    Creates hid2file.js that maps HID into HTML page
    uses get_url.xsl transform
    
    ./get_bookmark.sh $lang $productVersion $workDir
    Creates the index file 'bookmarks.js' based on
    <bookmark_values> tag in all localized XHP files.
    Visible in Index tab of the HTML page
    Uses get_bookmark.xsl transform.
    
    ./get_html.sh $lang $productVersion $workDir $local $fileTree
    Creates the HTML pages from localized XHP files
    local: is local or website (yes/no)
         If local="yes", the filetree should be $(installDir)
         else (i.e. website), root file tree should be '/'
    fileTree: is root file tree for $local=yes
    If local = yes, then language selector, PIWIK probe
    and global search services are removed.
    Uses: online_transform.xsl transform
    
    ./get_tree.sh $lang $productVersion $workDir
    Creates the contents.js from localized TREE files
    Visible in Contents tab of the HTML page
    Uses get_tree.xsl transform
    
    ./get_media.sh $lang $productVersion $workDir
    Copy several auxiliary files for navigation
    Copy HC2 media files
    Copy galaxy icon theme for HTML pages
    
    * minor change in file name hid2file.js
    
    Added 2 more small scripts to show how to build local and online
    
    ./makelocal.sh
    ./makeonline.sh
    
    Languages depends on the languages available in
    $(WORKDIR)/HelpTranslatePartTarget/, and includes qtz.
    
    will handle special case of en-US later
    
    Change-Id: I0b7fdf5e1460070413eb2303f8d69b2b85a40c3e
    Reviewed-on: https://gerrit.libreoffice.org/44114
    Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>
    Tested-by: Olivier Hallot <olivier.hallot at libreoffice.org>

diff --git a/help3xsl/get_bookmark.sh b/help3xsl/get_bookmark.sh
index e4d3fee10..652cef1bb 100755
--- a/help3xsl/get_bookmark.sh
+++ b/help3xsl/get_bookmark.sh
@@ -5,56 +5,75 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
+#
+###########################################
+#
+#   Create the file bookmarks.js containing the links between the
+#   keywords found in <bookmark_value> and the html help page.
+#   The file is used in the Index tab of the html help page
+#
+###########################################
+#
 # $1 is Language
 # $2 is productversion
+# $3 is location of $(WORKDIR)
 
-outdir=`pwd`'/html/'$2'/'$1
+lang=$1
+productversion=$2
+workDir=$(realpath $3)
+
+outDir=$(realpath $workDir/HelpTargetHTML/$productversion/$lang)
+sourceDir=$(realpath $workDir/HelpTranslatePartTarget/$lang/helpcontent2/source)
+
+bookmarkFile=$outDir/bookmarks.js
+mkdir -p $outDir
+
+rm -f $bookmarkFile
+touch $bookmarkFile
 
-# mkdir -p $outdir
-sourcedir=`pwd`'/l10n/'$2'/'$1
-ffile=$outdir'/bookmarks.js'
-rm -f $ffile
-ffile2=/tmp/temp.html
 stub2=\'
+
 xslfile=get_bookmark.xsl
 
-param1=' --stringparam Language '$1' --stringparam productversion '$2
+param1=' --stringparam Language '$lang' --stringparam productversion '$productversion
 
 # bookmarks for modules
 
 for i in CALC CHART WRITER DRAW IMPRESS MATH BASIC
 do
 stub1='document.getElementById("bookmark'$i'").innerHTML='\'\\
-sfind=$sourcedir'/'`echo 'text/s'$i | tr '[:upper:]' '[:lower:]'`
+sfind=$sourceDir'/'$(echo 'text/s'$i | tr '[:upper:]' '[:lower:]')
 param=$param1' --stringparam app '$i
-rm -f $ffile2
-find $sfind -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $ffile2
-echo $stub1 >> $ffile
-sort -k3b -t\> -s -o $ffile2 $ffile2
-awk 'NF' $ffile2 >> $ffile
-echo $stub2 >> $ffile
+tempFile=$(mktemp)
+find $sfind -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $tempFile
+echo $stub1 >> $bookmarkFile
+sort -k3b -t\> -s -o $tempFile $tempFile
+awk 'NF' $tempFile >> $bookmarkFile
+echo $stub2 >> $bookmarkFile
+rm -f $tempFile
 done
 
 # Case of SHARED
 
 stub1='document.getElementById("bookmarkSHARED").innerHTML='\'\\
-rm -f $ffile2
+tempFile=$(mktemp)
 param=$param1' --stringparam app SHARED'
-find $sourcedir'/text/shared' -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $ffile2
-echo $stub1 >> $ffile
-sort -k3b -t\> -s -o $ffile2 $ffile2
-awk 'NF' $ffile2 >> $ffile
-echo $stub2 >> $ffile
+find $sourceDir'/text/shared' -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $tempFile
+echo $stub1 >> $bookmarkFile
+sort -k3b -t\> -s -o $tempFile $tempFile
+awk 'NF' $tempFile >> $bookmarkFile
+echo $stub2 >> $bookmarkFile
+rm -f $tempFile
 
 # Case of Explorer (BASE)
 
 stub1='document.getElementById("bookmarkBASE").innerHTML='\'\\
-rm -f $ffile2
+tempFile=$(mktemp)
 param=$param1' --stringparam app BASE'
-find $sourcedir'/text/shared/explorer/database' -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $ffile2
-echo $stub1 >> $ffile
-sort -k3b -t\> -s -o $ffile2 $ffile2
-awk 'NF' $ffile2 >> $ffile
-echo $stub2 >> $ffile
-rm -f $ffile2
+find $sourceDir'/text/shared/explorer/database' -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $tempFile
+echo $stub1 >> $bookmarkFile
+sort -k3b -t\> -s -o $tempFile $tempFile
+awk 'NF' $tempFile >> $bookmarkFile
+echo $stub2 >> $bookmarkFile
+rm -f $tempFile
+exit
diff --git a/help3xsl/get_hid2file.sh b/help3xsl/get_hid2file.sh
new file mode 100755
index 000000000..26d692c87
--- /dev/null
+++ b/help3xsl/get_hid2file.sh
@@ -0,0 +1,40 @@
+#/bin/bash
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# $1 is Product Version
+# $2 is location of $(WORKDIR)
+
+###########################################
+#
+# Create the hid2file map that mapd HIDs into
+# HTML pages. Language independent.
+# will be put in $WORKDIR/HelpTargetHTML/$productversion/
+#
+###########################################
+
+workDir=$(realpath $2)
+productversion=$1
+
+helpFiles=$(realpath $workDir/../helpcontent2/source/text)
+
+outDir=$(realpath $workDir/HelpTargetHTML/$productversion)
+mkdir -p $outDir
+
+bookmarkFile=$outDir'/hid2file.js'
+
+tempFile=$(mktemp)
+rm -f $bookmarkFile
+touch $bookmarkFile
+
+find $helpFiles -type f -name "*.xhp" -exec xsltproc get_url.xsl {} + > $tempFile
+
+echo 'var map={' >> $bookmarkFile
+awk 'NF' $tempFile >> $bookmarkFile
+echo '};' >> $bookmarkFile
+rm -f $tempFile
+exit
diff --git a/help3xsl/get_html.sh b/help3xsl/get_html.sh
new file mode 100755
index 000000000..95224c144
--- /dev/null
+++ b/help3xsl/get_html.sh
@@ -0,0 +1,49 @@
+#/bin/bash
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+###########################################
+#
+# Takes all translated xhp files and convert into HTML files
+#
+###########################################
+#
+# $1 is Language
+# $2 is productversion
+# $3 is location of $(WORKDIR)
+# $4 is local or website
+#     If local, the filetree should be $(installDir)
+#     If website, filetree should be '/'
+# $5 is filetree for local
+
+
+lang=$1
+productversion=$2
+workDir=$(realpath $3)
+offline=$4
+fileTree=$5
+
+outDir=$(realpath $workDir/HelpTargetHTML/$productversion/$lang)
+sourceDir=$(realpath $workDir/HelpTranslatePartTarget/$lang/helpcontent2/source)
+
+###########################################
+#
+# Process translated XHP files
+#
+###########################################
+
+xsltparm='--stringparam fileTree '$fileTree' --stringparam local '$offline' --stringparam Language '$lang' --stringparam productversion '$productversion' --stringparam root '$sourceDir'/'
+
+echo 'Conversion to HTML started for '$lang
+for filep in $(find $sourceDir/text -name "*.xhp")
+do
+DIR=${filep##*text/}
+name=${DIR:0:-3}
+outFile=$outDir'/text/'$name'html'
+xsltproc $xsltparm -o $outFile online_transform.xsl $filep
+done
+exit
diff --git a/help3xsl/get_media.sh b/help3xsl/get_media.sh
new file mode 100755
index 000000000..d0b7060d3
--- /dev/null
+++ b/help3xsl/get_media.sh
@@ -0,0 +1,42 @@
+#/bin/bash
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+###########################################
+#
+# add auxiliary javascript and html files
+# add media files
+# will be located in $WORKDIR/HelpTargetHTML/$productversion/
+#
+#
+###########################################
+
+# $1 is Language
+# $2 is productversion
+# $3 is location of $(WORKDIR)
+
+lang=$1
+productVersion=$2
+workDir=$(realpath $3)
+
+# copy files
+
+echo 'copy global service files'
+
+outDir=$workDir'/HelpTargetHTML/'
+
+cp index.html $outDir
+cp help.html $outDir
+cp index2.html $outDir'/'$productVersion'/index.html'
+cp help.js $outDir'/'$productVersion'/'
+cp jquery-3.1.1.min.js $outDir'/'$productVersion'/'
+cp normalize.css $outDir'/'$productVersion'/'
+cp default.css $outDir'/'$productVersion'/'
+
+cp -rap ../source/media $outDir'/'$productVersion'/'
+
+galaxy=$(realpath $workDir'/../icon-themes/galaxy')
+cp -rap $galaxy $outDir'/'$productVersion'/media/icon-themes'
diff --git a/help3xsl/get_tree.sh b/help3xsl/get_tree.sh
new file mode 100755
index 000000000..58b3f48f8
--- /dev/null
+++ b/help3xsl/get_tree.sh
@@ -0,0 +1,128 @@
+#/bin/bash
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+###########################################
+#
+# Create the tree file named contents.js
+#
+# will be located in $WORKDIR/HelpTargetHTML/$productversion/$lang
+#
+#
+###########################################
+
+# $1 is Language
+# $2 is productversion
+# $3 is location of $(WORKDIR)
+
+lang=$1
+productversion=$2
+workDir=$(realpath $3)
+
+outDir=$(realpath $workDir/HelpTargetHTML/$productversion/$lang)
+sourceDir=$(realpath $workDir/HelpTreeTarget)
+
+treeFileHTML=$outDir/contents.js
+rm -f $treeFileHTML
+touch $treeFileHTML
+
+echo 'document.getElementById("Contents").innerHTML='$'\047''\'>$treeFileHTML
+
+xsltparm='--stringparam lang '$lang' --stringparam productversion '$productversion
+
+for module in sbasic  scalc  schart  shared  simpress  smath  swriter
+do
+
+treeSourceFile=$sourceDir'/'$module'/'$lang'.tree'
+
+treeTemp2=$(mktemp)
+
+xsltproc $xsltparm -o $treeTemp2 get_tree.xsl $treeSourceFile
+
+awk 'NF' $treeTemp2>>$treeFileHTML
+
+rm -f $treeTemp2
+done
+
+echo $'\047'';'>>$treeFileHTML
+exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ALL_LANGS='en-US am ar ast bg bn bn-IN bo bs ca ca-valencia cs da de dz el en-GB en-ZA eo es et eu fi fr gl gu he hi hr hu id is it ja ka km ko lo lt lv mk nb ne nl nn om pl pt-BR pt ro ru sid si sk sl sq sv ta tg tr ug uk vi zh-CN zh-TW'
+
+here=$(pwd)
+root=$(realpath "$here/../..")
+
+rootTreex=$root
+exedir="${rootTreex}"/workdir/LinkTarget/Executable
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}"${rootTreex}"/instdir/program
+
+
+# rm -rf $here/l10n
+rm -rf $here/html
+
+
+#
+
+
+ALL_LANGS='fr pt-BR'
+ALL_TREE='sbasic.tree  scalc.tree  schart.tree  shared.tree  simpress.tree  smath.tree  swriter.tree'
+for lang in $ALL_LANGS
+do
+treePOFile=`mktemp`
+echo $root/translations/source/$lang/helpcontent2/source/auxiliary.po > $treePOFile
+outDirLang=$here/html/$productversion/$lang
+mkdir -p $outDirLang
+
+for tree in $ALL_TREE
+do
+treeSourceFile=$root'/helpcontent2/source/auxiliary/'$tree
+
+outDirLang=$here/html/$productversion/$lang/$tree
+
+"${exedir}/treex" -l $lang -i $treeSourceFile -m $treePOFile -o $outDirLang
+done
+# rm -f $treePOFile
+done
+exit
+rm -f $treeSourceFiles
+
+exit
+pofiles=/tmp/pofiles.txt
+xhpfiles=/tmp/xhpfiles.txt
+# mkdir -p $here/html
+# mkdir -p $here'/html/'$productversion
diff --git a/help3xsl/index2.html b/help3xsl/index2.html
index fb0cb76a4..adc2010e8 100644
--- a/help3xsl/index2.html
+++ b/help3xsl/index2.html
@@ -9,7 +9,7 @@
 <html>
 	<head>
 	<script type="text/javascript" src="help.js"></script>
-	<script type="text/javascript" src="bookmark2file.js"></script>
+	<script type="text/javascript" src="hid2file.js"></script>
 	</head>
 	<body>
         <script type="text/javascript">
@@ -34,7 +34,7 @@
             case "sbasic":    {defaultFile='text/sbasic/shared/main0601.html';module="BASIC";break;}
             default:          {defaultFile='text/shared/main0000.html';module="WRITER";break;}
             }
-            var bookmark = rest.slice(rest.indexOf('/')+1, rest.indexOf('?')); 
+            var bookmark = rest.slice(rest.indexOf('/')+1, rest.indexOf('?'));
             var file = map[bookmark];
             // rebuild URL
             if (file=='undefined'){
diff --git a/help3xsl/makelocal.sh b/help3xsl/makelocal.sh
new file mode 100644
index 000000000..b455a5ba7
--- /dev/null
+++ b/help3xsl/makelocal.sh
@@ -0,0 +1,24 @@
+#/bin/bash
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+productVersion=6.0
+workDir=$(realpath '../../workdir')
+langDirSource=$workDir'/HelpTranslatePartTarget'
+
+./get_hid2file.sh $productVersion $workDir
+
+for lang in $(ls $langDirSource)
+do
+./get_bookmark.sh $lang $productVersion $workDir
+./get_html.sh $lang $productVersion $workDir 'yes' '/'
+./get_tree.sh $lang $productVersion $workDir
+done
+
+./get_media.sh 'dummy' $productVersion $workDir
+
+exit
diff --git a/help3xsl/makeonline.sh b/help3xsl/makeonline.sh
new file mode 100755
index 000000000..90813de2e
--- /dev/null
+++ b/help3xsl/makeonline.sh
@@ -0,0 +1,24 @@
+#/bin/bash
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+productVersion=6.0
+workDir=$(realpath '../../workdir')
+langDirSource=$workDir'/HelpTranslatePartTarget'
+
+./get_hid2file.sh $productVersion $workDir
+
+for lang in $(ls $langDirSource)
+do
+./get_bookmark.sh $lang $productVersion $workDir
+./get_html.sh $lang $productVersion $workDir 'no' '/'
+./get_tree.sh $lang $productVersion $workDir
+done
+
+./get_media.sh 'dummy' $productVersion $workDir
+
+exit
diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl
index 2c1acefda..649671421 100644
--- a/help3xsl/online_transform.xsl
+++ b/help3xsl/online_transform.xsl
@@ -31,12 +31,15 @@
 <xsl:param name="productversion"/>
 <xsl:param name="local" />
 <xsl:param name="fileTree"/>
+<xsl:param name="root"/>
+<xsl:param name="Language"/>
+
 <xsl:param name="productname" select="'LibreOffice'"/>
 <xsl:param name="System" select="'WIN'"/>
 <xsl:param name="imgtheme" select="''"/>
 <xsl:param name="Id" />
-<xsl:param name="Language"/>
-<xsl:param name="root"/>
+
+
 
 <!-- General Usage -->
 <xsl:variable name="am" select="'&'"/>
@@ -56,7 +59,7 @@
 
 <!-- Installation -->
 <xsl:variable name="online" select="$local!='yes'"/>
-<xsl:variable name="install" select="concat('file://',$fileTree)"/>
+<xsl:variable name="install" select="$fileTree"/>
 
 <!-- meta data variables from the help file -->
 <xsl:variable name="filename" select="/helpdocument/meta/topic/filename"/>
@@ -112,14 +115,7 @@
     </xsl:variable>
 <html  lang="{$lang}">
     <head>
-        <xsl:choose>
-            <xsl:when test="$online">
-                <base href="/"/>
-            </xsl:when>
-            <xsl:otherwise>
-                 <base href="{$install}"/>
-             </xsl:otherwise>
-        </xsl:choose>
+        <base href="{$install}"/>
         <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
         <title><xsl:value-of select="$titleL10N"/></title>
         <link rel="shortcut icon" href="{$productversion}/media/navigation/favicon.ico" />


More information about the Libreoffice-commits mailing list