Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing "error page" if no edition exists (prevents failing) #429

Merged
merged 8 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions add/data/xqm/edition.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:strin
if(doc-available($uri)) then
doc($uri)
else
doc(edition:findEdition($uri))
if(edition:findEdition($uri)) then
doc(edition:findEdition($uri))
else
()
)
return
if ($doc//edirom:language[@xml:lang eq $lang]/@xlink:href => string() != "") then
Expand Down Expand Up @@ -141,7 +144,7 @@ declare function edition:getPreferencesURI($uri as xs:string?) as xs:string {
: @param $editionID The '@xml:id' of the edirom:edition document to process
: @return The URI of the Edition file
:)
declare function edition:findEdition($editionID as xs:string?) as xs:string {
declare function edition:findEdition($editionID as xs:string?) as xs:string? {

if(not($editionID) or $editionID eq '') then(
let $edition := (collection('/db/apps')//edirom:edition)[1]
Expand Down
172 changes: 68 additions & 104 deletions add/index.xql
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ declare option output:omit-xml-declaration "yes";
(: VARIABLE DECLARATIONS =================================================== :)

declare variable $edition := request:get-parameter("edition", "");
declare variable $editionUri := edition:findEdition($edition);
declare variable $preferences := doc(edition:getPreferencesURI($editionUri));
declare variable $editionUri := if($edition) then edition:findEdition($edition) else();
riedde marked this conversation as resolved.
Show resolved Hide resolved
declare variable $preferences := if($editionUri) then(doc(edition:getPreferencesURI($editionUri))) else();

let $eoEditionFiles := collection('/db/apps')//edirom:edition[@xml:id]
let $eoEditionFilesCount := count($eoEditionFiles)
Expand All @@ -46,101 +46,63 @@ let $comment := comment{"
"
}

let $eoEditionFileSingle := <html>
<head>
<meta charset="UTF-8"/>
<title>{edition:getName($editionUri)} – Edirom-Online</title>
<!-- **CSS** -->
<link rel="stylesheet" type="text/css" href="resources/css/todo.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/annotation-style.css"/>

<!-- **CSS** -->
<link rel="stylesheet" href="resources/css/font-awesome.min.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/tipped/tipped.css"/>

<script>
var debug=false;
</script>

<!-- **Raphael JS** -->
<script type="text/javascript" src="resources/js/raphael-min.js"/>

<!-- **Leaflet** -->
<link rel="stylesheet" href="resources/leaflet-0.7.3/leaflet.css"/>
<link rel="stylesheet" href="resources/Leaflet.tooltip-master/dist/leaflet.tooltip.css"/>
<script type="text/javascript" src="resources/leaflet-0.7.3/leaflet.js"/>
<script type="text/javascript" src="resources/facsimileLayer/FacsimileLayer.js"/>
<script src="resources/Leaflet.tooltip-master/dist/leaflet.tooltip.js"/>

<!-- **Open Sea Dragon** -->
<script type="text/javascript" src="resources/js/openseadragon.min.js"/>

<!-- **JQUERY** -->
<script type="text/javascript" src="resources/jquery/jquery-2.1.3.js" charset="utf-8"/>

<!-- **ACE** -->
<script src="resources/js/ace/ace.js" type="text/javascript" charset="utf-8"/>
<script src="resources/js/ace/mode-xml.js" type="text/javascript" charset="utf-8"/>

<link rel="stylesheet" href="resources/EdiromOnline-all.css"/>
<!-- TODO if prefs css then include here -->
{
if ($preferences//entry[@key = "additional_css_path" and @value != ''])
then
<link rel="stylesheet" href="{string-join((request:get-context-path(), substring-after($preferences//entry[@key = 'additional_css_path']/@value, 'xmldb:exist:///db/')), '/')}"/>
else ()
}
<script type="text/javascript" src="app.js"/>

<!-- **WHERE TO OPEN LINKS** -->
<base target="_blank"/>

</head>
<body>
<script type="text/javascript" src="resources/js/tipped/tipped.js"/>
</body>
</html>
let $eoEditionFileMulti := <html>
<head>
<meta charset="UTF-8"/>
<title>Edirom-Online</title>
<!-- **CSS** -->
<link rel="stylesheet" type="text/css" href="resources/css/todo.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/annotation-style.css"/>

<!-- **CSS** -->
<link rel="stylesheet" href="resources/css/font-awesome.min.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/tipped/tipped.css"/>

<!-- **Raphael JS** -->
<script type="text/javascript" src="resources/js/raphael-min.js"/>

<!-- **Leaflet** -->
<link rel="stylesheet" href="resources/leaflet-0.7.3/leaflet.css"/>
<link rel="stylesheet" href="resources/Leaflet.tooltip-master/dist/leaflet.tooltip.css"/>
<script type="text/javascript" src="resources/leaflet-0.7.3/leaflet.js"/>
<script type="text/javascript" src="resources/facsimileLayer/FacsimileLayer.js"/>
<script src="resources/Leaflet.tooltip-master/dist/leaflet.tooltip.js"/>

<!-- **Open Sea Dragon** -->
<script type="text/javascript" src="resources/js/openseadragon.min.js"/>

<!-- **JQUERY** -->
<script type="text/javascript" src="resources/jquery/jquery-2.1.3.js" charset="utf-8"/>

<!-- **ACE** -->
<script src="resources/js/ace/ace.js" type="text/javascript" charset="utf-8"/>
<script src="resources/js/ace/mode-xml.js" type="text/javascript" charset="utf-8"/>

<link rel="stylesheet" href="resources/EdiromOnline-all.css"/>

</head>
<body class="x-body">
<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>
<h3 class="navigatorCategoryTitle">Bitte Edition auswählen</h3>
<ul>
let $eoIndexPage := <html>
<head>
<meta charset="UTF-8"/>
<title>Edirom-Online</title>
<!-- **CSS** -->
<link rel="stylesheet" type="text/css" href="resources/css/todo.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/annotation-style.css"/>

<!-- **CSS** -->
<link rel="stylesheet" href="resources/css/font-awesome.min.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/tipped/tipped.css"/>

<!-- **Raphael JS** -->
<script type="text/javascript" src="resources/js/raphael-min.js"/>

<!-- **Leaflet** -->
<link rel="stylesheet" href="resources/leaflet-0.7.3/leaflet.css"/>
<link rel="stylesheet" href="resources/Leaflet.tooltip-master/dist/leaflet.tooltip.css"/>
<script type="text/javascript" src="resources/leaflet-0.7.3/leaflet.js"/>
<script type="text/javascript" src="resources/facsimileLayer/FacsimileLayer.js"/>
<script src="resources/Leaflet.tooltip-master/dist/leaflet.tooltip.js"/>

<!-- **Open Sea Dragon** -->
<script type="text/javascript" src="resources/js/openseadragon.min.js"/>

<!-- **JQUERY** -->
<script type="text/javascript" src="resources/jquery/jquery-2.1.3.js" charset="utf-8"/>

<!-- **ACE** -->
<script src="resources/js/ace/ace.js" type="text/javascript" charset="utf-8"/>
<script src="resources/js/ace/mode-xml.js" type="text/javascript" charset="utf-8"/>

<link rel="stylesheet" href="resources/EdiromOnline-all.css"/>
{
if(($eoEditionFilesCount gt 1 or $eoEditionFilesCount eq 0) and not($edition)) then
()
else
(<!-- TODO if prefs css then include here -->,
if ($preferences//entry[@key = "additional_css_path" and @value != ''])
then
<link rel="stylesheet" href="{string-join((request:get-context-path(), substring-after($preferences//entry[@key = 'additional_css_path']/@value, 'xmldb:exist:///db/')), '/')}"/>
else (),
<script type="text/javascript" src="app.js"/>,
<!-- **WHERE TO OPEN LINKS** -->,
<base target="_blank"/>)
}
</head>
<body class="x-body">
{if(($eoEditionFilesCount gt 1 or $eoEditionFilesCount 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
(<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())
Expand All @@ -158,11 +120,13 @@ let $eoEditionFileMulti := <html>
)
}
</ul>
</div>
</body>
</html>

)
}
</div>)
else
(<script type="text/javascript" src="resources/js/tipped/tipped.js"/>)
}
</body>
</html>
return
if($eoEditionFilesCount > 1 and not($edition))
then($comment, $eoEditionFileMulti)
else($comment, $eoEditionFileSingle)
($comment, $eoIndexPage)