Skip to content

Commit

Permalink
update xqueries to use new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Jan 8, 2025
1 parent c9b90b6 commit 73341e0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
8 changes: 4 additions & 4 deletions add/data/xql/getEditionURI.xql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ xquery version "3.1";
(: IMPORTS ================================================================= :)

import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
import module namespace eutil = "http://www.edirom.de/xquery/eutil" at "../xqm/eutil.xqm";

(: NAMESPACE DECLARATIONS ================================================== :)

Expand All @@ -27,7 +28,6 @@ declare option output:method "text";

let $uri := request:get-parameter('uri', '')
return
if (doc-available($uri)) then
($uri)
else
(edition:findEdition($uri))
if (edition:getEditionURI($uri))
then edition:getEditionURI($uri)
else edition:findEditionUris()[1]
4 changes: 2 additions & 2 deletions add/data/xqm/eutil.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ declare function eutil:getLanguage($edition as xs:string?) as xs:string {

if (request:get-parameter("lang", "") != "") then
request:get-parameter("lang", "")
else if(eutil:getPreference('application_language', edition:findEdition($edition))) then
eutil:getPreference('application_language', edition:findEdition($edition))
else if(eutil:getPreference('application_language', edition:getEditionURI($edition))) then
eutil:getPreference('application_language', edition:getEditionURI($edition))
else
'de'
};
Expand Down
33 changes: 20 additions & 13 deletions add/index.xql
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ declare option output:omit-xml-declaration "yes";
(: VARIABLE DECLARATIONS =================================================== :)

declare variable $edition := request:get-parameter("edition", "");
declare variable $editionUri := edition:findEdition($edition);
declare variable $additional_css_path := eutil:getPreference('additional_css_path', $editionUri);
declare variable $editionUri := edition:getEditionURI($edition);

let $eoEditionFiles := collection('/db/apps')//edirom:edition[@xml:id]
let $eoEditionFilesCount := count($eoEditionFiles)
(: if no valid $editionUri is provided by the request we have to check the whole database :)
let $eoEditionUris :=
if($editionUri)
then $editionUri
else edition:findEditionUris()
let $eoEditionUrisCount := count($eoEditionUris)

(: if we have only one valid $editionUri we can look for edition specific CSS :)
let $additional_css_path :=
if($eoEditionUrisCount eq 1)
then eutil:getPreference('additional_css_path', $eoEditionUris)
else ()

let $comment := comment{"
* Edirom Online
Expand Down Expand Up @@ -74,7 +83,7 @@ let $eoIndexPage := <html>

<link rel="stylesheet" href="resources/EdiromOnline-all.css"/>
{
if(($eoEditionFilesCount gt 1 or $eoEditionFilesCount eq 0) and not($edition)) then
if(($eoEditionUrisCount gt 1 or $eoEditionUrisCount eq 0) and not($edition)) then
()
else
(<!-- TODO if prefs css then include here -->,
Expand All @@ -87,27 +96,25 @@ let $eoIndexPage := <html>
}
</head>
<body class="x-body">
{if(($eoEditionFilesCount gt 1 or $eoEditionFilesCount eq 0) and not($edition)) then
{if(($eoEditionUrisCount gt 1 or $eoEditionUrisCount eq 0) and not($edition)) then
(<div class="container" style="margin: 8.75%;">
<img src="resources/pix/ViFE-logo-small-144x144-trans.png"/>
<h1 style="margin-top:5px;">Edirom Online</h1>
{if($eoEditionFilesCount eq 0 and not($edition)) then
{if($eoEditionUrisCount eq 0 and not($edition)) then
(<h3 class="navigatorCategoryTitle">Es wurden keine Editionen gefunden.</h3>)
else
(<h3 class="navigatorCategoryTitle">Bitte Edition auswählen</h3>,
<ul>
{
for $eoEditionFile in $eoEditionFiles
let $editionUri := document-uri($eoEditionFile/root())
let $editionID := $eoEditionFile/string(@xml:id)
let $editionName := $eoEditionFile/edirom:editionName/text() => normalize-space()
for $editionUri in $eoEditionUris
let $editionDetails := edition:details($editionUri)
let $editionLanguages := edition:getLanguageCodesSorted($editionUri)
return (
<li class="navigatorItem" style="padding-bottom: 0.75em;">
<i>{$editionName}</i>
<i>{$editionDetails?name}</i>
<ul>{
for $lang in $editionLanguages return
<li><a class="x-btn" href="index.html?edition={$editionID}&amp;lang={$lang}">{$lang}</a></li>
<li><a class="x-btn" href="index.html?edition={$editionDetails?id}&amp;lang={$lang}">{$lang}</a></li>
}</ul>
</li>
)
Expand Down

0 comments on commit 73341e0

Please sign in to comment.