Commit 1249a0b5 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

renew index view process

parent e3f717ef
......@@ -17,6 +17,7 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
import module namespace rest="http://exquery.org/ns/restxq";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm";
import module namespace ixp="http://fontane-nb.dariah.eu/index-processor" at "index-processor.xqm";
declare variable $index:dataPath := "/db/sade-projects/textgrid/data/xml/data";
......@@ -202,7 +203,25 @@ declare
%output:method("html")
function index:rendered-entity($id as xs:string)
as element(xhtml:li)? {
doc("/db/sade-projects/textgrid/data/xml/xhtml/index.xml")//xhtml:li[@id = $id]
(: doc("/db/sade-projects/textgrid/data/xml/xhtml/index.xml")//xhtml:li[@id = $id]:)
let $node := collection($index:dataPath)/id($id)
let $type := $node/root()//tei:body/*[1]/local-name()
(: listEvent, listPlace, listOrg, listPerson or list :)
return
switch ($type)
case "listEvent" return
ixp:prepare-event($node)
case "listOrg" return
ixp:prepare-org($node)
case "listPerson" return
ixp:prepare-person($node)
case "listPlace" return
ixp:prepare-place($node)
case "list" return
ixp:prepare-work($node)
default return
error(QName("FONTANE", "INDEX-API4"), "unknown node-name: " || $type)
};
(:~ Provides a simple API for searching the index entries. Used for autocompletion.
......@@ -220,9 +239,7 @@ declare
function index:search($query as xs:string, $index)
as array(*) {
let $query := $query => xmldb:decode-uri()
(: central condition :)
return if(string-length($query) lt 2) then () else
let $prepare := tokenize($index, ",")
let $hits :=
(
......@@ -242,6 +259,7 @@ return
$hit/tei:note/tei:ptr/substring-after(@target, "#")
let $list := index:get-list-by-node($hit)
where $list = $prepare
where $id != ""
return
map{
"name": string($hit/*[1]),
......@@ -249,6 +267,5 @@ return
"list": $list,
"type": $hit/local-name()
}
}
};
This diff is collapsed.
......@@ -5,9 +5,9 @@ xquery version "3.1";
: @version 1.0
: @see https://fontane-nb.dariah.eu/register.html
:)
module namespace f-indexviewer="http://fontane-nb.dariah.eu/indexviewer";
module namespace ixv="http://fontane-nb.dariah.eu/index-viewer";
import module namespace f-indexproc="http://fontane-nb.dariah.eu/indexproc" at "index-processor.xqm";
import module namespace ixp="http://fontane-nb.dariah.eu/index-processor" at "index-processor.xqm";
import module namespace index="https://fontane-nb.dariah.eu/indexapi" at "index-api.xqm";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm";
......@@ -21,7 +21,7 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare
%test:setUp
function f-indexviewer:setup() {
function ixv:setup() {
if( xmldb:collection-available("/db/sade-projects/textgrid") )
then true()
else
......@@ -49,7 +49,7 @@ else
};
declare
%test:tearDown
function f-indexviewer:teardown(){
function ixv:teardown(){
xmldb:remove("/db/sade-projects")
};
......@@ -73,7 +73,7 @@ let $agg := '253st.xml' (: TextGrid Aggregation containing all index files :)
let $uris := (doc('/db/sade-projects/textgrid/data/xml/agg/' || $agg)
//ore:aggregates/substring-after(@rdf:resource, 'textgrid:')
)[. != "25547"] (: omit the bibliography here :)
let $lastMod := $uris ! xmldb:last-modified($f-indexproc:dataPath, . || '.xml')
let $lastMod := $uris ! xmldb:last-modified($ixp:dataPath, . || '.xml')
return
if(not(local:login($collection-uri)))
......@@ -86,7 +86,7 @@ return
else
(: create the cache :)
let $lock := xmldb:store("/db/sade-projects/textgrid/data/xml/xhtml", "index.lock", <lock/>),
$cache := xmldb:store($collection-uri, $resource, <xhtml:div>{util:eval('f-indexproc:register()')}</xhtml:div>),
$cache := xmldb:store($collection-uri, $resource, <xhtml:div>{util:eval('ixp:register()')}</xhtml:div>),
$removeLock := xmldb:remove("/db/sade-projects/textgrid/data/xml/xhtml", "index.lock")
return
$cache
......@@ -94,7 +94,7 @@ return
(: forces the creation of a new cache file
: @return document-node() of the index cache file :)
declare function f-indexviewer:prepare-new-cache()
declare function ixv:prepare-new-cache()
as document-node() {
let $path := "/db/sade-projects/textgrid/data/xml/xhtml/index.xml"
let $cleanup :=
......@@ -148,24 +148,24 @@ return
else $node
};
declare function f-indexviewer:main($model as map()*, $node as node(), $index as xs:string) {
if ($f-indexproc:notebookParam)
declare function ixv:main($model as map()*, $node as node(), $index as xs:string) {
if ($ixp:notebookParam)
then
f-indexproc:register($index)[./@id = $index]
ixp:register($index)[./@id = $index]
=> functx:change-element-ns-deep("http://www.w3.org/1999/xhtml", "")
else
let $doc := doc( local:cache() )
return
if ($f-indexproc:getEntity)
if ($ixp:getEntity)
then
let $id := generate-id($doc//xhtml:li[@id = $f-indexproc:getEntity])
let $id := generate-id($doc//xhtml:li[@id = $ixp:getEntity])
return
local:transform-entity($doc/xhtml:div/xhtml:div[@id = $index], $id)
else
$doc/*/xhtml:div[@id = $index]
};
declare function f-indexviewer:tabs($nodes as node(), $model as map(*), $index as xs:string) {
declare function ixv:tabs($nodes as node(), $model as map(*), $index as xs:string) {
local:transfrom-tabs($nodes/*, $index)
};
......@@ -208,10 +208,10 @@ return
}
case element(xhtml:a) return
element xhtml:a {
if($f-indexproc:notebookParam)
if($ixp:notebookParam)
then
($node/@*[local-name() != "href"],
attribute href { string($node/@href) || "?nb=" || $f-indexproc:notebookParam })
attribute href { string($node/@href) || "?nb=" || $ixp:notebookParam })
else $node/@*,
$node/(*,text())
}
......@@ -229,8 +229,8 @@ then
else true()
};
declare function f-indexviewer:item($node, $map, $e as xs:string?) {
if(string($e) != "")
declare function ixv:item($node, $map, $e as xs:string?) {
if(string-length($e) gt 1)
then
index:rendered-entity($e)
else ()
......
......@@ -5,14 +5,14 @@
:)
xquery version "3.1";
import module namespace templates="http://exist-db.org/xquery/templates" ;
import module namespace mviewer="http://sade/multiviewer" at "multiviewer/multiviewer.xqm" ;
import module namespace config="http://textgrid.de/ns/SADE/config" at "config/config.xqm";
import module namespace f-misc="http://fontane-nb.dariah.eu/ns/SADE/misc" at "fontane/misc.xqm";
import module namespace f-indexviewer="http://fontane-nb.dariah.eu/indexviewer" at "fontane/index-viewer.xqm";
import module namespace f-render="http://fontane-nb.dariah.eu/ns/SADE/render" at "fontane/render.xqm";
import module namespace config="http://textgrid.de/ns/SADE/config" at "config/config.xqm";
import module namespace fsearch = "http://sade/faceted-search" at "faceted-search/faceted-search.xqm";
import module namespace ixv="http://fontane-nb.dariah.eu/index-viewer" at "fontane/index-viewer.xqm";
import module namespace mviewer="http://sade/multiviewer" at "multiviewer/multiviewer.xqm" ;
import module namespace nav="http://sade/tmpl-nav" at "tmpl-nav/tmpl-nav.xqm";
import module namespace templates="http://exist-db.org/xquery/templates" ;
import module namespace wiki="http://textgrid.de/ns/SADE/wiki" at "wiki/wiki.xqm";
(:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment