[Libreoffice-commits] help.git: source/default.css source/get_bookmark.sh source/get_bookmark.xsl source/HELP-IN-BROWSER-README.txt source/help.js source/help-to-html.sh source/online_transform.xsl

Olivier Hallot olivier.hallot at libreoffice.org
Tue May 30 14:12:55 UTC 2017


 source/HELP-IN-BROWSER-README.txt |   44 --------
 source/default.css                |   18 ++-
 source/get_bookmark.sh            |   47 +++++----
 source/get_bookmark.xsl           |    5 -
 source/help-to-html.sh            |   24 ++++
 source/help.js                    |  186 ++++++++++----------------------------
 source/online_transform.xsl       |  183 +++++++++++++++++++++++++------------
 7 files changed, 244 insertions(+), 263 deletions(-)

New commits:
commit 72e210bd694688738bffb6855221e2b1ff0b1e72
Author: Olivier Hallot <olivier.hallot at libreoffice.org>
Date:   Tue May 30 10:19:56 2017 -0300

    Rewrite online help contents
    
    I have worked in a new implementation of the Help online. The strategy
    was to batch "flatten" all XHP into HTML files with an offline
    transformation using xsltproc.
    
    (by "flatten", I mean resolve all embeds in XHP files)
    
    see http://vm173.documentfoundation.org
    
    This way all displayed files are now HTML with minimal javascript. No
    more on-line XSLT transformation and their associate issues (delays) and
    poor debug.
    
    Advantages:
    1) preserve all XHP files as-is, authoring tools, DTD.
    2) preserve current translation workflow
    3) all files turned to HTML static, with minimum Javascript
    4) much faster load times, browser cache  used.
    5) Honors parameters &System and &DbPAR
    6) URL bookmarking in browser (Ctrl-D)
    7) Page navigation back and forth with browser buttons
    8) preserve current HC2 in LibreOffice (see 1).
    9) resolved <switchinline><caseinline> for &System and &DbPAR (aka
    module).
    10) maintained Fabio's bookmark search solution.
    11) index-able by search engines (XHP files were unknown to robots).
    12) pages can be directly accessed: e.g.
    http://localhost/text/scalc/01/04060106.html?DbPAR=CALC#bm_id3153114
    13) hold Google search snippet in TopRight area
    
    Disadvantages (Most are further work):
    1) issue with offline use (file://path/to/pages/)
    
    To do:
    1) batch create html of localized pages, localized bookmarks
    2) Resolve missing images paths (Icons are in core/icon-themes/)
    3) Resolve protocol file:// for offline use (hit CORS guideline
    restriction for browsers)
    4) provide better layout for bookmarks in the left pane
    5) work on web CSS to make it beautiful
    6) Clean up the XSLT filter, set a debug param.
    7) more
    
    Change-Id: I6de74037dbb59da872153f853237afd75b47c917
    Reviewed-on: https://gerrit.libreoffice.org/38220
    Reviewed-by: Olivier Hallot <olivier.hallot at edx.srv.br>
    Tested-by: Olivier Hallot <olivier.hallot at edx.srv.br>

diff --git a/source/HELP-IN-BROWSER-README.txt b/source/HELP-IN-BROWSER-README.txt
index ab8f49a5d..159c13482 100644
--- a/source/HELP-IN-BROWSER-README.txt
+++ b/source/HELP-IN-BROWSER-README.txt
@@ -28,24 +28,18 @@ default.css:
 -------------
 the cascading style sheet for HTML formatting.
 
-index.html: 
------------
-The entry web page in the root folder of the server. Displays the #TopLeft <div> with links to LibreOffice modules help libraries.
-
 online_transform.xsl:
 --------------------
 the XSL transform file. Transform XHP files into HTML files.
 
 This file is a modification of xmlhelper/util/main_transform.xsl, which was designed for xmlhelp XSL processor.
 
-The XSLT online_transform.xsl is used inside help.js. 
-
 help.js
 -------
 This javascript file: 
-1. takes XHP files and online_transform.xsl and generates the HTML contents to be displayed in #DisplayArea <div>. 
+1. modifies href attributes in <a> of #DisplayArea to handle &DbPAR and &System params
 2. picks the bookmarks file and displays in #BottomLeft <div> area.
-3. displays the XHP file patch and bookmark in the #TopRight <div> area
+3. Reads URL params.
 
 -----------------------------------------------------------------
 New ‘Object’ tag
@@ -71,39 +65,9 @@ Maps to HTML5 <object> tag:
 How to build the LibreOffice Browser help 
 ----------------------------------------------------------------- 
 
