diff options
author | Olivier Hallot <olivier.hallot@libreoffice.org> | 2017-12-21 19:22:29 -0200 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2017-12-22 00:30:25 +0100 |
commit | 0e5a56e81f63d2705f1083acda4b2d899783fdcd (patch) | |
tree | a2e6a246ff681d6e419a574e2bb20bacfb1d98c1 | |
parent | bb3fd71d51c84aa93df51c9e66d2dc0d1596d1a9 (diff) |
Relativise <base href="/"> wrt file position
Now <base href="/"> is changed to
<base href="../../../ (...) ../" to allow links to
operate with http:// and file:// protocol
Drop param from makefile too
Change-Id: I1aea5b9c564bdfe395e95400ecf87e068a5a7c86
Reviewed-on: https://gerrit.libreoffice.org/46932
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Tested-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r-- | CustomTarget_html.mk | 1 | ||||
-rw-r--r-- | help3xsl/online_transform.xsl | 108 |
2 files changed, 63 insertions, 46 deletions
diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk index 4c45dc44f4..85ae29b2a5 100644 --- a/CustomTarget_html.mk +++ b/CustomTarget_html.mk @@ -99,7 +99,6 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \ && find text -name "*.xhp" \ | while read xhp; do \ $(call gb_ExternalExecutable_get_command,xsltproc) \ - --stringparam fileTree '/' \ --stringparam Language $* \ --stringparam local $(if $(HELP_ONLINE),'no','yes') \ --stringparam root `pwd`/ \ diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl index 6496714215..1551a20382 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -30,7 +30,6 @@ <xsl:param name="productversion"/> <xsl:param name="local" /> -<xsl:param name="fileTree"/> <xsl:param name="root"/> <xsl:param name="Language"/> @@ -59,7 +58,6 @@ <!-- Installation --> <xsl:variable name="online" select="$local!='yes'"/> -<xsl:variable name="install" select="$fileTree"/> <!-- meta data variables from the help file --> <xsl:variable name="filename" select="/helpdocument/meta/topic/filename"/> @@ -113,6 +111,11 @@ <xsl:variable name="titleL10N"> <xsl:call-template name="brand"><xsl:with-param name="string"><xsl:value-of select="$title"/></xsl:with-param></xsl:call-template> </xsl:variable> + <xsl:variable name="install"> + <xsl:call-template name="tokenize"> + <xsl:with-param name="str" select="$filename"/> + </xsl:call-template> + </xsl:variable> <html lang="{$lang}"> <head> <base href="{$install}"/> @@ -299,15 +302,14 @@ <xsl:when test="$online"> <script type="text/javascript"> <![CDATA[ - var userLang = navigator.language || navigator.userLanguage; + var userLang = navigator.language || navigator.userLanguage; var module = getParameterByName("DbPAR"); setModule(module); var system = getParameterByName("System"); setSystem(system); fixURL(module,system); var dbg = getParameterByName("Debug"); - if (dbg == null){dbg=1} - //dbg=1 + if (dbg == null){dbg=0} document.getElementById("DEBUG").style.display = (dbg == 0) ? "none":"block"; document.getElementById("bm_module").innerHTML ="Module is: "+module; document.getElementById("bm_system").innerHTML ="System is: "+system; @@ -1089,56 +1091,56 @@ <!-- Insert a Table --> <xsl:template name="inserttable"> - <xsl:variable name="imgsrc"> <!-- see if we are in an image table --> - <xsl:value-of select="tablerow/tablecell[1]/paragraph[1]/image/@src"/> - </xsl:variable> + <xsl:variable name="imgsrc"> <!-- see if we are in an image table --> + <xsl:value-of select="tablerow/tablecell[1]/paragraph[1]/image/@src"/> + </xsl:variable> - <xsl:choose> - <xsl:when test="count(descendant::tablecell)=1"> - <table border="0" class="onecell" cellpadding="0" cellspacing="0"> - <xsl:apply-templates /> - </table> - </xsl:when> + <xsl:choose> + <xsl:when test="count(descendant::tablecell)=1"> + <table border="0" class="onecell" cellpadding="0" cellspacing="0"> + <xsl:apply-templates /> + </table> + </xsl:when> - <xsl:when test="descendant::tablecell[1]/descendant::image"> - <table border="0" class="icontable" cellpadding="5" cellspacing="0"> - <xsl:apply-templates mode="icontable"/> - </table> - </xsl:when> + <xsl:when test="descendant::tablecell[1]/descendant::image"> + <table border="0" class="icontable" cellpadding="5" cellspacing="0"> + <xsl:apply-templates mode="icontable"/> + </table> + </xsl:when> - <xsl:when test="@class='wide'"> - <table border="1" class="{@class}" cellpadding="0" cellspacing="0" width="100%" > - <xsl:apply-templates /> - </table> - </xsl:when> + <xsl:when test="@class='wide'"> + <table border="1" class="{@class}" cellpadding="0" cellspacing="0" width="100%" > + <xsl:apply-templates /> + </table> + </xsl:when> - <xsl:when test="not(@class='')"> - <table border="1" class="{@class}" cellpadding="0" cellspacing="0" > - <xsl:apply-templates /> - </table> - </xsl:when> + <xsl:when test="not(@class='')"> + <table border="1" class="{@class}" cellpadding="0" cellspacing="0" > + <xsl:apply-templates /> + </table> + </xsl:when> - <xsl:otherwise> - <table border="1" class="border" cellpadding="0" cellspacing="0" > - <xsl:apply-templates /> - </table> - </xsl:otherwise> - </xsl:choose> - <br/> + <xsl:otherwise> + <table border="1" class="border" cellpadding="0" cellspacing="0" > + <xsl:apply-templates /> + </table> + </xsl:otherwise> + </xsl:choose> + <br/> </xsl:template> <xsl:template name="resolveembed"> - <div class="embedded"> - <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)"/> + <div class="embedded"> + <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)"/> - <xsl:call-template name="insertembed"> - <xsl:with-param name="doc" select="$docum" /> - <xsl:with-param name="anchor" select="$anc" /> - </xsl:call-template> + <xsl:call-template name="insertembed"> + <xsl:with-param name="doc" select="$docum" /> + <xsl:with-param name="anchor" select="$anc" /> + </xsl:call-template> - </div> + </div> </xsl:template> <xsl:template name="resolveembedvar"> @@ -1177,4 +1179,20 @@ <xsl:value-of select="concat(substring-before($file,'.xhp'),'.html')"/> </xsl:template> +<!-- recursive named template --> +<xsl:template name="tokenize"> + <xsl:param name="str" /> + <xsl:param name="result" select="''" /> + <xsl:choose> + <xsl:when test="substring-after($str,'/')"> + <xsl:call-template name="tokenize"> + <xsl:with-param name="str" select="substring-after($str,'/')" /> + <xsl:with-param name="result" select="concat($result,'../')" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('../',$result)" /> + </xsl:otherwise> + </xsl:choose> +</xsl:template> </xsl:stylesheet> |