diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-31 16:07:28 +0300 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2020-02-10 02:34:34 +0100 |
commit | 96f1ee8417e4d6c7134e13ab86ac55e52f1bc841 (patch) | |
tree | a83046f8a02d0511eac775c566b7817a338ddc38 /help3xsl | |
parent | b6e3324d71cd4b17cd9384b43b762fb10ce92343 (diff) |
Don't hardcode version in links in online help
... so that when current page URL is like
https://help.libreoffice.org/latest/en-US/text/shared/05/new_help.html
links from it will lead to other pages under 'latest', not to
https://help.libreoffice.org/6.3/...
The problem reason was that in online help, HTML referred to resources
with relative URLs starting with version number, like
'href="6.3/media/navigation/favicon.ico"'. The links didn't include the
version level in local help: 'href="media/navigation/favicon.ico"'.
This was naturally accompanied by <base href="../../../../../"> (online)
and '<base href="../../../../">' (local), coming from "tokenize" in
help3xsl/online_transform.xsl.
This unifies online help behaviour with that of local help.
Change-Id: I486cbfbd680d52d00ef99ade9af5ecac2967c115
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/87768
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'help3xsl')
-rw-r--r-- | help3xsl/get_bookmark.xsl | 9 | ||||
-rw-r--r-- | help3xsl/get_tree.xsl | 10 | ||||
-rw-r--r-- | help3xsl/help2.js | 22 | ||||
-rw-r--r-- | help3xsl/online_transform.xsl | 73 |
4 files changed, 45 insertions, 69 deletions
diff --git a/help3xsl/get_bookmark.xsl b/help3xsl/get_bookmark.xsl index 692ded0ffe..c53a559596 100644 --- a/help3xsl/get_bookmark.xsl +++ b/help3xsl/get_bookmark.xsl @@ -22,13 +22,6 @@ xsltproc get_bookmark.xsl <file.xhp> <xsl:param name="productversion"/> <xsl:output indent="yes" method="text"/> -<xsl:variable name="online" select="$local!='yes'"/> -<xsl:variable name="target"> - <xsl:choose> - <xsl:when test="$online"><xsl:value-of select="concat($productversion,'/')"/></xsl:when> - <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise> - </xsl:choose> -</xsl:variable> <!-- ############################ @@ -61,7 +54,7 @@ xsltproc get_bookmark.xsl <file.xhp> <xsl:template match="/"> <xsl:for-each select="//bookmark[@branch='index']"> <xsl:variable name="hrefhtml" select="substring-before($filename,'xhp')"/> - <xsl:variable name="href" select="concat($target,$Language,'/',$hrefhtml,'html?DbPAR=',$app,'#',@id)"/> + <xsl:variable name="href" select="concat($Language,'/',$hrefhtml,'html?DbPAR=',$app,'#',@id)"/> <xsl:for-each select="bookmark_value"> <xsl:text disable-output-escaping="yes"><![CDATA[{url:"]]></xsl:text> <xsl:value-of select="$href"/> diff --git a/help3xsl/get_tree.xsl b/help3xsl/get_tree.xsl index d1cf965e12..df264d1b57 100644 --- a/help3xsl/get_tree.xsl +++ b/help3xsl/get_tree.xsl @@ -30,14 +30,6 @@ xsltproc get_tree.xsl <file.tree> <xsl:variable name="brand3" select="'%PRODUCTNAME'"/> <xsl:variable name="brand4" select="'%PRODUCTVERSION'"/> -<xsl:variable name="online" select="$local!='yes'"/> -<xsl:variable name="target"> - <xsl:choose> - <xsl:when test="$online"><xsl:value-of select="concat($productversion,'/')"/></xsl:when> - <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise> - </xsl:choose> -</xsl:variable> - <!-- ############# # Templates # @@ -57,7 +49,7 @@ xsltproc get_tree.xsl <file.tree> <xsl:template match="topic"> <xsl:variable name="htmlpage"> - <xsl:value-of select="concat($target,$lang,'/',substring-before(substring-after(@id,'/'),'.xhp'),'.html','?DbPAR=',$module)" /> + <xsl:value-of select="concat($lang,'/',substring-before(substring-after(@id,'/'),'.xhp'),'.html','?DbPAR=',$module)" /> </xsl:variable> <![CDATA[<li><a target="_top" href="]]><xsl:value-of select="$htmlpage"/><![CDATA[">]]><xsl:call-template name="replace"><xsl:with-param name="text"><xsl:value-of select="."/></xsl:with-param></xsl:call-template><![CDATA[</a></li>\]]> </xsl:template> diff --git a/help3xsl/help2.js b/help3xsl/help2.js index a1739eeaf0..8c2b60d725 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -154,29 +154,29 @@ function existingLang(lang) { return 'en-US'; } -function setupModules(target, lang) { +function setupModules(lang) { var modulesNav = document.getElementById('modules-nav'); if (!modulesNav.classList.contains('loaded')) { var html = - '<a href="' + target + lang + '/text/swriter/main0000.html?DbPAR=WRITER"><div class="writer-icon"></div>Writer</a>' + - '<a href="' + target + lang + '/text/scalc/main0000.html?DbPAR=CALC"><div class="calc-icon"></div>Calc</a>' + - '<a href="' + target + lang + '/text/simpress/main0000.html?DbPAR=IMPRESS"><div class="impress-icon"></div>Impress</a>' + - '<a href="' + target + lang + '/text/sdraw/main0000.html?DbPAR=DRAW"><div class="draw-icon"></div>Draw</a>' + - '<a href="' + target + lang + '/text/shared/explorer/database/main.html?DbPAR=BASE"><div class="base-icon"></div>Base</a>' + - '<a href="' + target + lang + '/text/smath/main0000.html?DbPAR=MATH"><div class="math-icon"></div>Math</a>' + - '<a href="' + target + lang + '/text/schart/main0000.html?DbPAR=CHART"><div class="chart-icon"></div>Chart</a>' + - '<a href="' + target + lang + '/text/sbasic/shared/main0601.html?DbPAR=BASIC"><div class="basic-icon"></div>Basic</a>'; + '<a href="' + lang + '/text/swriter/main0000.html?DbPAR=WRITER"><div class="writer-icon"></div>Writer</a>' + + '<a href="' + lang + '/text/scalc/main0000.html?DbPAR=CALC"><div class="calc-icon"></div>Calc</a>' + + '<a href="' + lang + '/text/simpress/main0000.html?DbPAR=IMPRESS"><div class="impress-icon"></div>Impress</a>' + + '<a href="' + lang + '/text/sdraw/main0000.html?DbPAR=DRAW"><div class="draw-icon"></div>Draw</a>' + + '<a href="' + lang + '/text/shared/explorer/database/main.html?DbPAR=BASE"><div class="base-icon"></div>Base</a>' + + '<a href="' + lang + '/text/smath/main0000.html?DbPAR=MATH"><div class="math-icon"></div>Math</a>' + + '<a href="' + lang + '/text/schart/main0000.html?DbPAR=CHART"><div class="chart-icon"></div>Chart</a>' + + '<a href="' + lang + '/text/sbasic/shared/main0601.html?DbPAR=BASIC"><div class="basic-icon"></div>Basic</a>'; modulesNav.innerHTML = html; modulesNav.classList.add('loaded'); } } -function setupLanguages(target, page) { +function setupLanguages(page) { var langNav = document.getElementById('langs-nav'); if (!langNav.classList.contains('loaded')) { var html = ''; languagesSet.forEach(function(lang) { - html += '<a href="' + target + lang + page + '">' + ((lang in languageNames)? languageNames[lang]: lang) + '</a>'; + html += '<a href="' + lang + page + '">' + ((lang in languageNames)? languageNames[lang]: lang) + '</a>'; }); langNav.innerHTML = html; langNav.classList.add('loaded'); diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl index f22262780c..9daccd5422 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -57,12 +57,6 @@ <!-- Installation --> <xsl:variable name="online" select="$local!='yes'"/> -<xsl:variable name="target"> - <xsl:choose> - <xsl:when test="$online"><xsl:value-of select="concat($productversion,'/')"/></xsl:when> - <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise> - </xsl:choose> -</xsl:variable> <!-- meta data variables from the help file --> <xsl:variable name="filename" select="/helpdocument/meta/topic/filename"/> @@ -84,11 +78,11 @@ <!-- parts of help and image urls --> -<xsl:variable name="img_url_prefix" select="concat($target,'media',$imgtheme,'/')"/> +<xsl:variable name="img_url_prefix" select="concat('media',$imgtheme,'/')"/> <xsl:variable name="urlpost" select="concat('?Language=',$lang,$am,'System=',$System,$am,'UseDB=no')"/> -<xsl:variable name="linkprefix" select="concat($target,$lang,'/')"/> +<xsl:variable name="linkprefix" select="concat($lang,'/')"/> <!--<xsl:variable name="linkpostfix" select="$urlpost"/>--> <xsl:variable name="linkpostfix" select="''"/> @@ -145,21 +139,21 @@ <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' piwik.documentfoundation.org"/> </xsl:if> <title><xsl:value-of select="$titleL10N"/></title> - <link rel="shortcut icon" href="{$target}media/navigation/favicon.ico"/> - <link type="text/css" href="{$target}normalize.css" rel="Stylesheet"/> - <link type="text/css" href="{$target}default.css" rel="Stylesheet"/> - <link type="text/css" href="{$target}prism.css" rel="Stylesheet"/> - <script type="text/javascript" src="{$target}polyfills.js"></script> - <script type="text/javascript" src="{$target}languages.js"></script> - <script type="text/javascript" src="{$target}fuzzysort.js"></script> - <script type="text/javascript" src="{$target}prism.js"></script> - <script type="text/javascript" src="{$target}help2.js" defer=""></script> - <script type="text/javascript" src="{$target}a11y-toggle.js" defer=""></script> - <script type="text/javascript" src="{$target}{$lang}/langnames.js" defer=""></script> - <script type="text/javascript" src="{$target}paginathing.js" defer=""></script> - <script type="text/javascript" src="{$target}{$lang}/bookmarks.js" defer=""></script> - <script type="text/javascript" src="{$target}{$lang}/contents.js" defer=""></script> - <script type="text/javascript" src="{$target}help.js" defer=""></script> + <link rel="shortcut icon" href="media/navigation/favicon.ico"/> + <link type="text/css" href="normalize.css" rel="Stylesheet"/> + <link type="text/css" href="default.css" rel="Stylesheet"/> + <link type="text/css" href="prism.css" rel="Stylesheet"/> + <script type="text/javascript" src="polyfills.js"></script> + <script type="text/javascript" src="languages.js"></script> + <script type="text/javascript" src="fuzzysort.js"></script> + <script type="text/javascript" src="prism.js"></script> + <script type="text/javascript" src="help2.js" defer=""></script> + <script type="text/javascript" src="a11y-toggle.js" defer=""></script> + <script type="text/javascript" src="{$lang}/langnames.js" defer=""></script> + <script type="text/javascript" src="paginathing.js" defer=""></script> + <script type="text/javascript" src="{$lang}/bookmarks.js" defer=""></script> + <script type="text/javascript" src="{$lang}/contents.js" defer=""></script> + <script type="text/javascript" src="help.js" defer=""></script> <meta name="viewport" content="width=device-width,initial-scale=1"/> </head> <body itemscope="true" itemtype="http://schema.org/TechArticle"> @@ -173,21 +167,21 @@ <div class="header-extrawurst"> <header> <div class="logo-container"> - <a class="logo" href="{$target}{$lang}/text/shared/05/new_help.html"> + <a class="logo" href="{$lang}/text/shared/05/new_help.html"> <div class="symbol"></div> <p><xsl:value-of select="$ui_logo"/></p> </a> </div> </header> <div class="modules"> - <button type="button" data-a11y-toggle="modules-nav" id="modules" onclick="setupModules('{$target}', '{$lang}');"> + <button type="button" data-a11y-toggle="modules-nav" id="modules" onclick="setupModules('{$lang}');"> <xsl:value-of select="$ui_module"/> </button> <nav id="modules-nav"/><!-- is filled in via setupModules() on demand --> </div> <xsl:if test="$online"> <div class="lang"> - <button type="button" data-a11y-toggle="langs-nav" id="langs" onclick="setupLanguages('{$target}', '{$htmlpage}');"> + <button type="button" data-a11y-toggle="langs-nav" id="langs" onclick="setupLanguages('{$htmlpage}');"> <xsl:value-of select="$ui_language"/> </button> <nav id="langs-nav"/><!-- is filled in via setupLanguages() on demand --> @@ -1110,16 +1104,16 @@ <xsl:variable name="tmp1" select="substring-after(@src, '/ui/')"/> <xsl:variable name="tmp2" select="substring-before($tmp1,'/')"/> <xsl:variable name="tmp3" select="substring-after($tmp1,'/')"/> - <xsl:value-of select="concat($target,$tmp0,'/ui/', $tmp2, '/',$lang,'/',$tmp3)"/> + <xsl:value-of select="concat($tmp0,'/ui/', $tmp2, '/',$lang,'/',$tmp3)"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($target,@src)"/> + <xsl:value-of select="@src"/> </xsl:otherwise> </xsl:choose> </xsl:when> <!-- generic media file --> <xsl:when test="starts-with(@src,'media/')"> - <xsl:value-of select="concat($target,@src)"/> + <xsl:value-of select="@src"/> </xsl:when> <!-- handle icons --> <xsl:when test="not(starts-with(@src,'media/'))"> @@ -1136,10 +1130,10 @@ </xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:value-of select="concat($target,'media/icon-themes/',$aux00)"/> + <xsl:value-of select="concat('media/icon-themes/',$aux00)"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($target,@src)"/> + <xsl:value-of select="@src"/> </xsl:otherwise> </xsl:choose> </xsl:variable> @@ -1212,7 +1206,7 @@ </xsl:variable> <div class="samplefilesection" id="{$auxID}"> <h3><xsl:apply-templates select="$tmp_doc//variable[@id='samplefile']"/></h3> - <a class="objectfiles" href="{concat($target,$src)}"><img src="{concat($target,'media/navigation/libo-calc.svg')}" width="25px" height="30px"></img></a> + <a class="objectfiles" href="{$src}"><img src="media/navigation/libo-calc.svg" width="25px" height="30px"></img></a> </div> </xsl:when> <xsl:when test="@type='application/vnd.oasis.opendocument.text'"> @@ -1223,7 +1217,7 @@ </xsl:variable> <div class="samplefilesection" id="{$auxID}"> <h3><xsl:apply-templates select="$tmp_doc//variable[@id='samplefile']"/></h3> - <a class="objectfiles" href="{concat($target,$src)}"><img src="{concat($target,'media/navigation/libo-writer.svg')}" width="25px" height="30px"></img></a> + <a class="objectfiles" href="{$src}"><img src="media/navigation/libo-writer.svg" width="25px" height="30px"></img></a> </div> </xsl:when> <xsl:when test="@type='application/vnd.oasis.opendocument.presentation'"> @@ -1234,7 +1228,7 @@ </xsl:variable> <div class="samplefilesection" id="{$auxID}"> <h3><xsl:apply-templates select="$tmp_doc//variable[@id='samplefile']"/></h3> - <a class="objectfiles" href="{concat($target,$src)}"><img src="{concat($target,'media/navigation/libo-impress.svg')}" width="25px" height="30px"></img></a> + <a class="objectfiles" href="{$src}"><img src="media/navigation/libo-impress.svg" width="25px" height="30px"></img></a> </div> </xsl:when> <xsl:when test="@type='application/vnd.oasis.opendocument.drawing'"> @@ -1245,7 +1239,7 @@ </xsl:variable> <div class="samplefilesection" id="{$auxID}"> <h3><xsl:apply-templates select="$tmp_doc//variable[@id='samplefile']"/></h3> - <a class="objectfiles" href="{concat($target,$src)}"><img src="{concat($target,'media/navigation/libo-draw.svg')}" width="25px" height="30px"></img></a> + <a class="objectfiles" href="{$src}"><img src="media/navigation/libo-draw.svg" width="25px" height="30px"></img></a> </div> </xsl:when> <xsl:when test="@type='application/vnd.oasis.opendocument.formula'"> @@ -1256,7 +1250,7 @@ </xsl:variable> <div class="samplefilesection" id="{$auxID}"> <h3><xsl:apply-templates select="$tmp_doc//variable[@id='samplefile']"/></h3> - <a class="objectfiles" href="{concat($target,$src)}"><img src="{concat($target,'media/navigation/libo-math.svg')}" width="25px" height="30px"></img></a> + <a class="objectfiles" href="{$src}"><img src="media/navigation/libo-math.svg" width="25px" height="30px"></img></a> </div> </xsl:when> <xsl:when test="@type='application/vnd.oasis.opendocument.database'"> @@ -1267,7 +1261,7 @@ </xsl:variable> <div class="samplefilesection" id="{$auxID}"> <h3><xsl:apply-templates select="$tmp_doc//variable[@id='samplefile']"/></h3> - <a class="objectfiles" href="{concat($target,$src)}"><img src="{concat($target,'media/navigation/libo-base.svg')}" width="25px" height="30px"></img></a> + <a class="objectfiles" href="{$src}"><img src="media/navigation/libo-base.svg" width="25px" height="30px"></img></a> </div> </xsl:when> <xsl:otherwise> @@ -1396,10 +1390,7 @@ </xsl:call-template> </xsl:when> <xsl:otherwise> - <xsl:choose> - <xsl:when test="$online"><xsl:value-of select="concat('../',$result)" /></xsl:when> - <xsl:otherwise><xsl:value-of select="$result" /></xsl:otherwise> - </xsl:choose> + <xsl:value-of select="$result" /> </xsl:otherwise> </xsl:choose> </xsl:template> |