-1) Media files: Media files in helpcontent2 are located in module 
-icons-themes/ . It is necessary to copy core/icon-themes/galaxy into the media/ folder 
+1) run help-to-html.sh 
 
-Note: For the moment, only Galaxy icon them is fully supported.
 
-2) Run the getbookmark.sh script to generate the bookmark index for the
-LibreOffice Modules
+2) copy folder html/ to your root web server.
 
------------------------------------------------------------------ 
-Folder layout.
------------------------------------------------------------------ 
 
-Root folder:source/
-			default.css
-			online_transform.xsl
-			index.html
-			help.js
-			jquery<version>-min.js
-			media/
-				movies/
-				screenshots/
-			text/
-
-
-Notes:
-1. the online_transform.xsl is main_transform.xsl of HC2 modified to accomodate the layout of the screen, It has 4 <div> hooked in each of the 4 corners of the browser screen to allow resizing.
-2. the lower-right <div> displays the help content
-3. the upper-left <div> has entries to change help books/modules
-4. the upper right <div> is available to place a search mechanism
-5. the lower-left <div> is available to inser a index with javascript
-6. index.html is just a top landing page.
-7. default.css is the css used in helpconten2/languages
-8. plenty of simplification/tweak is possible in the XSLT.
-9. The whole HC can be tranformed in html with XSLTPROC or any other XSL processor, provided the reference to the XSL file is fixed, and the xsl file be aware of the specifics of the XSL processor.
-10. Works with Firefox, Chrome, Rekonq.
-11. References to media are incomplete. That will require a change in the urls of the media inside the help pages, thus forking from HC2
diff --git a/source/default.css b/source/default.css
index 56d8572a3..ee9396f95 100644
--- a/source/default.css
+++ b/source/default.css
@@ -92,6 +92,10 @@ h4, h5, h6 {
   font-size: 11pt;
 }
 
+.avis {
+    background-color: #FFCCFF;
+}
+
 .relatedtopics {
   font-weight: normal;
 }
