Commit 3f556d65 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

search enabled

parent 4c91e004
......@@ -57,6 +57,7 @@ else if(starts-with($exist:resource, "textgrid")) then
<view>
<forward url="{$exist:controller}/modules/view.xql">
<add-parameter name="id" value="{$id}" />
<add-parameter name="exist-resource" value="content.html" />
</forward>
</view>
<error-handler>
......
......@@ -24,7 +24,7 @@ declare function app:title($node as node(), $model as map(*)) {
declare function app:css-injection($node as node(), $model as map(*), $exist-resource) {
switch ($exist-resource)
case "publish.html" return <link href="~assets/publish-gui/publish-gui.css" rel="stylesheet"/>
case "content.html" return <link href="css/content.css" rel="stylesheet"/>
case "content.html" return <link href="templates/css/content.css" rel="stylesheet"/>
default return ()
};
......
......@@ -33,12 +33,19 @@ declare variable $config:expath-descriptor := doc(concat($config:app-root, "/exp
declare variable $config:file := doc(concat($config:app-root, "/config.xml"));
(:~
: A function to query the global SADE config.
: @param $key – the name of the parameter to query for
: :)
declare function config:get($key as xs:string){
config:get($key, "")
$config:file/cf:config/cf:param[@key = $key]/node()
};
(:~
: A function to query the SADE config for module specific parameter.
: @param $key – the name of the parameter to query for
: @param $module-key – the name of the module
: :)
declare function config:get($key as xs:string, $module-key as xs:string?) {
if($module-key = "")
then $config:file/cf:config/cf:param[@key = $key]/node()
else $config:file/cf:config/cf:module[@key = $module-key]/cf:param[@key = $key]/node()
$config:file/cf:config/cf:module[@key = $module-key]/cf:param[@key = $key]/node()
};
......@@ -13,7 +13,8 @@ declare function fsearch:results($node as node(), $model as map(*)) as map()* {
let $target := config:get("data-dir")
let $hits := local:get-hits($model, $target)
let $obreq := request:get-parameter("order-by", "relevance")
let $order-by := string-join($config:configDoc//module[@key="faceted-search"]//order[@key = $obreq]//xpath , ",")
(: let $order-by := string-join($config:configDoc//module[@key="faceted-search"]//order[@key = $obreq]//xpath , ","):)
let $order-by := ""
let $hitsordered :=
if(request:get-parameter("order", "descending") = "descending") then
for $hit in $hits
......@@ -85,7 +86,7 @@ declare function fsearch:result-title($node as node(), $model as map(*)) {
return
<a href="{$viewdoc}{util:document-name($model("hit"))}">
{
for $titleQuery in $config:configDoc//module[@key="faceted-search"]/param[@key="result-title"]//xpath
for $titleQuery in config:get("result-title", "faceted-search")//xpath
return util:eval("($model('hit')" || $titleQuery || ")[1]")
}
</a>
......@@ -159,7 +160,7 @@ function fsearch:result-id($node as node(), $model as map(*)) {
declare function fsearch:facets($model as map(*), $hits) as map() {
map:new(
for $facet in $config:configDoc//module[@key="faceted-search"]//facet
for $facet in config:get("facets", "faceted-search")//facet
return
map:entry(xs:string($facet/@key), local:facet($model, $hits, $facet/@key, $facet//xpath/text()))
)
......@@ -175,7 +176,7 @@ function fsearch:facet-title($node as node(), $model as map(*)) {
};
declare function fsearch:facet($node as node(), $model as map(*)) as item()* {
let $facets := $config:configDoc//module[@key="faceted-search"]//facet
let $facets := config:get("facets", "faceted-search")//facet
for $facet in $facets
(: hide facet-categories with less than one entry :)
......@@ -232,8 +233,6 @@ declare function local:facet($model as map(*), $hits as node()*, $key as xs:stri
<a href="{$search-html}?q={$query}&amp;facet={$key}:{xmldb:encode($facet)},{$facetReq}&amp;order={$order}&amp;order-by={$order-by}">{$facet}</a> ({$freq})
</li>
};
declare function local:deselected-for-key($model, $key as xs:string) {
......@@ -273,7 +272,7 @@ declare function local:get-hits($model as map(*), $target as xs:string) as node(
<leading-wildcard>yes</leading-wildcard>
</options>
let $xqueries := for $query-root in $config:configDoc//module[@key="faceted-search"]/param[@key="query-root"]//xpath
let $xqueries := for $query-root in config:get("query-root", "faceted-search")//xpath
return
if($query) then
"collection($target)" || $query-root || $fxquery || "[ft:query(., $query, $options)]"
......@@ -293,7 +292,7 @@ declare function local:construct-facet-query($model as map(*)) as xs:string {
for $fquery in tokenize($facet, ",")
let $parts := tokenize($fquery, ":")
let $select :=
for $xpath in $config:configDoc//module[@key="faceted-search"]//facet[@key = $parts[1]]//xpath
for $xpath in config:get("facets", "faceted-search")//facet[@key = $parts[1]]//xpath
let $val := xmldb:decode($parts[2])
let $op := if(starts-with($val, "!"))
......
Supports Markdown
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