Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: help internal links modify window.location #507

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions add/data/xql/getHelp.xql
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,76 @@ xquery version "3.1";
: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
:)


(: IMPORTS ================================================================= :)

import module namespace eutil = "http://www.edirom.de/xquery/eutil" at "../xqm/eutil.xqm";


(: NAMESPACE DECLARATIONS ================================================== :)

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare namespace request = "http://exist-db.org/xquery/request";

declare namespace system = "http://exist-db.org/xquery/system";

declare namespace transform = "http://exist-db.org/xquery/transform";


(: OPTION DECLARATIONS ===================================================== :)

declare option output:media-type "text/html";

declare option output:method "xhtml";

declare option output:indent "yes";

declare option output:omit-xml-declaration "yes";


(: QUERY BODY ============================================================== :)

let $lang := request:get-parameter('lang', 'en')

let $idPrefix := request:get-parameter('idPrefix', '')

let $base := replace(system:get-module-load-path(), 'embedded-eXist-server', '') (:TODO:)
let $base := eutil:get-app-collection()

let $baseXslt := $base ||'/data/xslt/'

let $docUri := string-join(($base,concat('help/help_', $lang, '.xml')), '/')

let $contextPath :=
if(starts-with(document-uri($doc), '/db')) then
substring-after(document-uri($doc), '/db')
else document-uri($doc)

let $doc := doc(concat('../../help/help_', $lang, '.xml'))
let $contextPath := if(starts-with(document-uri($doc), '/db'))
then substring-after(document-uri($doc), '/db')
else document-uri($doc)
let $contextPath := substring-before($contextPath, concat('help/help_', $lang, '.xml'))

let $contextPath := request:get-context-path() || $contextPath

let $xsl := doc('../xslt/edirom_langReplacement.xsl')

let $doc :=
transform:transform($doc, $xsl,
<parameters>
<param name="base" value="{concat($base, '/../xslt/')}"/>
<param name="base" value="{$baseXslt}"/>
<param name="lang" value="{$lang}"/>
</parameters>
)

let $xsl := doc('../xslt/tei/profiles/edirom-body/teiBody2HTML.xsl')

let $doc :=
transform:transform($doc, $xsl,
<parameters>
<param name="base" value="{concat($base, '/../xslt/')}"/>
<param name="base" value="{$baseXslt}"/>
<param name="lang" value="{$lang}"/>
<param name="tocDepth" value="1"/>
<param name="contextPath" value="{$contextPath}"/>
(: == passing empty value for docUri (XSLT expects xs:anyURI, but ExtJS view does not provide value) -> github#480 == :)
<param name="docUri" value="''"/>
<param name="docUri" value="{$docUri}"/>
</parameters>
)

Expand All @@ -59,4 +82,3 @@ return
<param name="idPrefix" value="{$idPrefix}"/>
</parameters>
)

11 changes: 11 additions & 0 deletions add/data/xqm/eutil.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ declare function eutil:get-app-base-url() as xs:string? {
util:log-system-out('request object does not exist; failing to compute base url')
};

(:~
: Returns the xmldb-uri to the Edirom Online install directory
:
: @return xs:string absolute xmldb-uri to Edirom Online
:)
declare function eutil:get-app-collection() as xs:string {

functx:substring-before-last(functx:substring-before-last(replace(system:get-module-load-path(), 'embedded-eXist-server', ''),'/'),'/')

};

(:~
: Sorts a sequence of numeric-alpha values or nodes (e.g. 1, 1a, 1b, 2)
: This is an adaption of functx:sort-as-numeric()
Expand Down
Loading