@@ -163,8 +167,6 @@ h4, h5, h6 {
 }
 
 .topmenu {
-  color: #18A303;
-  background-color: white;
   font-size: 12pt;
   font-weight: bold;
   padding: 1px;
@@ -182,7 +184,7 @@ h4, h5, h6 {
   bottom: 5px;
   right: 5px;
   left: 30%;
-  top: 10%;
+  top: 15%;
   overflow: auto;
   border: solid 1px;
   padding: 10px;
@@ -194,7 +196,7 @@ h4, h5, h6 {
   left: 5px;
   overflow: auto;
   right: 70%;
-  top: 10%;
+  top: 15%;
   border-top: solid 1px;
   border-left: solid 1px;
   border-bottom: solid 1px;
@@ -207,9 +209,9 @@ h4, h5, h6 {
   border-right: solid 1px;
   position: fixed;
   right: 5px;
-  top: 10%;
-  left: 30%;
-  bottom: 90%;
+  top: 5px;
+  left: 50%;
+  bottom: 85%;
 }
 
 #TopLeft {
@@ -219,7 +221,7 @@ h4, h5, h6 {
   left: 5px;
   position: fixed;
   top: 5px;
-  bottom: 90%;
+  bottom: 85%;
 }
 
 #NavigationHistory {
diff --git a/source/get_bookmark.sh b/source/get_bookmark.sh
index 2957cb285..4aa4e44d0 100755
--- a/source/get_bookmark.sh
+++ b/source/get_bookmark.sh
@@ -6,84 +6,95 @@
 # 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/.
 
+outdir=$1
+
 stub1='<ul class="indexlink">'
 stub2='</ul>'
-ffile=bookmark_calc.html
+ffile=$outdir'bookmark_CALC.html'
 ffile2=temp.html
+param='--stringparam app CALC'
 rm -f $ffile $ffile2
-find text/scalc -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+find text/scalc -type f -name "*.xhp" -exec xsltproc $param  get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_writer.html
+ffile=$outdir'bookmark_WRITER.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/swriter -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app WRITER'
+find text/swriter -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_draw.html
+ffile=$outdir'bookmark_DRAW.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/sdraw -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app DRAW'
+find text/sdraw -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_impress.html
+ffile=$outdir'bookmark_IMPRESS.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/simpress -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app IMPRESS'
+find text/simpress -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_shared.html
+ffile=$outdir'bookmark_SHARED.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/shared -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app SHARED'
+find text/shared -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_chart.html
+ffile=$outdir'bookmark_CHART.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/schart -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app CHART'
+find text/schart -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_math.html
+ffile=$outdir'bookmark_MATH.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/smath -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app MATH'
+find text/smath -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_basic.html
+ffile=$outdir'bookmark_BASIC.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/sbasic -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app BASIC'
+find text/sbasic -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
 echo $stub2 >> $ffile
 
-ffile=bookmark_base.html
+ffile=$outdir'bookmark_BASE.html'
 rm -f $ffile $ffile2
 touch $ffile2
-find text/shared/explorer/database -type f -name "*.xhp" -exec xsltproc get_bookmark.xsl {} + >> $ffile2
+param='--stringparam app BASE'
+find text/shared/explorer/database -type f -name "*.xhp" -exec xsltproc $param get_bookmark.xsl {} + >> $ffile2
 echo $stub1 > $ffile
 awk 'NF' $ffile2 >> $ffile
 sort -k3b -t\> -s -o $ffile $ffile
diff --git a/source/get_bookmark.xsl b/source/get_bookmark.xsl
index 6f1bd17df..e13d1b333 100644
--- a/source/get_bookmark.xsl
+++ b/source/get_bookmark.xsl
@@ -15,6 +15,7 @@ xsltproc get_bookmark.xsl file.xhp
 -->
 <xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:param name="app"/>
 
 <xsl:output indent="yes" method="html"/>
 
@@ -50,7 +51,9 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Extract the bookmarks-->
 <xsl:template match="/">
       <xsl:for-each select="//bookmark[@branch='index']">
-           <xsl:variable name="href" select="concat($filename,'#', at id)"/>
+	      <xsl:variable name="hrefhtml" select="substring-before($filename,'xhp')"/>   
+	      <xsl:variable name="href" select="concat($hrefhtml,'html?DbPAR=',$app,'#', at id)"/>
+	   
            <xsl:for-each select="bookmark_value">
 		     <li><a href="{$href}" target="_top">
                      <xsl:call-template name="brand"><xsl:with-param name="string">
diff --git a/source/help-to-html.sh b/source/help-to-html.sh
new file mode 100755
index 000000000..e7be6cbea
--- /dev/null
+++ b/source/help-to-html.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/.
+
+outdir=html/
+filter=online_transform.xsl
+rm -rf $outdir
+mkdir $outdir
+cp default.css help.js jquery-3.1.1.min.js $outdir
+cp -rap media $outdir'media'
+./get_bookmark.sh $outdir
+for filep in `find text/ -name *.xhp`
+do
+DIR=${filep%/*}
+FILEN=${filep##*/}
+name=${FILEN:0:-3}
+outfile=$outdir$DIR/$name'html'
+xsltproc -o $outfile $filter $filep
+done
+ln -s text/shared/main0108.html $outdir'index.html'
diff --git a/source/help.js b/source/help.js
index cb9cf393b..dba3baf21 100644
--- a/source/help.js
+++ b/source/help.js
@@ -7,24 +7,56 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-function loadXMLDoc(filename, handler)
-{
-    if (window.ActiveXObject)
-    {
-        xhttp = new ActiveXObject("Msxml2.XMLHTTP");
-    }
-    else
-    {
-        xhttp = new XMLHttpRequest();
-    }
-
-    xhttp.open("GET", filename);
-    xhttp.onload = handler;
-    try {
-        xhttp.responseType = "msxml-document"
-    } catch(err) {} // Helping IE11
+function setModule(module){
+var itemspan = document.getElementsByTagName("span");
+
+if (module == null){module="DEFAPP"}
+var n = itemspan.length;
+for (var i = 0; i < n; i++){
+   if (itemspan[i].getAttribute("value") == module){
+      itemspan[i].removeAttribute("hidden");
+   }
+}
+}
+function setSystem(system){
+var itemspan = document.getElementsByTagName("span");
+if (system == null){system="DEFSYS"}
+var n = itemspan.length;
+for (var i = 0; i < n; i++){
+   if (itemspan[i].getAttribute("value") == system){
+       itemspan[i].removeAttribute("hidden");
+   }
+}
+}
+/* add &DbPAR= and &System= to the links in DisplayArea div */
+function fixURL(module, system){
+  var itemlink = document.getElementById("DisplayArea").getElementsByTagName("a");
+  var n = itemlink.length;
+  var pSystem = (system == null) ? "":"&System="+system;
+  var pAppl = (module == null) ? "":"&DbPAR="+module;
+  for (var i = 0; i<n; i++) {
+      if(true){
+      var href = itemlink[i].getAttribute("href");
+      if (href != null){
+          if (!href.startsWith("http")) {
+              var pre = href.substring(0,href.indexOf('?'));
+              if (href.lastIndexOf('#') > 0){
+              var post = href.substring(href.lastIndexOf('#'),href.length);
+              }
+              else{
+                  post='';
+              }
+              var url = pre+'?'+pAppl+pSystem+post;
+              itemlink[i].setAttribute("href",url);
+          }
+      }
+  }
+  }
+}
 
-    xhttp.send();
+function displayBookmark(module){
+    if (module==null){module='WRITER'}
+    $("#BottomLeft").load('bookmark_'+module+'.html');
 }
 
 function getParameterByName(name, url) {
@@ -47,117 +79,6 @@ function getParameterByName(name, url) {
     return decodeURIComponent(results[2].replace(/\+/g, " "));
 }
 
-var navigationHistory = [];
-
-function displayXML(xml, xsl, urlVars, moduleName, language, system) {
-    var xsltProcessor;
-    var resultDocument;
-    var bookmarkHTML;
-    var module = urlVars["DbPAR"];
-    moduleName = moduleName || module;
-    var language = urlVars["Language"];
-    var system = urlVars["System"];
-    var usedb = urlVars["UseDB"];
-    document.getElementById("DisplayArea").innerHTML= null;
-    document.getElementById("BottomLeft").innerHTML= null;
-    document.getElementById("TopRight").innerHTML= null;
-
-    if (window.ActiveXObject || xhttp.responseType == "msxml-document") {
-        // code for IE
-        ex = xml.transformNode(xsl);
-        document.getElementById("DisplayArea").innerHTML = ex;
-    }
-    else if (document.implementation && document.implementation.createDocument) {
-        // code for Chrome, Firefox, Opera, etc.
-        xsltProcessor = new XSLTProcessor();
-
-        if (module){xsltProcessor.setParameter(null, "appl", module);}
-        if (language){xsltProcessor.setParameter(null, "Language", language);}
-        if (system){xsltProcessor.setParameter(null, "System", system);}
-
-        $(document).on('click', '#BottomLeft a, #DisplayArea a', function(e) {
-                e.preventDefault();
-                $('#search-bar').val('');
-
-                var fileName = $(this).attr('href');
-
-                navigationHistory.push({
-                    name: $(this).text(),
-                    fileName: fileName
-                });
-                if (navigationHistory.length > 5) {
-                  navigationHistory.shift();
-                }
-                var previousHistory = ''
-                navigationHistory.forEach(function(history) {
-                  previousHistory += '<span class="section" filename="' + history.fileName + '">' + history.name + '</span> > '
-                });
-                $('#NavigationHistory')
-                  .html('<span>' + previousHistory + '</span>');
-
-                $('#NavigationHistory span.section').click(function() {
-                  loadXMLDoc($(this).attr('filename'), function() {
-                      var xmlDoc = this.responseXML;
-                      if (xmlDoc != null) {
-                          var resultDocument = xsltProcessor.transformToFragment(xmlDoc,  document);
-                          $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html());
-                          $("#TopRight").html('<p class="bug">Contents displayed is: ' + fileName + '</p>');
-                      }
-                      else {
-                          console.log('Cannot load ' + fileName);
-                      }
-                  });
-                })
-
-
-                loadXMLDoc(fileName, function() {
-                    var xmlDoc = this.responseXML;
-                    if (xmlDoc != null) {
-                        var resultDocument = xsltProcessor.transformToFragment(xmlDoc,  document);
-                        $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html());
-                        $("#TopRight").html('<p class="bug">Contents displayed is: ' + fileName + '</p>');
-                    }
-                    else {
-                        console.log('Cannot load ' + fileName);
-                    }
-                });
-                return false;
-            });
-
-        xsltProcessor.importStylesheet(xsl);
-        resultDocument = xsltProcessor.transformToFragment(xml,  document);
-        $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html());
-        // Handle bookmar panel
-        $("#BottomLeft").load('bookmark_'+moduleName+'.html');
-        $("#TopRight").html('<p class="bug">Contents displayed is: '+$(this).attr('href')+'</p>');
-    }
-}
-
-function displayResult(file, moduleName, language, system) {
-  $('#NavigationHistory')
-    .html('');
-    // load the XSLT
-    loadXMLDoc('online_transform.xsl', function() {
-        var xsl = this.responseXML;
-
-        // load the actual XHP file
-        if (xsl != null) {
-            loadXMLDoc(file, function(){
-                var xml = this.responseXML;
-                if (xml != null) {
-                    displayXML(xml, xsl, getUrlVars(file), moduleName, language, system);
-                }
-                else {
-                    console.log('Cannot load ' + file);
-                }
-            });
-        }
-        else {
-            console.log('Cannot load online_transform.xsl');
-        }
-    });
-}
-
 var debouncer = null;
 $(document).ready(function() {
     $('#search-bar').keyup(function() {
@@ -176,13 +97,4 @@ $(document).ready(function() {
     });
 });
 
-//http://papermashup.com/read-url-get-variables-withjavascript/
-
-function getUrlVars(file) {
-    var vars = {};
-    var parts = file.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {vars[key] = value;});
-    //var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {vars[key] = value;});
-    return vars;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/source/online_transform.xsl b/source/online_transform.xsl
index 4ff8d2a26..f79bfa659 100644
--- a/source/online_transform.xsl
+++ b/source/online_transform.xsl
@@ -1,31 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
-<!--***********************************************************************
-  This is the main transformation style sheet for transforming.
-  For use with LibreOffice 4.0+
-  =========================================================================
-  Changes Log
-    May 24 2004 Created
-    Aug 24 2004 Fixed for help2 CWS
-    Aug 27 2004 Added css link, fixed missing embed-mode for variable
-                Removed width/height for images
-    Sep 03 2004 Modularized xsl, added some embedded modes
-    Oct 08 2004 Fixed bug wrong mode "embedded" for links
-                Added embedded modes for embed and embedvar (for cascaded embeds)
-                Added <p> tags around falsely embedded pars and vars
-    Dec 08 2004 #i38483#, fixed wrong handling of web links
-                #i37377#, fixed missing usage of Database parameter for switching
-    Jan 04 2005 #i38905#, fixed buggy branding replacement template
-    Mar 17 2005 #i43972#, added language info to image URL, evaluate Language parameter
-                evaluate new localize attribute in images
-    May 10 2005 #i48785#, fixed wrong setting of distrib variable
-    Aug 16 2005 workaround for #i53365#
-    Aug 19 2005 fixed missing list processing in embedded sections
-    Aug 19 2005 #i53535#, fixed wrong handling of Database parameter
-    Oct 17 2006 #i70462#, disabled sorting to avoid output of error messages to console
-    Jun 15 2009 #i101799#, fixed wrong handling of http URLs with anchors
-***********************************************************************//-->
-
 <!--
  * This file is part of the LibreOffice project.
  *
@@ -65,6 +38,7 @@
 <!-- For calculating pixel sizes -->
 <xsl:variable name="dpi" select="'96'"/>
 <xsl:variable name="dpcm" select="'38'"/>
+<xsl:variable name="dpmm" select="'3.8'"/>
 
 <!-- Product brand variables used in the help files -->
 <xsl:variable name="brand1" select="'$[officename]'"/>
@@ -99,6 +73,7 @@
 	<xsl:value-of select="translate($productversion,' ','')"/>
 </xsl:variable>
 <!-- this is were the images are -->
+
 <xsl:param name="imgtheme" select="''"/>
 <xsl:param name="Id" />
 <xsl:param name="Language" select="'en-US'"/>
@@ -111,13 +86,15 @@
   <!-- parts of help and image urls -->
 <!--<xsl:variable name="help_url_prefix" select="'vnd.sun.star.help://'"/>-->
 <xsl:variable name="help_url_prefix" select="''"/>
+<xsl:variable name="img_url_internal" select="''"/>
 <xsl:variable name="img_url_prefix" select="concat('media',$imgtheme,'/')"/>
 <!-- <xsl:variable name="img_url_prefix" select="concat('vnd.libreoffice.image://',$imgtheme,'/')"/> -->
 <!--<xsl:variable name="urlpost" select=""/>-->
 <xsl:variable name="urlpost" select="concat('?Language=',$lang,$am,'System=',$System,$am,'UseDB=no')"/>
 <xsl:variable name="urlpre" select="$help_url_prefix" />
 <xsl:variable name="linkprefix" select="$urlpre"/>
-<xsl:variable name="linkpostfix" select="$urlpost"/>
+<!--<xsl:variable name="linkpostfix" select="$urlpost"/>-->
+<xsl:variable name="linkpostfix" select="'?'"/>
 
 
 <xsl:variable name="css" select="'default.css'"/>
@@ -130,6 +107,7 @@
 <!--<xsl:variable name="note_img" select="concat($img_url_prefix,$lang,'res/helpimg/note.png')"/>
 <xsl:variable name="tip_img" select="concat($img_url_prefix,'res/helpimg/tip.png')"/>
 <xsl:variable name="warning_img" select="concat($img_url_prefix,'res/helpimg/warning.png')"/>-->
+
 <!--
 #############
 # Templates #
@@ -138,9 +116,81 @@
 
 <!-- Create the document skeleton -->
 <xsl:template match="/">
-               <div id="DisplayArea">
-                    <xsl:apply-templates select="/helpdocument/body"/>
-               </div>
+	<!--<xsl:variable name="csslink" select="concat($urlpre,'/',$urlpost)"/>-->
+	<xsl:variable name="csslink" select="concat($urlpre,'default.css')"/>
+        <xsl:variable name="bookmarkref" select="concat('bookmark_',$appl,'.html')"/>
+	<html>
+		<head>
+		        <!--<base href="file:///home/olivier/tmp/help/source/h/"/>-->
+		        <base href="/"/>
+			<title><xsl:value-of select="$title"/></title>
+			<link href="{$csslink}" rel="Stylesheet" type="text/css" />
+			<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
+                        <script type="text/javascript" src="help.js"></script>
+  		<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
+		</head>
+		<body lang="{$lang}">
+                   <div id="DisplayArea">
+			<xsl:apply-templates select="/helpdocument/body"/>
+                        <div class="debug">
+                            <h3>Help content debug info:</h3>
+                            <p class="bug">This page is: <xsl:value-of select="$filename"/></p>
+                            <p>Title is: <xsl:value-of select="$title"/></p>
+                            <p id="bm_module"></p>
+                            <p id="bm_system"></p>
+                        </div>
+                   </div>
+                   <div id="BottomLeft"></div>
+                   <div id="TopRight">
+                       <script type="text/javascript">
+                       <![CDATA[
+                           (function() {
+                             var cx = '010161382024564278136:jcdsgegjym8';
+                             var gcse = document.createElement('script');
+                             gcse.type = 'text/javascript';
+                             gcse.async = true;
+                             gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
+                             var  s = document.getElementsByTagName('script')[0];
+                             s.parentNode.insertBefore(gcse, s);
+                           })();
+                       ]]>
+                       </script>
+                       <xsl:text disable-output-escaping="yes"><gcse:search></gcse:search></xsl:text>
+                   </div>
+                   <div id="TopLeft">
+                      <table>
+                        <tr>
+                            <td class="topmenu"><a href="text/scalc/main0000.html?DbPAR=CALC">Calc</a></td>
+                            <td class="topmenu"><a href="text/swriter/main0000.html?DbPAR=WRITER">Writer</a></td>
+                            <td class="topmenu"><a href="text/simpress/main0000.html?DbPAR=IMPRESS">Impress</a></td>
+                            <td class="topmenu"><a href="text/sdraw/main0000.html?DbPAR=DRAW">Draw</a></td>
+                            <td class="topmenu"><a href="text/schart/main0000.html?DbPAR=CHART">Chart</a></td>
+                            <td class="topmenu"><a href="text/sbasic/shared/main0601.html?DbPAR=BASIC">Basic</a></td>
+                            <td class="topmenu"><a href="text/smath/main0000.html?DbPAR=MATH">Math</a></td>
+                            <td class="topmenu"><a href="text/shared/explorer/database/main.html?DbPAR=BASE">Base</a></td>
+                            <td class="topmenu"><a href="text/shared/guide/main.html?DbPAR=SHARED">Guide</a></td>
+                        </tr>
+                      </table>
+                      <p>Search: <input type="text" id="search-bar"/></p>
+                 </div>
+                 <script type="text/javascript">
+<![CDATA[
+if (window.location.href.indexOf('?')) {
+var module = getParameterByName("DbPAR");
+displayBookmark(module);
+setModule(module);
+var system = getParameterByName("System");
+setSystem(system);
+document.getElementById("bm_module").innerHTML ="Module is: "+module;
+document.getElementById("bm_system").innerHTML ="System is: "+system;
+fixURL(module,system);
+} else {
+window.open('text/shared/main0108.html?System=DEFSYS&DbPAR=WRITER','_self');
+}
+]]>
+                 </script>
+                 </body>
+	</html>
 </xsl:template>
 
 <!-- AHELP -->
@@ -402,7 +452,8 @@
 
 			<xsl:when test="@id='relatedtopics'">
 				<div class="relatedtopics">
-					<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
+					<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>-->
+					<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'text/shared/00/00000004.xhp')"/></xsl:variable>
 					<xsl:variable name="anchor"><xsl:value-of select="'related'"/></xsl:variable>
 					<xsl:variable name="doc" select="document($href)"/>
 					<p class="related">
@@ -581,7 +632,8 @@
 <xsl:template name="insert_howtoget">
 	<xsl:param name="linkhref" />
 	<xsl:variable name="archive" select="'shared'"/>
-	<xsl:variable name="tmp_href"><xsl:value-of select="concat($urlpre,'text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
+	<!--<xsl:variable name="tmp_href"><xsl:value-of select="concat($urlpre,'text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>-->
+	<xsl:variable name="tmp_href"><xsl:value-of select="concat($urlpre,'text/shared/00/00000004.xhp')"/></xsl:variable>
 	<xsl:variable name="tmp_doc" select="document($tmp_href)"/>
 	<table class="howtoget" width="100%" border="1" cellpadding="3" cellspacing="0">
 		<tr>
@@ -595,7 +647,8 @@
 					<xsl:otherwise> <!-- old style -->
 						<xsl:variable name="archive1"><xsl:value-of select="concat(substring-before(substring-after($linkhref,'text/'),'/'),'/')"/></xsl:variable>
 						<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive1,substring-before($linkhref,'#'),$urlpost)"/></xsl:variable>-->
-						<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before($linkhref,'#'),$urlpost)"/></xsl:variable>
+						<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before($linkhref,'#'),$urlpost)"/></xsl:variable>-->
+						<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before($linkhref,'#'))"/></xsl:variable>
 						<xsl:variable name="anc"><xsl:value-of select="substring-after($linkhref,'#')"/></xsl:variable>
 						<xsl:variable name="docum" select="document($href)"/>
 
