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

156 searchwindow use edition path for collection function #463

Merged
34 changes: 19 additions & 15 deletions add/data/xql/search.xql
Original file line number Diff line number Diff line change
Expand Up @@ -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 ================================================== :)
Expand All @@ -22,17 +23,18 @@ declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare option output:method "xhtml";
declare option output:media-type "text/html";

(: VARIABLE DECLARATIONS =================================================== :)

declare variable $lang := request:get-parameter('lang', '');

(: FUNCTION DECLARATIONS =================================================== :)

declare function local:filter($node as node(), $mode as xs:string) as xs:string? {
(:~
: Callback function for `kwic:get-summary`
: Contrary to the documentation at https://exist-db.org/exist/apps/doc/kwic (1Q18)
: this function has to return a node(), see https://github.com/eXist-db/exist/issues/4239
:)
declare function local:filter($node as node(), $mode as xs:string) as node()? {
if ($mode eq 'before') then
concat($node, ' ')
text { concat($node, ' ') }
else
concat(' ', $node)
text { concat(' ', $node) }
};

declare function local:getPath($node as node()) as xs:string {
Expand All @@ -48,6 +50,8 @@ declare function local:getPath($node as node()) as xs:string {

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

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

let $trans :=
Expand Down Expand Up @@ -75,15 +79,14 @@ 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
()

return (

if (count($search) gt 0) then (
Expand Down Expand Up @@ -166,7 +169,8 @@ let $return :=
else
()
}?path={$path}&term={replace($term, '"', '\\"')}');"/>,
util:function(xs:QName("local:filter"), 2))
local:filter#2
)
}</div>
,
if ($hitCount gt 3) then
Expand Down
27 changes: 22 additions & 5 deletions add/data/xqm/edition.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ module namespace edition = "http://www.edirom.de/xquery/edition";

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 util = "http://exist-db.org/xquery/util";
declare namespace xlink = "http://www.w3.org/1999/xlink";

(: VARIABLE DECLARATIONS =================================================== :)
Expand Down Expand Up @@ -174,12 +177,11 @@ declare function edition:getName($uri as xs:string) as xs:string {
(:~
: Returns the frontend URI of the edition, e.g. if the edirom:edition file
: submitted via $editionUri is xmldb:exist///db/apps/editionFolder/edition.xml
: and the $contextPath is /exist the string returned woud be /exist/apps/editionFolder
:
: @param $editionUri The xmldb-collection-path of the edition
: @param $contextPath the request:get-context-path() of the frontend
: and the $contextPath is /exist the string returned would be /exist/apps/editionFolder
:
: @return xs:string
: @param $editionUri The URI of the Edition's document to process
: @param $contextPath The request:get-context-path() of the frontend
: @return The frontend URI of the edition
:)
declare function edition:getFrontendUri($editionUri as xs:string, $contextPath as xs:string) as xs:string {

Expand All @@ -188,3 +190,18 @@ declare function edition:getFrontendUri($editionUri as xs:string, $contextPath a
return
string-join(($contextPath, $editionContext), '/')
};

(:~
: Returns the documents contained in the collection specified by the
: `edition_path` parameter in the edition's preference file.
: If `$editionUri` is the empty sequence or no information is found
: for `edition_path`, the empty sequence is returned.
:
: @param $edition The URI of the Edition's document to process
: @return The document nodes contained in or under the given collection
:)
declare function edition:collection($editionUri as xs:string?) as document-node()* {
if($editionUri and eutil:getPreference('edition_path', $editionUri))
then collection(eutil:getPreference('edition_path', $editionUri))
else util:log('warn', 'No edition provided')
};
8 changes: 3 additions & 5 deletions app/view/desktop/Desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,11 @@ Ext.define('EdiromOnline.view.desktop.Desktop', {
me.addWindow(win);
win.show();

}else if(win != me.getActiveWindow())
}else {
win.show();

else
win.hide();
}

//win.doSearch(term);
win.doSearch(term);
},

getSizeAndPosition: function(maxWidth, maxHeight) {
Expand Down