Skip to content

Commit

Permalink
Merge pull request #13 from Max-Reger-Institut/hotfix/dynamic-navConfig
Browse files Browse the repository at this point in the history
Hotfix/dynamic nav config
  • Loading branch information
nikobeer authored Nov 17, 2022
2 parents b00195c + 5a688cc commit 7e45c12
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions add/data/xql/getNavigatorConfig.xql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ xquery version "1.0";
:)

import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
import module namespace console="http://exist-db.org/xquery/console";

declare namespace request="http://exist-db.org/xquery/request";
declare namespace edirom="http://www.edirom.de/ns/1.3";
Expand All @@ -34,6 +35,9 @@ declare option exist:serialize "method=xhtml media-type=text/html omit-xml-decla

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

declare variable $configResource := doc('xmldb:exist:///db/apps/mriExistDBconf/config.xml');
declare variable $env := $configResource//conf:env/text();

declare function local:getCategory($category, $depth) {


Expand All @@ -47,28 +51,28 @@ declare function local:getCategory($category, $depth) {
)
}
</div>
<div id="{$category/@xml:id}-items" class="{if($depth = 1)then()else('hidden')}">
{
for $elem in $category/edirom:navigatorItem | $category/edirom:navigatorCategory
return
(: RWA-specific: do not show (source) enties/@type = "private" when on public server :)
if(local-name($elem) eq 'navigatorItem')
then(
if ($elem/@type = 'private' and contains(request:get-server-name(), 'reger-werkausgabe.de'))
then ()
else (local:getItem($elem, $depth))
)
else if(local-name($elem) eq 'navigatorSeparator')
then(
local:getSeparator()
)
else if(local-name($elem) eq 'navigatorCategory')
then(
local:getCategory($elem, $depth + 1)
)
else()
}
</div>
<div id="{$category/@xml:id}-items" class="{if($depth = 1)then()else('hidden')}">
{
for $elem in $category/edirom:navigatorItem | $category/edirom:navigatorCategory
return
(: RWA-specific: do not show (source) entries/@type = "private" or "editions" when on public server :)
if(local-name($elem) eq 'navigatorItem')
then(
if ($env = ('beta', 'public') and ($elem/@type = 'private' or contains($elem/@targets/string(), '/music/editions/')))
then ()
else (local:getItem($elem, $depth))
)
else if(local-name($elem) eq 'navigatorSeparator')
then(
local:getSeparator()
)
else if(local-name($elem) eq 'navigatorCategory')
then(
local:getCategory($elem, $depth + 1)
)
else()
}
</div>
</div>
};

Expand Down Expand Up @@ -103,15 +107,9 @@ declare function local:getSeparator() {
};

declare function local:getDefinition($navConfig) {
(: Small temp. fix to hide RWA Object links in Navigator on public machines… :)
let $elems := if (contains(request:get-server-name(), 'reger-werkausgabe.de'))
then ($navConfig/*[not(./edirom:names/edirom:name[@xml:lang = 'de'] = 'Edition')])
else ($navConfig/*)

let $elems := $navConfig/*
for $elem in $elems

return

if(local-name($elem) eq 'navigatorItem')
then(
local:getItem($elem, 1)
Expand All @@ -122,7 +120,12 @@ declare function local:getDefinition($navConfig) {
)
else if(local-name($elem) eq 'navigatorCategory')
then(
local:getCategory($elem, 1)
(: check if there are any items in category to show, dependig on (RWA) rules defined in local:getDefinition :)
let $category := local:getCategory($elem, 1)
return
if ($category//div[@class="navigatorItem"])
then ($category)
else ()
)
else()
};
Expand Down

0 comments on commit 7e45c12

Please sign in to comment.