@@ -624,13 +677,16 @@
 		<xsl:when test="contains(@href,'#')">
 			<xsl:variable name="anchor"><xsl:value-of select="concat('#',substring-after(@href,'#'))"/></xsl:variable>
 			<!--<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,substring-before(@href,'#'),$linkpostfix,$dbpostfix,$anchor)"/></xsl:variable>-->
-			<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,substring-before(@href,'#'),$linkpostfix,$dbpostfix,$anchor)"/></xsl:variable>
+			<!--<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,substring-before(@href,'#'),$linkpostfix,$dbpostfix,$anchor)"/></xsl:variable>-->
+			<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,substring-before(@href, 'xhp'),'html',$anchor,$linkpostfix)"/></xsl:variable>
 			<a href="{$href}"><xsl:apply-templates /></a>
 		</xsl:when>
 		<xsl:otherwise>
 			<!--<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive, at href,$linkpostfix,$dbpostfix)"/></xsl:variable>-->
 			<!--<xsl:variable name="href"><xsl:value-of select="concat($linkprefix, at href,$linkpostfix,$dbpostfix)"/></xsl:variable>-->
-			<xsl:variable name="href"><xsl:value-of select="concat($linkprefix, at href,$linkpostfix,$dbpostfix)"/></xsl:variable>
+			
+			<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,substring-before(@href, 'xhp'),'html',$linkpostfix)"/></xsl:variable>
+			
 			<a href="{$href}"><xsl:apply-templates /></a>
 		<!--	<span class="hotlink" onclick="javascript:displayResult('{$href}')"><xsl:apply-templates /></span>-->
 		</xsl:otherwise>
