Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SADE
SADE
Commits
83d9f23e
Commit
83d9f23e
authored
Jan 17, 2019
by
Mathias Goebel
Browse files
prepare search and fsearch
parent
bd76b8e3
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
modules/faceted-search.xqm
View file @
83d9f23e
...
...
@@ -2,7 +2,6 @@ xquery version "3.1";
module namespace fsearch="https://sade.textgrid.de/ns/faceted-search";
import module namespace config="https://sade.textgrid.de/ns/config" at "config.xqm";
import module namespace console="http://exist-db.org/xquery/console";
import module namespace kwic="http://exist-db.org/xquery/kwic";
declare namespace bol="http://blumenbach-online.de/blumenbachiana";
...
...
@@ -12,7 +11,7 @@ declare namespace templates="http://exist-db.org/xquery/templates";
declare function fsearch:results($node as node(), $model as map(*)) as map()* {
let $page := xs:integer(request:get-parameter("page", "1"))
let $target := $config:
app
-root ||
"/" || config:get("project-id") ||
"/data"
let $target := $config:
data
-root || "/data"
let $hits := local:get-hits($model, $target)
let $obreq := request:get-parameter("order-by", "relevance")
...
...
@@ -30,7 +29,6 @@ declare function fsearch:results($node as node(), $model as map(*)) as map()* {
let $num := try{ xs:integer(config:get("hits-per-page", "faceted-search")) } catch * {0}
let $pages := try { ceiling(count($hits) div $num) } catch * { 0 }
let $start := $page * $num - $num + 1
return
map {
"facets" := fsearch:facets($model, $hits),
...
...
@@ -101,7 +99,7 @@ declare function fsearch:result-xslt($node as node(), $model as map(*)) {
let $link := config:get('viewer-html','faceted-search') || $docname
let $xslt := $config:app-root || "/" || config:get('result-xslt','faceted-search')
let $docpath := config:
get("data-dir")
|| "/
xml/
data/" || $docname
let $docpath :=
$
config:
data-root
|| "/data/" || $docname
let $title := doc($docpath)//tei:fileDesc/tei:titleStmt/tei:title
return
...
...
@@ -146,8 +144,7 @@ declare function fsearch:result-kwic($node as node(), $model as map(*)) {
for $i in 1 to xs:integer(config:get("kwic-hits", "faceted-search"))
return
if(($expanded//exist:match)[$i]) then
let $summary := kwic:get-summary($expanded, ($expanded//exist:match)[$i], <config width="{$kwic-width}"/>),
$console := console:log($summary)
let $summary := kwic:get-summary($expanded, ($expanded//exist:match)[$i], <config width="{$kwic-width}"/>)
return
<p class="kwic"><span class="kwic-prev">{$summary/span[@class="previous"]/node()}</span> <span class="kwic-hit">{$summary/span[@class="hi"]/node()}</span> <span>{$summary/span[@class="following"]/node()}</span></p>
else ()
...
...
@@ -155,7 +152,7 @@ declare function fsearch:result-kwic($node as node(), $model as map(*)) {
declare function fsearch:result-source($node as node(), $model as map(*)) {
let $docloc := config:
get("data-dir")
|| "/
xml/
data/" || util:document-name($model("hit"))
let $docloc :=
$
config:
data-root
|| "/data/" || util:document-name($model("hit"))
return
<a href="/exist/rest{$docloc}">{ $node/@class, $node/* }</a>
};
...
...
@@ -287,39 +284,36 @@ declare function local:get-hits($model as map(*), $target as xs:string) as node(
"collection($target)" || $query-root || $fxquery
let $xquery := string-join($xqueries, " | ")
return
util:eval($xquery)
return
util:eval($xquery)
};
declare function local:construct-facet-query($model as map(*))
as xs:string {
declare function local:construct-facet-query($model as map(*))
as xs:string {
let $facet := local:facet-query-from-request()
let $fxquery :=
if ($facet) then
for $fquery in tokenize($facet, ",")
for $fquery in tokenize($facet, ",")
[.!=""]
let $parts := tokenize($fquery, ":")
let $select :=
for $xpath in config:get("facets", "faceted-search")//cf:facet[@key = $parts[1]]//cf:xpath
let $select :=
for $xpath in config:get("facets", "faceted-search")[@key = $parts[1]]//cf:xpath
let $val := xmldb:decode($parts[2])
let $op := if(starts-with($val, "!"))
then " ne "
else " eq "
let $op := if(starts-with($val, "!"))
then " ne "
else " eq "
let $val := replace($val, "!", "")
return if(starts-with($xpath, ".") or starts-with($xpath, "/"))
(: to escpae quotes, you have to double them :)
return
if(starts-with($xpath, ".") or starts-with($xpath, "/"))
then $xpath || $op || """" || $val || """"
else ".//" || $xpath || $op || """" || $val || """"
return
if(not(empty($select))) then "[" || string-join($select, " or ") || "]"
else ()
else
()
return string-join($fxquery, "")
else ()
return
string-join($fxquery)
};
(: we need the facet uri encoded, so request-get parameter does not work :)
...
...
post-install.xq
View file @
83d9f23e
...
...
@@ -85,8 +85,7 @@ let $project-name := tokenize($target, "/")[last()]
let
$log
:=
util:log-system-out
(
"installing "
||
$project-name
)
let
$system-path
:=
system:get-exist-home
()
||
util:system-property
(
"file.separator"
)
let
$use-template
:=
xmldb:rename
(
$target
||
"/textgrid/data"
,
"collection-template.xconf"
,
"collection.xconf"
)
let
$data-xconf
:=
$target
||
"/textgrid/data/collection.xconf"
let
$data-xconf
:=
$target
||
"/textgrid/data/collection-template.xconf"
(: prepare empty Lucene Config files :)
let
$prepare-config
:=
(
...
...
@@ -107,6 +106,7 @@ let $rewrite-synonyms := update value
with
$system-path
||
$project-name
||
"-synonyms.txt"
let
$store-xconf
:=
xmldb:store
(
"/db/system/config"
||
$target
||
"/textgrid/data"
,
"collection.xconf"
,
doc
(
$data-xconf
))
let
$reindex
:=
xmldb:reindex
(
$target
||
"/textgrid/data"
)
(: we have to test for writable path :)
let
$path
:=
$system-path
let
$user
:=
util:system-property
(
"user.name"
)
...
...
pre-install.xq
View file @
83d9f23e
...
...
@@ -31,6 +31,7 @@ declare function local:mkcol($collection, $path) {
(:for $collection in ( $target, $target || "/textgrid/data", $target || "/textgrid/meta", $target || "/textgrid/rdf" ) :)
(:return:)
(
local:mkcol
(
"/db/system/config"
,
$target
)
,
local:mkcol
(
"/db/system/config"
,
$target
||
"/textgrid/data"
)
,
local:mkcol
(
"/db/system/config"
,
$target
)
,
local:mkcol
(
"/db/system/config"
,
$target
||
"/textgrid/data"
)
,
xmldb:store-files-from-pattern
(
concat
(
"/db/system/config"
,
$target
)
,
$dir
,
"**/collection.xconf"
,
"text/xml"
,
true
())
)
textgrid/data/collection-template.xconf
View file @
83d9f23e
<collection xmlns="http://exist-db.org/collection-config/1.0">
<!-- to omit the installation during pre-install, this file is named
`collection-template.xconf` in the application package. it will be setup and
stored by `post-install.xq` -->
<!-- when you going to edit here, keep in mind that this file is stored in the
$APP_HOME and in the system/config collection.
Always edit both!!!!1! -->
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment