From a80dfceb806e28007be7d6321864b490b63dfa6b Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Wed, 6 Nov 2024 16:53:09 +0100 Subject: [PATCH] first shot at fixing #156 --- add/data/xql/search.xql | 14 ++++++++------ add/data/xqm/edition.xqm | 8 ++++++++ app/controller/window/search/SearchWindow.js | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/add/data/xql/search.xql b/add/data/xql/search.xql index 54ec0bb8b..a4f9c45f8 100644 --- a/add/data/xql/search.xql +++ b/add/data/xql/search.xql @@ -8,6 +8,7 @@ xquery version "3.1"; import module namespace kwic = "http://exist-db.org/xquery/kwic"; import module namespace transform="http://exist-db.org/xquery/transform"; +import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; (: NAMESPACE DECLARATIONS ================================================== :) @@ -25,6 +26,7 @@ declare option output:media-type "text/html"; (: VARIABLE DECLARATIONS =================================================== :) declare variable $lang := request:get-parameter('lang', ''); +declare variable $edition := request:get-parameter('uri', ''); (: FUNCTION DECLARATIONS =================================================== :) @@ -75,12 +77,12 @@ let $return := let $search := if (string-length($term) gt 0) then ( - collection('/db')//tei:text[ft:query(., $term)]/ancestor::tei:TEI - | collection('/db')//tei:title[ft:query(., $term)]/ancestor::tei:TEI - | collection('/db')//mei:mei[ft:query(., $term)] - | collection('/db')//mei:title[ft:query(., $term)]/ancestor::mei:mei - | collection('/db')//mei:annot[ft:query(., $term)][@type eq 'editorialComment'] - | collection('/db')//mei:annot[contains(@xml:id, $term)] + edition:collection($edition)//tei:text[ft:query(., $term)]/ancestor::tei:TEI + | edition:collection($edition)//tei:title[ft:query(., $term)]/ancestor::tei:TEI + | edition:collection($edition)//mei:mei[ft:query(., $term)] + | edition:collection($edition)//mei:title[ft:query(., $term)]/ancestor::mei:mei + | edition:collection($edition)//mei:annot[ft:query(., $term)][@type eq 'editorialComment'] + | edition:collection($edition)//mei:annot[contains(@xml:id, $term)] ) else () diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index d47d1d235..5c5f684dd 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -13,11 +13,13 @@ module namespace edition = "http://www.edirom.de/xquery/edition"; (: IMPORTS ================================================================= :) import module namespace functx="http://www.functx.com"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "util.xqm"; (: NAMESPACE DECLARATIONS ================================================== :) declare namespace edirom = "http://www.edirom.de/ns/1.3"; declare namespace xlink = "http://www.w3.org/1999/xlink"; +declare namespace util = "http://exist-db.org/xquery/util"; (: VARIABLE DECLARATIONS =================================================== :) @@ -188,3 +190,9 @@ declare function edition:getFrontendUri($editionUri as xs:string, $contextPath a return string-join(($contextPath, $editionContext), '/') }; + +declare function edition:collection($edition as xs:string?) as document-node()* { + if($edition) + then collection(eutil:getPreference('edition_path', $edition)) + else util:log('warn', 'No edition provided') +}; diff --git a/app/controller/window/search/SearchWindow.js b/app/controller/window/search/SearchWindow.js index 8430b601d..4fa95dfef 100644 --- a/app/controller/window/search/SearchWindow.js +++ b/app/controller/window/search/SearchWindow.js @@ -68,7 +68,8 @@ Ext.define('EdiromOnline.controller.window.search.SearchWindow', { 'GET', { term: term, - lang: getPreference('application_language') + lang: getPreference('application_language'), + uri: view.uri }, Ext.bind(function(response){ me.win.setResult(response.responseText);