@@ -649,7 +705,9 @@
 	</xsl:variable>
 	<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="'shared'"/></xsl:call-template></xsl:variable>
 	<xsl:variable name="alt">
-		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/',$alttext,$urlpost,$dbpostfix)"/></xsl:variable>
+		<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/',$alttext,$urlpost,$dbpostfix)"/></xsl:variable>-->
+		<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/',$alttext)"/></xsl:variable>-->
+		<xsl:variable name="href"><xsl:value-of select="$alttext"/></xsl:variable>
 		<xsl:variable name="anchor"><xsl:value-of select="concat('alt_',$type)"/></xsl:variable>
 		<xsl:variable name="doc" select="document($href)"/>
 		<xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
@@ -691,40 +749,40 @@
 	<xsl:param name="embedded" />
 	<xsl:choose>
 		<xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
-			<xsl:if test="@select = $System">
+			<!--<xsl:if test="@select = $System">-->
 				<xsl:choose>
 					<xsl:when test="$embedded = 'yes'">
-						<xsl:apply-templates mode="embedded"/>
+						<span hidden="true" itemprop="system" value="{@select}"><xsl:apply-templates mode="embedded"/></span>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:apply-templates />
+						<span  hidden="true" itemprop="system" value="{@select}"><xsl:apply-templates /></span>
 					</xsl:otherwise>
 				</xsl:choose>
-			</xsl:if>
+			<!--</xsl:if>-->
 		</xsl:when>
 		<xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
-			<xsl:if test="@select = $appl">
+			<!--<xsl:if test="@select = $appl">-->
 				<xsl:choose>
 					<xsl:when test="$embedded = 'yes'">
-						<xsl:apply-templates mode="embedded"/>
+						<span  hidden="true" itemprop="appl" value="{@select}"><xsl:apply-templates mode="embedded"/></span>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:apply-templates />
+						<span  hidden="true" itemprop="appl" value="{@select}"><xsl:apply-templates /></span>
 					</xsl:otherwise>
 				</xsl:choose>
-			</xsl:if>
+			<!--</xsl:if>-->
 		</xsl:when>
 		<xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
-			<xsl:if test="@select = $distrib">
+			<!--<xsl:if test="@select = $distrib">-->
 				<xsl:choose>
 					<xsl:when test="$embedded = 'yes'">
-						<xsl:apply-templates mode="embedded"/>
+						<span  hidden="true" itemprop="distrib" value="{@select}"><xsl:apply-templates mode="embedded"/></span>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:apply-templates />
+						<span  hidden="true" itemprop="distrib" value="{@select}"><xsl:apply-templates /></span>
 					</xsl:otherwise>
 				</xsl:choose>
-			</xsl:if>
+			<!--</xsl:if>-->
 		</xsl:when>
 	</xsl:choose>
 </xsl:template>
@@ -732,16 +790,15 @@
 <!-- Evaluate a default or defaultinline switch -->
 <xsl:template name="insertdefault">
 	<xsl:param name="embedded" />
-
 	<xsl:choose>
 		<xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
 			<xsl:if test="not(../child::case[@select=$System]) and not(../child::caseinline[@select=$System])">
 				<xsl:choose>
 					<xsl:when test="$embedded = 'yes'">
-						<xsl:apply-templates mode="embedded"/>
+						<span hidden="true" itemprop="system" value="DEFSYS"><xsl:apply-templates mode="embedded"/></span>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:apply-templates />
+						<span hidden="true" itemprop="system" value="DEFSYS"><xsl:apply-templates /></span>
 					</xsl:otherwise>
 				</xsl:choose>
 			</xsl:if>
@@ -750,10 +807,10 @@
 			<xsl:if test="not(../child::case[@select=$appl]) and not(../child::caseinline[@select=$appl])">
 				<xsl:choose>
 					<xsl:when test="$embedded = 'yes'">
-						<xsl:apply-templates mode="embedded"/>
+						<span hidden="true" itemprop="appl" value="DEFAPP"><xsl:apply-templates mode="embedded"/></span>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:apply-templates />
+						<span hidden="true" itemprop="appl" value="DEFAPP"><xsl:apply-templates /></span>
 					</xsl:otherwise>
 				</xsl:choose>
 			</xsl:if>
@@ -762,10 +819,10 @@
 			<xsl:if test="not(../child::case[@select=$distrib]) and not(../child::caseinline[@select=$distrib])">
 				<xsl:choose>
 					<xsl:when test="$embedded = 'yes'">
-						<xsl:apply-templates mode="embedded"/>
+						<span hidden="true" itemprop="distrib" value="DEFDIST"><xsl:apply-templates mode="embedded"/></span>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:apply-templates />
+						<span hidden="true" itemprop="distrib" value="DEFDIST"><xsl:apply-templates /></span>
 					</xsl:otherwise>
 				</xsl:choose>
 			</xsl:if>
@@ -802,7 +859,10 @@
 <xsl:template name="insertimage">
   <xsl:variable name="src">
     <xsl:choose>
-      <xsl:when test="not($ExtensionId='') and starts-with(@src,$ExtensionId)">
+     <xsl:when test="starts-with(@src,'media/')">
+          <xsl:value-of select="concat($img_url_internal, at src)"/>
+     </xsl:when>
+    <xsl:when test="not($ExtensionId='') and starts-with(@src,$ExtensionId)">
         <xsl:value-of select="concat($ExtensionPath,'/', at src)"/>
       </xsl:when>
       <xsl:otherwise>
@@ -867,6 +927,9 @@
                 <xsl:when test="contains($value, 'cm')">
                      <xsl:value-of select="concat(round(number(substring-before($value, 'cm')) * $dpcm),'px')"/>
                 </xsl:when>
+                <xsl:when test="contains($value, 'mm')">
+                     <xsl:value-of select="concat(round(number(substring-before($value, 'mm')) * $dpmm),'px')"/>
+                </xsl:when>
                 <xsl:when test="contains($value, 'in')">
                      <xsl:value-of select="concat(round(number(substring-before($value, 'in')) * $dpi),'px')"/>
                 </xsl:when>
@@ -929,7 +992,8 @@
 		<xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
 		<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
 		<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>-->
-		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>
+		<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>-->
+		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'))"/></xsl:variable>
 		<xsl:variable name="anc"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
 		<xsl:variable name="docum" select="document($href)"/>
 <!--		<p>Archive: <xsl:value-of select="$archive"/></p>
@@ -951,7 +1015,8 @@
 		<xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
 		<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
 		<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>-->
-		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>
+		<!--<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>-->
+		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'))"/></xsl:variable>
 		<xsl:variable name="anchor"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
 		<xsl:variable name="doc" select="document($href)"/>
 		<xsl:choose>


More information about the Libreoffice-commits mailing list