From 43805c4c83aef3f81003ae9d0b6f18d259f49166 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Mon, 16 May 2022 17:38:21 +0200 Subject: [PATCH 001/107] Merge branch 'rel_v1.0.0-beta' closes #228 --- add/data/xql/getAnnotation.xql | 4 +- add/data/xql/getExtendedStaff.xql | 19 +- add/data/xql/getLinkTarget.xql | 80 +++--- add/data/xql/getMeasuresOnPage.xql | 2 +- add/data/xql/getParts.xql | 2 +- add/data/xql/getText.xql | 27 +- add/data/xql/search.xql | 27 +- add/data/xqm/annotation.xqm | 13 +- add/data/xqm/util.xqm | 50 ++++ add/data/xqm/work.xqm | 17 +- add/data/xslt/teiBody2HTML.xsl | 256 +++++++++++++++++- add/index.xql | 2 +- app/view/window/image/VerovioImage.js | 60 +--- app/view/window/source/MeasureBasedView.js | 2 +- app/view/window/source/VerovioView.js | 256 +++++------------- bootstrap.js | 5 - build.xml | 3 +- packages/eoTheme/sass/etc/facsimile.scss | 4 +- .../eoTheme/sass/etc/freidi-textView.scss | 79 ++++-- packages/eoTheme/sass/etc/freidi-texts.scss | 23 +- .../eoTheme/sass/etc/textViewContent.scss | 21 -- packages/eoTheme/sass/var/button/Button.scss | 5 + resources/css/todo.css | 50 +--- resources/js/verovio-view.js | 42 ++- 24 files changed, 584 insertions(+), 465 deletions(-) diff --git a/add/data/xql/getAnnotation.xql b/add/data/xql/getAnnotation.xql index 727177475..e28a33021 100644 --- a/add/data/xql/getAnnotation.xql +++ b/add/data/xql/getAnnotation.xql @@ -409,11 +409,11 @@ return then( for $a in $annot/mei:annot return - (

{annotation:getLocalizedTitle($annot)}

, (:TODO vs eutil:getLocalizedName($annot, $lang) :) + (

{eutil:getLocalizedTitle($annot, $lang)}

, annotation:getContent($a,'', $edition)) ) else( - (

{annotation:getLocalizedTitle($annot)}

, + (

{eutil:getLocalizedTitle($annot, $lang)}

, annotation:getContent($annot,'', $edition)) ) } diff --git a/add/data/xql/getExtendedStaff.xql b/add/data/xql/getExtendedStaff.xql index 7c6de9219..05f0674f3 100644 --- a/add/data/xql/getExtendedStaff.xql +++ b/add/data/xql/getExtendedStaff.xql @@ -8,10 +8,17 @@ declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace system="http://exist-db.org/xquery/system"; declare namespace transform="http://exist-db.org/xquery/transform"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; + declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; let $uri := request:get-parameter('uri', '') let $edition := request:get-parameter('edition', '') +let $basePath := eutil:get-app-base-url() + + +let $mei := doc($uri)/root() +let $mdivId := $mei//mei:mdiv[1]/data(@xml:id) return @@ -19,12 +26,12 @@ return - + - - + + - + @@ -43,7 +50,9 @@ return - + diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql index adaf33ca8..d9f1ba406 100644 --- a/add/data/xql/getLinkTarget.xql +++ b/add/data/xql/getLinkTarget.xql @@ -1,4 +1,4 @@ -xquery version "3.0"; +xquery version "3.1"; (: Edirom Online Copyright (C) 2011 The Edirom Project @@ -37,22 +37,6 @@ import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-n declare variable $lang := request:get-parameter('lang', ''); -declare function local:getLocalizedMEITitle($node) { - let $nodeName := local-name($node) - return - if ($lang = $node/mei:title/@xml:lang) - then ($node/mei:title[@xml:lang = $lang]/text()) - else ($node/mei:title[1]/text()) -}; -declare function local:getLocalizedTEITitle($node) { - let $nodeName := local-name($node) - return - if ($lang = $node/tei:title/@xml:lang) - then $node/tei:title[@xml:lang = $lang]/text() - else $node/tei:title[1]/text() - -}; - declare function local:getViews($type, $docUri, $doc) { @@ -104,6 +88,35 @@ declare function local:getViews($type, $docUri, $doc) { ), ',') }; +declare function local:getWindowTitle($doc, $type) as xs:string { + (: Work :) + if(exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) + then(eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang)) + + (: Recording :) + else if(exists($doc//mei:mei) and exists($doc//mei:recording)) + then(eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang)) + + (: Source / Score :) + else if($type = 'source' and exists($doc//mei:manifestation)) + then(string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang), + ($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type)='shelfmark'][1]), ' | ') + => normalize-space()) + else if($type = 'source' and exists($doc//mei:source)) + then(string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang), + ($doc//mei:source)[1]//mei:identifier[lower-case(@type)='shelfmark'][1]), ' | ') + => normalize-space()) + + (: Text :) + else if(exists($doc/tei:TEI)) + then(eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang)) + + (: HTML :) + else if($type = 'html') + then($doc//head/data(title)) + + else(string('unknown')) +}; let $uri := request:get-parameter('uri', '') let $uriParams := if(contains($uri, '?')) then(substring-after($uri, '?')) else('') @@ -136,8 +149,7 @@ let $internal := if(exists($internal))then($internal)else( else($internal) ) -let $type := - (: Work :) +let $type := (: Work :) if(exists($doc//mei:mei) and exists($doc//mei:work) and not(exists($doc//mei:perfMedium))) then(string('work')) @@ -149,7 +161,6 @@ let $type := else if(source:isSource($docUri)) then(string('source')) - (: Text :) else if(exists($doc/tei:TEI)) then(string('text')) @@ -163,33 +174,6 @@ let $type := else(string('unknown')) -let $title := (: Work :) - - if(exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) - then(local:getLocalizedMEITitle($doc//mei:work/mei:titleStmt)[1]) - - (: Recording :) - else if(exists($doc//mei:mei) and exists($doc//mei:recording)) - then(local:getLocalizedMEITitle($doc//mei:fileDesc/mei:titleStmt[1])) - - (: Source / Score without Shelfmark:) - else if(exists($doc//mei:mei) and exists($doc//mei:source) and not(exists($doc//mei:identifier[@type='shelfmark']))) - then(normalize-space(local:getLocalizedMEITitle($doc//mei:source/mei:titleStmt[1]))) - - (: Source / Score with Shelfmark:) - else if(exists($doc//mei:mei) and exists($doc//mei:source) and exists($doc//mei:identifier[@type='shelfmark'])) - then(concat(normalize-space(local:getLocalizedMEITitle($doc//mei:source/mei:titleStmt[1])),' | ',normalize-space($doc//mei:source//mei:identifier[@type='shelfmark']))) - - (: Text :) - else if(exists($doc/tei:TEI)) - then(local:getLocalizedTEITitle($doc//tei:fileDesc/tei:titleStmt[1])) - - (: HTML :) - else if($type = 'html') - then($doc//head/data(title)) - - else(string('unknown')) - let $internalIdType := if(exists($internal)) then(local-name($internal)) else('unknown') @@ -197,7 +181,7 @@ let $internalIdType := if(exists($internal)) return concat("{", "type:'", $type, - "',title:'", $title, + "',title:'", local:getWindowTitle($doc, $type), "',doc:'", $docUri, "',views:[", local:getViews($type, $docUri, $doc), "]", ",internalId:'", $internalId, $internalIdParam, diff --git a/add/data/xql/getMeasuresOnPage.xql b/add/data/xql/getMeasuresOnPage.xql index 73d1d7619..5a5533bc0 100644 --- a/add/data/xql/getMeasuresOnPage.xql +++ b/add/data/xql/getMeasuresOnPage.xql @@ -44,7 +44,7 @@ declare option exist:serialize "method=text media-type=text/plain omit-xml-decla declare function local:getMeasures($mei as node(), $surface as node()) as xs:string* { for $zone in $surface/mei:zone[@type='measure'] - let $measures := $mei//mei:measure[contains(@facs, concat('#', $zone/@xml:id))] + let $measures := $mei//mei:measure[concat('#', $zone/@xml:id) = tokenize(@facs, ' ')] return for $measure in $measures let $measureLabel := if ($measure/@label) then ($measure/string(@label)) else ($measure/string(@n)) diff --git a/add/data/xql/getParts.xql b/add/data/xql/getParts.xql index acd41fbfd..6cf9572b1 100644 --- a/add/data/xql/getParts.xql +++ b/add/data/xql/getParts.xql @@ -29,7 +29,7 @@ declare option exist:serialize "method=text media-type=text/plain omit-xml-decla let $uri := request:get-parameter('uri', '') let $mei := doc($uri)/root() -let $ret := for $part in $mei//mei:instrumentation/mei:instrVoice +let $ret := for $part in ($mei//mei:instrumentation/mei:instrVoice | $mei//mei:perfMedium//mei:perfRes) return concat('{label: "', $part/@label, '", id:"', $part/@xml:id, '", selectedByDefault:true, selected:true}') return concat('[', string-join($ret, ','), ']') \ No newline at end of file diff --git a/add/data/xql/getText.xql b/add/data/xql/getText.xql index 211f43a81..b534a2ed1 100644 --- a/add/data/xql/getText.xql +++ b/add/data/xql/getText.xql @@ -23,8 +23,8 @@ import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; declare namespace request="http://exist-db.org/xquery/request"; - declare namespace tei="http://www.tei-c.org/ns/1.0"; +declare namespace xhtml="http://www.w3.org/1999/xhtml"; declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; (:declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";:) @@ -66,14 +66,29 @@ let $imagePrefix := if($imageserver = 'leaflet') let $xsl := if($xslInstruction)then($xslInstruction)else('../xslt/teiBody2HTML.xsl') -let $params := (, - , - +let $params := ( + (: parameters for Edirom-Online :) + , + , + (: parameters for the TEI Stypesheets :) + , + , + , + , + ,(:TODO frm XSLT :) + , + ) let $doc := if($xslInstruction)then(transform:transform($doc, doc($xsl), {$params})) else(transform:transform($doc, doc($xsl), {$params})) +let $doc := transform:transform($doc, doc('../xslt/edirom_idPrefix.xsl'), ) + +let $body := $doc//xhtml:body + return - - transform:transform($doc, doc('../xslt/edirom_idPrefix.xsl'), ) + element div { + for $attribute in $body/@* return $attribute, + for $node in $body/node() return $node + } \ No newline at end of file diff --git a/add/data/xql/search.xql b/add/data/xql/search.xql index f3eaeacda..6f2fb4a2b 100644 --- a/add/data/xql/search.xql +++ b/add/data/xql/search.xql @@ -19,6 +19,7 @@ xquery version "3.0"; :) import module namespace kwic="http://exist-db.org/xquery/kwic"; +import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; declare namespace tei="http://www.tei-c.org/ns/1.0"; declare namespace mei="http://www.music-encoding.org/ns/mei"; @@ -28,24 +29,6 @@ declare namespace request="http://exist-db.org/xquery/request"; declare variable $lang := request:get-parameter('lang', ''); -declare function local:getLocalizedMEITitle($node) { - let $nodeName := local-name($node) - return - if ($lang = $node/mei:title/@xml:lang) - then $node/mei:title[@xml:lang = $lang]/text() - else $node/mei:title[1]/text() - -}; - -declare function local:getLocalizedTEITitle($node) { - let $nodeName := local-name($node) - return - if ($lang = $node/tei:title/@xml:lang) - then $node/tei:title[@xml:lang = $lang]/text() - else $node/tei:title[1]/text() - -}; - declare function local:filter($node as node(), $mode as xs:string) as xs:string? { if ($mode eq 'before') then concat($node, ' ') @@ -116,16 +99,16 @@ let $return := let $uri := document-uri($doc) let $title := (: Annotation :) if(local-name($hit) eq 'annot') - then(local:getLocalizedMEITitle($hit)) + then(eutil:getLocalizedTitle($hit, $lang)) (: Work :) else if(exists($doc//mei:mei) and exists($doc//mei:work)) - then(local:getLocalizedMEITitle($doc//mei:work/mei:titleStmt)) + then(eutil:getLocalizedTitle($doc//mei:work/mei:titleStmt, $lang)) (: Source / Score :) else if(exists($doc//mei:mei) and exists($doc//mei:source)) - then(local:getLocalizedMEITitle($doc//mei:source/mei:titleStmt)) + then(eutil:getLocalizedTitle($doc//mei:source/mei:titleStmt, $lang)) (: Text :) else if(exists($doc/tei:TEI)) - then(local:getLocalizedTEITitle($doc//tei:titleStmt)) + then(eutil:getLocalizedTitle($doc//tei:titleStmt, $lang)) else(string('unknown')) order by ft:score($hit) descending return diff --git a/add/data/xqm/annotation.xqm b/add/data/xqm/annotation.xqm index a1ccd28d8..b1e9f6f13 100644 --- a/add/data/xqm/annotation.xqm +++ b/add/data/xqm/annotation.xqm @@ -37,16 +37,6 @@ declare namespace mei="http://www.music-encoding.org/ns/mei"; declare namespace system="http://exist-db.org/xquery/system"; declare namespace transform="http://exist-db.org/xquery/transform"; -declare function local:getLocalizedTitle($node) { - let $lang := request:get-parameter('lang', '') - let $nodeName := local-name($node) - return - if ($lang = $node/mei:title/@xml:lang) - then $node/mei:title[@xml:lang = $lang]/text() - else $node/mei:title[1]/text() - -}; - declare function local:getLocalizedName($node) { let $lang := request:get-parameter('lang', '') let $nodeName := local-name($node) @@ -82,7 +72,8 @@ declare function annotation:annotationsToJSON($uri as xs:string, $edition as xs: :) declare function annotation:toJSON($anno as element(), $edition as xs:string) as xs:string { let $id := $anno/@xml:id - let $title := normalize-space(local:getLocalizedTitle($anno)) + let $lang := request:get-parameter('lang', '') + let $title := eutil:getLocalizedTitle($anno, $lang) let $doc := $anno/root() let $prio := local:getLocalizedName($doc/id(substring($anno/mei:ptr[@type = 'priority']/@target,2))) let $pList := distinct-values(tokenize($anno/@plist, ' ')) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 42385c194..933c5f7c1 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -37,8 +37,24 @@ import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace tei="http://www.tei-c.org/ns/1.0"; declare namespace edirom="http://www.edirom.de/ns/1.3"; +(:~ +: Returns the namespace (standardized prefix) +: +: @param $node The node to be processed +: @return The namespace (prefix) +:) + +declare function eutil:getNamespace($node as node()) as xs:string { + switch (namespace-uri($node)) + case 'http://www.music-encoding.org/ns/mei' return 'mei' + case 'http://www.tei-c.org/ns/1.0' return 'tei' + case 'http://www.edirom.de/ns/1.3' return 'edirom' + default return 'unknown' +}; + (:~ : Returns a localized string : @@ -72,6 +88,34 @@ return $name => string-join(' ') }; +(:~ +: Returns a localized string +: +: @param $node The node to be processed +: @param $lang Optional parameter for lang selection +: @return The string (normalized space) +:) + +declare function eutil:getLocalizedTitle($node as node(), $lang as xs:string?) as xs:string { + + let $namespace := eutil:getNamespace($node) + + let $titleMEI := if ($lang != '' and $lang = $node/mei:title/@xml:lang) + then ($node/mei:title[@xml:lang = $lang]//text() => string-join() => normalize-space()) + else (($node//mei:title)[1]//text() => string-join() => normalize-space()) + + let $titleTEI := if ($lang != '' and $lang = $node/tei:title/@xml:lang) + then $node/tei:title[@xml:lang = $lang]/text() + else $node/tei:title[1]/text() + + return + if ($namespace = 'mei') + then($titleMEI) + else if ($namespace = 'tei') + then($titleTEI) + else('unknown') + +}; (:~ : Returns a document : @@ -201,3 +245,9 @@ declare function eutil:getLanguage($edition as xs:string?) as xs:string { eutil:getPreference('application_language', $edition) ) }; + +declare function eutil:get-app-base-url() as xs:string { + let $appName := substring-before(substring-after(request:get-url(), 'apps/'), '/') + let $basePath := concat(substring-before(request:get-uri(), $appName), $appName) return + $basePath +}; diff --git a/add/data/xqm/work.xqm b/add/data/xqm/work.xqm index e35141352..7e384ec8a 100644 --- a/add/data/xqm/work.xqm +++ b/add/data/xqm/work.xqm @@ -33,15 +33,6 @@ import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util declare namespace mei="http://www.music-encoding.org/ns/mei"; declare namespace edirom="http://www.edirom.de/ns/1.3"; -declare function local:getLocalizedTitle($node) { - - let $lang := request:get-parameter('lang', '') - return - if ($lang = $node/mei:title/@xml:lang) - then (normalize-space(($node/mei:title)[@xml:lang = $lang][1]/text())) - else (normalize-space(($node//mei:title)[1]/text())) -}; - (:~ : Returns a JSON representation of a Work : @@ -51,12 +42,13 @@ declare function local:getLocalizedTitle($node) { declare function work:toJSON($uri as xs:string, $edition as xs:string) as xs:string { let $work := doc($uri)/mei:mei + let $lang := request:get-parameter('lang', '') return concat(' {', 'id: "', $work/string(@xml:id), '", ', 'doc: "', $uri, '", ', - 'title: "', replace(local:getLocalizedTitle($work//mei:work), '"', '\\"'), '"', + 'title: "', replace(eutil:getLocalizedTitle($work//mei:work, $lang), '"', '\\"'), '"', '}') }; @@ -74,12 +66,13 @@ declare function work:isWork($uri as xs:string) as xs:boolean { (:~ : Returns a works's label : -: @param $source The URIs of the Work's document to process +: @param $work The URIs of the Work's document to process +: @param $edition The ID of the Edition the Work is part of : @return The label :) declare function work:getLabel($work as xs:string, $edition as xs:string) as xs:string { - local:getLocalizedTitle(doc($work)//mei:work) + eutil:getLocalizedTitle(doc($work)//mei:work, request:get-parameter('lang', '')) }; (:~ diff --git a/add/data/xslt/teiBody2HTML.xsl b/add/data/xslt/teiBody2HTML.xsl index cd0c9dc35..854d13ba9 100644 --- a/add/data/xslt/teiBody2HTML.xsl +++ b/add/data/xslt/teiBody2HTML.xsl @@ -31,11 +31,8 @@ en - + - false - false - @@ -108,9 +105,6 @@ - - - false @@ -1026,6 +1020,246 @@ + + +

Process element note

+

copied from TEI Stylesheets xhtml2/core.xsl in order to fix link target in Edirom-Online

+
+
+ + + + + + + + [ + + ] + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + notelink + + + + loadLink(' + + ', {useExisting:true}); return false; + + + + + + + + + , + + + + + + + + + + + + + [ + + ] + + +
+ + + + + + + +
+
+ +
+ + + + + + + + + + + Note + + : + + + + +
+
+ +
+ + + + + + + + + + + + +

+ +

+
+
+
+
+ + + + + + + + + +
+ + + + +
+
+ + + + + + + + + + + + + + [ + + ] + + + +
+ + + + + note + + + + + + + + + + Note + + : + + + + +
+
+
+
+ + + +

Process element note

+

copied from TEI Stylesheets xhtml2/core.xsl in order to fix link target in Edirom-Online

+
+
+ + + + + + Make note + +
+ + + + + + + . + + + +
+ +
+ + + + + link_return + + "Go back to text + + loadLink(' + + ', {useExisting:true}); return false; + + + + + +
+
+ @@ -1040,4 +1274,12 @@ + + + + + + + + \ No newline at end of file diff --git a/add/index.xql b/add/index.xql index fceebc539..261ce156b 100755 --- a/add/index.xql +++ b/add/index.xql @@ -118,7 +118,7 @@ let $eoEditionFileMulti := - +

Edirom Online

diff --git a/app/view/window/image/VerovioImage.js b/app/view/window/image/VerovioImage.js index cbf6239c8..f61c262ca 100644 --- a/app/view/window/image/VerovioImage.js +++ b/app/view/window/image/VerovioImage.js @@ -21,22 +21,9 @@ Ext.define('EdiromOnline.view.window.image.VerovioImage', { layout: 'fit', - currId: null, - renderer: null, - text: null, - imageSet: null, - bodyDoc: null, - pageSpinner: null, - pageHeight: null, - pageWidth: null, - numberPages: null, - - iframe: null, - initComponent: function () { var me = this; - me.currId = me.id; me.html = '
'; @@ -44,54 +31,19 @@ Ext.define('EdiromOnline.view.window.image.VerovioImage', { me.callParent(); }, - setBody: function (bodyDoc) { - var me = this; - me.bodyDoc = bodyDoc; - }, - - setImageSet: function (imageSet) { + setIFrameURL: function (url) { var me = this; - me.imageSet = imageSet; - var contEl = me.el.getById(me.id + '_rendContIFrame'); contEl.set({ - 'src': imageSet + 'src': url }); }, - showPage: function (pageNr, isSetCount) { - var me = this; - - var iframe = Ext.getDom(me.id + '_rendContIFrame').contentWindow; - if (isSetCount) { - var pageCount = iframe.numberPages; - me.pageSpinner.setStore(pageCount); - me.pageSpinner.setPage(1); - } - iframe.loadPage(pageNr); - }, - - showAllPages: function () { + showMovement: function (movementId) { var me = this; - var iframe = Ext.getDom(me.id + '_rendContIFrame').contentWindow; - iframe.allPages(); - }, - - showContinuousWidth: function () { - var me = this; - var iframe = Ext.getDom(me.id + '_rendContIFrame').contentWindow; - iframe.loadContinuousWidth(); - }, - - showContinuousHight: function () { - var me = this; - var iframe = Ext.getDom(me.id + '_rendContIFrame').contentWindow; - iframe.loadContinuousHight(); - }, - - setPageSpinner: function (pageSpinner) { - this.pageSpinner = pageSpinner; + var iframe = Ext.fly(me.id + '_rendContIFrame').dom.contentWindow; + iframe.showMovement(movementId); } -}); \ No newline at end of file +}); diff --git a/app/view/window/source/MeasureBasedView.js b/app/view/window/source/MeasureBasedView.js index ea8a3d4ab..881f9af00 100644 --- a/app/view/window/source/MeasureBasedView.js +++ b/app/view/window/source/MeasureBasedView.js @@ -105,7 +105,7 @@ Ext.define('EdiromOnline.view.window.source.MeasureBasedView', { cls : 'voiceFilter toolButton', tooltip: { text: getLangString('view.window.source.SourceView_MeasureBasedView_selectVoices'), align: 'bl-tl' }, margin: '0 0 0 5', - // disabled: false, + disabled: true, hidden: true }); diff --git a/app/view/window/source/VerovioView.js b/app/view/window/source/VerovioView.js index 3d6c14ad8..d2404b211 100644 --- a/app/view/window/source/VerovioView.js +++ b/app/view/window/source/VerovioView.js @@ -20,11 +20,7 @@ Ext.define('EdiromOnline.view.window.source.VerovioView', { extend: 'EdiromOnline.view.window.View', requires:[ - 'EdiromOnline.view.window.image.VerovioImage', - 'Ext.draw.Component', - 'Ext.slider.Single', - 'Ext.form.ComboBox', - 'Ext.window.MessageBox'], + 'EdiromOnline.view.window.image.VerovioImage'], alias: 'widget.verovioView', @@ -33,11 +29,7 @@ Ext.define('EdiromOnline.view.window.source.VerovioView', { border: 0, bottomBar: null, - imageToShow: null, - - pageSpinner: null, - - pageBasedView: null, + verovioImageView: null, cls: 'verovioView', @@ -45,202 +37,90 @@ Ext.define('EdiromOnline.view.window.source.VerovioView', { var me = this; - me.pageBasedView = Ext.create('EdiromOnline.view.window.image.VerovioImage'); + me.addEvents( + 'gotoMeasure', + 'gotoMeasureByName' + ); + me.verovioImageView = Ext.create('EdiromOnline.view.window.image.VerovioImage'); me.viewerContainer = Ext.create('Ext.panel.Panel', { region: 'center', border: 0, layout: 'card', - items:[ - me.pageBasedView] - }); - - - me.bottomBar = new EdiromOnline.view.window.BottomBar({ - owner: me, region: 'south', enableOverflow: false + items: [me.verovioImageView] }); - me.items =[ - me.viewerContainer, - me.bottomBar]; + me.items = [ + me.viewerContainer ]; me.callParent(); - me.on('afterrender', me.createToolbarEntries, me); + me.on('afterrender', me.createMenuEntries, me, {single: true}); }, - setIFrameURL: function (imageSet) { + setIFrameURL: function (url) { var me = this; - me.imageSet = imageSet; - me.pageBasedView.setImageSet(me.imageSet); + me.verovioImageView.setIFrameURL(url); }, - createToolbarEntries: function () { + createMenuEntries: function() { + var me = this; - var entries = me.createPageSpinner(); - Ext.Array.each(entries, function (entry) { - me.bottomBar.add(entry); - }); - }, - - stretchHightClick: function (me) { - me.pageSpinner.setDisabled(true); - me.pageBasedView.showContinuousHight(); - }, - - stretchWidthClick: function (me) { - me.pageSpinner.setDisabled(true); - me.pageBasedView.showContinuousWidth(); - }, - - pageClick: function (me) { - me.pageSpinner.setDisabled(false); - me.pageBasedView.showPage(1, true); - }, - - pageOriginalClick: function (me) { - me.pageSpinner.setDisabled(true); - me.pageBasedView.showAllPages(); + + me.gotoMenu = Ext.create('Ext.button.Button', { + text: getLangString('view.window.source.SourceView_gotoMenu'), + indent: false, + cls: 'menuButton', + menu : { + items: [ + { + id: me.id + '_gotoMeasure', + text: getLangString('view.window.source.SourceView_gotoMeasure'), + handler: Ext.bind(me.gotoMeasureDialog, me) + } + ] + } + }); + me.window.getTopbar().addViewSpecificItem(me.gotoMenu, me.id); }, - - createPageSpinner: function () { - + + setMovements: function(movements) { var me = this; - - //var storeField = new Array('Original', 'Pages', 'Continuous Height', 'Continuous Width'); - var storeField = new Array('All Pages', 'Pagebased', 'Continuous Staff'); - - var combo = Ext.create('Ext.form.ComboBox', { - fieldLabel: 'Rendering View', - store: storeField, - queryMode: 'local', - width: 230, - displayField: 'name', - editable: false, - - listeners: { - select: function (combo, record, index) { - if (combo.getValue() === 'All Pages') { - me.pageOriginalClick(me); - } else if (combo.getValue() === 'Pagebased') { - me.pageClick(me); - /*} else if (combo.getValue() === 'Continuous Height') { - me.stretchHightClick(me);*/ - } else if (combo.getValue() === 'Continuous Staff') { - me.stretchWidthClick(me); - } - } - } - }); - combo.setValue(storeField[0]); - - me.pageSpinner = Ext.create('EdiromOnline.view.window.source.VerovioPageSpinner', { - width: 120, - cls: 'pageSpinner' - }); - - me.pageBasedView.setPageSpinner(me.pageSpinner); - me.pageSpinner.setPageBasedView(me.pageBasedView); - - return[combo, me.pageSpinner]; + + me.movements = movements; + + var movementItems = []; + movements.each(function(movement) { + movementItems.push({ + text: movement.get('name'), + handler: Ext.bind(me.showMovement, me, movement.get('id'), true) + }); + }); + + me.gotoMenu.menu.add({ + id: me.id + '_gotoMovement', + text: getLangString('view.window.source.SourceView_gotoMovement'), + menu: { + items: movementItems } -}); + }); + }, -Ext.define('EdiromOnline.view.window.source.VerovioPageSpinner', { - extend: 'Ext.container.Container', - - alias: 'widget.verovioPageSpinner', - - layout: 'hbox', - - pageBasedView: null, - - initComponent: function () { - - this.items =[]; - this.callParent(); - }, - - next: function () { - var newValue = this.combo.getValue() + 1; - if (this.store.indexOf(newValue) != -1) { - this.setPage(newValue); - this.pageBasedView.showPage(newValue, false); - } - }, - - prev: function () { - var newValue = this.combo.getValue() -1; - if (this.store.indexOf(newValue) != -1) { - this.setPage(newValue); - this.pageBasedView.showPage(newValue, false); - } - }, - - setPageBasedView: function (pageBasedView) { - this.pageBasedView = pageBasedView; - }, - - setPage: function (id) { - this.combo.setValue(id); - }, - - setStore: function (test) { - + showMovement: function(menuItem, event, movementId) { var me = this; - - this.removeAll(); - - var storeField = new Array(test-1); - var value = 1; - for (var i = 0; i <= test-1; i++) { - storeField[i] = value++; - } - - this.store = storeField; - - this.combo = Ext.create('Ext.form.ComboBox', { - width: 35, - hideTrigger: true, - queryMode: 'local', - store: this.store, - displayField: 'name', - editable: true, - valueField: 'id', - cls: 'pageInputBox', - autoSelect: true, - enableKeyEvents: true, - listeners: { - keydown:function (combo, e, eOpts) { - if (e.getKey() == 13) { - me.setPage(combo.getValue()); - me.pageBasedView.showPage(combo.getValue(), false); - } - } - } - }); - - this.add([ { - xtype: 'button', - cls: 'prev toolButton', - listeners: { - scope: this, - click: this.prev - } - }, - this.combo, - { - xtype: 'label', - text: 'von '+ test, - margins: '5 0 0 5' - }, - { - xtype: 'button', - cls: 'next toolButton', - listeners: { - scope: this, - click: this.next - } - }]); - } -}); \ No newline at end of file + me.verovioImageView.showMovement(movementId); + }, + + gotoMeasureDialog: function() { + var me = this; + + Ext.create('EdiromOnline.view.window.source.GotoMsg', { + movements: me.movements, + callback: Ext.bind(function(measure, movementId) { + this.fireEvent('gotoMeasureByName', this, measure, movementId); + }, + me) + }).show(); + }, + +}); diff --git a/bootstrap.js b/bootstrap.js index 3b4a3d04c..940016f16 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -12,7 +12,6 @@ Ext.Loader.addClassPathMappings({ "EdiromOnline.view.window.source.HorizontalMeasureViewer": "app/view/window/source/MeasureBasedView.js", "EdiromOnline.view.window.source.IntervalSpinner": "app/view/window/source/MeasureBasedView.js", "EdiromOnline.view.window.source.MeasureSpinner": "app/view/window/source/MeasureBasedView.js", - "EdiromOnline.view.window.source.VerovioPageSpinner": "app/view/window/source/VerovioView.js", "Ext": "ext/src", "Ext.DomHelper": "ext/src/dom/Helper.js", "Ext.DomQuery": "ext/src/dom/Query.js", @@ -101,7 +100,6 @@ Ext.ClassManager.addNameAlternateMappings({ "EdiromOnline.view.window.source.MeasureSpinner": [], "EdiromOnline.view.window.source.PageBasedView": [], "EdiromOnline.view.window.source.SourceView": [], - "EdiromOnline.view.window.source.VerovioPageSpinner": [], "EdiromOnline.view.window.source.VerovioView": [], "EdiromOnline.view.window.text.FacsimileView": [], "EdiromOnline.view.window.text.TextFacsimileSplitView": [], @@ -1066,9 +1064,6 @@ Ext.ClassManager.addNameAliasMappings({ "EdiromOnline.view.window.source.SourceView": [ "widget.sourceView" ], - "EdiromOnline.view.window.source.VerovioPageSpinner": [ - "widget.verovioPageSpinner" - ], "EdiromOnline.view.window.source.VerovioView": [ "widget.verovioView" ], diff --git a/build.xml b/build.xml index f41391280..c2009803c 100755 --- a/build.xml +++ b/build.xml @@ -3,7 +3,7 @@ - + @@ -24,6 +24,7 @@ + diff --git a/packages/eoTheme/sass/etc/facsimile.scss b/packages/eoTheme/sass/etc/facsimile.scss index 8339fd590..9811183e8 100644 --- a/packages/eoTheme/sass/etc/facsimile.scss +++ b/packages/eoTheme/sass/etc/facsimile.scss @@ -9,11 +9,11 @@ } .measureInner { -/* background-color: rgba(100, 100, 100, 0.2); */ + background-color: rgba(255, 255, 255, 0.5); border-radius: 15px; padding: 3px 5px 0; text-shadow: 0 1px 2px #000000, 0 0 5px #ffffff; - + top: 50%; @include background-image(radial-gradient(center , rgba(100, 100, 100, 0.3), rgba(0, 0, 0, 0) 5px)); } diff --git a/packages/eoTheme/sass/etc/freidi-textView.scss b/packages/eoTheme/sass/etc/freidi-textView.scss index b0462d3df..cd099ff76 100644 --- a/packages/eoTheme/sass/etc/freidi-textView.scss +++ b/packages/eoTheme/sass/etc/freidi-textView.scss @@ -165,7 +165,7 @@ $underlineColor: #333333; .titlePart:nth-child(4) { } - } + } //für die CastList-Zeitangabe ul > p {margin-left: 9.5em;} @@ -173,8 +173,8 @@ $underlineColor: #333333; //für die CastList-Rollennamen li span.role:first-child {letter-spacing: 0.2em;} - .stage { - font-size: 0.8em; + .stage { + font-size: 0.8em; //&.left {margin-left: 6em;} &.center {width: $pageWidth - 1.5em; margin-left: 2em;} @@ -230,7 +230,7 @@ $underlineColor: #333333; .expanded {letter-spacing: 0.2em;} - .antiqua {font-style: italic;} + .antiqua {font-style: italic;} .lb_indent {padding-left: 12em;} @@ -253,7 +253,7 @@ $underlineColor: #333333; font-size: 16px; display: block; - line-height: 1.3em; + line-height: 1.4em; h1 { font-size: 2em; @@ -282,7 +282,7 @@ $underlineColor: #333333; font-size: 1.2em; margin-top: 3em; - margin-bottom: 1em; + margin-bottom: 1em; } div.act { @@ -293,6 +293,18 @@ $underlineColor: #333333; display: none; } + .sup, sup { + font-size: 0.7em; //TODO maybe this can be calculated as 50% line-height? + line-height: 1; + vertical-align: super; + } + + .sub, sub { + font-size: 0.7em; //TODO maybe this can be calculated as 50% line-height? + line-height: 1; + vertical-align: sub; + } + .stage { font-style: normal; font-size: 0.9em; @@ -352,7 +364,7 @@ $underlineColor: #333333; div.p-in-sp, div.l { margin-left: 2em; - line-height: 1.4em; + line-height: 1.4em; } .sp { @@ -399,9 +411,44 @@ $underlineColor: #333333; display: inline; margin-left: 0; font-size: 1em; - } - - div.note {display: none;} + } + + /* textViewContent footnotes as generated by the TEI Stylesheets */ + div.notes { + display: table; + + div.note { + display: table-row; + font-size: smaller; + //margin-left: 1em; + //margin-bottom: 1em; + //text-indent: -1em; + + /*div.noteHeading + { + margin-top: 9pt; + border: 0; + border-top: 1pt; + border-style: solid; + padding-top: 6pt; + font-size: larger; + font-weight: bold; + }*/ + + span.noteLabel { + display: table-cell; + font-style: italic; + text-align: right; + } + + div.noteBody { + display: table-cell; + padding-bottom: 1em; + padding-left: 1em; + } + } + } + span.note {display: none;} i.inline-comment { @@ -412,7 +459,7 @@ $underlineColor: #333333; color: #999999; &:hover { - color: #cc3333; + color: #cc3333; } } @@ -1207,7 +1254,7 @@ $underlineColor: #333333; tr:first-child td { @include background-image(linear-gradient(top, #e5e5e5, #cccccc)); - font-weight: normal; + font-weight: normal; /*&:first-child { border-radius: 5px 0 0 5px; @@ -1263,7 +1310,7 @@ $underlineColor: #333333; cursor: pointer; &:visited, &:active, &:hover { - color: #666666; + color: #666666; } } @@ -1362,7 +1409,7 @@ $underlineColor: #333333; /* td:first-child + td p:first-child { - display: none; + display: none; } */ } @@ -1376,7 +1423,7 @@ $underlineColor: #333333; .musikgenese, .startwindow, .referenceoverview, .audiooverview, .workoverview { td:first-child + td p:first-child { - display: none; + display: none; } } @@ -1419,7 +1466,7 @@ $underlineColor: #333333; //das arbeitet auf XML, nicht auf HTML (Attribut @rend!) .lg[rend~="indent"] { - display: block; + display: block; margin-left: 8em; margin-top: 0.5em; margin-bottom: 0.5em; diff --git a/packages/eoTheme/sass/etc/freidi-texts.scss b/packages/eoTheme/sass/etc/freidi-texts.scss index 36886ee84..201ff001f 100644 --- a/packages/eoTheme/sass/etc/freidi-texts.scss +++ b/packages/eoTheme/sass/etc/freidi-texts.scss @@ -103,7 +103,7 @@ /* Libretto KAtx4 */ .textViewContent .freidi_libretto.KAtx4 .titlePart.main span.underline { border-bottom: 1px solid #000000; -} +} .textViewContent .freidi_libretto.KAtx4 div.l { margin-left: 7em; @@ -370,11 +370,11 @@ .textViewContent .freidi_libretto .p-in-sp .pagebreak { margin-left: -6em; -} +} .textViewContent .freidi_libretto .p-in-sp .pagebreak.inner { margin-left: 6em; -} +} .textViewContent .freidi_libretto .titlePart { line-height: 1.6em; @@ -383,7 +383,7 @@ .textViewContent .freidi_libretto .titlePart.main { font-size: 28px; -} +} .textViewContent .freidi_libretto span.role { margin-left: 0.2em; @@ -394,11 +394,11 @@ } .textViewContent span.act { - font-size: 28px; + font-size: 28px; } .textViewContent span.scene { - font-size: 23px; + font-size: 23px; } .textViewContent div.stage, .textViewContent span.stage { @@ -483,7 +483,7 @@ .textViewContent div.note { - display: none; + display: block; } .textViewContent h2, .textViewContent h3 { @@ -505,7 +505,7 @@ .textViewContent .sp { margin-top: 1em; margin-bottom: 1em; - line-height: 1.4em; + line-height: 1.4em; } @@ -518,7 +518,7 @@ } .lg[rend~="indent"] { - display: block; + display: block; margin-left: 8em; margin-top: 0.5em; margin-bottom: 0.5em; @@ -583,8 +583,8 @@ .textViewContent span.place { font-size: 70%; - position: relative; - top: -0.3em; + position: relative; + top: -0.3em; } @@ -622,4 +622,3 @@ } /****************/ - diff --git a/packages/eoTheme/sass/etc/textViewContent.scss b/packages/eoTheme/sass/etc/textViewContent.scss index 5cf560359..8b33d1ec9 100644 --- a/packages/eoTheme/sass/etc/textViewContent.scss +++ b/packages/eoTheme/sass/etc/textViewContent.scss @@ -386,27 +386,6 @@ text-decoration: none; } -.textViewContent div.noteHeading -{ - margin-top: 9pt; - border: 0; - border-top: 1pt; - border-style: solid; - padding-top: 6pt; - font-size: larger; - font-weight: bold; -} - -.textViewContent div.noteBody { display: inline; } - -.textViewContent div.note -{ - margin-left: 1em; - margin-bottom: 4pt; - text-indent: -1em; -} - -.textViewContent span.noteLabel { font-style: italic; } .textViewContent span.noteNumber:before { content: "["; } .textViewContent span.noteNumber:after { content: "]. "; } .textViewContent span.note { font-size: smaller; } diff --git a/packages/eoTheme/sass/var/button/Button.scss b/packages/eoTheme/sass/var/button/Button.scss index 995422c19..b7f102363 100644 --- a/packages/eoTheme/sass/var/button/Button.scss +++ b/packages/eoTheme/sass/var/button/Button.scss @@ -112,6 +112,11 @@ $edirom-taskbarWindowButton-background-color: #cccccc; } } +.x-btn-default-toolbar-small.x-pressed { + background-color: #A3A3A3 !important; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4) inset; +} + .toolButton { width: 24px; cursor: pointer; diff --git a/resources/css/todo.css b/resources/css/todo.css index eb8756881..38aefe7e6 100644 --- a/resources/css/todo.css +++ b/resources/css/todo.css @@ -57,13 +57,13 @@ span.musicalSymbol { font-family: Bravura; } -@font-face { - font-family: 'Bravura'; - src: url('../fonts/bravura/eot/Bravura.eot#') format('eot'), +@font-face { + font-family: 'Bravura'; + src: url('../fonts/bravura/eot/Bravura.eot#') format('eot'), url('../fonts/bravura/woff/Bravura.woff') format('woff'), url('../fonts/bravura/otf/Bravura.otf') format('opentype'), url('../fonts/bravura/svg/Bravura.svg#bravuraregular') format('svg'), - url('../fonts/bravura/eot/BravuraText.eot#') format('eot'), + url('../fonts/bravura/eot/BravuraText.eot#') format('eot'), url('../fonts/bravura/woff/BravuraText.woff') format('woff'), url('../fonts/bravura/otf/BravuraText.otf') format('opentype'), url('../fonts/bravura/svg/BravuraText.svg#bravuraregular') format('svg'); @@ -91,16 +91,6 @@ span.musicalSymbol { z-index: 5; } -.measureInner { - position: relative; - float: left; - left: 50%; - transform: translate(0, -50%); - - background-color: rgba(255, 255, 255, 0.5); - border-radius: 4px; -} - .ediromWindow .annotation { border: 1px solid red; background-color: rgba(255, 0, 0, 0.3); @@ -185,16 +175,6 @@ span.musicalSymbol { line-height: 12px; } -.sup { - font-size: 60%; - vertical-align: super; -} - -.sub { - font-size: 60%; - vertical-align: sub; -} - .address.plain { margin: 0.5em 0 0 0; } @@ -219,10 +199,6 @@ span.italic { font-style: italic; } -p { - line-height: 1.2; -} - #navigator .navigatorCategory2 { padding: 0 0 2px 10px; } @@ -266,16 +242,6 @@ p { text-decoration: underline; } -.ediromWindow .measureInner { - background-image: radial-gradient(at center center , rgba(100, 100, 100, 0.3), rgba(0, 0, 0, 0) 5px); - border-radius: 15px; - padding: 3px 5px 0; - text-shadow: 0 1px 2px #000, 0 0 5px #fff; - font-size: 20px; - background-color: grey; - color: white; -} - /* SEARCH WINDOW */ .searchWindow .searchResultDoc { @@ -283,7 +249,7 @@ p { } .searchWindow .searchResultDoc .doc { - margin-top: 10px; + margin-top: 10px; } .searchWindow .searchResultDoc:first-child .doc { @@ -413,3 +379,9 @@ span#workSwitch-btnInnerEl:before { background-color: rgb(36, 145, 235) !important; color: rgb(161, 209, 247) !important; } + +/* Verovio view */ + +.renderingViewContent { + height: 100%; +} diff --git a/resources/js/verovio-view.js b/resources/js/verovio-view.js index 4434f40ce..5c9db4f18 100644 --- a/resources/js/verovio-view.js +++ b/resources/js/verovio-view.js @@ -1,10 +1,12 @@ window.vrvToolkit = new verovio.toolkit(); -showMovement(); +showMovement(movementId); function showMovement(movementId) { showLoader(); + window.movementId = movementId; + var initHeight = Math.floor($(document).height() * 100.0 / 33.0) - 35; var initWidth = Math.floor($(document).width() * 100.0 / 33.0); @@ -16,11 +18,7 @@ function showMovement(movementId) { }; /* Load the file using HTTP GET */ - var url = "/data/xql/getMusicInMdiv.xql?uri=" + uri + "&edition=" + edition; - if(typeof movementId !== 'undefined') { - url += "&movementId=" + movementId; - } - + var url = appBasePath + "/data/xql/getMusicInMdiv.xql?uri=" + uri + "&edition=" + edition + "&movementId=" + movementId; $.get(url, function( data ) { var svg = vrvToolkit.renderData(data, options); $("#output").html(svg); @@ -39,13 +37,32 @@ function updatePageData() { $("#page").html(page); $("#pageCount").html(pageCount); - var url = "/data/xql/getAnnotationsInRendering.xql?uri=" + uri + "&edition=" + edition; + var url = appBasePath + "/data/xql/getAnnotationsInRendering.xql?uri=" + uri + "&edition=" + edition; url += "&measureIds=" + getMeasureIds(); + if(page == 1) + url += "&mdivId=" + movementId; + $.getJSON(url, function( data ) { $.each( data, function( key, val ) { - var rect = $('#' + val.measureId)[0].getBBox(); + if(val.measureId == movementId) { + var rect = $('.page-margin')[0].getBBox(); + rect = {'x': rect.width - 700, 'y': 20, 'width': 600, 'height': 600}; + + var xmlns = "http://www.w3.org/2000/svg"; + var svgRect = document.createElementNS(xmlns, "image"); + svgRect.setAttributeNS(null, "id", val.measureId + "_" + val.id); + svgRect.setAttributeNS(null, "x", rect.x); + svgRect.setAttributeNS(null, "y", rect.y); + svgRect.setAttributeNS(null, "width", rect.width); + svgRect.setAttributeNS(null, "height", rect.height); + svgRect.setAttributeNS(null, "href", "/resources/pix/info.png"); + + $('.page-margin')[0].append(svgRect); + + }else { + var rect = $('#' + val.measureId)[0].getBBox(); var xmlns = "http://www.w3.org/2000/svg"; var svgRect = document.createElementNS(xmlns, "rect"); @@ -60,7 +77,8 @@ function updatePageData() { svgRect.setAttributeNS(null, "stroke-width", "20px"); $('#' + val.measureId)[0].append(svgRect); - + } + Tipped.create('#' + val.measureId + "_" + val.id, { ajax: { url: '/data/xql/getAnnotation.xql', @@ -72,7 +90,11 @@ function updatePageData() { } }, hideDelay: 1000, - skin: 'gray' + skin: 'gray', + containment: { + selector: '#output', + padding: 0 + } }); }); }); From 87938d84446490ef4b56d31a3d3201278de6ea49 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Tue, 14 Jun 2022 13:54:30 +0200 Subject: [PATCH 002/107] bump version number --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index c2009803c..7de6bd1bf 100755 --- a/build.xml +++ b/build.xml @@ -3,7 +3,7 @@ - + From 81cb5e06ba24afc42de6788048f666c4d13d5915 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Sun, 27 Nov 2022 16:22:11 +0100 Subject: [PATCH 003/107] allow work to be root element --- add/data/xqm/work.xqm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/add/data/xqm/work.xqm b/add/data/xqm/work.xqm index 7e384ec8a..73d210cf7 100644 --- a/add/data/xqm/work.xqm +++ b/add/data/xqm/work.xqm @@ -41,14 +41,14 @@ declare namespace edirom="http://www.edirom.de/ns/1.3"; :) declare function work:toJSON($uri as xs:string, $edition as xs:string) as xs:string { - let $work := doc($uri)/mei:mei + let $work := doc($uri)/mei:mei | doc($uri)/mei:work let $lang := request:get-parameter('lang', '') return concat(' {', 'id: "', $work/string(@xml:id), '", ', 'doc: "', $uri, '", ', - 'title: "', replace(eutil:getLocalizedTitle($work//mei:work, $lang), '"', '\\"'), '"', + 'title: "', replace(eutil:getLocalizedTitle(($work//mei:work[1] | $work), $lang), '"', '\\"'), '"', '}') }; @@ -60,7 +60,7 @@ declare function work:toJSON($uri as xs:string, $edition as xs:string) as xs:str :) declare function work:isWork($uri as xs:string) as xs:boolean { - exists(doc($uri)//mei:mei) and exists(doc($uri)//mei:work) and not(doc($uri)//mei:source) + (exists(doc($uri)//mei:mei) and exists(doc($uri)//mei:work) and not(doc($uri)//mei:source)) or exists(doc($uri)/mei:work) }; (:~ @@ -72,7 +72,7 @@ declare function work:isWork($uri as xs:string) as xs:boolean { :) declare function work:getLabel($work as xs:string, $edition as xs:string) as xs:string { - eutil:getLocalizedTitle(doc($work)//mei:work, request:get-parameter('lang', '')) + eutil:getLocalizedTitle(doc($work)/root()//mei:work, request:get-parameter('lang', '')) }; (:~ From d96f50191d6316ade7587f5ea167845604e753ce Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Sun, 27 Nov 2022 16:22:31 +0100 Subject: [PATCH 004/107] handling of MEI4 titlePart for works --- add/data/xql/getLinkTarget.xql | 4 +++- add/data/xqm/util.xqm | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql index 84e516561..d90d84a89 100644 --- a/add/data/xql/getLinkTarget.xql +++ b/add/data/xql/getLinkTarget.xql @@ -142,7 +142,9 @@ declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs (: Work :) if(exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) then(eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang)) - + else if(exists($doc/root()/mei:work)) + then(eutil:getLocalizedTitle($doc/root()/mei:work, $lang)) + (: Recording :) else if(exists($doc//mei:mei) and exists($doc//mei:recording)) then(eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang)) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index b8eab38fb..9c201d909 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -106,8 +106,10 @@ declare function eutil:getLocalizedTitle($node as node(), $lang as xs:string?) a let $namespace := eutil:getNamespace($node) - let $titleMEI := if ($lang != '' and $lang = $node/mei:title/@xml:lang) + let $titleMEI := if ($lang != '' and $lang = $node/mei:title/@xml:lang and not($node/mei:title/mei:titlePart)) then ($node/mei:title[@xml:lang = $lang]//text() => string-join() => normalize-space()) + else if ($lang != '' and $lang = $node/mei:title/@xml:lang and $node/mei:title/mei:titlePart) + then ($node/mei:title[@xml:lang = $lang]/mei:titlePart[1]//text() => string-join() => normalize-space()) else (($node//mei:title)[1]//text() => string-join() => normalize-space()) let $titleTEI := if ($lang != '' and $lang = $node/tei:title/@xml:lang) From d18f247073cfbe1bfae08dcfdab0517d2170ab0d Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Sun, 27 Nov 2022 17:28:16 +0100 Subject: [PATCH 005/107] fix workflow --- .github/workflows/docker-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index cc386f981..996725178 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -18,11 +18,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Build Edirom Online from ${{ GITHUB_REF }} + - name: Build Edirom Online from ${{ github.ref }} run: docker run --rm -v `pwd`:/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd - uses: actions/upload-artifact@v2 with: - name: EdiromOnline_${{ GITHUB_REF }}.zip + name: EdiromOnline_${{ github.ref }}.zip path: build-xar/EdiromOnline*.xar if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` From 3af03b4a4f79013ed7db1a8e1b7c24aa3fa55255 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Sun, 27 Nov 2022 17:32:38 +0100 Subject: [PATCH 006/107] update artifacts path --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 996725178..625cedc3f 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/upload-artifact@v2 with: name: EdiromOnline_${{ github.ref }}.zip - path: build-xar/EdiromOnline*.xar + path: /app/build-xar/EdiromOnline*.xar if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` # deploy: From dfcab077f8f606f9009cd62cb65d6343f9a19631 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 10:49:23 +0100 Subject: [PATCH 007/107] bump version --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 59dd87f9e..80fbf7e27 100755 --- a/build.xml +++ b/build.xml @@ -3,7 +3,7 @@ - + From 3fc5329212dc6e1ac2efcb4cde3e4bc6739ea7f2 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 12:17:18 +0100 Subject: [PATCH 008/107] copy code from imageViewer --- app/view/window/image/OpenSeaDragonViewer.js | 26 +++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/view/window/image/OpenSeaDragonViewer.js b/app/view/window/image/OpenSeaDragonViewer.js index 7bb6d4594..96ef671e2 100644 --- a/app/view/window/image/OpenSeaDragonViewer.js +++ b/app/view/window/image/OpenSeaDragonViewer.js @@ -35,6 +35,7 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', { imagePrefix: null, shapes: null, + partLabel: null, annotTipWidth: 220, annotTipMaxWidth: 300, @@ -49,11 +50,25 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', { me.addEvents('zoomChanged', 'imageChanged'); - - me.html = '
'; + + var openseadragonEvents; + + if (me.partLabel != null) { + openseadragonEvents = '
' + + '
' + + '' + + me.partLabel + '' + + '
' + + '
'; + } + else { + openseadragonEvents = '
'; + }; + + me.html = '
' + openseadragonEvents; me.shapes = new Ext.util.MixedCollection(); - + me.callParent(); me.on('afterrender', me.initSurface, me, {single: true}); @@ -62,6 +77,11 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', { initSurface: function() { var me = this; + var eventEl = me.el.getById(me.id + '_openseadragonEvents'); + eventEl.unselectable(); + eventEl.on('mousedown', me.onMouseDown, me); + eventEl.on('mousewheel', me.onScroll, me); + me.viewer = OpenSeadragon({ id: me.id + '_openseadragon', showNavigator: false, From fdd2b0e3694eaa34fa92a0277efbaabd1bc00305 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 14:30:32 +0100 Subject: [PATCH 009/107] delete mouse wheel listener --- app/view/window/image/OpenSeaDragonViewer.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/view/window/image/OpenSeaDragonViewer.js b/app/view/window/image/OpenSeaDragonViewer.js index 96ef671e2..0c6fa75f0 100644 --- a/app/view/window/image/OpenSeaDragonViewer.js +++ b/app/view/window/image/OpenSeaDragonViewer.js @@ -77,11 +77,6 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', { initSurface: function() { var me = this; - var eventEl = me.el.getById(me.id + '_openseadragonEvents'); - eventEl.unselectable(); - eventEl.on('mousedown', me.onMouseDown, me); - eventEl.on('mousewheel', me.onScroll, me); - me.viewer = OpenSeadragon({ id: me.id + '_openseadragon', showNavigator: false, From d6ab3a78e7a680a6effda3fdbf41092466e108e2 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 16:16:43 +0100 Subject: [PATCH 010/107] update source.xqm version and path --- add/data/xqm/source.xqm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/add/data/xqm/source.xqm b/add/data/xqm/source.xqm index 08c8ccd78..e54187df1 100644 --- a/add/data/xqm/source.xqm +++ b/add/data/xqm/source.xqm @@ -1,4 +1,4 @@ -xquery version "1.0"; +xquery version "3.1"; (: Edirom Online Copyright (C) 2011 The Edirom Project @@ -31,7 +31,7 @@ module namespace source = "http://www.edirom.de/xquery/source"; declare namespace mei="http://www.music-encoding.org/ns/mei"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil="http://www.edirom.de/xquery/util" at "/db/apps/Edirom-Online/data/xqm/util.xqm"; (:~ : Returns whether a document is a source or not From 595e50b8bb63f383709bba666b8551ddefdf8abb Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 16:17:00 +0100 Subject: [PATCH 011/107] introduce function for getting part labels --- add/data/xqm/util.xqm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 38102f194..c2332e024 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -189,6 +189,37 @@ declare function eutil:getDocumentLabel($doc as xs:string, $edition as xs:string else('') }; +(:~ +: Returns a part's label (translated if available) +: +: @author Dennis Ried +: @param $partID The xml:id of the Part's node() to process +: @return The label (translated if available) +:) +declare function eutil:getPartLabel($measureOrPerfRes as node(), $type as xs:string) as xs:string { + (: request:get-parameter('lang', '') doesn't work?? [DeRi]:) +let $lang := if(request:get-parameter('lang', '') = '') + then('de') + else(request:get-parameter('lang', '')) +let $part := $measureOrPerfRes/ancestor::mei:part +let $voiceRef := $part//mei:staffDef/@decls +let $voiceID := substring-after($voiceRef, '#') + +let $perfResLabel := if($type eq 'measure') + then($measureOrPerfRes/ancestor::mei:mei/id($voiceID)/@label) + else($measureOrPerfRes/@label) +let $dictKey := 'perfMedium.perfRes.' || functx:substring-before-if-contains($perfResLabel,'.') +let $label := if(eutil:getLanguageString($dictKey, (), $lang)) + then(eutil:getLanguageString($dictKey, (), $lang)) + else($perfResLabel) +let $numbering := for $i in subsequence(tokenize($perfResLabel,'\.'),2) + where matches($i, '([0-9])|([ivxIVX])') + return + upper-case($i) +return + normalize-space(string-join(($label, $numbering),' ')) +}; + (:~ : Returns a language specific string : From b2cbdf48af58e6626c81d4a9d5b932337b4cc272 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 16:18:18 +0100 Subject: [PATCH 012/107] substitute code with function and clean up --- add/data/xql/getMeasures.xql | 36 +++++++++++------------------------- add/data/xql/getParts.xql | 7 ++++--- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/add/data/xql/getMeasures.xql b/add/data/xql/getMeasures.xql index 0252ed5db..ce0af33b3 100644 --- a/add/data/xql/getMeasures.xql +++ b/add/data/xql/getMeasures.xql @@ -60,31 +60,17 @@ declare function local:getMeasures($mei as node(), $mdivID as xs:string) as xs:s let $measures := if ($mdiv//mei:measure/@label) then ($mdiv//mei:measure[.//mei:multiRest][number(substring-before(@label, '–')) <= $measureNNumber][.//mei:multiRest/number(@num) gt ($measureNNumber - number(substring-before(@label, '–')))]) else ($mdiv//mei:measure[.//mei:multiRest][number(@n) lt $measureNNumber][.//mei:multiRest/number(@num) gt ($measureNNumber - number(@n))]) - let $measures := if ($mdiv//mei:measure/@label) - then ( - for $part in $mdiv//mei:part - for $measure in $part//mei:measure[@label = $measureN][1] | $measures[ancestor::mei:part = $part] - let $voiceRef := $part//mei:staffDef/@decls - let $voiceID := substring-after($voiceRef, '#') - return - concat('{id:"', $measure/@xml:id, '", - voice: "', $voiceRef, - '", partLabel: "', $mei/id($voiceID)/@label, - '"}') - ) - else ( - for $part in $mdiv//mei:part -(: let $partMeasures := $part//mei:measure:) - for $measure in $part//mei:measure[@n = $measureN][1] | $measures[ancestor::mei:part = $part] - let $voiceRef := $part//mei:staffDef/@decls - let $voiceID := substring-after($voiceRef, '#') - return - concat('{id:"', - $measure/@xml:id, - '", voice: "', $voiceRef, - '", partLabel: "', $mei/id($voiceID)/@label, - '"}') - ) + let $measures := for $part in $mdiv//mei:part + let $partMeasures := if($part//mei:measure/@label) + then($part//mei:measure[@label = $measureN][1]) + else($part//mei:measure[@n = $measureN][1]) + for $measure in $partMeasures | $measures[ancestor::mei:part = $part] + let $voiceRef := $part//mei:staffDef/@decls + return + concat('{id:"', $measure/@xml:id, '", + voice: "', $voiceRef, + '", partLabel: "', eutil:getPartLabel($measure, 'measure'), + '"}') return concat('{', 'id: "measure_', $mdiv/@xml:id, '_', $measureN, '", ', diff --git a/add/data/xql/getParts.xql b/add/data/xql/getParts.xql index 6cf9572b1..bed6a9989 100644 --- a/add/data/xql/getParts.xql +++ b/add/data/xql/getParts.xql @@ -1,4 +1,4 @@ -xquery version "1.0"; +xquery version "3.1"; (: Edirom Online Copyright (C) 2011 The Edirom Project @@ -21,15 +21,16 @@ xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace mei="http://www.music-encoding.org/ns/mei"; - declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +import module namespace eutil="http://www.edirom.de/xquery/util" at "/db/apps/Edirom-Online/data/xqm/util.xqm"; + declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; let $uri := request:get-parameter('uri', '') let $mei := doc($uri)/root() let $ret := for $part in ($mei//mei:instrumentation/mei:instrVoice | $mei//mei:perfMedium//mei:perfRes) - return concat('{label: "', $part/@label, '", id:"', $part/@xml:id, '", selectedByDefault:true, selected:true}') + return concat('{label: "', eutil:getPartLabel($part, 'perfRes'), '", id:"', $part/@xml:id, '", selectedByDefault:true, selected:true}') return concat('[', string-join($ret, ','), ']') \ No newline at end of file From 55168cdb6c12f3bd3a1aa48a77380e45293b27ad Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 16:18:26 +0100 Subject: [PATCH 013/107] add lang values for instruments --- add/data/locale/edirom-lang-de.xml | 35 ++++++++++++++++++++++++++++++ add/data/locale/edirom-lang-en.xml | 35 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/add/data/locale/edirom-lang-de.xml b/add/data/locale/edirom-lang-de.xml index 21f3437ee..943934a3d 100644 --- a/add/data/locale/edirom-lang-de.xml +++ b/add/data/locale/edirom-lang-de.xml @@ -176,5 +176,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/add/data/locale/edirom-lang-en.xml b/add/data/locale/edirom-lang-en.xml index 8e39ac716..44d568e4a 100644 --- a/add/data/locale/edirom-lang-en.xml +++ b/add/data/locale/edirom-lang-en.xml @@ -176,5 +176,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 7e8b7041da9fd604d8605210275f2ef34a0442f4 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 22 Dec 2022 16:44:38 +0100 Subject: [PATCH 014/107] set part defaultSelection false if `@sameas` is present --- add/data/xql/getParts.xql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/add/data/xql/getParts.xql b/add/data/xql/getParts.xql index bed6a9989..feb305aa5 100644 --- a/add/data/xql/getParts.xql +++ b/add/data/xql/getParts.xql @@ -31,6 +31,13 @@ let $uri := request:get-parameter('uri', '') let $mei := doc($uri)/root() let $ret := for $part in ($mei//mei:instrumentation/mei:instrVoice | $mei//mei:perfMedium//mei:perfRes) - return concat('{label: "', eutil:getPartLabel($part, 'perfRes'), '", id:"', $part/@xml:id, '", selectedByDefault:true, selected:true}') + let $hasNoAttrSameas := not(exists($part/@sameas)) + return + concat( + '{label: "', eutil:getPartLabel($part, 'perfRes'), + '", id:"', $part/@xml:id, + '", selectedByDefault:', $hasNoAttrSameas, + ', selected:', $hasNoAttrSameas, '}' + ) return concat('[', string-join($ret, ','), ']') \ No newline at end of file From 873f4899498d64117b2aa21c108f2da1db31d55b Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Fri, 23 Dec 2022 16:20:16 +0100 Subject: [PATCH 015/107] prevent multiple values for sorting --- add/data/xqm/util.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 38102f194..17e179143 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -281,7 +281,7 @@ declare function eutil:get-app-base-url() as xs:string? { :) declare function eutil:sort-as-numeric-alpha($seq as item()* ) as item()* { for $item in $seq - let $itemPart1 := functx:get-matches($item, '\d+') + let $itemPart1 := (functx:get-matches($item, '\d+'))[1] let $itemPart2 := substring-after($item, $itemPart1) order by number($itemPart1), $itemPart2 return $item From dc3f5ac032b103ef60710ec06793953c1407fb08 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 29 Dec 2022 09:06:55 +0100 Subject: [PATCH 016/107] fix getting sigla for annotation list (mei4+) --- add/data/xqm/annotation.xqm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/add/data/xqm/annotation.xqm b/add/data/xqm/annotation.xqm index 4123ceb50..c45949408 100644 --- a/add/data/xqm/annotation.xqm +++ b/add/data/xqm/annotation.xqm @@ -99,7 +99,9 @@ declare function annotation:toJSON($anno as element(), $edition as xs:string) as else(collection(eutil:getPreference('edition_path', $edition))//id($p)/root()) return if ($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum']) - then $pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum']/text() + then ($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum']/text()) + else if ($pDoc//mei:manifestationList/mei:manifestation/mei:identifier[@type = 'siglum']) + then ($pDoc//mei:manifestationList/mei:manifestation/mei:identifier[@type = 'siglum']/text()) else ($pDoc//mei:title[@type = 'siglum']/text()) let $classes := tokenize(replace(normalize-space($anno/@class),'#',''),' ') From 813dd3704463d79f836fff9446ca142f738f098a Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Thu, 29 Dec 2022 09:07:18 +0100 Subject: [PATCH 017/107] fix isSource-function (mei4+) for prints --- add/data/xqm/source.xqm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/add/data/xqm/source.xqm b/add/data/xqm/source.xqm index 08c8ccd78..001ab77cb 100644 --- a/add/data/xqm/source.xqm +++ b/add/data/xqm/source.xqm @@ -41,9 +41,13 @@ import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util :) declare function source:isSource($uri as xs:string) as xs:boolean { let $doc := eutil:getDoc($uri) + let $meiVersionRegex := '(([4-9])|(\d+[0-9]))\.\d+\.\d+(-dev)?' return - exists($doc//mei:mei) and exists($doc//mei:source) (:mei2 and ?3 :) - or ($doc//mei:mei/@meiversion = ("4.0.0", "4.0.1") and exists($doc//mei:manifestation[@singleton='true'])) (:mei4 :) + (exists($doc//mei:mei) and exists($doc//mei:source)) (:mei2 and ?3 :) + or + (matches($doc//mei:mei/@meiversion, $meiVersionRegex) and exists($doc//mei:manifestation[@singleton='true'])) (:mei4+ for manuscripts:) + or + (matches($doc//mei:mei/@meiversion, $meiVersionRegex) and exists($doc//mei:manifestation//mei:item)) (: mei4+ for prints :) }; (:~ From 1a6f570c6e2d78deaff50fafd4a48c4566e0cd56 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 15 Feb 2023 10:47:19 +0100 Subject: [PATCH 018/107] Update add/data/xqm/work.xqm Co-authored-by: Benjamin W. Bohl --- add/data/xqm/work.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/work.xqm b/add/data/xqm/work.xqm index 73d210cf7..b9935a71d 100644 --- a/add/data/xqm/work.xqm +++ b/add/data/xqm/work.xqm @@ -48,7 +48,7 @@ declare function work:toJSON($uri as xs:string, $edition as xs:string) as xs:str {', 'id: "', $work/string(@xml:id), '", ', 'doc: "', $uri, '", ', - 'title: "', replace(eutil:getLocalizedTitle(($work//mei:work[1] | $work), $lang), '"', '\\"'), '"', + 'title: "', replace(eutil:getLocalizedTitle((($work//mei:work)[1] | $work), $lang), '"', '\\"'), '"', '}') }; From daaf4573cfd0133c95af7c2cd316f2359ad51697 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 00:53:51 +0100 Subject: [PATCH 019/107] edition.xqm: update findEdition to accept URL or ID --- add/data/xqm/edition.xqm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index a96aa1416..b576d9dd8 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -97,8 +97,8 @@ declare function edition:getPreferencesURI($uri as xs:string) as xs:string { (:~ : Returns the URI of the edition specified by the submitted $editionID parameter. -: Only succeeds if the supplied id is the @xml:id of a edirom:edition element in '/db/apps'. : If $editionID is the empty string, returns the URI of the first edition found in '/db/apps'. +: If the submitted $editionID already qualifies to read a document, return $editionID unaltered. : : @param $editionID The '@xml:id' of the edirom:edition document to process : @return The URI of the Edition file @@ -109,6 +109,9 @@ declare function edition:findEdition($editionID as xs:string) as xs:string { let $edition := (collection('/db/apps')//edirom:edition)[1] return 'xmldb:exist://' || document-uri($edition/root()) ) + else if(doc-available($editionID)) (:already a qualified URI :) + then + $editionID else ( let $edition := collection('/db/apps')//edirom:edition/id($editionID) return 'xmldb:exist://' || document-uri($edition/root()) From 1e5bff60d491646a53a5bff5143655a4066c257a Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 00:54:12 +0100 Subject: [PATCH 020/107] edition.xqm: add some xqdoc --- add/data/xqm/edition.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index b576d9dd8..a96972347 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -88,7 +88,7 @@ declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:strin : Returns the URI for the preferences file : : @param $uri The URI of the Edition's document to process -: @return The URI +: @return The URI of the preference file :) declare function edition:getPreferencesURI($uri as xs:string) as xs:string { From 67c0f74f726505cdb5c530f757370c2ad70df199 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:08:10 +0100 Subject: [PATCH 021/107] index.xql: add content-language links --- add/controller.xql | 1 + add/data/xqm/edition.xqm | 13 +++++++++++++ add/index.xql | 11 +++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/add/controller.xql b/add/controller.xql index acedaa4d7..a491e3410 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -1,5 +1,6 @@ xquery version "1.0"; +import module namespace edition="http://www.edirom.de/xquery/edition" at "data/xqm/edition.xqm"; import module namespace eutil = "http://www.edirom.de/xquery/util" at "data/xqm/util.xqm"; declare variable $exist:path external; diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index a96972347..c1b90e656 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -82,6 +82,19 @@ declare function edition:getWorkUris($uri as xs:string) as xs:string* { declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:string) as xs:string { doc($uri)//edirom:language[@xml:lang eq $lang]/string(@xlink:href) + let $doc := ( + if(doc-available($uri)) + then + doc($uri) + else + doc(edition:findEdition($uri)) + ) + return + if ($doc//edirom:language[@xml:lang eq $lang]/string(@xlink:href)) + then + $doc//edirom:language[@xml:lang eq $lang]/string(@xlink:href) + else + "" }; (:~ diff --git a/add/index.xql b/add/index.xql index 8f8902b62..ddcbf00e9 100755 --- a/add/index.xql +++ b/add/index.xql @@ -126,12 +126,19 @@ let $eoEditionFileMulti :=
    { for $eoEditionFile in $eoEditionFiles + let $editionUri := document-uri($eoEditionFile/root()) let $editionID := $eoEditionFile/string(@xml:id) let $editionName := $eoEditionFile/edirom:editionName/text() => normalize-space() - return + let $editionLanguages := edition:getLanguageCodesSorted($editionUri) + return ( + ) }
From 8236fcb05b67e7b21c84ee7211a2a4483b77384e Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:32:29 +0100 Subject: [PATCH 022/107] util.xqm: add function converting iso3166-1 to is639 --- add/data/xqm/util.xqm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 38102f194..18d37ec6e 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -287,3 +287,15 @@ declare function eutil:sort-as-numeric-alpha($seq as item()* ) as item()* { return $item } ; + +(:~ + : Extracts an ISO 639 language code from a given ISO 3166-1 language code + : + : @author Benjamin W. Bohl + : @param $iso3166-1 xs:string the given ISO 3166-1 language code, e.g., en-US + : @return xs:string ISO 639 language code, e.g., en + :) +declare function eutil:iso3166-1-to-iso639($iso3166-1 as xs:string) as xs:string { + tokenize($iso3166-1, "-")[1] +}; + From efde8efc9b1a31449fa46feacf25e2903c43bc65 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:33:20 +0100 Subject: [PATCH 023/107] util.xqm: add function to sort browser preferred langs by quality --- add/data/xqm/util.xqm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 18d37ec6e..cebbe55ff 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -299,3 +299,33 @@ declare function eutil:iso3166-1-to-iso639($iso3166-1 as xs:string) as xs:string tokenize($iso3166-1, "-")[1] }; +(:~ + : Returns the ISO 639 language code with the highest 'quality' (none cosidered as 1) from + : the HTTP-request Accept-Language header + : + : @author Benjamin W. Bohl + : @return xs:string ISO 639 language code + :) +declare function eutil:request-lang-preferred-iso639() as xs:string { +let $request.accept-language := request:get-header("Accept-Language") +return +if($request.accept-language) +then + let $tokens := tokenize($request.accept-language, ";") + let $tokens.qless.ordered := ( + for $token in $tokens + let $q := substring-after(string-join((analyze-string($token, "(q=\d(\.\d)?)")//fn:match)[1], ""), "q=") + let $q.decimal := if($q = "") then xs:decimal(1) else xs:decimal($q) + let $token.qless := replace($token,",?q=\d(\.\d)?,?", "") + order by $q.decimal descending + return + $token.qless + ) + let $tokens.qmax := $tokens.qless.ordered[1] + let $tokens.qmax.first := tokenize($tokens.qmax, ",")[1] + return + eutil:iso3166-1-to-iso639($tokens.qmax.first) + +else + "en" +}; From b55bed9585d9bbab9bcadf3019039df8e443f5d3 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:34:00 +0100 Subject: [PATCH 024/107] util.xqm: getLanguage fallbacks --- add/data/xqm/util.xqm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index cebbe55ff..8878e3109 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -250,7 +250,11 @@ declare function eutil:getLanguage($edition as xs:string?) as xs:string { request:get-cookie-value('edirom-language') ) else( - eutil:getPreference('application_language', $edition) + let $prefsAppLang := eutil:getPreference('application_language', edition:findEdition($edition)) + return + if($prefsAppLang) + then $prefsAppLang + else eutil:request-lang-preferred-iso639() ) }; From b2e9ecfdaa0da55997b21d7cde3dafa4441b8c75 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:38:40 +0100 Subject: [PATCH 025/107] controller.xql: set lang cookie instead of URL-param --- add/controller.xql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/add/controller.xql b/add/controller.xql index a491e3410..fd73eb2b8 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -21,12 +21,15 @@ return else if ($exist:path eq "/") then (: redirect root path to index.html :) - + + + else if ($exist:path eq "/index.html") then (: forward index.html to index.xql :) + From 0bd5b291e919c632495150e1418cc942519cc9cd Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:38:56 +0100 Subject: [PATCH 026/107] controller.xql: fallbacks for langVar --- add/controller.xql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/add/controller.xql b/add/controller.xql index fd73eb2b8..1fc1dfa76 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -10,7 +10,12 @@ declare variable $exist:controller external; declare option exist:serialize "method=xhtml media-type=application/xhtml+html"; -let $langVal := eutil:getLanguage(request:get-parameter("edition", "")) +let $langVal := if (request:get-parameter("lang", "") != "") then + request:get-parameter("lang", "") + else if (request:get-parameter("edition", "") != "") then + eutil:getLanguage(edition:findEdition(request:get-parameter("edition", ""))) + else + eutil:request-lang-preferred-iso639() return if ($exist:path eq "") then From 43db74231a5cfc429ef7c98c5030bba6bfa6ce31 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:39:20 +0100 Subject: [PATCH 027/107] Update edition.xqm --- add/data/xqm/edition.xqm | 1 - 1 file changed, 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index c1b90e656..b2e5312b3 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -81,7 +81,6 @@ declare function edition:getWorkUris($uri as xs:string) as xs:string* { :) declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:string) as xs:string { - doc($uri)//edirom:language[@xml:lang eq $lang]/string(@xlink:href) let $doc := ( if(doc-available($uri)) then From fd2bb6b7771935ff85b27b1afc9a554cab75e570 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Fri, 17 Feb 2023 01:39:59 +0100 Subject: [PATCH 028/107] edition.xqm: add getLanguageCodesSorted function --- add/data/xqm/edition.xqm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index b2e5312b3..473dccf73 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -96,6 +96,36 @@ declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:strin "" }; +(:~ +: Returns the URI for a specific language file +: +: @param $uri The URI of the Edition's document to process +: @return the edition's languages as defined in the edition file sorted as +: complete languages in document-order followed by incomplete langauges in document-order +:) +declare function edition:getLanguageCodesSorted($uri as xs:string) as xs:string { + + let $editionDoc := doc($uri) + let $languagesComplete := ( + for $lang in $editionDoc//edirom:language + let $langCode := $lang/@xml:lang + let $langComplete := xs:boolean($lang/@complete) + where $langComplete = true() + return + $langCode + ) + let $languagesIncomplete := ( + for $lang in $editionDoc//edirom:language + let $langCode := $lang/@xml:lang + let $langComplete := xs:boolean($lang/@complete) + where $langComplete = false() + return + $langCode + ) + return + ($languagesComplete, $languagesIncomplete) +}; + (:~ : Returns the URI for the preferences file : From d0f64431ef1d3cfed3588f9f0af8787a41531136 Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Mon, 6 Mar 2023 09:11:19 +0100 Subject: [PATCH 029/107] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d5b603f5d..ef633cde5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ Thumbs.db /tmp *.xpr local.properties +.idea/ From 05c00e3071fe5ddce51a8634e5f13287a16f7adf Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Tue, 11 Apr 2023 14:31:52 +0200 Subject: [PATCH 030/107] adjust return values to function signatures NB, I did not introduce any error checking but only adjusted the return values to the current function signatures. --- add/data/xqm/edition.xqm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index a96aa1416..f41b9c5eb 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -69,7 +69,7 @@ declare function edition:getUris() as xs:string* { :) declare function edition:getWorkUris($uri as xs:string) as xs:string* { - doc($uri)//edirom:work/string(@xlink:href) + doc($uri)//edirom:work/@xlink:href ! string(.) }; (:~ @@ -81,7 +81,7 @@ declare function edition:getWorkUris($uri as xs:string) as xs:string* { :) declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:string) as xs:string { - doc($uri)//edirom:language[@xml:lang eq $lang]/string(@xlink:href) + doc($uri)//edirom:language[@xml:lang eq $lang]/@xlink:href => string() }; (:~ @@ -92,7 +92,7 @@ declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:strin :) declare function edition:getPreferencesURI($uri as xs:string) as xs:string { - doc($uri)//edirom:preferences/string(@xlink:href) + doc($uri)//edirom:preferences/@xlink:href => string() }; (:~ @@ -122,7 +122,7 @@ declare function edition:findEdition($editionID as xs:string) as xs:string { : @return the text contents of edirom:edition/edirom:editionName :) declare function edition:getName($uri as xs:string) as xs:string { - doc($uri)/edirom:edition/edirom:editionName/text() + doc($uri)/edirom:edition/edirom:editionName => fn:normalize-space() }; (:~ From 7ef75e0e7e0d54a0869dbe813485d92690306606 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 09:42:41 +0200 Subject: [PATCH 031/107] Create dependabot.yml --- .github/dependabot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..c0bb7e6b5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'weekly' + labels: + - 'gh actions dependencies' From a194c991f10488331b49178ff795c3bc6e8aaca3 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 31 May 2023 10:05:08 +0200 Subject: [PATCH 032/107] Revert "update source.xqm version and path" This reverts commit d6ab3a78e7a680a6effda3fdbf41092466e108e2. --- add/data/xqm/source.xqm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/add/data/xqm/source.xqm b/add/data/xqm/source.xqm index e54187df1..08c8ccd78 100644 --- a/add/data/xqm/source.xqm +++ b/add/data/xqm/source.xqm @@ -1,4 +1,4 @@ -xquery version "3.1"; +xquery version "1.0"; (: Edirom Online Copyright (C) 2011 The Edirom Project @@ -31,7 +31,7 @@ module namespace source = "http://www.edirom.de/xquery/source"; declare namespace mei="http://www.music-encoding.org/ns/mei"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "/db/apps/Edirom-Online/data/xqm/util.xqm"; +import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; (:~ : Returns whether a document is a source or not From 61dd185caaf35a1445b71dbdb73429d0aa48578b Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 31 May 2023 10:09:34 +0200 Subject: [PATCH 033/107] make uri path relative --- add/data/xql/getParts.xql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xql/getParts.xql b/add/data/xql/getParts.xql index feb305aa5..4b041881f 100644 --- a/add/data/xql/getParts.xql +++ b/add/data/xql/getParts.xql @@ -23,7 +23,7 @@ declare namespace request="http://exist-db.org/xquery/request"; declare namespace mei="http://www.music-encoding.org/ns/mei"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "/db/apps/Edirom-Online/data/xqm/util.xqm"; +import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; From b55b5c6a908e7beb08e50d026fda002fffcde642 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 10:37:52 +0200 Subject: [PATCH 034/107] Fix: GitHub Action upload artifacts --- .github/workflows/docker-ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 625cedc3f..28ed128e4 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -20,11 +20,16 @@ jobs: - uses: actions/checkout@v2 - name: Build Edirom Online from ${{ github.ref }} run: docker run --rm -v `pwd`:/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd - - uses: actions/upload-artifact@v2 + - name: Upload Artifacts + if: github.repository == 'Edirom/Edirom-Online' + uses: actions/actions/upload-artifact@v3.1.2 with: + # The name that the artifact will be made available under name: EdiromOnline_${{ github.ref }}.zip - path: /app/build-xar/EdiromOnline*.xar - if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + # The path to retrieve the artifact + path: build-xar/EdiromOnline*.xar + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + #optional retention-days: 1 to 90 # deploy: # needs: build From 54f97fa859f951780859e4243e4257935035c946 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 11:56:33 +0200 Subject: [PATCH 035/107] Create CONTRIBUTING.md --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..a01fa0b69 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Edirom Online Contributing Guidelines + +# General Guidelines + +## Whitespace handling + +1. Use whitespaces, not tabs to indent code +2. Close file with + + +# XQuery + +## Importing modules + +* always use relative URIs for `import module namespace` statements that import a local edirom xqm From 78588e0464067f3b7d5a49919b02f66327957de5 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 14:08:38 +0200 Subject: [PATCH 036/107] upgrade to xquery 3.1 --- add/controller.xql | 2 +- add/data/xqm/edition.xqm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/add/controller.xql b/add/controller.xql index 1fc1dfa76..28f6cd97f 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -1,4 +1,4 @@ -xquery version "1.0"; +xquery version "3.1"; import module namespace edition="http://www.edirom.de/xquery/edition" at "data/xqm/edition.xqm"; import module namespace eutil = "http://www.edirom.de/xquery/util" at "data/xqm/util.xqm"; diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index 8235a5b6c..cbd67f646 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -1,4 +1,4 @@ -xquery version "3.0"; +xquery version "3.1"; (: Edirom Online Copyright (C) 2011 The Edirom Project From 43f1f51d9ed4785848e47aa7eb327be6a2317b27 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 14:09:14 +0200 Subject: [PATCH 037/107] move langVar resolution to functions in XQuery modules --- add/controller.xql | 7 +------ add/data/xqm/edition.xqm | 4 ++-- add/data/xqm/util.xqm | 16 +++++----------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/add/controller.xql b/add/controller.xql index 28f6cd97f..e4f1fb2d3 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -10,12 +10,7 @@ declare variable $exist:controller external; declare option exist:serialize "method=xhtml media-type=application/xhtml+html"; -let $langVal := if (request:get-parameter("lang", "") != "") then - request:get-parameter("lang", "") - else if (request:get-parameter("edition", "") != "") then - eutil:getLanguage(edition:findEdition(request:get-parameter("edition", ""))) - else - eutil:request-lang-preferred-iso639() +let $langVal := eutil:getLanguage(request:get-parameter("edition", "")) return if ($exist:path eq "") then diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index cbd67f646..6c2bb17a5 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -145,8 +145,8 @@ 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 { - if($editionID eq '') +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] return 'xmldb:exist://' || document-uri($edition/root()) diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 32aeccdd6..1050e6c90 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -245,17 +245,11 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?) :) declare function eutil:getLanguage($edition as xs:string?) as xs:string { - if(request:get-cookie-names() = 'edirom-language') - then( - request:get-cookie-value('edirom-language') - ) - else( - let $prefsAppLang := eutil:getPreference('application_language', edition:findEdition($edition)) - return - if($prefsAppLang) - then $prefsAppLang - else eutil:request-lang-preferred-iso639() - ) + if (request:get-parameter("lang", "") != "") + then request:get-parameter("lang", "") + else if(request:get-cookie-names() = 'edirom-language') + then request:get-cookie-value('edirom-language') + else eutil:getPreference('application_language', edition:findEdition($edition)) }; (:~ From 7515fa36804719e6a57cac8fd6782438dd484be0 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 14:17:04 +0200 Subject: [PATCH 038/107] remove setting of cookie on redirect --- add/controller.xql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/add/controller.xql b/add/controller.xql index e4f1fb2d3..41ce373cd 100755 --- a/add/controller.xql +++ b/add/controller.xql @@ -21,9 +21,7 @@ return else if ($exist:path eq "/") then (: redirect root path to index.html :) - - - + else if ($exist:path eq "/index.html") then (: forward index.html to index.xql :) From 1ea162108d8f3d361a366e8331ed5d3cea44176f Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 15:10:07 +0200 Subject: [PATCH 039/107] update edition.xqm to xquery v3.1 --- add/data/xqm/edition.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index f41b9c5eb..cc755e6b7 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -1,4 +1,4 @@ -xquery version "3.0"; +xquery version "3.1"; (: Edirom Online Copyright (C) 2011 The Edirom Project From d9ac08d50c0975febe3c4d55c4ec2e7c51b5c658 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 15:25:32 +0200 Subject: [PATCH 040/107] Update getLinkTarget.xql * according to new coding guidelines --- add/data/xql/getLinkTarget.xql | 54 ++++++++++------------------------ 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql index d90d84a89..22fce4681 100644 --- a/add/data/xql/getLinkTarget.xql +++ b/add/data/xql/getLinkTarget.xql @@ -1,43 +1,25 @@ xquery version "3.1"; (: - Edirom Online - Copyright (C) 2011 The Edirom Project - http://www.edirom.de - - Edirom Online is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Edirom Online is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Edirom Online. If not, see . - - ID: $Id: getLinkTarget.xql 1334 2012-06-14 12:40:33Z daniel $ +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) -import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; -import module namespace work="http://www.edirom.de/xquery/work" at "../xqm/work.xqm"; -import module namespace teitext="http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; - -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace html="http://www.w3.org/1999/xhtml"; -declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare namespace map="http://www.w3.org/2005/xpath-functions/map"; -declare namespace f="http://local.link"; +declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; +declare namespace tei="http://www.tei-c.org/ns/1.0"; -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; +import module namespace request="http://exist-db.org/xquery/request"; +import module namespace xmldb="http://exist-db.org/xquery/xmldb"; -declare option output:method "text"; -declare option output:media-type "text/plain"; +import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; +import module namespace teitext="http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; +import module namespace work="http://www.edirom.de/xquery/work" at "../xqm/work.xqm"; + +declare option output:method "json"; +declare option output:media-type "application/json"; declare variable $lang := request:get-parameter('lang', ''); @@ -250,10 +232,4 @@ let $map := 'internalIdType': $internalIdType } -let $options := - map { - 'method': 'json', - 'media-type': 'text/plain' - } - -return serialize($map, $options) +return $map From b2f95ce59e9aa2ea5ddb00790a6ecb74f8d82177 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 15:25:59 +0200 Subject: [PATCH 041/107] linting --- add/data/xql/getLinkTarget.xql | 456 ++++++++++++++++++++------------- 1 file changed, 279 insertions(+), 177 deletions(-) diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql index 22fce4681..aee7b54ae 100644 --- a/add/data/xql/getLinkTarget.xql +++ b/add/data/xql/getLinkTarget.xql @@ -3,20 +3,20 @@ xquery version "3.1"; For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) -declare namespace html="http://www.w3.org/1999/xhtml"; -declare namespace map="http://www.w3.org/2005/xpath-functions/map"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace html = "http://www.w3.org/1999/xhtml"; +declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; -declare namespace tei="http://www.tei-c.org/ns/1.0"; +declare namespace tei = "http://www.tei-c.org/ns/1.0"; import module namespace functx = "http://www.functx.com"; -import module namespace request="http://exist-db.org/xquery/request"; -import module namespace xmldb="http://exist-db.org/xquery/xmldb"; +import module namespace request = "http://exist-db.org/xquery/request"; +import module namespace xmldb = "http://exist-db.org/xquery/xmldb"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; -import module namespace teitext="http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; -import module namespace work="http://www.edirom.de/xquery/work" at "../xqm/work.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; +import module namespace teitext = "http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; +import module namespace work = "http://www.edirom.de/xquery/work" at "../xqm/work.xqm"; declare option output:method "json"; declare option output:media-type "application/json"; @@ -25,150 +25,233 @@ declare variable $lang := request:get-parameter('lang', ''); declare function local:getView($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)? { let $baseMap := map { - 'type': substring-after($type,'_'), - 'uri': if($type = ('mei_textView', 'desc_xmlView')) then string(($doc//mei:annot[@type='descLink'])[1]/@plist) else $docUri + 'type': substring-after($type, '_'), + 'uri': if ($type = ('mei_textView', 'desc_xmlView')) then + string(($doc//mei:annot[@type = 'descLink'])[1]/@plist) + else + $docUri } (: optionally set label for some views:) let $labeled.map := - if($type = 'mei_textView') - then(map:put($baseMap, 'label', 'Quellenbeschreibung')) - else if($type = 'desc_xmlView') - then(map:put($baseMap, 'label', 'XML Quellenbeschreibung')) - else($baseMap) - - (: whether to set the view as default view:) - let $defaultViewed.map := - if($type = ('mei_sourceView', - 'mei_audioView', - 'tei_textView', - 'tei_facsimileView', - 'tei_textFacsimileSplitView', - 'mei_annotationView', - 'mei_verovioView')) - then(map:put($labeled.map, 'defaultView', true())) - else($labeled.map) + if ($type = 'mei_textView') + then + (map:put($baseMap, 'label', 'Quellenbeschreibung')) + else + if ($type = 'desc_xmlView') + then + (map:put($baseMap, 'label', 'XML Quellenbeschreibung')) + else + ($baseMap) + + (: whether to set the view as default view:) + let $defaultViewed.map := + if ($type = ('mei_sourceView', + 'mei_audioView', + 'tei_textView', + 'tei_facsimileView', + 'tei_textFacsimileSplitView', + 'mei_annotationView', + 'mei_verovioView')) + then + (map:put($labeled.map, 'defaultView', true())) + else + ($labeled.map) - (: xpath check whether any given view is supported :) + (: xpath check whether any given view is supported :) let $hasView := - if($type = 'desc_summaryView') - then(true()) - - else if($type = 'desc_headerView') - then(exists($doc//mei:meiHead or $doc//tei:teiHeader)) - - else if($type = 'mei_textView') - then(exists($doc//mei:annot[@type='descLink'])) - - else if($type = 'mei_sourceView') - then(exists($doc//mei:facsimile//mei:graphic[@type='facsimile'])) - - else if($type = 'mei_audioView') - then(exists($doc//mei:recording)) - - else if($type = 'mei_verovioView') - then(exists($doc//mei:body//mei:measure) and exists($doc//mei:body//mei:note)) - - else if($type = 'tei_textView') - then(exists($doc//tei:body[matches(.//text(), '[^\s]+')])) - - else if($type = 'tei_facsimileView') - then(exists($doc//tei:facsimile//tei:graphic)) - - else if($type = 'tei_textFacsimileSplitView') - then(exists($doc//tei:facsimile//tei:graphic) and exists($doc//tei:pb[@facs])) - - else if($type = 'mei_annotationView') - then(exists($doc//mei:annot[@type='editorialComment'])) - - else if($type = 'xml_xmlView') - then(true()) - - else if($type = 'desc_xmlView') - then(exists($doc//mei:annot[@type='descLink'])) + if ($type = 'desc_summaryView') + then + (true()) + + else + if ($type = 'desc_headerView') + then + (exists($doc//mei:meiHead or $doc//tei:teiHeader)) - else(false()) + else + if ($type = 'mei_textView') + then + (exists($doc//mei:annot[@type = 'descLink'])) + + else + if ($type = 'mei_sourceView') + then + (exists($doc//mei:facsimile//mei:graphic[@type = 'facsimile'])) + + else + if ($type = 'mei_audioView') + then + (exists($doc//mei:recording)) + + else + if ($type = 'mei_verovioView') + then + (exists($doc//mei:body//mei:measure) and exists($doc//mei:body//mei:note)) + + else + if ($type = 'tei_textView') + then + (exists($doc//tei:body[matches(.//text(), '[^\s]+')])) + + else + if ($type = 'tei_facsimileView') + then + (exists($doc//tei:facsimile//tei:graphic)) + + else + if ($type = 'tei_textFacsimileSplitView') + then + (exists($doc//tei:facsimile//tei:graphic) and exists($doc//tei:pb[@facs])) + + else + if ($type = 'mei_annotationView') + then + (exists($doc//mei:annot[@type = 'editorialComment'])) + + else + if ($type = 'xml_xmlView') + then + (true()) + + else + if ($type = 'desc_xmlView') + then + (exists($doc//mei:annot[@type = 'descLink'])) + + else + (false()) return - if($hasView) - then($defaultViewed.map) - else() + if ($hasView) + then + ($defaultViewed.map) + else + () }; declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)* { let $views := ( - (:'desc_summaryView',:) - (:'desc_headerView',:) - 'mei_textView', - 'mei_sourceView', - 'mei_audioView', - 'mei_verovioView', - 'tei_textView', - 'tei_facsimileView', - 'tei_textFacsimileSplitView', - 'mei_annotationView', - 'xml_xmlView', - 'desc_xmlView' + (:'desc_summaryView',:) + (:'desc_headerView',:) + 'mei_textView', + 'mei_sourceView', + 'mei_audioView', + 'mei_verovioView', + 'tei_textView', + 'tei_facsimileView', + 'tei_textFacsimileSplitView', + 'mei_annotationView', + 'xml_xmlView', + 'desc_xmlView' ) let $maps := - for $view in $views - return local:getView($view, $docUri, $doc) - - return $maps + for $view in $views + return + local:getView($view, $docUri, $doc) + + return + $maps }; declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string { - (: Work :) - if(exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) - then(eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang)) - else if(exists($doc/root()/mei:work)) - then(eutil:getLocalizedTitle($doc/root()/mei:work, $lang)) - - (: Recording :) - else if(exists($doc//mei:mei) and exists($doc//mei:recording)) - then(eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang)) - - (: Source / Score :) - else if($type = 'source' and exists($doc//mei:manifestation/mei:titleStmt)) - then(string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang), - ($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type)='shelfmark'][1]), ' | ') - => normalize-space()) - else if($type = 'source' and exists($doc//mei:source/mei:titleStmt)) - then(string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang), - ($doc//mei:source)[1]//mei:identifier[lower-case(@type)='shelfmark'][1]), ' | ') - => normalize-space()) - - (: MEI fallback if no title is found :) - else if(exists($doc//mei:mei) and exists(($doc//mei:titleStmt)[1])) - then(eutil:getLocalizedTitle(($doc//mei:titleStmt)[1], $lang)) - - (: Text :) - else if(exists($doc/tei:TEI)) - then(eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang)) - - (: HTML :) - else if($type = 'html') - then($doc//head/data(title)) - - else(string('unknown')) + (: Work :) + if (exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) + then + (eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang)) + else + if (exists($doc/root()/mei:work)) + then + (eutil:getLocalizedTitle($doc/root()/mei:work, $lang)) + + (: Recording :) + else + if (exists($doc//mei:mei) and exists($doc//mei:recording)) + then + (eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang)) + + (: Source / Score :) + else + if ($type = 'source' and exists($doc//mei:manifestation/mei:titleStmt)) + then + (string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang), + ($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ') + => normalize-space()) + else + if ($type = 'source' and exists($doc//mei:source/mei:titleStmt)) + then + (string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang), + ($doc//mei:source)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ') + => normalize-space()) + + (: MEI fallback if no title is found :) + else + if (exists($doc//mei:mei) and exists(($doc//mei:titleStmt)[1])) + then + (eutil:getLocalizedTitle(($doc//mei:titleStmt)[1], $lang)) + + (: Text :) + else + if (exists($doc/tei:TEI)) + then + (eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang)) + + (: HTML :) + else + if ($type = 'html') + then + ($doc//head/data(title)) + + else + (string('unknown')) }; let $uri := request:get-parameter('uri', '') -let $uriParams := if(contains($uri, '?')) then(substring-after($uri, '?')) else('') -let $uri := if(contains($uri, '?')) then(replace($uri, '[?&](term|path)=[^&]*', '')) else($uri) -let $docUri := if(contains($uri, '#')) then(substring-before($uri, '#')) else($uri) -let $internalId := if(contains($uri, '#')) then(substring-after($uri, '#')) else() -let $internalIdParam := if(contains($internalId, '?')) then(concat('?', substring-after($internalId, '?'))) else('') -let $internalId := if(contains($internalId, '?')) then(substring-before($internalId, '?')) else($internalId) +let $uriParams := if (contains($uri, '?')) then + (substring-after($uri, '?')) +else + ('') +let $uri := if (contains($uri, '?')) then + (replace($uri, '[?&](term|path)=[^&]*', '')) +else + ($uri) +let $docUri := if (contains($uri, '#')) then + (substring-before($uri, '#')) +else + ($uri) +let $internalId := if (contains($uri, '#')) then + (substring-after($uri, '#')) +else + () +let $internalIdParam := if (contains($internalId, '?')) then + (concat('?', substring-after($internalId, '?'))) +else + ('') +let $internalId := if (contains($internalId, '?')) then + (substring-before($internalId, '?')) +else + ($internalId) -let $term := if(contains($uriParams, 'term='))then(substring-after($uriParams, 'term='))else() -let $term := if(contains($term, '&'))then(substring-before($term, '&'))else($term) +let $term := if (contains($uriParams, 'term=')) then + (substring-after($uriParams, 'term=')) +else + () +let $term := if (contains($term, '&')) then + (substring-before($term, '&')) +else + ($term) -let $path := if(contains($uriParams, 'path='))then(substring-after($uriParams, 'path='))else() -let $path := if(contains($path, '&'))then(substring-before($path, '&'))else($path) +let $path := if (contains($uriParams, 'path=')) then + (substring-after($uriParams, 'path=')) +else + () +let $path := if (contains($path, '&')) then + (substring-before($path, '&')) +else + ($path) let $doc := eutil:getDoc($docUri) let $internal := $doc/id($internalId) @@ -177,59 +260,78 @@ let $edition := request:get-parameter('edition', '') (: Specific handling of virtual measure IDs for parts in OPERA project :) let $internal := - if(exists($internal)) - then($internal) - else( - if(starts-with($internalId, 'measure_') and $doc//mei:parts) - then( - - let $mdivId := functx:substring-before-last(substring-after($internalId, 'measure_'), '_') - let $measureN := functx:substring-after-last($internalId, '_') - return - ($doc/id($mdivId)//mei:measure[@n eq $measureN])[1] +if (exists($internal)) +then + ($internal) +else + ( + if (starts-with($internalId, 'measure_') and $doc//mei:parts) + then + ( + + let $mdivId := functx:substring-before-last(substring-after($internalId, 'measure_'), '_') + let $measureN := functx:substring-after-last($internalId, '_') + return + ($doc/id($mdivId)//mei:measure[@n eq $measureN])[1] ) - else($internal) + else + ($internal) ) let $type := (: Work :) - if(exists($doc//mei:mei) and exists($doc//mei:work) and not(exists($doc//mei:perfMedium))) - then(string('work')) - - (: Recording :) - else if(exists($doc//mei:mei) and exists($doc//mei:recording)) - then(string('recording')) - - (: Source / Score :) - else if(source:isSource($docUri)) - then(string('source')) - - (: Text :) - else if(exists($doc/tei:TEI)) - then(string('text')) - - (: HTML :) - else if(exists($doc/html) or exists($doc/html:html)) - then(string('html')) - - else if(contains($docUri, '.html')) - then(string('html')) - - else(string('unknown')) - -let $internalIdType := if(exists($internal)) - then(local-name($internal)) - else('unknown') +if (exists($doc//mei:mei) and exists($doc//mei:work) and not(exists($doc//mei:perfMedium))) +then + (string('work')) + + (: Recording :) +else + if (exists($doc//mei:mei) and exists($doc//mei:recording)) + then + (string('recording')) + + (: Source / Score :) + else + if (source:isSource($docUri)) + then + (string('source')) + + (: Text :) + else + if (exists($doc/tei:TEI)) + then + (string('text')) + + (: HTML :) + else + if (exists($doc/html) or exists($doc/html:html)) + then + (string('html')) + + else + if (contains($docUri, '.html')) + then + (string('html')) + + else + (string('unknown')) + +let $internalIdType := if (exists($internal)) +then + (local-name($internal)) +else + ('unknown') let $map := - map { - 'type': $type, - 'title': local:getWindowTitle($doc, $type), - 'doc': $docUri, - 'views': array {local:getViews($type, $docUri, $doc)}, - 'internalId': $internalId || $internalIdParam, - 'term': $term, - 'path': $path, - 'internalIdType': $internalIdType - } +map { + 'type': $type, + 'title': local:getWindowTitle($doc, $type), + 'doc': $docUri, + 'views': array {local:getViews($type, $docUri, $doc)}, + 'internalId': $internalId || $internalIdParam, + 'term': $term, + 'path': $path, + 'internalIdType': $internalIdType +} -return $map +return + $map From 162b0207e3c9281f54b4e6849da3838fbe632877 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 15:26:23 +0200 Subject: [PATCH 042/107] Update getLinkTarget.xql * add basic function documentation --- add/data/xql/getLinkTarget.xql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql index aee7b54ae..2f7c4f79f 100644 --- a/add/data/xql/getLinkTarget.xql +++ b/add/data/xql/getLinkTarget.xql @@ -23,6 +23,9 @@ declare option output:media-type "application/json"; declare variable $lang := request:get-parameter('lang', ''); +(:~ + : Returns a view for an edirom object + :) declare function local:getView($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)? { let $baseMap := map { 'type': substring-after($type, '_'), @@ -131,6 +134,9 @@ declare function local:getView($type as xs:string, $docUri as xs:string, $doc as () }; +(:~ + : Returns the views for an edirom object + :) declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)* { let $views := ( @@ -157,6 +163,9 @@ declare function local:getViews($type as xs:string, $docUri as xs:string, $doc a $maps }; +(:~ + : Returns the window title for an edirom-object + :) declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string { (: Work :) if (exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) From 9a64b698f7ceb6bac362f14d133be6325de1f1e5 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 15:26:37 +0200 Subject: [PATCH 043/107] Update getLinkTarget.xql * move let statement to declare variable --- add/data/xql/getLinkTarget.xql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql index 2f7c4f79f..86dcbca9a 100644 --- a/add/data/xql/getLinkTarget.xql +++ b/add/data/xql/getLinkTarget.xql @@ -22,6 +22,7 @@ declare option output:method "json"; declare option output:media-type "application/json"; declare variable $lang := request:get-parameter('lang', ''); +declare variable $uri := request:get-parameter('uri', ''); (:~ : Returns a view for an edirom object @@ -218,7 +219,6 @@ declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs (string('unknown')) }; -let $uri := request:get-parameter('uri', '') let $uriParams := if (contains($uri, '?')) then (substring-after($uri, '?')) else From 969b76ed284ae31091d37bcc169ed8398049f796 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 15:30:08 +0200 Subject: [PATCH 044/107] Update CONTRIBUTING.md --- CONTRIBUTING.md | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a01fa0b69..baf708cc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,14 +2,47 @@ # General Guidelines +* do not combine code-linting and contet work in one commit + ## Whitespace handling 1. Use whitespaces, not tabs to indent code -2. Close file with +2. Close file with newline character # XQuery -## Importing modules +## XQuery version + +```xquery +xquery version 3.1 +``` + +## Version Statement + +```xquery +(: +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. +:) +``` + +## Module imports + +1. declare namespaces +2. import module namespaces of registered modules +3. import module namespaces of custom modules + +* Sort all three alphabetically. +* Always use relative URIs for `import module namespace` statements that import for modules not registered with eXist-db. + +## Declare variables + +* Use declare function statements for all required external parameters + +## Function declarations + +* functions have to be preceeded by a XQDoc code-block + +## Strings -* always use relative URIs for `import module namespace` statements that import a local edirom xqm +* escape with single upper straight quote \ No newline at end of file From 85a24268fc01088727ce3444e007afce7ff669ae Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 15:37:00 +0200 Subject: [PATCH 045/107] Fix docker-ci.yml --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 28ed128e4..f266b2853 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -22,7 +22,7 @@ jobs: run: docker run --rm -v `pwd`:/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd - name: Upload Artifacts if: github.repository == 'Edirom/Edirom-Online' - uses: actions/actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v3.1.2 with: # The name that the artifact will be made available under name: EdiromOnline_${{ github.ref }}.zip From c42c93eb34c759a6104f181d4a36c6896c18c564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 15:52:38 +0200 Subject: [PATCH 046/107] Function documentation and async param Provided a function documentation for 'doAJAXRequest' Added a 'async' parameter for async AJAX calls --- app/controller/AJAXController.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controller/AJAXController.js b/app/controller/AJAXController.js index 6db90970b..580b062b5 100644 --- a/app/controller/AJAXController.js +++ b/app/controller/AJAXController.js @@ -27,7 +27,17 @@ Ext.define('EdiromOnline.controller.AJAXController', { window.doAJAXRequest = Ext.bind(this.doAJAXRequest, this); }, - doAJAXRequest: function(url, method, params, successFn, retryNo) { + /** + * Performs an AJAX request. + * + * @param {String} url The URL of the requestet site or end point. + * @param {String} method The HTTP method like 'PUT', 'GET', 'POST'. + * @param {Object} params An object containing key-value-pairs of parameters for the request. + * @param {Function} successFn A callback function which is called when the AJAX request was successfull. + * @param {Number} retryNo The number of retries, if the requests fails. Standard is 2 retries. + * @param {Boolean} async Defines the async parameter for AJAX calls. Default is 'true'. + */ + doAJAXRequest: function(url, method, params, successFn, retryNo, async) { var me = this; var editionId = this.application.activeEdition; @@ -38,8 +48,11 @@ Ext.define('EdiromOnline.controller.AJAXController', { if(override != null) url = override; - if(typeof(retryNo) === 'undefined') + if(typeof retryNo === 'undefined') retryNo = 2; + + if(typeof async === 'undefined') + async = true; var fn = Ext.bind(function(response, options, retryNoInt) { @@ -58,7 +71,8 @@ Ext.define('EdiromOnline.controller.AJAXController', { url: url, method: method, params: params, - success: fn + success: fn, + async: async }); } }); \ No newline at end of file From 15e449c6e1c3b3526d0e70a0001ddd59da0726e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 15:53:22 +0200 Subject: [PATCH 047/107] Documentation of how to call a URL with AJAX in Edirom --- CONTRIBUTING.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a01fa0b69..98179da4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,3 +13,34 @@ ## Importing modules * always use relative URIs for `import module namespace` statements that import a local edirom xqm + +# Javascript + +## AJAX calls + +The class `EdiromOnline.controller.AJAXController` provides a central method `doAJAXRequest` for performing AJAX requests. The method is provided globally as `window.doAJAXRequest`. + +`doAJAXRequest` takes the following arguments: + +* `url`: The URL of the requestet site or end point. +* `method`: The HTTP method like `PUT`, `GET`, `POST`. +* `params`: An object containing key-value-pairs of parameters for the request. +* `successFn`: A callback function which is called when the AJAX request was successfull. +* `retryNo`: The number of retries, if the requests fails. Standard is 2 retries. +* `async`: Defines the async parameter for AJAX calls. Default is 'true'. + +An example of using the function would be: + +```javascript +window.doAJAXRequest('data/xql/getAnnotationMeta.xql', + 'GET', + { + uri: uri, + lang: lang + }, + Ext.bind(function(response){ + view.setMeta(response.responseText); + }, this) +); +``` + From 96511351649ca83cf50dadc450fa7f7fbda3a101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 15:53:50 +0200 Subject: [PATCH 048/107] AJAX calls updated --- app/Application.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/Application.js b/app/Application.js index 2d340823f..f28a016e4 100644 --- a/app/Application.js +++ b/app/Application.js @@ -75,34 +75,34 @@ Ext.define('EdiromOnline.Application', { if(editionParam !== null) me.activeEdition = editionParam; - Ext.Ajax.request({ - url: 'data/xql/getEditionURI.xql', - async: false, - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getEditionURI.xql', + 'GET', + { uri: me.activeEdition - },success: function(response){ - this.activeEdition = response.responseText; }, - scope: this - }); - + Ext.bind(function(response){ + this.activeEdition = response.responseText; + }, this), + 2, // retries + false // async + ); + var workParam = me.getURLParameter('work'); if(workParam !== null) me.activeWork = workParam; - Ext.Ajax.request({ - url: 'data/xql/getWorkID.xql', - async: false, - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getWorkID.xql', + 'GET', + { uri: me.activeEdition, workId: me.activeWork - },success: function(response){ - this.activeWork = response.responseText; }, - scope: this - }); + Ext.bind(function(response){ + this.activeWork = response.responseText; + }, this), + 2, // retries + false // async + ); me.getController('PreferenceController').initPreferences(me.activeEdition); me.getController('LanguageController').initLangFile(me.activeEdition, 'de'); From 5e6d6336b962858a257004691097639e65561c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 15:53:56 +0200 Subject: [PATCH 049/107] AJAX calls updated --- app/controller/LanguageController.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controller/LanguageController.js b/app/controller/LanguageController.js index 14741d0ae..6df3c0039 100644 --- a/app/controller/LanguageController.js +++ b/app/controller/LanguageController.js @@ -35,20 +35,19 @@ Ext.define('EdiromOnline.controller.LanguageController', { initLangFile: function(editionURI, lang) { - Ext.Ajax.request({ - url: 'data/xql/getLanguageFile.xql', - async: false, - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getLanguageFile.xql', + 'GET', + { lang: lang, mode: 'json', edition: editionURI - },success: function(response){ - - this.langFiles.add(lang, Ext.JSON.decode(response.responseText)); }, - scope: this - }); + Ext.bind(function(response){ + this.langFiles.add(lang, Ext.JSON.decode(response.responseText)); + }, this), + 2, // retries + false // async + ); }, getLanguageString: function(key) { From dfcb3bcccb6dcbab16fc9e90af5ff025f066a548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 15:54:00 +0200 Subject: [PATCH 050/107] AJAX calls updated --- app/controller/LinkController.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controller/LinkController.js b/app/controller/LinkController.js index 23cbc0d53..794818d98 100644 --- a/app/controller/LinkController.js +++ b/app/controller/LinkController.js @@ -156,18 +156,16 @@ Ext.define('EdiromOnline.controller.LinkController', { if(singleUri.indexOf('#') != -1) { - Ext.Ajax.request({ - url: 'data/xql/getInternalIdType.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getInternalIdType.xql', + 'GET', + { uri: singleUri }, - success: function(response){ + Ext.bind(function(response){ win.loadInternalId(singleUri.split('#')[1], response.responseText.trim()); win.show(); - }, - scope: this - }); + }, this) + ); }else win.showView('summaryView'); From f210e761b688db4c3302f7c53e7dda9bf400680e Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Wed, 31 May 2023 16:29:14 +0200 Subject: [PATCH 051/107] remove outdated code I checked the namespace "http://exist-db.org/xquery/apps/config" and it is nowhere imported. So I believe this is just a left over from some former file reorganization which can safely be removed now. --- add/modules/config.xqm | 64 ------------------------------------------ 1 file changed, 64 deletions(-) delete mode 100755 add/modules/config.xqm diff --git a/add/modules/config.xqm b/add/modules/config.xqm deleted file mode 100755 index 2b14f4213..000000000 --- a/add/modules/config.xqm +++ /dev/null @@ -1,64 +0,0 @@ -(:~ - : A set of helper functions to access the application context from - : within a module. - :) -module namespace config="http://exist-db.org/xquery/apps/config"; - -declare namespace repo="http://exist-db.org/xquery/repo"; -declare namespace expath="http://expath.org/ns/pkg"; - -(: - Determine the application root collection from the current module load path. -:) -declare variable $config:app-root := - let $rawPath := system:get-module-load-path() - let $modulePath := - (: strip the xmldb: part :) - if (starts-with($rawPath, "xmldb:exist://")) then - if (starts-with($rawPath, "xmldb:exist://embedded-eXist-server")) then - substring($rawPath, 36) - else - substring($rawPath, 15) - else - $rawPath - return - substring-before($modulePath, "/modules") -; - -(:~ - : Returns the repo.xml descriptor for the current application. - :) -declare function config:repo-descriptor() as element(repo:meta) { - doc(concat($config:app-root, "/repo.xml"))/repo:meta -}; - -(:~ - : Returns the expath-pkg.xml descriptor for the current application. - :) -declare function config:expath-descriptor() as element(expath:package) { - doc(concat($config:app-root, "/expath-pkg.xml"))/expath:package -}; - -(:~ - : For debugging: generates a table showing all properties defined - : in the application descriptors. - :) -declare function config:app-info($node) { - let $expath := config:expath-descriptor() - let $repo := config:repo-descriptor() - return - - - - - - { - for $attr in ($expath/@*, $expath/*, $repo/*) - return - - - - - } -
app collection:{$config:app-root}
{node-name($attr)}:{$attr/string()}
-}; \ No newline at end of file From 572b0087c7f22a8396dec8f8ae53cd3c57811dad Mon Sep 17 00:00:00 2001 From: Silke Reich Date: Wed, 31 May 2023 16:43:13 +0200 Subject: [PATCH 052/107] Update getAnnotationInfos.xql - New license declaration - import modules updated and sorted - output method json - returns application/json --- add/data/xql/getAnnotationInfos.xql | 146 +++++++++++++--------------- 1 file changed, 65 insertions(+), 81 deletions(-) diff --git a/add/data/xql/getAnnotationInfos.xql b/add/data/xql/getAnnotationInfos.xql index a3dbe0f7d..9b41a213a 100644 --- a/add/data/xql/getAnnotationInfos.xql +++ b/add/data/xql/getAnnotationInfos.xql @@ -1,102 +1,86 @@ xquery version "3.1"; (: - Edirom Online - Copyright (C) 2011 The Edirom Project - http://www.edirom.de - - Edirom Online is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Edirom Online is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Edirom Online. If not, see . - - ID: $Id: getAnnotationInfos.xql 1261 2012-02-28 15:50:45Z daniel $ +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) - -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; - -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; +declare namespace request = "http://exist-db.org/xquery/request"; -declare option output:method "text"; -declare option output:media-type "text/plain"; +import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +declare option output:method "json"; +declare option output:media-type "application/json"; declare variable $lang := request:get-parameter('lang', ''); +declare variable $uri := request:get-parameter('uri', ''); +declare variable $edition := request:get-parameter('edition', ''); +declare variable $edition_path := eutil:getPreference('edition_path', $edition); +(:~ + : Returns distinct list of catagories + :) declare function local:getDistinctCategories($annots as element()*) as xs:string* { - - let $oldCats := distinct-values($annots/mei:ptr[@type="categories"]/replace(@target, '#', '')) - let $newCats := distinct-values(for $annot in $annots return tokenize(replace(normalize-space($annot/@class),'#',''),' '))[contains(., 'annotation.category')] - - return distinct-values(($oldCats, $newCats)[string-length() gt 0]) + + let $oldCats := distinct-values($annots/mei:ptr[@type = "categories"]/replace(@target, '#', '')) + let $newCats := distinct-values(for $annot in $annots + return + tokenize(replace(normalize-space($annot/@class), '#', ''), ' '))[contains(., 'annotation.category')] + + return + distinct-values(($oldCats, $newCats)[string-length() gt 0]) }; +(:~ + : Returns distinct list of annotation priorities + :) declare function local:getDistinctPriorities($annots as element()*) as xs:string* { - - distinct-values( - for $annot in $annots - let $oldLink := $annot/mei:ptr[@type="priority"]/replace(@target, '#', '') - let $classes := tokenize(replace(normalize-space($annot/@class),'#',''),' ') - let $newLink := $classes[starts-with(.,'ediromAnnotPrio')] - return - distinct-values(($oldLink, $newLink))[string-length(.) gt 0] - ) + + distinct-values( + for $annot in $annots + let $oldLink := $annot/mei:ptr[@type = "priority"]/replace(@target, '#', '') + let $classes := tokenize(replace(normalize-space($annot/@class), '#', ''), ' ') + let $newLink := $classes[starts-with(., 'ediromAnnotPrio')] + return + distinct-values(($oldLink, $newLink))[string-length(.) gt 0] + ) }; -let $uri := request:get-parameter('uri', '') -let $edition := request:get-parameter('edition', '') let $mei := doc($uri)/root() -let $edition_path := eutil:getPreference('edition_path', $edition) let $annots := collection($edition_path)//mei:annot[matches(@plist, $uri)] | $mei//mei:annot - -let $categories := - for $category in local:getDistinctCategories($annots) - let $categoryElement := (collection($edition_path)/id($category)[mei:label or mei:name])[1] - let $name := annotation:category_getName($categoryElement, eutil:getLanguage($edition)) - order by $name - return map { - 'id': $category, - 'name': $name - } - -let $prios := - for $priority in local:getDistinctPriorities($annots) - let $name := annotation:getPriorityLabel((collection($edition_path)//id($priority)[mei:label or mei:name])[1]) - order by $name - return map { - 'id': $priority, - 'name': $name - } - -let $map := - map { - 'categories': array { $categories }, - 'priorities': array { $prios }, - 'count': count($annots) - } - -let $options := - map { - 'method': 'json', - 'media-type': 'text/plain' - } - -return serialize($map, $options) - -(: +let $categories := +for $category in local:getDistinctCategories($annots) +let $categoryElement := (collection($edition_path)/id($category)[mei:label or mei:name])[1] +let $name := annotation:category_getName($categoryElement, eutil:getLanguage($edition)) + order by $name +return + map { + 'id': $category, + 'name': $name + } + +let $prios := +for $priority in local:getDistinctPriorities($annots) +let $name := annotation:getPriorityLabel((collection($edition_path)//id($priority)[mei:label or mei:name])[1]) + order by $name +return + map { + 'id': $priority, + 'name': $name + } + +let $map := +map { + 'categories': array {$categories}, + 'priorities': array {$prios}, + 'count': count($annots) +} + +return + $map + + (: return concat('{categories: [', string-join( From 4256ec196390857674536ddf6f274c8ba9eedb5f Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 16:52:04 +0200 Subject: [PATCH 053/107] Update CONTRIBUTING.md * fix typos * add section on xqDoc * restructure --- CONTRIBUTING.md | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index baf708cc7..80e39c2f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,47 +2,57 @@ # General Guidelines -* do not combine code-linting and contet work in one commit +* do not combine code-linting and content work in one commit ## Whitespace handling 1. Use whitespaces, not tabs to indent code -2. Close file with newline character +2. Close file with a newline character # XQuery -## XQuery version +## xqDoc + +We use [xqDoc](https://xqdoc.org) for documenting the XQueries in this repository. Please refer to the section [xqDoc Comments](https://xqdoc.org/xqdoc_comments_doc.html) of the xyDoc-website for details on formatting the documentation comment blocks. + +* XQuery modules must have a library module xqDoc comment preceding the module declaration. +* Function declarations must have a library module xqDoc function comment preceding the function. + +## XQuery document structure + +### XQuery version ```xquery -xquery version 3.1 +xquery version 3.1; ``` -## Version Statement +### License Statement ```xquery (: -For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) ``` -## Module imports - -1. declare namespaces -2. import module namespaces of registered modules -3. import module namespaces of custom modules +### File Header -* Sort all three alphabetically. -* Always use relative URIs for `import module namespace` statements that import for modules not registered with eXist-db. +1. `declare namespace` statements + * sort alphabetically by prefix +2. `import module namespace` statements of registered modules + * sort alphabetically by prefix +3. `import module namespace` statements of custom modules + * sort alphabetically by prefix + * Always use relative URIs for `import module namespace` statements that import for modules not registered with eXist-db. -## Declare variables +### Declare variables -* Use declare function statements for all required external parameters +* Use `declare variable` statements for all required external parameters -## Function declarations +### Function declarations -* functions have to be preceeded by a XQDoc code-block +* functions have to be preceded by an xqDoc comment -## Strings +### XQuery body -* escape with single upper straight quote \ No newline at end of file +* Strings: escape with U+00027 APOSTROPHE: `'` \ No newline at end of file From 2b1f790fcaaa991b1acc6bff7782fc2a04519492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:03:52 +0200 Subject: [PATCH 054/107] AJAX calls updated --- app/controller/navigator/Navigator.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controller/navigator/Navigator.js b/app/controller/navigator/Navigator.js index 784f86de0..52e645973 100644 --- a/app/controller/navigator/Navigator.js +++ b/app/controller/navigator/Navigator.js @@ -47,24 +47,22 @@ Ext.define('EdiromOnline.controller.navigator.Navigator', { var editionId = this.application.activeEdition; var lang = window.getLanguage('application_language'); - Ext.Ajax.request({ - url: 'data/xql/getNavigatorConfig.xql', - params: { + window.doAJAXRequest('data/xql/getNavigatorConfig.xql', + 'GET', + { editionId: editionId, workId: workId, lang: lang }, - success: function(response){ - + Ext.bind(function(response){ this.navigatorContents.add(workId, response.responseText); Ext.Array.each(this.navigators, function(navigator) { navigator.body.update(this.getNavigatorContent(workId)); navigator.setLoading(false); }, this); - }, - scope: this - }); + }, this) + ); }, getNavigatorContent: function(workId) { From 669b288f136ab4c929bdacf1f5d9a05ca7d45c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:03:55 +0200 Subject: [PATCH 055/107] AJAX calls updated --- app/controller/PreferenceController.js | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controller/PreferenceController.js b/app/controller/PreferenceController.js index 5669b75e7..c4e5d86a9 100644 --- a/app/controller/PreferenceController.js +++ b/app/controller/PreferenceController.js @@ -30,18 +30,18 @@ Ext.define('EdiromOnline.controller.PreferenceController', { initPreferences: function(editionURI) { - Ext.Ajax.request({ - url: 'data/xql/getPreferences.xql', - async: false, - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getPreferences.xql', + 'GET', + { mode: 'json', edition: editionURI - },success: function(response){ - this.setPreferences(Ext.JSON.decode(response.responseText)); }, - scope: this - }); + Ext.bind(function(response){ + this.setPreferences(Ext.JSON.decode(response.responseText)); + }, this), + 2, // retries + false // async + ); }, setPreferences: function(preferences) { @@ -50,14 +50,14 @@ Ext.define('EdiromOnline.controller.PreferenceController', { for(var key in me.preferences) { if(key.indexOf('plugin_') == 0) - Ext.Ajax.request({ - url: me.preferences[key], - method: 'GET', - success: function(response){ + + window.doAJAXRequest(me.preferences[key], + 'GET', + {}, + Ext.bind(function(response){ eval(response.responseText); - }, - scope: this - }); + }, this) + ); } }, From 922f5e1b24886321eac81c7d410efc6fbcb1c915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:01 +0200 Subject: [PATCH 056/107] AJAX calls updated --- app/controller/window/HeaderView.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controller/window/HeaderView.js b/app/controller/window/HeaderView.js index e08ee87f6..e48adac7f 100644 --- a/app/controller/window/HeaderView.js +++ b/app/controller/window/HeaderView.js @@ -42,17 +42,15 @@ Ext.define('EdiromOnline.controller.window.HeaderView', { var uri = view.uri; var type = view.type; - Ext.Ajax.request({ - url: 'data/xql/getHeader.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getHeader.xql', + 'GET', + { uri: uri, type: type }, - success: function(response){ + Ext.bind(function(response){ view.setContent(response.responseText); - }, - scope: this - }); + }, this) + ); } }); From 63d67ad1781c9756d2c6edc80022347330b8ae4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:04 +0200 Subject: [PATCH 057/107] AJAX calls updated --- app/controller/window/iFrameView.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controller/window/iFrameView.js b/app/controller/window/iFrameView.js index a8bba086f..b0c4a0e85 100644 --- a/app/controller/window/iFrameView.js +++ b/app/controller/window/iFrameView.js @@ -41,16 +41,14 @@ Ext.define('EdiromOnline.controller.window.iFrameView', { var uri = view.uri; - Ext.Ajax.request({ - url: 'data/xql/getiFrameURL.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getiFrameURL.xql', + 'GET', + { uri: uri }, - success: function(response){ + Ext.bind(function(response){ view.setContent(response.responseText); - }, - scope: this - }); + }, this) + ); } }); From 42811146b70d1c81d5806c78f0dd34b2e8d3e290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:08 +0200 Subject: [PATCH 058/107] AJAX calls updated --- .../window/source/MeasureBasedView.js | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/app/controller/window/source/MeasureBasedView.js b/app/controller/window/source/MeasureBasedView.js index d9f69fb8d..dd051b7e9 100644 --- a/app/controller/window/source/MeasureBasedView.js +++ b/app/controller/window/source/MeasureBasedView.js @@ -68,14 +68,13 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { onMdivSelected: function(mdiv, view) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMeasures.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getMeasures.xql', + 'GET', + { uri: view.owner.uri, mdiv: mdiv }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var measures = Ext.create('Ext.data.Store', { @@ -83,8 +82,8 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { data: Ext.JSON.decode(data) }); me.measuresLoaded(measures, view); - } - }); + }, this) + ); }, measuresLoaded: function(measures, view) { @@ -98,19 +97,18 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { onShowMeasure: function(view, uri, measureId, count) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMeasurePage.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getMeasurePage.xql', + 'GET', + { id: uri, measure: measureId, measureCount: count }, - success: Ext.bind(function(response){ + Ext.bind(function(response){ var data = response.responseText; this.showMeasure(view, uri, measureId, Ext.JSON.decode(data)); }, me) - }); + ); }, showMeasure: function(view, uri, measureId, data) { @@ -128,14 +126,13 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { }, fetchMeasures: function(uri, pageId, fn) { - Ext.Ajax.request({ - url: 'data/xql/getMeasuresOnPage.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getMeasuresOnPage.xql', + 'GET', + { uri: uri, pageId: pageId }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var measures = Ext.create('Ext.data.Store', { @@ -145,8 +142,8 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { if(typeof fn == 'function') fn(measures); - } - }); + }, this) + ); }, measuresOnPageLoaded: function(measures, viewer, pageId) { @@ -198,16 +195,15 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { if(overlays[overlayId]) { - Ext.Ajax.request({ - url: 'data/xql/getOverlayOnPage.xql', - method: 'GET', - params: { - uri: uri, - pageId: pageId, - overlayId: overlayId - }, - success: function (response) { - var data = response.responseText; + window.doAJAXRequest('data/xql/getOverlayOnPage.xql', + 'GET', + { + uri: uri, + pageId: pageId, + overlayId: overlayId + }, + Ext.bind(function(response){ + var data = response.responseText; if (data.trim() == '') return; @@ -218,8 +214,8 @@ Ext.define('EdiromOnline.controller.window.source.MeasureBasedView', { me.overlayLoaded(viewer, pageId, overlayId, overlay, sourceView); - } - }); + }, this) + ); }else { viewer.removeSVGOverlay(overlayId); } From 39db36fced189f58ab897a1bb7e896945f27201d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:12 +0200 Subject: [PATCH 059/107] AJAX calls updated --- app/controller/window/source/PageBasedView.js | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/app/controller/window/source/PageBasedView.js b/app/controller/window/source/PageBasedView.js index 0101cd168..7835cf120 100644 --- a/app/controller/window/source/PageBasedView.js +++ b/app/controller/window/source/PageBasedView.js @@ -40,14 +40,13 @@ Ext.define('EdiromOnline.controller.window.source.PageBasedView', { if (view.initialized) return; view.initialized = true; - Ext.Ajax.request({ - url: 'data/xql/getPages.xql', - method: 'GET', - params: { - uri: view.owner.uri - }, - success: function (response) { - var data = response.responseText; + window.doAJAXRequest('data/xql/getPages.xql', + 'GET', + { + uri: view.owner.uri + }, + Ext.bind(function(response){ + var data = response.responseText; var pages = Ext.create('Ext.data.Store', { fields:[ 'id', 'name', 'path', 'width', 'height', 'measures', 'annotations'], @@ -55,8 +54,8 @@ Ext.define('EdiromOnline.controller.window.source.PageBasedView', { }); me.pagesLoaded(pages, view); - } - }); + }, this) + ); }, pagesLoaded: function (pages, view) { @@ -70,16 +69,15 @@ Ext.define('EdiromOnline.controller.window.source.PageBasedView', { if(overlays[overlayId]) { // if visible - Ext.Ajax.request({ - url: 'data/xql/getOverlayOnPage.xql', - method: 'GET', - params: { - uri: uri, - pageId: pageId, - overlayId: overlayId - }, - success: function (response) { - var data = response.responseText; + window.doAJAXRequest('data/xql/getOverlayOnPage.xql', + 'GET', + { + uri: uri, + pageId: pageId, + overlayId: overlayId + }, + Ext.bind(function(response){ + var data = response.responseText; if (data.trim() == '') return; @@ -89,8 +87,8 @@ Ext.define('EdiromOnline.controller.window.source.PageBasedView', { }); me.overlayLoaded(viewer, pageId, overlayId, overlay, sourceView); - } - }); + }, this) + ); }else { viewer.imageViewer.removeSVGOverlay(overlayId); } From 69378721ca3cea9c4983269135c2f6c59a2f7bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:15 +0200 Subject: [PATCH 060/107] AJAX calls updated --- app/controller/window/source/SourceView.js | 113 ++++++++++----------- 1 file changed, 51 insertions(+), 62 deletions(-) diff --git a/app/controller/window/source/SourceView.js b/app/controller/window/source/SourceView.js index 6d6281169..a5a7b1606 100644 --- a/app/controller/window/source/SourceView.js +++ b/app/controller/window/source/SourceView.js @@ -53,14 +53,12 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { ToolsController.addAnnotationVisibilityListener(view.id, Ext.bind(view.checkGlobalAnnotationVisibility, view)); view.checkGlobalAnnotationVisibility(ToolsController.areAnnotationsVisible()); - - Ext.Ajax.request({ - url: 'data/xql/getMovements.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getMovements.xql', + 'GET', + { uri: view.uri }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var movements = Ext.create('Ext.data.Store', { @@ -69,8 +67,8 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { }); me.movementsLoaded(movements, view); - } - }); + }, this) + ); window.doAJAXRequest('data/xql/getAnnotationInfos.xql', 'GET', @@ -97,13 +95,12 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { }, this) ); - Ext.Ajax.request({ - url: 'data/xql/getOverlays.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getOverlays.xql', + 'GET', + { uri: view.uri }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var overlays = Ext.create('Ext.data.Store', { @@ -112,8 +109,8 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { }); me.overlaysLoaded(overlays, view); - } - }); + }, this) + ); }, movementsLoaded: function(movements, view) { @@ -131,18 +128,17 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { onGotoMovement: function(view, movementId) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMovementsFirstPage.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getMovementsFirstPage.xql', + 'GET', + { uri: view.uri, movementId: movementId }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; me.gotoMovement(Ext.String.trim(data), view); - } - }); + }, this) + ); }, gotoMovement: function(pageId, view) { @@ -167,14 +163,13 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { }, fetchMeasures: function(uri, pageId, fn) { - Ext.Ajax.request({ - url: 'data/xql/getMeasuresOnPage.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getMeasuresOnPage.xql', + 'GET', + { uri: uri, pageId: pageId }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var measures = Ext.create('Ext.data.Store', { @@ -184,8 +179,8 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { if(typeof fn == 'function') fn(measures); - } - }); + }, this) + ); }, measuresOnPageLoaded: function(measures, view, pageId) { @@ -242,39 +237,35 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { onGotoMeasureByName: function (view, measure, movementId) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMeasurePage.xql', - method: 'GET', - params: { - id: view.uri, + window.doAJAXRequest('data/xql/getMeasurePage.xql', + 'GET', + { + id: view.uri, measure: measure, movementId: movementId - }, - success: Ext.bind(function (response) { - var data = response.responseText; + }, + Ext.bind(function(response){ + var data = response.responseText; this.gotoMeasure(Ext.JSON.decode(data)[0], view); - }, - me) - }); + }, me) + ); }, onGotoMeasure: function (view, measureId) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMeasure.xql', - method: 'GET', - params: { - id: view.uri, + window.doAJAXRequest('data/xql/getMeasure.xql', + 'GET', + { + id: view.uri, measureId: measureId - }, - success: Ext.bind(function (response) { - var data = response.responseText; + }, + Ext.bind(function(response){ + var data = response.responseText; this.gotoMeasure(Ext.JSON.decode(data), view); - }, - me) - }); + }, me) + ); }, gotoMeasure: function (result, view) { @@ -293,19 +284,17 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getZone.xql', - method: 'GET', - params: { - uri: view.uri, + window.doAJAXRequest('data/xql/getZone.xql', + 'GET', + { + uri: view.uri, zoneId: zoneId - }, - success: Ext.bind(function (response) { - var data = response.responseText; + }, + Ext.bind(function(response){ + var data = response.responseText; this.gotoZone(Ext.JSON.decode(data), view); - }, - me) - }); + }, this) + ); }, gotoZone: function (result, view) { From 479b5667dcf10ae792a6e49827b0186343e96e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:19 +0200 Subject: [PATCH 061/107] AJAX calls updated --- app/controller/window/source/VerovioView.js | 59 ++++++++++----------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/app/controller/window/source/VerovioView.js b/app/controller/window/source/VerovioView.js index e0fd376c7..fb79c506d 100644 --- a/app/controller/window/source/VerovioView.js +++ b/app/controller/window/source/VerovioView.js @@ -44,14 +44,13 @@ Ext.define('EdiromOnline.controller.window.source.VerovioView', { view.on('gotoMeasureByName', me.onGotoMeasureByName, me); view.on('gotoMeasure', me.onGotoMeasure, me); - Ext.Ajax.request({ - url: 'data/xql/getMovements.xql', - method: 'GET', - params: { - uri: view.uri - }, - success: function (response) { - var data = response.responseText; + window.doAJAXRequest('data/xql/getMovements.xql', + 'GET', + { + uri: view.uri + }, + Ext.bind(function(response){ + var data = response.responseText; var movements = Ext.create('Ext.data.Store', { fields:[ 'id', 'name'], @@ -59,8 +58,8 @@ Ext.define('EdiromOnline.controller.window.source.VerovioView', { }); me.movementsLoaded(movements, view); - } - }); + }, this) + ); }, movementsLoaded: function (movements, view) { @@ -70,39 +69,35 @@ Ext.define('EdiromOnline.controller.window.source.VerovioView', { onGotoMeasureByName: function (view, measure, movementId) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMeasurePage.xql', - method: 'GET', - params: { - id: view.uri, + window.doAJAXRequest('data/xql/getMeasurePage.xql', + 'GET', + { + id: view.uri, measure: measure, movementId: movementId - }, - success: Ext.bind(function (response) { - var data = response.responseText; + }, + Ext.bind(function(response){ + var data = response.responseText; this.gotoMeasure(Ext.JSON.decode(data)[0], view); - }, - me) - }); + }, me) + ); }, onGotoMeasure: function (view, measureId) { var me = this; - Ext.Ajax.request({ - url: 'data/xql/getMeasure.xql', - method: 'GET', - params: { - id: view.uri, + window.doAJAXRequest('data/xql/getMeasure.xql', + 'GET', + { + id: view.uri, measureId: measureId - }, - success: Ext.bind(function (response) { - var data = response.responseText; + }, + Ext.bind(function(response){ + var data = response.responseText; this.gotoMeasure(Ext.JSON.decode(data), view); - }, - me) - }); + }, me) + ); }, gotoMeasure: function (result, view) { From 4a6cd0bfb99ee412ab03da613c9fc073815d996c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:22 +0200 Subject: [PATCH 062/107] AJAX calls updated --- app/controller/window/SummaryView.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controller/window/SummaryView.js b/app/controller/window/SummaryView.js index e60519c8b..e7c911e27 100644 --- a/app/controller/window/SummaryView.js +++ b/app/controller/window/SummaryView.js @@ -43,20 +43,18 @@ Ext.define('EdiromOnline.controller.window.SummaryView', { var app = EdiromOnline.getApplication(); var activeEdition = app.activeEdition - Ext.Ajax.request({ - url: 'data/xql/getSummary.xql', - method: 'GET', - params: { - uri: uri, + window.doAJAXRequest('data/xql/getSummary.xql', + 'GET', + { + uri: uri, type: type, edition: activeEdition - }, - success: function (response) { - var data = response.responseText; + }, + Ext.bind(function(response){ + var data = response.responseText; view.setContent(data); - }, - scope: this - }); + }, this) + ); } }); \ No newline at end of file From c1387486332c47ea3f567b1ad77a211dc060dbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:25 +0200 Subject: [PATCH 063/107] AJAX calls updated --- app/controller/window/text/FacsimileView.js | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/controller/window/text/FacsimileView.js b/app/controller/window/text/FacsimileView.js index b15bb7a47..642fc00d3 100644 --- a/app/controller/window/text/FacsimileView.js +++ b/app/controller/window/text/FacsimileView.js @@ -44,13 +44,12 @@ Ext.define('EdiromOnline.controller.window.text.FacsimileView', { var uri = view.uri; - Ext.Ajax.request({ - url: 'data/xql/getPages.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getPages.xql', + 'GET', + { uri: uri }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var pages = Ext.create('Ext.data.Store', { @@ -59,17 +58,16 @@ Ext.define('EdiromOnline.controller.window.text.FacsimileView', { }); view.setImageSet(pages); - } - }); + }, this) + ); - Ext.Ajax.request({ - url: 'data/xql/getChapters.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getChapters.xql', + 'GET', + { uri: view.uri, mode: 'pageMode' }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var chapters = Ext.create('Ext.data.Store', { @@ -78,8 +76,8 @@ Ext.define('EdiromOnline.controller.window.text.FacsimileView', { }); me.chaptersLoaded(chapters, view); - } - }); + }, this) + ); }, chaptersLoaded: function(chapters, view) { From a2b61495f9cd9cb002d505d7bef4d04361cc7724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:29 +0200 Subject: [PATCH 064/107] AJAX calls updated --- .../window/text/TextFacsimileSplitView.js | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/app/controller/window/text/TextFacsimileSplitView.js b/app/controller/window/text/TextFacsimileSplitView.js index 1d47b36d4..e05b08aae 100644 --- a/app/controller/window/text/TextFacsimileSplitView.js +++ b/app/controller/window/text/TextFacsimileSplitView.js @@ -50,13 +50,12 @@ Ext.define('EdiromOnline.controller.window.text.TextFacsimileSplitView', { var uri = view.uri; - Ext.Ajax.request({ - url: 'data/xql/getPages.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getPages.xql', + 'GET', + { uri: uri }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var pages = Ext.create('Ext.data.Store', { @@ -65,17 +64,16 @@ Ext.define('EdiromOnline.controller.window.text.TextFacsimileSplitView', { }); view.setImageSet(pages); - } - }); + }, this) + ); - Ext.Ajax.request({ - url: 'data/xql/getChapters.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getChapters.xql', + 'GET', + { uri: view.uri, mode: 'pageMode' }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var chapters = Ext.create('Ext.data.Store', { @@ -84,8 +82,8 @@ Ext.define('EdiromOnline.controller.window.text.TextFacsimileSplitView', { }); me.chaptersLoaded(chapters, view); - } - }); + }, this) + ); }, onAfterImageChanged: function(view) { @@ -148,14 +146,13 @@ Ext.define('EdiromOnline.controller.window.text.TextFacsimileSplitView', { var me = this; if(visible) - Ext.Ajax.request({ - url: 'data/xql/getAnnotationsInText.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getAnnotationsInText.xql', + 'GET', + { uri: view.uri, page: view.getActivePage() }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var annotations = Ext.create('Ext.data.Store', { @@ -164,9 +161,8 @@ Ext.define('EdiromOnline.controller.window.text.TextFacsimileSplitView', { }); me.annotationsLoaded(annotations, view); - } - }); - + }, this) + ); else view.hideAnnotations(); }, From 0bf713d50c17d61d8340af3433823a31fb433888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:32 +0200 Subject: [PATCH 065/107] AJAX calls updated --- app/controller/window/text/TextView.js | 27 ++++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/app/controller/window/text/TextView.js b/app/controller/window/text/TextView.js index f780d1851..d40bae8e5 100644 --- a/app/controller/window/text/TextView.js +++ b/app/controller/window/text/TextView.js @@ -69,13 +69,12 @@ Ext.define('EdiromOnline.controller.window.text.TextView', { view.setContent(content); - Ext.Ajax.request({ - url: 'data/xql/getChapters.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getChapters.xql', + 'GET', + { uri: view.uri }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var chapters = Ext.create('Ext.data.Store', { @@ -84,8 +83,8 @@ Ext.define('EdiromOnline.controller.window.text.TextView', { }); me.chaptersLoaded(chapters, view); - } - }); + }, this) + ); window.doAJAXRequest('data/xql/getAnnotationInfos.xql', 'GET', @@ -121,13 +120,12 @@ Ext.define('EdiromOnline.controller.window.text.TextView', { var me = this; if(visible) - Ext.Ajax.request({ - url: 'data/xql/getAnnotationsInText.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getAnnotationsInText.xql', + 'GET', + { uri: view.uri }, - success: function(response){ + Ext.bind(function(response){ var data = response.responseText; var annotations = Ext.create('Ext.data.Store', { @@ -136,9 +134,8 @@ Ext.define('EdiromOnline.controller.window.text.TextView', { }); me.annotationsLoaded(annotations, view); - } - }); - + }, this) + ); else view.hideAnnotations(); }, From 3bd53a363eedd559006efb35e9421334e322c1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:36 +0200 Subject: [PATCH 066/107] AJAX calls updated --- app/controller/window/XmlView.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controller/window/XmlView.js b/app/controller/window/XmlView.js index f8d4b03f3..c1bf4bd4a 100644 --- a/app/controller/window/XmlView.js +++ b/app/controller/window/XmlView.js @@ -47,18 +47,16 @@ Ext.define('EdiromOnline.controller.window.XmlView', { var uri = xmlview.uri; var internalId = xmlview.internalId; - Ext.Ajax.request({ - url: 'data/xql/getXml.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getXml.xql', + 'GET', + { uri: uri, internalId: internalId }, - success: function(response){ + Ext.bind(function(response){ xmlview.setXmlContent(response.responseText); - }, - scope: this - }); + }, this) + ); }, resize: function(xmlview, width, height){ From 233a3b5b3f4cfa05f90b2ad7775ea7c00047844e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:39 +0200 Subject: [PATCH 067/107] AJAX calls updated --- app/view/window/AnnotationView.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/view/window/AnnotationView.js b/app/view/window/AnnotationView.js index 97f18033a..74d95e4c0 100644 --- a/app/view/window/AnnotationView.js +++ b/app/view/window/AnnotationView.js @@ -753,17 +753,17 @@ Ext.define('EdiromOnline.view.window.AnnotationView', { var uri = txtData.match(/uri:(.*)__\$\$__/)[1]; var id = txtData.match(/__\$\$__participantId:(.*)/)[1]; - Ext.Ajax.request({ - url: 'data/xql/getReducedDocument.xql?uri=' + uri + '&selectionId=' + id + '&subtreeRoot=div&idPrefix=' + me.id + '_', - success: function(response){ + window.doAJAXRequest('data/xql/getReducedDocument.xql?uri=' + uri + '&selectionId=' + id + '&subtreeRoot=div&idPrefix=' + me.id + '_', + 'GET', + {}, + Ext.bind(function(response){ var contEl = this.el.getById(me.id + '_annotationParticipantsSingle'); var txtBox = new Ext.Element(contEl.query('div.txtBox')[0]); txtBox.update(response.responseText); contEl.query('#' + this.id + '_' + id)[0].scrollIntoView(txtBox); - }, - scope: me - }); + }, me) + ); }, previousParticipantSingle: function() { From 56984dda0ccbf8693ba0959d22f61db81bdff108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:42 +0200 Subject: [PATCH 068/107] AJAX calls updated --- app/view/window/image/LeafletFacsimile.js | 38 ++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/app/view/window/image/LeafletFacsimile.js b/app/view/window/image/LeafletFacsimile.js index ffb198a72..ed933f676 100644 --- a/app/view/window/image/LeafletFacsimile.js +++ b/app/view/window/image/LeafletFacsimile.js @@ -303,32 +303,28 @@ Ext.define('EdiromOnline.view.window.image.LeafletFacsimile', { var me = this; rectangleCenter.on('mouseover', function (e) { - Ext.Ajax.request({ - url: 'data/xql/getAnnotation.xql', - method: 'GET', - params: { - uri: annotURI, - target: 'tip', - edition: EdiromOnline.getApplication().activeEdition - }, - success: function(response){ - //this.update(response.responseText); - me.facsimileTile.disableRectangle(); - me.facsimileTile.enableRectangle(ulx, uly, lrx, lry, true); - //rect_tmp = me.facsimileTile.createPupup(ulx, uly, lrx, lry, rectangleCenter , response.responseText); - var overview = response.responseText; - var test = $(overview).html(); - tooltip.setHtml(test); + window.doAJAXRequest('data/xql/getAnnotation.xql', + 'GET', + { + uri: annotURI, + target: 'tip', + edition: EdiromOnline.getApplication().activeEdition + }, + Ext.bind(function(response){ + //this.update(response.responseText); + me.facsimileTile.disableRectangle(); + me.facsimileTile.enableRectangle(ulx, uly, lrx, lry, true); + //rect_tmp = me.facsimileTile.createPupup(ulx, uly, lrx, lry, rectangleCenter , response.responseText); + var overview = response.responseText; + var test = $(overview).html(); + tooltip.setHtml(test); /*var tooltip = L.tooltip({ target: rectangleCenter, map: me.getMap(), html: response.responseText });*/ - - - } - // scope: this - }); + }, this) + ); }); From a81d29df6bc5e7f8965d68989f61be70afc43654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:46 +0200 Subject: [PATCH 069/107] AJAX calls updated --- app/view/window/text/TextFacsimileSplitView.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/view/window/text/TextFacsimileSplitView.js b/app/view/window/text/TextFacsimileSplitView.js index 325e3ca09..d0605307c 100644 --- a/app/view/window/text/TextFacsimileSplitView.js +++ b/app/view/window/text/TextFacsimileSplitView.js @@ -205,18 +205,16 @@ Ext.define('EdiromOnline.view.window.text.TextFacsimileSplitView', { }); tip.on('afterrender', function() { - Ext.Ajax.request({ - url: 'data/xql/getAnnotation.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getAnnotation.xql', + 'GET', + { uri: uri, target: 'tip' }, - success: function(response){ + Ext.bind(function(response){ this.update(response.responseText); - }, - scope: this - }); + }, this) + ); }, tip); }, me); From a4b2b8c980998a4b7066c1168b8195d04ac9502a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:04:50 +0200 Subject: [PATCH 070/107] AJAX calls updated --- app/view/window/text/TextView.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/view/window/text/TextView.js b/app/view/window/text/TextView.js index 7221b9b12..08c6a5364 100644 --- a/app/view/window/text/TextView.js +++ b/app/view/window/text/TextView.js @@ -170,18 +170,16 @@ Ext.define('EdiromOnline.view.window.text.TextView', { }); tip.on('afterrender', function() { - Ext.Ajax.request({ - url: 'data/xql/getAnnotation.xql', - method: 'GET', - params: { + window.doAJAXRequest('data/xql/getAnnotation.xql', + 'GET', + { uri: uri, target: 'tip' }, - success: function(response){ + Ext.bind(function(response){ this.update(response.responseText); - }, - scope: this - }); + }, this) + ); }, tip); }, me); From da7946d4a3ce7b7f7d40311666a5a629ba076cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ro=CC=88wenstrunk?= Date: Wed, 31 May 2023 17:16:29 +0200 Subject: [PATCH 071/107] Language parameter for AJAX calls #186 --- app/controller/AJAXController.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controller/AJAXController.js b/app/controller/AJAXController.js index 580b062b5..4258fc2b1 100644 --- a/app/controller/AJAXController.js +++ b/app/controller/AJAXController.js @@ -43,6 +43,9 @@ Ext.define('EdiromOnline.controller.AJAXController', { var editionId = this.application.activeEdition; params = Ext.applyIf(params, {edition: editionId}); + var lang = window.getLanguage(); + params = Ext.applyIf(params, {lang: lang}); + var override = window.getPreference(url, true); if(override != null) From a05f932e76e17d29655e77e7a4391a98f53641de Mon Sep 17 00:00:00 2001 From: Silke Reich Date: Wed, 31 May 2023 18:07:47 +0200 Subject: [PATCH 072/107] Update getAnnotationPreviews - New license declaration - import modules updated and sorted - output method json - returns application/json --- add/data/xql/getAnnotationPreviews.xql | 649 ++++++++++++++----------- 1 file changed, 353 insertions(+), 296 deletions(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 1d4992018..32e422989 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -1,23 +1,6 @@ xquery version "3.1"; (: - Edirom Online - Copyright (C) 2011 The Edirom Project - http://www.edirom.de - - Edirom Online is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Edirom Online is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Edirom Online. If not, see . - - ID: $Id: getAnnotationPreviews.xql 1455 2012-10-11 10:42:55Z daniel $ +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) (:~ @@ -26,235 +9,267 @@ xquery version "3.1"; @author Daniel Röwenstrunk @author Benjamin W. Bohl :) -import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; -import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; -import module namespace teitext="http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; -import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; - -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; -declare namespace exist="http://exist.sourceforge.net/NS/exist"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace edirom_image="http://www.edirom.de/ns/image"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; -declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; +import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; +import module namespace teitext = "http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare option output:method "text"; -declare option output:media-type "text/plain"; +declare option output:method "json"; +declare option output:media-type "application/json"; declare variable $lang := request:get-parameter('lang', ''); declare variable $imageWidth := 600; - declare variable $edition := request:get-parameter('edition', ''); -declare variable $imageserver := eutil:getPreference('image_server', $edition); -declare variable $imageBasePath := if($imageserver = 'leaflet') - then(eutil:getPreference('leaflet_prefix', $edition)) - else(eutil:getPreference('image_prefix', $edition)); +declare variable $imageserver := eutil:getPreference('image_server', $edition); +declare variable $uri := request:get-parameter('uri', ''); +declare variable $imageBasePath := if ($imageserver = 'leaflet') +then + (eutil:getPreference('leaflet_prefix', $edition)) +else + (eutil:getPreference('image_prefix', $edition)); declare function local:getParticipants($annot as element()) as map(*)* { - - let $participants := tokenize($annot/string(@plist), ' ') - let $docs := distinct-values(for $p in $participants return substring-before($p, '#')) + + let $participants := tokenize($annot/string(@plist), ' ') + let $docs := distinct-values(for $p in $participants + return + substring-before($p, '#')) + return + for $doc in $docs + order by $doc return - for $doc in $docs - order by $doc - return - if(source:isSource($doc)) - then(local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - - else if(teitext:isText($doc)) - then(local:getTextParticipants($participants[starts-with(., $doc)], $doc)) - - else() + if (source:isSource($doc)) + then + (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) + + else + if (teitext:isText($doc)) + then + (local:getTextParticipants($participants[starts-with(., $doc)], $doc)) + + else + () }; declare function local:getTextParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - - for $participant in $participants - let $id := substring-after($participant, '#') - let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) - return map { - 'type': 'text', - 'label': 'Textstelle', - 'mdiv': '', - 'part': '', - 'page': '', - 'source': teitext:getLabel($doc, $edition), - 'siglum': '', - 'digilibBaseParams': '', - 'digilibSizeParams': '', - 'hiddenData': $hiddenData, - 'content': normalize-space(local:getTextNoteContent($doc, $id)), - 'linkUri': $participant + + for $participant in $participants + let $id := substring-after($participant, '#') + let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) + return + map { + 'type': 'text', + 'label': 'Textstelle', + 'mdiv': '', + 'part': '', + 'page': '', + 'source': teitext:getLabel($doc, $edition), + 'siglum': '', + 'digilibBaseParams': '', + 'digilibSizeParams': '', + 'hiddenData': $hiddenData, + 'content': normalize-space(local:getTextNoteContent($doc, $id)), + 'linkUri': $participant } }; declare function local:getTextNoteContent($doc as xs:string, $id as xs:string) as xs:string { - let $elem := doc($doc)/id($id) - let $content := data($elem) - return - if(string-length($content) gt 0) - then($content) - else(local:getTextNotePrecedingContent($elem)) + let $elem := doc($doc)/id($id) + let $content := data($elem) + return + if (string-length($content) gt 0) + then + ($content) + else + (local:getTextNotePrecedingContent($elem)) }; declare function local:getTextNotePrecedingContent($elem as element()) as xs:string { - let $preceding := $elem/preceding-sibling::*[1] - let $content := data($preceding) - return - if(string-length($content) gt 0) - then($content) - else(local:getTextNotePrecedingContent($preceding)) + let $preceding := $elem/preceding-sibling::*[1] + let $content := data($preceding) + return + if (string-length($content) gt 0) + then + ($content) + else + (local:getTextNotePrecedingContent($preceding)) }; declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - - let $combs := local:groupParticipants($participants, $doc) + + let $combs := local:groupParticipants($participants, $doc) + + return - return - - for $comb in distinct-values($combs) - let $partIndices := tokenize($comb,'-') - - let $elems := - for $p in distinct-values($partIndices) - let $relevant.participant := $participants[starts-with(., $doc)][number($p)] - let $element.id := substring-after($relevant.participant,'#') - let $elem := local:getElement($relevant.participant) - (:return if(exists($elem)) then(local-name($elem)) else($relevant.participant):) - where exists($elem) - order by count($elem/preceding::*) - return $elem - - where count($elems) gt 0 - - let $zones := for $elem in $elems return local:getZone($elem) - - let $type := local:getType($zones) - let $label := local:getItemLabel($elems) - - let $mdiv := ''(: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) - let $page := if($zones[1]/parent::mei:surface/@label != '') then($zones[1]/parent::mei:surface/string(@label)) else($zones[1]/parent::mei:surface/string(@n)) - let $sourceLabel := source:getLabel($doc, $edition) - let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() - - let $part := string-join(distinct-values(for $e in $elems return $e/ancestor::mei:part/string(@label)),'-') - - let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] - let $imgWidth := number($graphic/@width) - let $imgHeight := number($graphic/@height) - - let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) - let $rect := local:getBoundingZone($zones) - - let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) - - let $hiddenData := map { - 'width': number($rect/@lrx) - number($rect/@ulx), - 'height': number($rect/@lry) - number($rect/@uly), - 'x': number($rect/@ulx), - 'y': number($rect/@uly), - 'origH': $imgHeight, - 'origW': $imgWidth - } - - let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) - - return map { - 'type': $type, - 'label': $label, - 'mdiv': $mdiv, - 'part': $part, - 'page': $page, - 'source': $sourceLabel, - 'siglum': $siglum, - 'digilibBaseParams': $digilibBaseParams, - 'digilibSizeParams': $digilibSizeParams, - 'hiddenData': $hiddenData, - 'content': '', - 'linkUri': $linkUri - } + for $comb in distinct-values($combs) + let $partIndices := tokenize($comb, '-') + + let $elems := + for $p in distinct-values($partIndices) + let $relevant.participant := $participants[starts-with(., $doc)][number($p)] + let $element.id := substring-after($relevant.participant, '#') + let $elem := local:getElement($relevant.participant) + (:return if(exists($elem)) then(local-name($elem)) else($relevant.participant):) + where exists($elem) + order by count($elem/preceding::*) + return + $elem + + where count($elems) gt 0 + + let $zones := for $elem in $elems + return + local:getZone($elem) + + let $type := local:getType($zones) + let $label := local:getItemLabel($elems) + + let $mdiv := '' (: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) + let $page := if ($zones[1]/parent::mei:surface/@label != '') then + ($zones[1]/parent::mei:surface/string(@label)) + else + ($zones[1]/parent::mei:surface/string(@n)) + let $sourceLabel := source:getLabel($doc, $edition) + let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() + + let $part := string-join(distinct-values(for $e in $elems + return + $e/ancestor::mei:part/string(@label)), '-') + + let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] + let $imgWidth := number($graphic/@width) + let $imgHeight := number($graphic/@height) + + let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) + let $rect := local:getBoundingZone($zones) + + let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) + + let $hiddenData := map { + 'width': number($rect/@lrx) - number($rect/@ulx), + 'height': number($rect/@lry) - number($rect/@uly), + 'x': number($rect/@ulx), + 'y': number($rect/@uly), + 'origH': $imgHeight, + 'origW': $imgWidth + } + + let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) + + return + map { + 'type': $type, + 'label': $label, + 'mdiv': $mdiv, + 'part': $part, + 'page': $page, + 'source': $sourceLabel, + 'siglum': $siglum, + 'digilibBaseParams': $digilibBaseParams, + 'digilibSizeParams': $digilibSizeParams, + 'hiddenData': $hiddenData, + 'content': '', + 'linkUri': $linkUri + } }; declare function local:getSourceLinkTarget($elems as node()*, $zones as node()*) as xs:string { - if(local-name($elems[1]) eq 'zone') - then($elems[1]/string(@xml:id)) - else if(count($elems) > 1) - then( - let $elemsSorted := for $elem in $elems - order by count($elem/preceding::*) - return $elem - return concat($elemsSorted[1]/@xml:id, '?tstamp2=', (count($elems) -1), 'm+0') - ) - else($elems[1]/string(@xml:id)) - + if (local-name($elems[1]) eq 'zone') + then + ($elems[1]/string(@xml:id)) + else + if (count($elems) > 1) + then + ( + let $elemsSorted := for $elem in $elems + order by count($elem/preceding::*) + return + $elem + return + concat($elemsSorted[1]/@xml:id, '?tstamp2=', (count($elems) - 1), 'm+0') + ) + else + ($elems[1]/string(@xml:id)) + }; declare function local:groupParticipants($participants as xs:string*, $doc as xs:string) as xs:string* { - - let $elems := for $p in $participants - let $id := substring-after($p, '#') - return doc($doc)/id($id) - - let $zones := for $elem in $elems - return local:getZone($elem) - - let $combs := for $p at $i in $participants - return - local:getCombinations($elems, $zones, $i, count($zones)) - + + let $elems := for $p in $participants + let $id := substring-after($p, '#') + return + doc($doc)/id($id) + + let $zones := for $elem in $elems + return + local:getZone($elem) + + let $combs := for $p at $i in $participants + return + local:getCombinations($elems, $zones, $i, count($zones)) + + return + reverse( + for $comb at $i in reverse($combs) + let $contained := for $n in (1 to count($combs) - $i) return - reverse( - for $comb at $i in reverse($combs) - let $contained := for $n in (1 to count($combs) - $i) - return - if(contains($combs[$n], $comb)) - then(1) - else(0) - return - if(exists(index-of($contained, 1))) - then() - else($comb) - ) + if (contains($combs[$n], $comb)) + then + (1) + else + (0) + return + if (exists(index-of($contained, 1))) + then + () + else + ($comb) + ) }; declare function local:getCombinations($elems as element()*, $zones as element()*, $i as xs:int, $total as xs:int) as xs:string { - - let $currentZone := $zones[$i] - let $currentElem := $elems[$i] - return - if(local-name($currentElem) eq 'measure' or local-name($currentElem) eq 'staff') - then( - string-join(( - string($i), - for $n in ($i + 1 to $total) - return - if((local-name($elems[$n]) eq 'measure' or local-name($elems[$n]) eq 'staff') and local:compareZones($currentZone, $zones[$n])) - then(local:getCombinations($elems, $zones, $n, $total)) - else() - ),'-') - ) - else( - string($i) - ) + + let $currentZone := $zones[$i] + let $currentElem := $elems[$i] + return + if (local-name($currentElem) eq 'measure' or local-name($currentElem) eq 'staff') + then + ( + string-join(( + string($i), + for $n in ($i + 1 to $total) + return + if ((local-name($elems[$n]) eq 'measure' or local-name($elems[$n]) eq 'staff') and local:compareZones($currentZone, $zones[$n])) + then + (local:getCombinations($elems, $zones, $n, $total)) + else + () + ), '-') + ) + else + ( + string($i) + ) }; declare function local:compareZones($zone1 as element(), $zone2 as element()) as xs:boolean { - - let $samePage := deep-equal($zone1/.., $zone2/..) - let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) - return - $samePage and $overlapping + + let $samePage := deep-equal($zone1/.., $zone2/..) + let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) + return + $samePage and $overlapping }; declare function local:getElement($uri as xs:string) as element()? { - let $doc := substring-before($uri, '#') - let $id := substring-after($uri, '#') - - return doc($doc)/id($id) + let $doc := substring-before($uri, '#') + let $id := substring-after($uri, '#') + + return + doc($doc)/id($id) }; (: TODO: in Modul auslagern :) @@ -266,22 +281,32 @@ declare function local:getElement($uri as xs:string) as element()? { @return The zone element :) declare function local:getZone($elem as element()) as element()? { - if($elem/@facs) - then( - let $zoneId := replace($elem/@facs, '^#', '') - return $elem/root()/id($zoneId) + if ($elem/@facs) + then + ( + let $zoneId := replace($elem/@facs, '^#', '') + return + $elem/root()/id($zoneId) ) - else( - $elem + else + ( + $elem ) }; +(:~ + : Returns type of a zone + :) declare function local:getType($zones as element()*) as xs:string { - $zones[1]/@type (: TODO: besser machen :) + $zones[1]/@type (: TODO: besser machen :) }; declare function local:getBoundingZone($zones as element()*) as element() { - + }; (: TODO: in Modul auslagern :) @@ -289,23 +314,32 @@ declare function local:getBoundingZone($zones as element()*) as element() { :) declare function local:getImageAreaPath($basePath as xs:string, $graphic as element()?) as xs:string { - - let $imagePath := string($graphic/@target) - let $imgWidth := number($graphic/@width) - let $imgHeight := number($graphic/@height) - let $isAbsolute := starts-with($imagePath, 'http') - - let $fields := if($imageserver = 'leaflet')then(substring-before($imagePath, '.') )else() - - return - if ($isAbsolute) - then $imagePath - else - switch ($imageserver) - case 'leaflet' return concat($basePath,$fields) - case 'openseadragon' return concat($basePath,translate($imagePath, '/', '!')) - default return concat($basePath, $imagePath, '?') - + + let $imagePath := string($graphic/@target) + let $imgWidth := number($graphic/@width) + let $imgHeight := number($graphic/@height) + let $isAbsolute := starts-with($imagePath, 'http') + + let $fields := if ($imageserver = 'leaflet') then + (substring-before($imagePath, '.')) + else + () + + return + if ($isAbsolute) + then + $imagePath + else + switch ($imageserver) + case 'leaflet' + return + concat($basePath, $fields) + case 'openseadragon' + return + concat($basePath, translate($imagePath, '/', '!')) + default return + concat($basePath, $imagePath, '?') + }; (: TODO: in Modul auslagern :) @@ -320,83 +354,106 @@ declare function local:getImageAreaPath($basePath as xs:string, $graphic as elem @return A URL pointing to an image based as xs:string :) declare function local:getImageAreaParams($zone as element()?, $imgWidth as xs:int, $imgHeight as xs:int) as xs:string { - let $graphic := $zone/../mei:graphic[@type = 'facsimile'] - - let $imgX := number($zone/@ulx) - let $imgY := number($zone/@uly) - let $w := number($zone/@lrx) - number($zone/@ulx) - let $h := number($zone/@lry) - number($zone/@uly) - - let $wx := $imgX div $imgWidth - let $wy := $imgY div $imgHeight - let $ww := $w div $imgWidth - let $wh := $h div $imgHeight - - return - concat('&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;mo=fit') + let $graphic := $zone/../mei:graphic[@type = 'facsimile'] + + let $imgX := number($zone/@ulx) + let $imgY := number($zone/@uly) + let $w := number($zone/@lrx) - number($zone/@ulx) + let $h := number($zone/@lry) - number($zone/@uly) + + let $wx := $imgX div $imgWidth + let $wy := $imgY div $imgHeight + let $ww := $w div $imgWidth + let $wh := $h div $imgHeight + + return + concat('&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;mo=fit') }; declare function local:getItemLabel($elems as element()*) as xs:string { - let $language := eutil:getLanguage($edition) - return + let $language := eutil:getLanguage($edition) + return string-join( - for $type in distinct-values(for $elem in $elems return local-name($elem)) - let $items := for $elem in $elems return if(local-name($elem) eq $type) then($elem) else() - let $itemLabelMultiRestSensitive := if($items[1]//mei:multiRest) - then ($items[1]/@n || '–' || number($items[1]/@n) + number($items[1]//mei:multiRest/@num) - 1) - else ($items[1]/@n) - return - if(local-name($items[1]) eq 'measure') - then( - if(count($items) gt 1) - then(eutil:getLanguageString('Bars_from_to', ($items[1]/@n, $items[last()]/@n), $language)) - else(eutil:getLanguageString('Bar_n', $itemLabelMultiRestSensitive, $language)) - ) - else if(local-name($items[1]) eq 'staff') - (: TODO: $itemLabelMultiRestSensitive also for staffs? :) - then( - if(count($items) gt 1) - then( - - let $measureNs := distinct-values($items/ancestor::mei:measure/@n) - - let $label := if ($lang = 'de') - then (if(count($measureNs) gt 1) then (concat('Takte ',$measureNs[1], '-', $measureNs[last()])) else (concat('Takt ', $measureNs[1]))) - else (if(count($measureNs) gt 1) then (concat('Bars ',$measureNs[1], '-', $measureNs[last()])) else (concat('Bar ', $measureNs[1]))) - - return - - concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr,', '),')') - - ) - else(concat('Takt ',$items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr,')')) + for $type in distinct-values(for $elem in $elems + return + local-name($elem)) + let $items := for $elem in $elems + return + if (local-name($elem) eq $type) then + ($elem) + else + () + let $itemLabelMultiRestSensitive := if ($items[1]//mei:multiRest) + then + ($items[1]/@n || '–' || number($items[1]/@n) + number($items[1]//mei:multiRest/@num) - 1) + else + ($items[1]/@n) + return + if (local-name($items[1]) eq 'measure') + then + ( + if (count($items) gt 1) + then + (eutil:getLanguageString('Bars_from_to', ($items[1]/@n, $items[last()]/@n), $language)) + else + (eutil:getLanguageString('Bar_n', $itemLabelMultiRestSensitive, $language)) + ) + else + if (local-name($items[1]) eq 'staff') + (: TODO: $itemLabelMultiRestSensitive also for staffs? :) + then + ( + if (count($items) gt 1) + then + ( + + let $measureNs := distinct-values($items/ancestor::mei:measure/@n) + + let $label := if ($lang = 'de') + then + (if (count($measureNs) gt 1) then + (concat('Takte ', $measureNs[1], '-', $measureNs[last()])) + else + (concat('Takt ', $measureNs[1]))) + else + (if (count($measureNs) gt 1) then + (concat('Bars ', $measureNs[1], '-', $measureNs[last()])) + else + (concat('Bar ', $measureNs[1]))) + + return + + concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ', '), ')') + ) - else if(local-name($items[1]) eq 'zone') - then( - if(count($items) gt 1) - then((:Dieser Fall sollte nicht vorkommen, da freie zones nicht zusammengefasst werden dürfen:)) - else(concat('Ausschnitt (S. ',$items[1]/parent::mei:surface/@n,')')) + else + (concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')')) + ) + else + if (local-name($items[1]) eq 'zone') + then + ( + if (count($items) gt 1) + then + ((:Dieser Fall sollte nicht vorkommen, da freie zones nicht zusammengefasst werden dürfen:) ) + else + (concat('Ausschnitt (S. ', $items[1]/parent::mei:surface/@n, ')')) ) - else() - ,' ') - + else + () + , ' ') + }; -let $uri := request:get-parameter('uri', '') let $docUri := substring-before($uri, '#') let $internalId := substring-after($uri, '#') let $doc := doc($docUri) let $annot := $doc/id($internalId) let $map := map { - 'success': true(), - 'participants': array { local:getParticipants($annot)} + 'success': true(), + 'participants': array {local:getParticipants($annot)} } -let $options := - map { - 'method': 'json', - 'media-type': 'text/plain' - } - -return serialize($map, $options) +return + $map From 3ae3adfbef05cb9c06e5be1098a9ed11ce0cf8cf Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 18:23:21 +0200 Subject: [PATCH 073/107] add functx 1.0 as package-dependency * add to expath-pkg.xml * remove uri from xquery import module statements * remove functx library from add/data/xqm --- add/data/xql/getAnnotationPreviews.xql | 2 +- add/data/xql/getAnnotationsInRendering.xql | 2 +- add/data/xql/getAnnotationsOnPage.xql | 2 +- add/data/xql/getInternalIdType.xql | 2 +- add/data/xql/getMeasure.xql | 2 +- add/data/xqm/functx-1.0-nodoc-2007-01.xq | 1410 -------------------- add/data/xqm/util.xqm | 2 +- add/expath-pkg.xml | 1 + 8 files changed, 7 insertions(+), 1416 deletions(-) delete mode 100644 add/data/xqm/functx-1.0-nodoc-2007-01.xq diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 1d4992018..2c59bd3b8 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -32,7 +32,7 @@ import module namespace teitext="http://www.edirom.de/xquery/teitext" at "../xqm import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; declare namespace exist="http://exist.sourceforge.net/NS/exist"; declare namespace request="http://exist-db.org/xquery/request"; diff --git a/add/data/xql/getAnnotationsInRendering.xql b/add/data/xql/getAnnotationsInRendering.xql index 75d9127af..78d744e85 100644 --- a/add/data/xql/getAnnotationsInRendering.xql +++ b/add/data/xql/getAnnotationsInRendering.xql @@ -26,7 +26,7 @@ xquery version "3.0"; @author Daniel Röwenstrunk :) -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; diff --git a/add/data/xql/getAnnotationsOnPage.xql b/add/data/xql/getAnnotationsOnPage.xql index 18a4c2fe5..0dbba5837 100644 --- a/add/data/xql/getAnnotationsOnPage.xql +++ b/add/data/xql/getAnnotationsOnPage.xql @@ -27,7 +27,7 @@ xquery version "3.1"; : @author Benjamin W. Bohl :) -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; diff --git a/add/data/xql/getInternalIdType.xql b/add/data/xql/getInternalIdType.xql index 64d185c0c..43cd7314b 100644 --- a/add/data/xql/getInternalIdType.xql +++ b/add/data/xql/getInternalIdType.xql @@ -23,7 +23,7 @@ xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace mei="http://www.music-encoding.org/ns/mei"; -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; diff --git a/add/data/xql/getMeasure.xql b/add/data/xql/getMeasure.xql index ffca1c8e6..99e592b6f 100644 --- a/add/data/xql/getMeasure.xql +++ b/add/data/xql/getMeasure.xql @@ -26,7 +26,7 @@ declare namespace xlink="http://www.w3.org/1999/xlink"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; diff --git a/add/data/xqm/functx-1.0-nodoc-2007-01.xq b/add/data/xqm/functx-1.0-nodoc-2007-01.xq deleted file mode 100644 index dd8ca2a68..000000000 --- a/add/data/xqm/functx-1.0-nodoc-2007-01.xq +++ /dev/null @@ -1,1410 +0,0 @@ - -(:~ - - : -------------------------------- - : The FunctX XQuery Function Library - : -------------------------------- - - : Copyright (C) 2007 Datypic - - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public - : License as published by the Free Software Foundation; either - : version 2.1 of the License. - - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - : Lesser General Public License for more details. - - : You should have received a copy of the GNU Lesser General Public - : License along with this library; if not, write to the Free Software - : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - : For more information on the FunctX XQuery library, contact contrib@functx.com. - - : @version 1.0 - : @see http://www.xqueryfunctions.com - :) -module namespace functx = "http://www.functx.com" ; - -declare function functx:add-attributes - ( $elements as element()* , - $attrNames as xs:QName* , - $attrValues as xs:anyAtomicType* ) as element()? { - - for $element in $elements - return element { node-name($element)} - { for $attrName at $seq in $attrNames - return if ($element/@*[node-name(.) = $attrName]) - then () - else attribute {$attrName} - {$attrValues[$seq]}, - $element/@*, - $element/node() } - } ; - -declare function functx:add-months - ( $date as xs:anyAtomicType? , - $months as xs:integer ) as xs:date? { - - xs:date($date) + functx:yearMonthDuration(0,$months) - } ; - -declare function functx:add-or-update-attributes - ( $elements as element()* , - $attrNames as xs:QName* , - $attrValues as xs:anyAtomicType* ) as element()? { - - for $element in $elements - return element { node-name($element)} - { for $attrName at $seq in $attrNames - return attribute {$attrName} - {$attrValues[$seq]}, - $element/@*[not(node-name(.) = $attrNames)], - $element/node() } - } ; - -declare function functx:all-whitespace - ( $arg as xs:string? ) as xs:boolean { - - normalize-space($arg) = '' - } ; - -declare function functx:are-distinct-values - ( $seq as xs:anyAtomicType* ) as xs:boolean { - - count(distinct-values($seq)) = count($seq) - } ; - -declare function functx:atomic-type - ( $values as xs:anyAtomicType* ) as xs:string* { - - for $val in $values - return - (if ($val instance of xs:untypedAtomic) then 'xs:untypedAtomic' - else if ($val instance of xs:anyURI) then 'xs:anyURI' - else if ($val instance of xs:ENTITY) then 'xs:ENTITY' - else if ($val instance of xs:ID) then 'xs:ID' - else if ($val instance of xs:NMTOKEN) then 'xs:NMTOKEN' - else if ($val instance of xs:language) then 'xs:language' - else if ($val instance of xs:NCName) then 'xs:NCName' - else if ($val instance of xs:Name) then 'xs:Name' - else if ($val instance of xs:token) then 'xs:token' - else if ($val instance of xs:normalizedString) - then 'xs:normalizedString' - else if ($val instance of xs:string) then 'xs:string' - else if ($val instance of xs:QName) then 'xs:QName' - else if ($val instance of xs:boolean) then 'xs:boolean' - else if ($val instance of xs:base64Binary) then 'xs:base64Binary' - else if ($val instance of xs:hexBinary) then 'xs:hexBinary' - else if ($val instance of xs:byte) then 'xs:byte' - else if ($val instance of xs:short) then 'xs:short' - else if ($val instance of xs:int) then 'xs:int' - else if ($val instance of xs:long) then 'xs:long' - else if ($val instance of xs:unsignedByte) then 'xs:unsignedByte' - else if ($val instance of xs:unsignedShort) then 'xs:unsignedShort' - else if ($val instance of xs:unsignedInt) then 'xs:unsignedInt' - else if ($val instance of xs:unsignedLong) then 'xs:unsignedLong' - else if ($val instance of xs:positiveInteger) - then 'xs:positiveInteger' - else if ($val instance of xs:nonNegativeInteger) - then 'xs:nonNegativeInteger' - else if ($val instance of xs:negativeInteger) - then 'xs:negativeInteger' - else if ($val instance of xs:nonPositiveInteger) - then 'xs:nonPositiveInteger' - else if ($val instance of xs:integer) then 'xs:integer' - else if ($val instance of xs:decimal) then 'xs:decimal' - else if ($val instance of xs:float) then 'xs:float' - else if ($val instance of xs:double) then 'xs:double' - else if ($val instance of xs:date) then 'xs:date' - else if ($val instance of xs:time) then 'xs:time' - else if ($val instance of xs:dateTime) then 'xs:dateTime' - else if ($val instance of xs:dayTimeDuration) - then 'xs:dayTimeDuration' - else if ($val instance of xs:yearMonthDuration) - then 'xs:yearMonthDuration' - else if ($val instance of xs:duration) then 'xs:duration' - else if ($val instance of xs:gMonth) then 'xs:gMonth' - else if ($val instance of xs:gYear) then 'xs:gYear' - else if ($val instance of xs:gYearMonth) then 'xs:gYearMonth' - else if ($val instance of xs:gDay) then 'xs:gDay' - else if ($val instance of xs:gMonthDay) then 'xs:gMonthDay' - else 'unknown') - } ; - -declare function functx:avg-empty-is-zero - ( $values as xs:anyAtomicType* , - $allNodes as node()* ) as xs:double { - - if (empty($allNodes)) - then 0 - else sum($values[string(.) != '']) div count($allNodes) - } ; - -declare function functx:between-exclusive - ( $value as xs:anyAtomicType? , - $minValue as xs:anyAtomicType , - $maxValue as xs:anyAtomicType ) as xs:boolean { - - $value > $minValue and $value < $maxValue - } ; - -declare function functx:between-inclusive - ( $value as xs:anyAtomicType? , - $minValue as xs:anyAtomicType , - $maxValue as xs:anyAtomicType ) as xs:boolean { - - $value >= $minValue and $value <= $maxValue - } ; - -declare function functx:camel-case-to-words - ( $arg as xs:string? , - $delim as xs:string ) as xs:string { - - concat(substring($arg,1,1), - replace(substring($arg,2),'(\p{Lu})', - concat($delim, '$1'))) - } ; - -declare function functx:capitalize-first - ( $arg as xs:string? ) as xs:string? { - - concat(upper-case(substring($arg,1,1)), - substring($arg,2)) - } ; - -declare function functx:change-element-names-deep - ( $nodes as node()* , - $oldNames as xs:QName* , - $newNames as xs:QName* ) as node()* { - - if (count($oldNames) != count($newNames)) - then error(xs:QName('functx:Different_number_of_names')) - else - for $node in $nodes - return if ($node instance of element()) - then element - {functx:if-empty - ($newNames[index-of($oldNames, - node-name($node))], - node-name($node)) } - {$node/@*, - functx:change-element-names-deep($node/node(), - $oldNames, $newNames)} - else if ($node instance of document-node()) - then functx:change-element-names-deep($node/node(), - $oldNames, $newNames) - else $node - } ; - -declare function functx:change-element-ns-deep - ( $nodes as node()* , - $newns as xs:string , - $prefix as xs:string ) as node()* { - - for $node in $nodes - return if ($node instance of element()) - then (element - {QName ($newns, - concat($prefix, - if ($prefix = '') - then '' - else ':', - local-name($node)))} - {$node/@*, - functx:change-element-ns-deep($node/node(), - $newns, $prefix)}) - else if ($node instance of document-node()) - then functx:change-element-ns-deep($node/node(), - $newns, $prefix) - else $node - } ; - -declare function functx:change-element-ns - ( $elements as element()* , - $newns as xs:string , - $prefix as xs:string ) as element()? { - - for $element in $elements - return - element {QName ($newns, - concat($prefix, - if ($prefix = '') - then '' - else ':', - local-name($element)))} - {$element/@*, $element/node()} - } ; - -declare function functx:chars - ( $arg as xs:string? ) as xs:string* { - - for $ch in string-to-codepoints($arg) - return codepoints-to-string($ch) - } ; - -declare function functx:contains-any-of - ( $arg as xs:string? , - $searchStrings as xs:string* ) as xs:boolean { - - some $searchString in $searchStrings - satisfies contains($arg,$searchString) - } ; - -declare function functx:contains-case-insensitive - ( $arg as xs:string? , - $substring as xs:string ) as xs:boolean? { - - contains(upper-case($arg), upper-case($substring)) - } ; - -declare function functx:contains-word - ( $arg as xs:string? , - $word as xs:string ) as xs:boolean { - - matches(upper-case($arg), - concat('^(.*\W)?', - upper-case(functx:escape-for-regex($word)), - '(\W.*)?$')) - } ; - -declare function functx:copy-attributes - ( $copyTo as element() , - $copyFrom as element() ) as element() { - - element { node-name($copyTo)} - { $copyTo/@*[not(node-name(.) = $copyFrom/@*/node-name(.))], - $copyFrom/@*, - $copyTo/node() } - - } ; - -declare function functx:date - ( $year as xs:anyAtomicType , - $month as xs:anyAtomicType , - $day as xs:anyAtomicType ) as xs:date { - - xs:date( - concat( - functx:pad-integer-to-length(xs:integer($year),4),'-', - functx:pad-integer-to-length(xs:integer($month),2),'-', - functx:pad-integer-to-length(xs:integer($day),2))) - } ; - -declare function functx:dateTime - ( $year as xs:anyAtomicType , - $month as xs:anyAtomicType , - $day as xs:anyAtomicType , - $hour as xs:anyAtomicType , - $minute as xs:anyAtomicType , - $second as xs:anyAtomicType ) as xs:dateTime { - - xs:dateTime( - concat(functx:date($year,$month,$day),'T', - functx:time($hour,$minute,$second))) - } ; - -declare function functx:day-in-year - ( $date as xs:anyAtomicType? ) as xs:integer? { - - days-from-duration( - xs:date($date) - functx:first-day-of-year($date)) + 1 - } ; - -declare function functx:day-of-week-abbrev-en - ( $date as xs:anyAtomicType? ) as xs:string? { - - ('Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat') - [functx:day-of-week($date) + 1] - } ; - -declare function functx:day-of-week-name-en - ( $date as xs:anyAtomicType? ) as xs:string? { - - ('Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thursday', 'Friday', 'Saturday') - [functx:day-of-week($date) + 1] - } ; - -declare function functx:day-of-week - ( $date as xs:anyAtomicType? ) as xs:integer? { - - if (empty($date)) - then () - else xs:integer((xs:date($date) - xs:date('1901-01-06')) - div xs:dayTimeDuration('P1D')) mod 7 - } ; - -declare function functx:dayTimeDuration - ( $days as xs:decimal? , - $hours as xs:decimal? , - $minutes as xs:decimal? , - $seconds as xs:decimal? ) as xs:dayTimeDuration { - - (xs:dayTimeDuration('P1D') * functx:if-empty($days,0)) + - (xs:dayTimeDuration('PT1H') * functx:if-empty($hours,0)) + - (xs:dayTimeDuration('PT1M') * functx:if-empty($minutes,0)) + - (xs:dayTimeDuration('PT1S') * functx:if-empty($seconds,0)) - } ; - -declare function functx:days-in-month - ( $date as xs:anyAtomicType? ) as xs:integer? { - - if (month-from-date(xs:date($date)) = 2 and - functx:is-leap-year($date)) - then 29 - else - (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) - [month-from-date(xs:date($date))] - } ; - -declare function functx:depth-of-node - ( $node as node()? ) as xs:integer { - - count($node/ancestor-or-self::node()) - } ; - -declare function functx:distinct-attribute-names - ( $nodes as node()* ) as xs:string* { - - distinct-values($nodes//@*/name(.)) - } ; - -declare function functx:distinct-deep - ( $nodes as node()* ) as node()* { - - for $seq in (1 to count($nodes)) - return $nodes[$seq][not(functx:is-node-in-sequence-deep-equal( - .,$nodes[position() < $seq]))] - } ; - -declare function functx:distinct-element-names - ( $nodes as node()* ) as xs:string* { - - distinct-values($nodes/descendant-or-self::*/name(.)) - } ; - -declare function functx:distinct-element-paths - ( $nodes as node()* ) as xs:string* { - - distinct-values(functx:path-to-node($nodes/descendant-or-self::*)) - } ; - -declare function functx:distinct-nodes - ( $nodes as node()* ) as node()* { - - for $seq in (1 to count($nodes)) - return $nodes[$seq][not(functx:is-node-in-sequence( - .,$nodes[position() < $seq]))] - } ; - -declare function functx:duration-from-timezone - ( $timezone as xs:string ) as xs:dayTimeDuration { - - xs:dayTimeDuration( - if (not(matches($timezone,'Z|[\+\-]\d{2}:\d{2}'))) - then error(xs:QName('functx:Invalid_Timezone_Value')) - else if ($timezone = 'Z') - then 'PT0S' - else replace($timezone,'\+?(\d{2}):\d{2}','PT$1H') - ) - } ; - -declare function functx:dynamic-path - ( $parent as node() , - $path as xs:string ) as item()* { - - let $nextStep := functx:substring-before-if-contains($path,'/') - let $restOfSteps := substring-after($path,'/') - for $child in - ($parent/*[functx:name-test(name(),$nextStep)], - $parent/@*[functx:name-test(name(), - substring-after($nextStep,'@'))]) - return if ($restOfSteps) - then functx:dynamic-path($child, $restOfSteps) - else $child - } ; - -declare function functx:escape-for-regex - ( $arg as xs:string? ) as xs:string { - - replace($arg, - '(\.|\[|\]|\\|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1') - } ; - -declare function functx:exclusive-or - ( $arg1 as xs:boolean? , - $arg2 as xs:boolean? ) as xs:boolean? { - - $arg1 != $arg2 - } ; - -declare function functx:first-day-of-month - ( $date as xs:anyAtomicType? ) as xs:date? { - - functx:date(year-from-date(xs:date($date)), - month-from-date(xs:date($date)), - 1) - } ; - -declare function functx:first-day-of-year - ( $date as xs:anyAtomicType? ) as xs:date? { - - functx:date(year-from-date(xs:date($date)), 1, 1) - } ; - -declare function functx:first-node - ( $nodes as node()* ) as node()? { - - ($nodes/.)[1] - } ; - -declare function functx:follows-not-descendant - ( $a as node()? , - $b as node()? ) as xs:boolean { - - $a >> $b and empty($b intersect $a/ancestor::node()) - } ; - -declare function functx:format-as-title-en - ( $titles as xs:string* ) as xs:string* { - - let $wordsToMoveToEnd := ('A', 'An', 'The') - for $title in $titles - let $firstWord := functx:substring-before-match($title,'\W') - return if ($firstWord = $wordsToMoveToEnd) - then replace($title,'(.*?)\W(.*)', '$2, $1') - else $title - } ; - -declare function functx:fragment-from-uri - ( $uri as xs:string? ) as xs:string? { - - substring-after($uri,'#') - } ; - -declare function functx:get-matches-and-non-matches - ( $string as xs:string? , - $regex as xs:string ) as element()* { - - let $iomf := functx:index-of-match-first($string, $regex) - return - if (empty($iomf)) - then {$string} - else - if ($iomf > 1) - then ({substring($string,1,$iomf - 1)}, - functx:get-matches-and-non-matches( - substring($string,$iomf),$regex)) - else - let $length := - string-length($string) - - string-length(functx:replace-first($string, $regex,'')) - return ({substring($string,1,$length)}, - if (string-length($string) > $length) - then functx:get-matches-and-non-matches( - substring($string,$length + 1),$regex) - else ()) - } ; - -declare function functx:get-matches - ( $string as xs:string? , - $regex as xs:string ) as xs:string* { - - functx:get-matches-and-non-matches($string,$regex)/ - string(self::match) - } ; - -declare function functx:has-element-only-content - ( $element as element() ) as xs:boolean { - - not($element/text()[normalize-space(.) != '']) and $element/* - } ; - -declare function functx:has-empty-content - ( $element as element() ) as xs:boolean { - - not($element/node()) - } ; - -declare function functx:has-mixed-content - ( $element as element() ) as xs:boolean { - - $element/text()[normalize-space(.) != ''] and $element/* - } ; - -declare function functx:has-simple-content - ( $element as element() ) as xs:boolean { - - $element/text() and not($element/*) - } ; - -declare function functx:id-from-element - ( $element as element()? ) as xs:string? { - - data(($element/@*[id(.) is ..])[1]) - } ; - -declare function functx:id-untyped - ( $node as node()* , - $id as xs:anyAtomicType ) as element()* { - - $node//*[@* = $id] - } ; - -declare function functx:if-absent - ( $arg as item()* , - $value as item()* ) as item()* { - - if (exists($arg)) - then $arg - else $value - } ; - -declare function functx:if-empty - ( $arg as item()? , - $value as item()* ) as item()* { - - if (string($arg) != '') - then data($arg) - else $value - } ; - -declare function functx:index-of-deep-equal-node - ( $nodes as node()* , - $nodeToFind as node() ) as xs:integer* { - - for $seq in (1 to count($nodes)) - return $seq[deep-equal($nodes[$seq],$nodeToFind)] - } ; - -declare function functx:index-of-match-first - ( $arg as xs:string? , - $pattern as xs:string ) as xs:integer? { - - if (matches($arg,$pattern)) - then string-length(tokenize($arg, $pattern)[1]) + 1 - else () - } ; - -declare function functx:index-of-node - ( $nodes as node()* , - $nodeToFind as node() ) as xs:integer* { - - for $seq in (1 to count($nodes)) - return $seq[$nodes[$seq] is $nodeToFind] - } ; - -declare function functx:index-of-string-first - ( $arg as xs:string? , - $substring as xs:string ) as xs:integer? { - - if (contains($arg, $substring)) - then string-length(substring-before($arg, $substring))+1 - else () - } ; - -declare function functx:index-of-string-last - ( $arg as xs:string? , - $substring as xs:string ) as xs:integer? { - - functx:index-of-string($arg, $substring)[last()] - } ; - -declare function functx:index-of-string - ( $arg as xs:string? , - $substring as xs:string ) as xs:integer* { - - if (contains($arg, $substring)) - then (string-length(substring-before($arg, $substring))+1, - for $other in - functx:index-of-string(substring-after($arg, $substring), - $substring) - return - $other + - string-length(substring-before($arg, $substring)) + - string-length($substring)) - else () - } ; - -declare function functx:insert-string - ( $originalString as xs:string? , - $stringToInsert as xs:string? , - $pos as xs:integer ) as xs:string { - - concat(substring($originalString,1,$pos - 1), - $stringToInsert, - substring($originalString,$pos)) - } ; - -declare function functx:is-a-number - ( $value as xs:anyAtomicType? ) as xs:boolean { - - string(number($value)) != 'NaN' - } ; - -declare function functx:is-absolute-uri - ( $uri as xs:string? ) as xs:boolean { - - matches($uri,'^[a-z]+:') - } ; - -declare function functx:is-ancestor - ( $node1 as node() , - $node2 as node() ) as xs:boolean { - - exists($node1 intersect $node2/ancestor::node()) - } ; - -declare function functx:is-descendant - ( $node1 as node() , - $node2 as node() ) as xs:boolean { - - boolean($node2 intersect $node1/ancestor::node()) - } ; - -declare function functx:is-leap-year - ( $date as xs:anyAtomicType? ) as xs:boolean { - - for $year in xs:integer(substring(string($date),1,4)) - return ($year mod 4 = 0 and - $year mod 100 != 0) or - $year mod 400 = 0 - } ; - -declare function functx:is-node-among-descendants-deep-equal - ( $node as node()? , - $seq as node()* ) as xs:boolean { - - some $nodeInSeq in $seq/descendant-or-self::*/(.|@*) - satisfies deep-equal($nodeInSeq,$node) - } ; - -declare function functx:is-node-among-descendants - ( $node as node()? , - $seq as node()* ) as xs:boolean { - - some $nodeInSeq in $seq/descendant-or-self::*/(.|@*) - satisfies $nodeInSeq is $node - } ; - -declare function functx:is-node-in-sequence-deep-equal - ( $node as node()? , - $seq as node()* ) as xs:boolean { - - some $nodeInSeq in $seq satisfies deep-equal($nodeInSeq,$node) - } ; - -declare function functx:is-node-in-sequence - ( $node as node()? , - $seq as node()* ) as xs:boolean { - - some $nodeInSeq in $seq satisfies $nodeInSeq is $node - } ; - -declare function functx:is-value-in-sequence - ( $value as xs:anyAtomicType? , - $seq as xs:anyAtomicType* ) as xs:boolean { - - $value = $seq - } ; - -declare function functx:last-day-of-month - ( $date as xs:anyAtomicType? ) as xs:date? { - - functx:date(year-from-date(xs:date($date)), - month-from-date(xs:date($date)), - functx:days-in-month($date)) - } ; - -declare function functx:last-day-of-year - ( $date as xs:anyAtomicType? ) as xs:date? { - - functx:date(year-from-date(xs:date($date)), 12, 31) - } ; - -declare function functx:last-node - ( $nodes as node()* ) as node()? { - - ($nodes/.)[last()] - } ; - -declare function functx:leaf-elements - ( $root as node()? ) as element()* { - - $root/descendant-or-self::*[not(*)] - } ; - -declare function functx:left-trim - ( $arg as xs:string? ) as xs:string { - - replace($arg,'^\s+','') - } ; - -declare function functx:line-count - ( $arg as xs:string? ) as xs:integer { - - count(functx:lines($arg)) - } ; - -declare function functx:lines - ( $arg as xs:string? ) as xs:string* { - - tokenize($arg, '(\r\n?|\n\r?)') - } ; - -declare function functx:max-depth - ( $root as node()? ) as xs:integer? { - - if ($root/*) - then max($root/*/functx:max-depth(.)) + 1 - else 1 - } ; - -declare function functx:max-determine-type - ( $seq as xs:anyAtomicType* ) as xs:anyAtomicType? { - - if (every $value in $seq satisfies ($value castable as xs:double)) - then max(for $value in $seq return xs:double($value)) - else max(for $value in $seq return xs:string($value)) - } ; - -declare function functx:max-line-length - ( $arg as xs:string? ) as xs:integer { - - max( - for $line in functx:lines($arg) - return string-length($line)) - } ; - -declare function functx:max-node - ( $nodes as node()* ) as node()* { - - $nodes[. = max($nodes)] - } ; - -declare function functx:max-string - ( $strings as xs:anyAtomicType* ) as xs:string? { - - max(for $string in $strings return string($string)) - } ; - -declare function functx:min-determine-type - ( $seq as xs:anyAtomicType* ) as xs:anyAtomicType? { - - if (every $value in $seq satisfies ($value castable as xs:double)) - then min(for $value in $seq return xs:double($value)) - else min(for $value in $seq return xs:string($value)) - } ; - -declare function functx:min-node - ( $nodes as node()* ) as node()* { - - $nodes[. = min($nodes)] - } ; - -declare function functx:min-non-empty-string - ( $strings as xs:string* ) as xs:string? { - - min($strings[. != '']) - } ; - -declare function functx:min-string - ( $strings as xs:anyAtomicType* ) as xs:string? { - - min(for $string in $strings return string($string)) - } ; - -declare function functx:mmddyyyy-to-date - ( $dateString as xs:string? ) as xs:date? { - - if (empty($dateString)) - then () - else if (not(matches($dateString, - '^\D*(\d{2})\D*(\d{2})\D*(\d{4})\D*$'))) - then error(xs:QName('functx:Invalid_Date_Format')) - else xs:date(replace($dateString, - '^\D*(\d{2})\D*(\d{2})\D*(\d{4})\D*$', - '$3-$1-$2')) - } ; - -declare function functx:month-abbrev-en - ( $date as xs:anyAtomicType? ) as xs:string? { - - ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') - [month-from-date(xs:date($date))] - } ; - -declare function functx:month-name-en - ( $date as xs:anyAtomicType? ) as xs:string? { - - ('January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December') - [month-from-date(xs:date($date))] - } ; - -declare function functx:name-test - ( $testname as xs:string? , - $names as xs:string* ) as xs:boolean { - -$testname = $names -or -$names = '*' -or -functx:substring-after-if-contains($testname,':') = - (for $name in $names - return substring-after($name,'*:')) -or -substring-before($testname,':') = - (for $name in $names[contains(.,':*')] - return substring-before($name,':*')) - } ; - -declare function functx:namespaces-in-use - ( $root as node()? ) as xs:anyURI* { - - distinct-values( - $root/descendant-or-self::*/(.|@*)/namespace-uri(.)) - } ; - -declare function functx:next-day - ( $date as xs:anyAtomicType? ) as xs:date? { - - xs:date($date) + xs:dayTimeDuration('P1D') - } ; - -declare function functx:node-kind - ( $nodes as node()* ) as xs:string* { - - for $node in $nodes - return - if ($node instance of element()) then 'element' - else if ($node instance of attribute()) then 'attribute' - else if ($node instance of text()) then 'text' - else if ($node instance of document-node()) then 'document-node' - else if ($node instance of comment()) then 'comment' - else if ($node instance of processing-instruction()) - then 'processing-instruction' - else 'unknown' - } ; - -declare function functx:non-distinct-values - ( $seq as xs:anyAtomicType* ) as xs:anyAtomicType* { - - for $val in distinct-values($seq) - return $val[count($seq[. = $val]) > 1] - } ; - -declare function functx:number-of-matches - ( $arg as xs:string? , - $pattern as xs:string ) as xs:integer { - - count(tokenize($arg,$pattern)) - 1 - } ; - -declare function functx:open-ref-document - ( $refNode as node() ) as document-node() { - - if (base-uri($refNode)) - then doc(resolve-uri($refNode, base-uri($refNode))) - else doc(resolve-uri($refNode)) - } ; - -declare function functx:ordinal-number-en - ( $num as xs:integer? ) as xs:string { - - concat(xs:string($num), - if (matches(xs:string($num),'[04-9]$|1[1-3]$')) then 'th' - else if (ends-with(xs:string($num),'1')) then 'st' - else if (ends-with(xs:string($num),'2')) then 'nd' - else if (ends-with(xs:string($num),'3')) then 'rd' - else '') - } ; - -declare function functx:pad-integer-to-length - ( $integerToPad as xs:anyAtomicType? , - $length as xs:integer ) as xs:string { - - if ($length < string-length(string($integerToPad))) - then error(xs:QName('functx:Integer_Longer_Than_Length')) - else concat - (functx:repeat-string( - '0',$length - string-length(string($integerToPad))), - string($integerToPad)) - } ; - -declare function functx:pad-string-to-length - ( $stringToPad as xs:string? , - $padChar as xs:string , - $length as xs:integer ) as xs:string { - - substring( - string-join ( - ($stringToPad, for $i in (1 to $length) return $padChar) - ,'') - ,1,$length) - } ; - -declare function functx:path-to-node-with-pos - ( $node as node()? ) as xs:string { - -string-join( - for $ancestor in $node/ancestor-or-self::* - let $sibsOfSameName := $ancestor/../*[name() = name($ancestor)] - return concat(name($ancestor), - if (count($sibsOfSameName) <= 1) - then '' - else concat( - '[',functx:index-of-node($sibsOfSameName,$ancestor),']')) - , '/') - } ; - -declare function functx:path-to-node - ( $nodes as node()* ) as xs:string* { - -$nodes/string-join(ancestor-or-self::*/name(.), '/') - } ; - -declare function functx:precedes-not-ancestor - ( $a as node()? , - $b as node()? ) as xs:boolean { - - $a << $b and empty($a intersect $b/ancestor::node()) - } ; - -declare function functx:previous-day - ( $date as xs:anyAtomicType? ) as xs:date? { - - xs:date($date) - xs:dayTimeDuration('P1D') - } ; - -declare function functx:remove-attributes-deep - ( $nodes as node()* , - $names as xs:string* ) as node()* { - - for $node in $nodes - return if ($node instance of element()) - then element { node-name($node)} - { $node/@*[not(functx:name-test(name(),$names))], - functx:remove-attributes-deep($node/node(), $names)} - else if ($node instance of document-node()) - then functx:remove-attributes-deep($node/node(), $names) - else $node - } ; - -declare function functx:remove-attributes - ( $elements as element()* , - $names as xs:string* ) as element() { - - for $element in $elements - return element - {node-name($element)} - {$element/@*[not(functx:name-test(name(),$names))], - $element/node() } - } ; - -declare function functx:remove-elements-deep - ( $nodes as node()* , - $names as xs:string* ) as node()* { - - for $node in $nodes - return - if ($node instance of element()) - then if (functx:name-test(name($node),$names)) - then () - else element { node-name($node)} - { $node/@*, - functx:remove-elements-deep($node/node(), $names)} - else if ($node instance of document-node()) - then functx:remove-elements-deep($node/node(), $names) - else $node - } ; - -declare function functx:remove-elements-not-contents - ( $nodes as node()* , - $names as xs:string* ) as node()* { - - for $node in $nodes - return - if ($node instance of element()) - then if (functx:name-test(name($node),$names)) - then functx:remove-elements-not-contents($node/node(), $names) - else element {node-name($node)} - {$node/@*, - functx:remove-elements-not-contents($node/node(),$names)} - else if ($node instance of document-node()) - then functx:remove-elements-not-contents($node/node(), $names) - else $node - } ; - -declare function functx:remove-elements - ( $elements as element()* , - $names as xs:string* ) as element()* { - - for $element in $elements - return element - {node-name($element)} - {$element/@*, - $element/node()[not(functx:name-test(name(),$names))] } - } ; - -declare function functx:repeat-string - ( $stringToRepeat as xs:string? , - $count as xs:integer ) as xs:string { - - string-join((for $i in 1 to $count return $stringToRepeat), - '') - } ; - -declare function functx:replace-beginning - ( $arg as xs:string? , - $pattern as xs:string , - $replacement as xs:string ) as xs:string { - - replace($arg, concat('^.*?', $pattern), $replacement) - } ; - -declare function functx:replace-element-values - ( $elements as element()* , - $values as xs:anyAtomicType* ) as element()* { - - for $element at $seq in $elements - return element { node-name($element)} - { $element/@*, - $values[$seq] } - } ; - -declare function functx:replace-first - ( $arg as xs:string? , - $pattern as xs:string , - $replacement as xs:string ) as xs:string { - - replace($arg, concat('(^.*?)', $pattern), - concat('$1',$replacement)) - } ; - -declare function functx:replace-multi - ( $arg as xs:string? , - $changeFrom as xs:string* , - $changeTo as xs:string* ) as xs:string? { - - if (count($changeFrom) > 0) - then functx:replace-multi( - replace($arg, $changeFrom[1], - functx:if-absent($changeTo[1],'')), - $changeFrom[position() > 1], - $changeTo[position() > 1]) - else $arg - } ; - -declare function functx:reverse-string - ( $arg as xs:string? ) as xs:string { - - codepoints-to-string(reverse(string-to-codepoints($arg))) - } ; - -declare function functx:right-trim - ( $arg as xs:string? ) as xs:string { - - replace($arg,'\s+$','') - } ; - -declare function functx:scheme-from-uri - ( $uri as xs:string? ) as xs:string? { - - substring-before($uri,':') - } ; - -declare function functx:sequence-deep-equal - ( $seq1 as item()* , - $seq2 as item()* ) as xs:boolean { - - every $i in 1 to max((count($seq1),count($seq2))) - satisfies deep-equal($seq1[$i],$seq2[$i]) - } ; - -declare function functx:sequence-node-equal-any-order - ( $seq1 as node()* , - $seq2 as node()* ) as xs:boolean { - - not( ($seq1 except $seq2, $seq2 except $seq1)) - } ; - -declare function functx:sequence-node-equal - ( $seq1 as node()* , - $seq2 as node()* ) as xs:boolean { - - every $i in 1 to max((count($seq1),count($seq2))) - satisfies $seq1[$i] is $seq2[$i] - } ; - -declare function functx:sequence-type - ( $items as item()* ) as xs:string { - -concat( - if (empty($items)) - then 'empty-sequence()' - else if (every $val in $items - satisfies $val instance of xs:anyAtomicType) - then if (count(distinct-values(functx:atomic-type($items))) - > 1) - then 'xs:anyAtomicType' - else functx:atomic-type($items[1]) - else if (some $val in $items - satisfies $val instance of xs:anyAtomicType) - then 'item()' - else if (count(distinct-values(functx:node-kind($items))) > 1) - then 'node()' - else concat(functx:node-kind($items[1]),'()') - , - if (count($items) > 1) - then '+' else '') - } ; - -declare function functx:siblings-same-name - ( $element as element()? ) as element()* { - - $element/../*[node-name(.) = node-name($element)] - except $element - } ; - -declare function functx:siblings - ( $node as node()? ) as node()* { - - $node/../node() except $node - } ; - -declare function functx:sort-as-numeric - ( $seq as item()* ) as item()* { - - for $item in $seq - order by number($item) - return $item - } ; - -declare function functx:sort-case-insensitive - ( $seq as item()* ) as item()* { - - for $item in $seq - order by upper-case(string($item)) - return $item - } ; - -declare function functx:sort-document-order - ( $seq as node()* ) as node()* { - - $seq/. - } ; - -declare function functx:sort - ( $seq as item()* ) as item()* { - - for $item in $seq - order by $item - return $item - } ; - -declare function functx:substring-after-if-contains - ( $arg as xs:string? , - $delim as xs:string ) as xs:string? { - - if (contains($arg,$delim)) - then substring-after($arg,$delim) - else $arg - } ; - -declare function functx:substring-after-last-match - ( $arg as xs:string? , - $regex as xs:string ) as xs:string { - - replace($arg,concat('^.*',$regex),'') - } ; - -declare function functx:substring-after-last - ( $arg as xs:string? , - $delim as xs:string ) as xs:string { - - replace ($arg,concat('^.*',functx:escape-for-regex($delim)),'') - } ; - -declare function functx:substring-after-match - ( $arg as xs:string? , - $regex as xs:string ) as xs:string? { - - replace($arg,concat('^.*?',$regex),'') - } ; - -declare function functx:substring-before-if-contains - ( $arg as xs:string? , - $delim as xs:string ) as xs:string? { - - if (contains($arg,$delim)) - then substring-before($arg,$delim) - else $arg - } ; - -declare function functx:substring-before-last-match - ( $arg as xs:string? , - $regex as xs:string ) as xs:string? { - - replace($arg,concat('^(.*)',$regex,'.*'),'$1') - } ; - -declare function functx:substring-before-last - ( $arg as xs:string? , - $delim as xs:string ) as xs:string { - - if (matches($arg, functx:escape-for-regex($delim))) - then replace($arg, - concat('^(.*)', functx:escape-for-regex($delim),'.*'), - '$1') - else '' - } ; - -declare function functx:substring-before-match - ( $arg as xs:string? , - $regex as xs:string ) as xs:string { - - tokenize($arg,$regex)[1] - } ; - -declare function functx:time - ( $hour as xs:anyAtomicType , - $minute as xs:anyAtomicType , - $second as xs:anyAtomicType ) as xs:time { - - xs:time( - concat( - functx:pad-integer-to-length(xs:integer($hour),2),':', - functx:pad-integer-to-length(xs:integer($minute),2),':', - functx:pad-integer-to-length(xs:integer($second),2))) - } ; - -declare function functx:timezone-from-duration - ( $duration as xs:dayTimeDuration ) as xs:string { - - if (string($duration) = ('PT0S','-PT0S')) - then 'Z' - else if (matches(string($duration),'-PT[1-9]H')) - then replace(string($duration),'PT([1-9])H','0$1:00') - else if (matches(string($duration),'PT[1-9]H')) - then replace(string($duration),'PT([1-9])H','+0$1:00') - else if (matches(string($duration),'-PT1[0-4]H')) - then replace(string($duration),'PT(1[0-4])H','$1:00') - else if (matches(string($duration),'PT1[0-4]H')) - then replace(string($duration),'PT(1[0-4])H','+$1:00') - else error(xs:QName('functx:Invalid_Duration_Value')) - } ; - -declare function functx:total-days-from-duration - ( $duration as xs:dayTimeDuration? ) as xs:decimal? { - - $duration div xs:dayTimeDuration('P1D') - } ; - -declare function functx:total-hours-from-duration - ( $duration as xs:dayTimeDuration? ) as xs:decimal? { - - $duration div xs:dayTimeDuration('PT1H') - } ; - -declare function functx:total-minutes-from-duration - ( $duration as xs:dayTimeDuration? ) as xs:decimal? { - - $duration div xs:dayTimeDuration('PT1M') - } ; - -declare function functx:total-months-from-duration - ( $duration as xs:yearMonthDuration? ) as xs:decimal? { - - $duration div xs:yearMonthDuration('P1M') - } ; - -declare function functx:total-seconds-from-duration - ( $duration as xs:dayTimeDuration? ) as xs:decimal? { - - $duration div xs:dayTimeDuration('PT1S') - } ; - -declare function functx:total-years-from-duration - ( $duration as xs:yearMonthDuration? ) as xs:decimal? { - - $duration div xs:yearMonthDuration('P1Y') - } ; - -declare function functx:trim - ( $arg as xs:string? ) as xs:string { - - replace(replace($arg,'\s+$',''),'^\s+','') - } ; - -declare function functx:update-attributes - ( $elements as element()* , - $attrNames as xs:QName* , - $attrValues as xs:anyAtomicType* ) as element()? { - - for $element in $elements - return element { node-name($element)} - { for $attrName at $seq in $attrNames - return if ($element/@*[node-name(.) = $attrName]) - then attribute {$attrName} - {$attrValues[$seq]} - else (), - $element/@*[not(node-name(.) = $attrNames)], - $element/node() } - } ; - -declare function functx:value-except - ( $arg1 as xs:anyAtomicType* , - $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType* { - - distinct-values($arg1[not(.=$arg2)]) - } ; - -declare function functx:value-intersect - ( $arg1 as xs:anyAtomicType* , - $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType* { - - distinct-values($arg1[.=$arg2]) - } ; - -declare function functx:value-union - ( $arg1 as xs:anyAtomicType* , - $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType* { - - distinct-values(($arg1, $arg2)) - } ; - -declare function functx:word-count - ( $arg as xs:string? ) as xs:integer { - - count(tokenize($arg, '\W+')[. != '']) - } ; - -declare function functx:words-to-camel-case - ( $arg as xs:string? ) as xs:string { - - string-join((tokenize($arg,'\s+')[1], - for $word in tokenize($arg,'\s+')[position() > 1] - return functx:capitalize-first($word)) - ,'') - } ; - -declare function functx:wrap-values-in-elements - ( $values as xs:anyAtomicType* , - $elementName as xs:QName ) as element()* { - - for $value in $values - return element {$elementName} {$value} - } ; - -declare function functx:yearMonthDuration - ( $years as xs:decimal? , - $months as xs:integer? ) as xs:yearMonthDuration { - - (xs:yearMonthDuration('P1M') * functx:if-empty($months,0)) + - (xs:yearMonthDuration('P1Y') * functx:if-empty($years,0)) - } ; diff --git a/add/data/xqm/util.xqm b/add/data/xqm/util.xqm index 9a3663c03..78f18ae69 100644 --- a/add/data/xqm/util.xqm +++ b/add/data/xqm/util.xqm @@ -34,7 +34,7 @@ import module namespace work="http://www.edirom.de/xquery/work" at "work.xqm"; import module namespace source="http://www.edirom.de/xquery/source" at "source.xqm"; import module namespace teitext="http://www.edirom.de/xquery/teitext" at "teitext.xqm"; import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; -import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq"; +import module namespace functx = "http://www.functx.com"; import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; declare namespace request="http://exist-db.org/xquery/request"; diff --git a/add/expath-pkg.xml b/add/expath-pkg.xml index 266f4fd42..c6e477f8d 100755 --- a/add/expath-pkg.xml +++ b/add/expath-pkg.xml @@ -5,4 +5,5 @@ version="@project.version@" spec="1.0"> @project.title@ + \ No newline at end of file From e91c70eb7241d06f4c7482173404f9013d7c92f9 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 18:46:13 +0200 Subject: [PATCH 074/107] use functx xslt module in XSLTs --- add/data/xslt/ediromOnline_functions.xsl | 2 +- add/data/xslt/functx-1.0-nodoc-2007-01.xsl | 1488 -------------------- add/data/xslt/teiBody2HTML.xsl | 2 +- 3 files changed, 2 insertions(+), 1490 deletions(-) delete mode 100644 add/data/xslt/functx-1.0-nodoc-2007-01.xsl diff --git a/add/data/xslt/ediromOnline_functions.xsl b/add/data/xslt/ediromOnline_functions.xsl index 961d59306..b23021590 100644 --- a/add/data/xslt/ediromOnline_functions.xsl +++ b/add/data/xslt/ediromOnline_functions.xsl @@ -14,7 +14,7 @@ - + diff --git a/add/data/xslt/functx-1.0-nodoc-2007-01.xsl b/add/data/xslt/functx-1.0-nodoc-2007-01.xsl deleted file mode 100644 index c5048f89a..000000000 --- a/add/data/xslt/functx-1.0-nodoc-2007-01.xsl +++ /dev/null @@ -1,1488 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/add/data/xslt/teiBody2HTML.xsl b/add/data/xslt/teiBody2HTML.xsl index a01b527c3..921dd1426 100644 --- a/add/data/xslt/teiBody2HTML.xsl +++ b/add/data/xslt/teiBody2HTML.xsl @@ -3,7 +3,7 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" exclude-result-prefixes="#default xs tei xhtml" version="2.0"> - + From 18ffb3f1548f8b2d7c377a96f80fe83453515cf4 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 31 May 2023 19:26:48 +0200 Subject: [PATCH 075/107] fix function: workToJSON selection of `mei:work` as descendant-or-self * fix wor --- add/data/xqm/work.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/work.xqm b/add/data/xqm/work.xqm index b9935a71d..d167c8468 100644 --- a/add/data/xqm/work.xqm +++ b/add/data/xqm/work.xqm @@ -48,7 +48,7 @@ declare function work:toJSON($uri as xs:string, $edition as xs:string) as xs:str {', 'id: "', $work/string(@xml:id), '", ', 'doc: "', $uri, '", ', - 'title: "', replace(eutil:getLocalizedTitle((($work//mei:work)[1] | $work), $lang), '"', '\\"'), '"', + 'title: "', replace(eutil:getLocalizedTitle((($work/descendant-or-self::mei:work)[1]), $lang), '"', '\\"'), '"', '}') }; From cf1489e96b3f6b56d02260e285f18d30e5be5d57 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 19:33:22 +0200 Subject: [PATCH 076/107] Update docker-ci.yml --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index f266b2853..305a9e263 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -27,7 +27,7 @@ jobs: # The name that the artifact will be made available under name: EdiromOnline_${{ github.ref }}.zip # The path to retrieve the artifact - path: build-xar/EdiromOnline*.xar + path: ${{ github.workspace }}/build-xar/EdiromOnline*.xar if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` #optional retention-days: 1 to 90 From 1ab2a0e697aeac8aa0c31fce462e0a6efcdee5bf Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 19:36:20 +0200 Subject: [PATCH 077/107] Update docker-ci.yml update checkout action --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 305a9e263..49ef04a3c 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build Edirom Online from ${{ github.ref }} run: docker run --rm -v `pwd`:/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd - name: Upload Artifacts From c14c73e0e3c830c562730241ad6cc1bb9af43bea Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 19:40:02 +0200 Subject: [PATCH 078/107] Update docker-ci.yml --- .github/workflows/docker-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 49ef04a3c..6404eff8a 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -17,9 +17,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Chekout repository + uses: actions/checkout@v3 - name: Build Edirom Online from ${{ github.ref }} - run: docker run --rm -v `pwd`:/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd + run: docker run --rm -v $(pwd):/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd - name: Upload Artifacts if: github.repository == 'Edirom/Edirom-Online' uses: actions/upload-artifact@v3.1.2 From 8220b5f9fe3bf4e68c65c0e49e54c936dd65c41f Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 19:44:21 +0200 Subject: [PATCH 079/107] Update docker-ci.yml --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 6404eff8a..8df4af3a2 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -4,7 +4,7 @@ on: # push: # branches: [ main ] pull_request: - types: [opened, edited, reopened] + types: [opened, synchronize, reopened] branches: [ develop, main ] env: From a4d0952aad963039f4c8d7d1a34df047e4dcb920 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 31 May 2023 20:29:38 +0200 Subject: [PATCH 080/107] Update docker-ci.yml --- .github/workflows/docker-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 8df4af3a2..2cd5fdbd8 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -28,8 +28,8 @@ jobs: # The name that the artifact will be made available under name: EdiromOnline_${{ github.ref }}.zip # The path to retrieve the artifact - path: ${{ github.workspace }}/build-xar/EdiromOnline*.xar - if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + path: ${{ github.workspace }}/build-xar/*.xar + if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn` #optional retention-days: 1 to 90 # deploy: From 2ccd0b9a0474de4f1828f3e60d937d27773cacaf Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Thu, 1 Jun 2023 09:39:18 +0200 Subject: [PATCH 081/107] Update docker-ci.yml --- .github/workflows/docker-ci.yml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 2cd5fdbd8..8fc2df94d 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -1,10 +1,10 @@ name: Docker build PR on: -# push: -# branches: [ main ] + push: + branches: [ develop ] pull_request: - types: [opened, synchronize, reopened] + types: [ opened, synchronize, reopened ] branches: [ develop, main ] env: @@ -13,32 +13,23 @@ env: jobs: build: - + name: Build Edirom Online runs-on: ubuntu-latest steps: - name: Chekout repository uses: actions/checkout@v3 - - name: Build Edirom Online from ${{ github.ref }} + + - name: Build Edirom Online from ${{ github.ref }} at ${{ github.sha }} run: docker run --rm -v $(pwd):/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd - - name: Upload Artifacts + + - name: Upload Artifacts to action run if: github.repository == 'Edirom/Edirom-Online' uses: actions/upload-artifact@v3.1.2 with: # The name that the artifact will be made available under - name: EdiromOnline_${{ github.ref }}.zip + name: EdiromOnline_${{ github.sha }}.zip # The path to retrieve the artifact - path: ${{ github.workspace }}/build-xar/*.xar + path: ${{ github.workspace }}/build-xar/Edirom-Online-*.xar if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn` #optional retention-days: 1 to 90 - -# deploy: -# needs: build -# runs-on: ubuntu-latest -# steps: -# - name: deploy -# uses: jaapio/keelsh-deploy@master -# with: -# keelBaseUrl: http://keel.euryanthe.de -# image: 'bazga/existdb' -# tag: 'latest' From 48f8df8efac987f614d9dab2c72027e17d65d594 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Thu, 1 Jun 2023 09:47:27 +0200 Subject: [PATCH 082/107] GHA: Use short sha for uploaded artifacts --- .github/workflows/docker-ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 8fc2df94d..a91fc8bc1 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -19,6 +19,12 @@ jobs: steps: - name: Chekout repository uses: actions/checkout@v3 + + - name: Get short sha + uses: benjlevesque/short-sha@2.2 + id: short-sha + with: + length: 7 - name: Build Edirom Online from ${{ github.ref }} at ${{ github.sha }} run: docker run --rm -v $(pwd):/app -w /app --entrypoint ./build.sh bwbohl/sencha-cmd @@ -28,7 +34,7 @@ jobs: uses: actions/upload-artifact@v3.1.2 with: # The name that the artifact will be made available under - name: EdiromOnline_${{ github.sha }}.zip + name: EdiromOnline_${{ steps.short-sha.outputs.sha }}.zip # The path to retrieve the artifact path: ${{ github.workspace }}/build-xar/Edirom-Online-*.xar if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn` From 3075dc117e8481751b44d680e4ad60e08acaedf7 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Thu, 1 Jun 2023 09:48:36 +0200 Subject: [PATCH 083/107] GHA: Fix action version --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index a91fc8bc1..1aa50f82c 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: Get short sha - uses: benjlevesque/short-sha@2.2 + uses: benjlevesque/short-sha@v2.2 id: short-sha with: length: 7 From 09e1efcfdd3d2772acb361851b2de522d5aaab56 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Thu, 1 Jun 2023 10:01:34 +0200 Subject: [PATCH 084/107] Update docker-ci.yml --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 1aa50f82c..0308d2d9e 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -1,4 +1,4 @@ -name: Docker build PR +name: Build on: push: From a18409326756ea39df0db84cbd353ef79c51db38 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Thu, 1 Jun 2023 10:05:38 +0200 Subject: [PATCH 085/107] Add status badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 77131a87e..49a4b0d66 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build](https://github.com/Edirom/Edirom-Online/actions/workflows/docker-ci.yml/badge.svg?branch=develop&event=push)](https://github.com/Edirom/Edirom-Online/actions/workflows/docker-ci.yml) + # Edirom Online Edirom Online is a web application written in XQuery and JavaScript, and designed for deployment in [eXist-db](https://exist-db.org/). It is based on the work of the [_Edirom_-Project](https://edirom.de/edirom-projekt/) that originally was funded by the German Research Foundation (DFG). This software brings paperbased historio-critical editions of music texts to the web. From 366ed7ec5ffa1982eca073b6585f4def938085d9 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 13:52:11 +0200 Subject: [PATCH 086/107] remove unused variable --- add/data/xql/getAnnotationPreviews.xql | 1 - 1 file changed, 1 deletion(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 32e422989..15b99afc3 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -22,7 +22,6 @@ declare option output:method "json"; declare option output:media-type "application/json"; declare variable $lang := request:get-parameter('lang', ''); -declare variable $imageWidth := 600; declare variable $edition := request:get-parameter('edition', ''); declare variable $imageserver := eutil:getPreference('image_server', $edition); declare variable $uri := request:get-parameter('uri', ''); From 02eb09bebac5e190c93237f717a288d6961964e7 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 13:52:27 +0200 Subject: [PATCH 087/107] whitespace linting wh --- add/data/xql/getAnnotationPreviews.xql | 88 +++++++++++++------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 15b99afc3..1873d8266 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -1,11 +1,11 @@ xquery version "3.1"; (: -For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) (:~ Returns the HTML for a specific annotation for an AnnotationView. - + @author Daniel Röwenstrunk @author Benjamin W. Bohl :) @@ -32,7 +32,7 @@ else (eutil:getPreference('image_prefix', $edition)); declare function local:getParticipants($annot as element()) as map(*)* { - + let $participants := tokenize($annot/string(@plist), ' ') let $docs := distinct-values(for $p in $participants return @@ -44,18 +44,18 @@ declare function local:getParticipants($annot as element()) as map(*)* { if (source:isSource($doc)) then (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - + else if (teitext:isText($doc)) then (local:getTextParticipants($participants[starts-with(., $doc)], $doc)) - + else () }; declare function local:getTextParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - + for $participant in $participants let $id := substring-after($participant, '#') let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) @@ -99,14 +99,14 @@ declare function local:getTextNotePrecedingContent($elem as element()) as xs:str }; declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - + let $combs := local:groupParticipants($participants, $doc) - + return - + for $comb in distinct-values($combs) let $partIndices := tokenize($comb, '-') - + let $elems := for $p in distinct-values($partIndices) let $relevant.participant := $participants[starts-with(., $doc)][number($p)] @@ -117,16 +117,16 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a order by count($elem/preceding::*) return $elem - + where count($elems) gt 0 - + let $zones := for $elem in $elems return local:getZone($elem) - + let $type := local:getType($zones) let $label := local:getItemLabel($elems) - + let $mdiv := '' (: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) let $page := if ($zones[1]/parent::mei:surface/@label != '') then ($zones[1]/parent::mei:surface/string(@label)) @@ -134,20 +134,20 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a ($zones[1]/parent::mei:surface/string(@n)) let $sourceLabel := source:getLabel($doc, $edition) let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() - + let $part := string-join(distinct-values(for $e in $elems return $e/ancestor::mei:part/string(@label)), '-') - + let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] let $imgWidth := number($graphic/@width) let $imgHeight := number($graphic/@height) - + let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) let $rect := local:getBoundingZone($zones) - + let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) - + let $hiddenData := map { 'width': number($rect/@lrx) - number($rect/@ulx), 'height': number($rect/@lry) - number($rect/@uly), @@ -156,9 +156,9 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a 'origH': $imgHeight, 'origW': $imgWidth } - + let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) - + return map { 'type': $type, @@ -197,20 +197,20 @@ declare function local:getSourceLinkTarget($elems as node()*, $zones as node()*) }; declare function local:groupParticipants($participants as xs:string*, $doc as xs:string) as xs:string* { - + let $elems := for $p in $participants let $id := substring-after($p, '#') return doc($doc)/id($id) - + let $zones := for $elem in $elems return local:getZone($elem) - + let $combs := for $p at $i in $participants return local:getCombinations($elems, $zones, $i, count($zones)) - + return reverse( for $comb at $i in reverse($combs) @@ -231,7 +231,7 @@ declare function local:groupParticipants($participants as xs:string*, $doc as xs }; declare function local:getCombinations($elems as element()*, $zones as element()*, $i as xs:int, $total as xs:int) as xs:string { - + let $currentZone := $zones[$i] let $currentElem := $elems[$i] return @@ -256,7 +256,7 @@ declare function local:getCombinations($elems as element()*, $zones as element() }; declare function local:compareZones($zone1 as element(), $zone2 as element()) as xs:boolean { - + let $samePage := deep-equal($zone1/.., $zone2/..) let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) return @@ -266,7 +266,7 @@ declare function local:compareZones($zone1 as element(), $zone2 as element()) as declare function local:getElement($uri as xs:string) as element()? { let $doc := substring-before($uri, '#') let $id := substring-after($uri, '#') - + return doc($doc)/id($id) }; @@ -274,9 +274,9 @@ declare function local:getElement($uri as xs:string) as element()? { (: TODO: in Modul auslagern :) (:~ Gets the zone holding the graphical representation of an element - + @param $elem The element for which the graphical representation shall be found - + @return The zone element :) declare function local:getZone($elem as element()) as element()? { @@ -310,20 +310,20 @@ declare function local:getBoundingZone($zones as element()*) as element() { (: TODO: in Modul auslagern :) (:~ - + :) declare function local:getImageAreaPath($basePath as xs:string, $graphic as element()?) as xs:string { - + let $imagePath := string($graphic/@target) let $imgWidth := number($graphic/@width) let $imgHeight := number($graphic/@height) let $isAbsolute := starts-with($imagePath, 'http') - + let $fields := if ($imageserver = 'leaflet') then (substring-before($imagePath, '.')) else () - + return if ($isAbsolute) then @@ -345,26 +345,26 @@ declare function local:getImageAreaPath($basePath as xs:string, $graphic as elem (:~ This function generates an image path for a specific zone on an image. Based on a path prefix and a width. - + @param $basePath The base path prefix for the image databse @param $zone The zone with coordiantes on the image @param $width The width the image should be loaded with - + @return A URL pointing to an image based as xs:string :) declare function local:getImageAreaParams($zone as element()?, $imgWidth as xs:int, $imgHeight as xs:int) as xs:string { let $graphic := $zone/../mei:graphic[@type = 'facsimile'] - + let $imgX := number($zone/@ulx) let $imgY := number($zone/@uly) let $w := number($zone/@lrx) - number($zone/@ulx) let $h := number($zone/@lry) - number($zone/@uly) - + let $wx := $imgX div $imgWidth let $wy := $imgY div $imgHeight let $ww := $w div $imgWidth let $wh := $h div $imgHeight - + return concat('&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;mo=fit') }; @@ -405,9 +405,9 @@ declare function local:getItemLabel($elems as element()*) as xs:string { if (count($items) gt 1) then ( - + let $measureNs := distinct-values($items/ancestor::mei:measure/@n) - + let $label := if ($lang = 'de') then (if (count($measureNs) gt 1) then @@ -419,11 +419,11 @@ declare function local:getItemLabel($elems as element()*) as xs:string { (concat('Bars ', $measureNs[1], '-', $measureNs[last()])) else (concat('Bar ', $measureNs[1]))) - + return - + concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ', '), ')') - + ) else (concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')')) From b4d3996f83b8e6721ac10dc89ea24834f4b03499 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 13:53:10 +0200 Subject: [PATCH 088/107] format and indent --- add/data/xql/getAnnotationPreviews.xql | 654 ++++++++++++------------- 1 file changed, 327 insertions(+), 327 deletions(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 1873d8266..59d269fb1 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -27,248 +27,248 @@ declare variable $imageserver := eutil:getPreference('image_server', $edition); declare variable $uri := request:get-parameter('uri', ''); declare variable $imageBasePath := if ($imageserver = 'leaflet') then - (eutil:getPreference('leaflet_prefix', $edition)) + (eutil:getPreference('leaflet_prefix', $edition)) else - (eutil:getPreference('image_prefix', $edition)); + (eutil:getPreference('image_prefix', $edition)); declare function local:getParticipants($annot as element()) as map(*)* { - - let $participants := tokenize($annot/string(@plist), ' ') - let $docs := distinct-values(for $p in $participants - return - substring-before($p, '#')) - return - for $doc in $docs - order by $doc + + let $participants := tokenize($annot/string(@plist), ' ') + let $docs := distinct-values(for $p in $participants return - if (source:isSource($doc)) - then - (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - - else - if (teitext:isText($doc)) - then - (local:getTextParticipants($participants[starts-with(., $doc)], $doc)) - - else - () + substring-before($p, '#')) + return + for $doc in $docs + order by $doc + return + if (source:isSource($doc)) + then + (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) + + else + if (teitext:isText($doc)) + then + (local:getTextParticipants($participants[starts-with(., $doc)], $doc)) + + else + () }; declare function local:getTextParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - - for $participant in $participants - let $id := substring-after($participant, '#') - let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) - return - map { - 'type': 'text', - 'label': 'Textstelle', - 'mdiv': '', - 'part': '', - 'page': '', - 'source': teitext:getLabel($doc, $edition), - 'siglum': '', - 'digilibBaseParams': '', - 'digilibSizeParams': '', - 'hiddenData': $hiddenData, - 'content': normalize-space(local:getTextNoteContent($doc, $id)), - 'linkUri': $participant - } + + for $participant in $participants + let $id := substring-after($participant, '#') + let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) + return + map { + 'type': 'text', + 'label': 'Textstelle', + 'mdiv': '', + 'part': '', + 'page': '', + 'source': teitext:getLabel($doc, $edition), + 'siglum': '', + 'digilibBaseParams': '', + 'digilibSizeParams': '', + 'hiddenData': $hiddenData, + 'content': normalize-space(local:getTextNoteContent($doc, $id)), + 'linkUri': $participant + } }; declare function local:getTextNoteContent($doc as xs:string, $id as xs:string) as xs:string { - let $elem := doc($doc)/id($id) - let $content := data($elem) - return - if (string-length($content) gt 0) - then - ($content) - else - (local:getTextNotePrecedingContent($elem)) + let $elem := doc($doc)/id($id) + let $content := data($elem) + return + if (string-length($content) gt 0) + then + ($content) + else + (local:getTextNotePrecedingContent($elem)) }; declare function local:getTextNotePrecedingContent($elem as element()) as xs:string { - let $preceding := $elem/preceding-sibling::*[1] - let $content := data($preceding) - return - if (string-length($content) gt 0) - then - ($content) - else - (local:getTextNotePrecedingContent($preceding)) + let $preceding := $elem/preceding-sibling::*[1] + let $content := data($preceding) + return + if (string-length($content) gt 0) + then + ($content) + else + (local:getTextNotePrecedingContent($preceding)) }; declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - - let $combs := local:groupParticipants($participants, $doc) - - return - - for $comb in distinct-values($combs) - let $partIndices := tokenize($comb, '-') - - let $elems := - for $p in distinct-values($partIndices) - let $relevant.participant := $participants[starts-with(., $doc)][number($p)] - let $element.id := substring-after($relevant.participant, '#') - let $elem := local:getElement($relevant.participant) - (:return if(exists($elem)) then(local-name($elem)) else($relevant.participant):) - where exists($elem) - order by count($elem/preceding::*) - return - $elem - - where count($elems) gt 0 - - let $zones := for $elem in $elems - return - local:getZone($elem) - - let $type := local:getType($zones) - let $label := local:getItemLabel($elems) - - let $mdiv := '' (: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) - let $page := if ($zones[1]/parent::mei:surface/@label != '') then - ($zones[1]/parent::mei:surface/string(@label)) - else - ($zones[1]/parent::mei:surface/string(@n)) - let $sourceLabel := source:getLabel($doc, $edition) - let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() - - let $part := string-join(distinct-values(for $e in $elems + + let $combs := local:groupParticipants($participants, $doc) + return - $e/ancestor::mei:part/string(@label)), '-') - - let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] - let $imgWidth := number($graphic/@width) - let $imgHeight := number($graphic/@height) - - let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) - let $rect := local:getBoundingZone($zones) - - let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) - - let $hiddenData := map { - 'width': number($rect/@lrx) - number($rect/@ulx), - 'height': number($rect/@lry) - number($rect/@uly), - 'x': number($rect/@ulx), - 'y': number($rect/@uly), - 'origH': $imgHeight, - 'origW': $imgWidth - } - - let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) - - return - map { - 'type': $type, - 'label': $label, - 'mdiv': $mdiv, - 'part': $part, - 'page': $page, - 'source': $sourceLabel, - 'siglum': $siglum, - 'digilibBaseParams': $digilibBaseParams, - 'digilibSizeParams': $digilibSizeParams, - 'hiddenData': $hiddenData, - 'content': '', - 'linkUri': $linkUri - } + + for $comb in distinct-values($combs) + let $partIndices := tokenize($comb, '-') + + let $elems := + for $p in distinct-values($partIndices) + let $relevant.participant := $participants[starts-with(., $doc)][number($p)] + let $element.id := substring-after($relevant.participant, '#') + let $elem := local:getElement($relevant.participant) + (:return if(exists($elem)) then(local-name($elem)) else($relevant.participant):) + where exists($elem) + order by count($elem/preceding::*) + return + $elem + + where count($elems) gt 0 + + let $zones := for $elem in $elems + return + local:getZone($elem) + + let $type := local:getType($zones) + let $label := local:getItemLabel($elems) + + let $mdiv := '' (: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) + let $page := if ($zones[1]/parent::mei:surface/@label != '') then + ($zones[1]/parent::mei:surface/string(@label)) + else + ($zones[1]/parent::mei:surface/string(@n)) + let $sourceLabel := source:getLabel($doc, $edition) + let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() + + let $part := string-join(distinct-values(for $e in $elems + return + $e/ancestor::mei:part/string(@label)), '-') + + let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] + let $imgWidth := number($graphic/@width) + let $imgHeight := number($graphic/@height) + + let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) + let $rect := local:getBoundingZone($zones) + + let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) + + let $hiddenData := map { + 'width': number($rect/@lrx) - number($rect/@ulx), + 'height': number($rect/@lry) - number($rect/@uly), + 'x': number($rect/@ulx), + 'y': number($rect/@uly), + 'origH': $imgHeight, + 'origW': $imgWidth + } + + let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) + + return + map { + 'type': $type, + 'label': $label, + 'mdiv': $mdiv, + 'part': $part, + 'page': $page, + 'source': $sourceLabel, + 'siglum': $siglum, + 'digilibBaseParams': $digilibBaseParams, + 'digilibSizeParams': $digilibSizeParams, + 'hiddenData': $hiddenData, + 'content': '', + 'linkUri': $linkUri + } }; declare function local:getSourceLinkTarget($elems as node()*, $zones as node()*) as xs:string { - if (local-name($elems[1]) eq 'zone') - then - ($elems[1]/string(@xml:id)) - else - if (count($elems) > 1) + if (local-name($elems[1]) eq 'zone') then - ( - let $elemsSorted := for $elem in $elems - order by count($elem/preceding::*) - return - $elem - return - concat($elemsSorted[1]/@xml:id, '?tstamp2=', (count($elems) - 1), 'm+0') - ) + ($elems[1]/string(@xml:id)) else - ($elems[1]/string(@xml:id)) + if (count($elems) > 1) + then + ( + let $elemsSorted := for $elem in $elems + order by count($elem/preceding::*) + return + $elem + return + concat($elemsSorted[1]/@xml:id, '?tstamp2=', (count($elems) - 1), 'm+0') + ) + else + ($elems[1]/string(@xml:id)) }; declare function local:groupParticipants($participants as xs:string*, $doc as xs:string) as xs:string* { - - let $elems := for $p in $participants - let $id := substring-after($p, '#') - return - doc($doc)/id($id) - - let $zones := for $elem in $elems - return - local:getZone($elem) - - let $combs := for $p at $i in $participants - return - local:getCombinations($elems, $zones, $i, count($zones)) - - return - reverse( - for $comb at $i in reverse($combs) - let $contained := for $n in (1 to count($combs) - $i) + + let $elems := for $p in $participants + let $id := substring-after($p, '#') + return + doc($doc)/id($id) + + let $zones := for $elem in $elems return - if (contains($combs[$n], $comb)) - then - (1) - else - (0) + local:getZone($elem) + + let $combs := for $p at $i in $participants return - if (exists(index-of($contained, 1))) - then - () - else - ($comb) - ) + local:getCombinations($elems, $zones, $i, count($zones)) + + return + reverse( + for $comb at $i in reverse($combs) + let $contained := for $n in (1 to count($combs) - $i) + return + if (contains($combs[$n], $comb)) + then + (1) + else + (0) + return + if (exists(index-of($contained, 1))) + then + () + else + ($comb) + ) }; declare function local:getCombinations($elems as element()*, $zones as element()*, $i as xs:int, $total as xs:int) as xs:string { - - let $currentZone := $zones[$i] - let $currentElem := $elems[$i] - return - if (local-name($currentElem) eq 'measure' or local-name($currentElem) eq 'staff') - then - ( - string-join(( - string($i), - for $n in ($i + 1 to $total) - return - if ((local-name($elems[$n]) eq 'measure' or local-name($elems[$n]) eq 'staff') and local:compareZones($currentZone, $zones[$n])) + + let $currentZone := $zones[$i] + let $currentElem := $elems[$i] + return + if (local-name($currentElem) eq 'measure' or local-name($currentElem) eq 'staff') then - (local:getCombinations($elems, $zones, $n, $total)) + ( + string-join(( + string($i), + for $n in ($i + 1 to $total) + return + if ((local-name($elems[$n]) eq 'measure' or local-name($elems[$n]) eq 'staff') and local:compareZones($currentZone, $zones[$n])) + then + (local:getCombinations($elems, $zones, $n, $total)) + else + () + ), '-') + ) else - () - ), '-') - ) - else - ( - string($i) - ) + ( + string($i) + ) }; declare function local:compareZones($zone1 as element(), $zone2 as element()) as xs:boolean { - - let $samePage := deep-equal($zone1/.., $zone2/..) - let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) - return - $samePage and $overlapping + + let $samePage := deep-equal($zone1/.., $zone2/..) + let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) + return + $samePage and $overlapping }; declare function local:getElement($uri as xs:string) as element()? { - let $doc := substring-before($uri, '#') - let $id := substring-after($uri, '#') - - return - doc($doc)/id($id) + let $doc := substring-before($uri, '#') + let $id := substring-after($uri, '#') + + return + doc($doc)/id($id) }; (: TODO: in Modul auslagern :) @@ -280,32 +280,32 @@ declare function local:getElement($uri as xs:string) as element()? { @return The zone element :) declare function local:getZone($elem as element()) as element()? { - if ($elem/@facs) - then - ( - let $zoneId := replace($elem/@facs, '^#', '') - return - $elem/root()/id($zoneId) - ) - else - ( - $elem - ) + if ($elem/@facs) + then + ( + let $zoneId := replace($elem/@facs, '^#', '') + return + $elem/root()/id($zoneId) + ) + else + ( + $elem + ) }; (:~ : Returns type of a zone :) declare function local:getType($zones as element()*) as xs:string { - $zones[1]/@type (: TODO: besser machen :) + $zones[1]/@type (: TODO: besser machen :) }; declare function local:getBoundingZone($zones as element()*) as element() { - + }; (: TODO: in Modul auslagern :) @@ -313,31 +313,31 @@ declare function local:getBoundingZone($zones as element()*) as element() { :) declare function local:getImageAreaPath($basePath as xs:string, $graphic as element()?) as xs:string { - - let $imagePath := string($graphic/@target) - let $imgWidth := number($graphic/@width) - let $imgHeight := number($graphic/@height) - let $isAbsolute := starts-with($imagePath, 'http') - - let $fields := if ($imageserver = 'leaflet') then - (substring-before($imagePath, '.')) - else - () - - return - if ($isAbsolute) - then - $imagePath + + let $imagePath := string($graphic/@target) + let $imgWidth := number($graphic/@width) + let $imgHeight := number($graphic/@height) + let $isAbsolute := starts-with($imagePath, 'http') + + let $fields := if ($imageserver = 'leaflet') then + (substring-before($imagePath, '.')) else - switch ($imageserver) - case 'leaflet' - return - concat($basePath, $fields) - case 'openseadragon' - return - concat($basePath, translate($imagePath, '/', '!')) - default return - concat($basePath, $imagePath, '?') + () + + return + if ($isAbsolute) + then + $imagePath + else + switch ($imageserver) + case 'leaflet' + return + concat($basePath, $fields) + case 'openseadragon' + return + concat($basePath, translate($imagePath, '/', '!')) + default return + concat($basePath, $imagePath, '?') }; @@ -353,94 +353,94 @@ declare function local:getImageAreaPath($basePath as xs:string, $graphic as elem @return A URL pointing to an image based as xs:string :) declare function local:getImageAreaParams($zone as element()?, $imgWidth as xs:int, $imgHeight as xs:int) as xs:string { - let $graphic := $zone/../mei:graphic[@type = 'facsimile'] - - let $imgX := number($zone/@ulx) - let $imgY := number($zone/@uly) - let $w := number($zone/@lrx) - number($zone/@ulx) - let $h := number($zone/@lry) - number($zone/@uly) - - let $wx := $imgX div $imgWidth - let $wy := $imgY div $imgHeight - let $ww := $w div $imgWidth - let $wh := $h div $imgHeight - - return - concat('&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;mo=fit') + let $graphic := $zone/../mei:graphic[@type = 'facsimile'] + + let $imgX := number($zone/@ulx) + let $imgY := number($zone/@uly) + let $w := number($zone/@lrx) - number($zone/@ulx) + let $h := number($zone/@lry) - number($zone/@uly) + + let $wx := $imgX div $imgWidth + let $wy := $imgY div $imgHeight + let $ww := $w div $imgWidth + let $wh := $h div $imgHeight + + return + concat('&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;mo=fit') }; declare function local:getItemLabel($elems as element()*) as xs:string { - let $language := eutil:getLanguage($edition) - return - string-join( - for $type in distinct-values(for $elem in $elems + let $language := eutil:getLanguage($edition) return - local-name($elem)) - let $items := for $elem in $elems - return - if (local-name($elem) eq $type) then - ($elem) - else - () - let $itemLabelMultiRestSensitive := if ($items[1]//mei:multiRest) - then - ($items[1]/@n || '–' || number($items[1]/@n) + number($items[1]//mei:multiRest/@num) - 1) - else - ($items[1]/@n) - return - if (local-name($items[1]) eq 'measure') - then - ( - if (count($items) gt 1) - then - (eutil:getLanguageString('Bars_from_to', ($items[1]/@n, $items[last()]/@n), $language)) - else - (eutil:getLanguageString('Bar_n', $itemLabelMultiRestSensitive, $language)) - ) - else - if (local-name($items[1]) eq 'staff') - (: TODO: $itemLabelMultiRestSensitive also for staffs? :) - then - ( - if (count($items) gt 1) - then - ( - - let $measureNs := distinct-values($items/ancestor::mei:measure/@n) - - let $label := if ($lang = 'de') - then - (if (count($measureNs) gt 1) then - (concat('Takte ', $measureNs[1], '-', $measureNs[last()])) - else - (concat('Takt ', $measureNs[1]))) + string-join( + for $type in distinct-values(for $elem in $elems + return + local-name($elem)) + let $items := for $elem in $elems + return + if (local-name($elem) eq $type) then + ($elem) else - (if (count($measureNs) gt 1) then - (concat('Bars ', $measureNs[1], '-', $measureNs[last()])) - else - (concat('Bar ', $measureNs[1]))) - - return - - concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ', '), ')') - - ) - else - (concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')')) - ) + () + let $itemLabelMultiRestSensitive := if ($items[1]//mei:multiRest) + then + ($items[1]/@n || '–' || number($items[1]/@n) + number($items[1]//mei:multiRest/@num) - 1) else - if (local-name($items[1]) eq 'zone') - then - ( - if (count($items) gt 1) + ($items[1]/@n) + return + if (local-name($items[1]) eq 'measure') then - ((:Dieser Fall sollte nicht vorkommen, da freie zones nicht zusammengefasst werden dürfen:) ) + ( + if (count($items) gt 1) + then + (eutil:getLanguageString('Bars_from_to', ($items[1]/@n, $items[last()]/@n), $language)) + else + (eutil:getLanguageString('Bar_n', $itemLabelMultiRestSensitive, $language)) + ) else - (concat('Ausschnitt (S. ', $items[1]/parent::mei:surface/@n, ')')) - ) - else - () - , ' ') + if (local-name($items[1]) eq 'staff') + (: TODO: $itemLabelMultiRestSensitive also for staffs? :) + then + ( + if (count($items) gt 1) + then + ( + + let $measureNs := distinct-values($items/ancestor::mei:measure/@n) + + let $label := if ($lang = 'de') + then + (if (count($measureNs) gt 1) then + (concat('Takte ', $measureNs[1], '-', $measureNs[last()])) + else + (concat('Takt ', $measureNs[1]))) + else + (if (count($measureNs) gt 1) then + (concat('Bars ', $measureNs[1], '-', $measureNs[last()])) + else + (concat('Bar ', $measureNs[1]))) + + return + + concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ', '), ')') + + ) + else + (concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')')) + ) + else + if (local-name($items[1]) eq 'zone') + then + ( + if (count($items) gt 1) + then + ((:Dieser Fall sollte nicht vorkommen, da freie zones nicht zusammengefasst werden dürfen:) ) + else + (concat('Ausschnitt (S. ', $items[1]/parent::mei:surface/@n, ')')) + ) + else + () + , ' ') }; @@ -450,9 +450,9 @@ let $doc := doc($docUri) let $annot := $doc/id($internalId) let $map := map { - 'success': true(), - 'participants': array {local:getParticipants($annot)} + 'success': true(), + 'participants': array {local:getParticipants($annot)} } return - $map + $map From f5f25fa11edca42560cb7dc441348413847d404c Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 14:01:31 +0200 Subject: [PATCH 089/107] whitespace linting --- add/data/xql/getAnnotationPreviews.xql | 74 +++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 59d269fb1..ecae4be91 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -32,7 +32,7 @@ else (eutil:getPreference('image_prefix', $edition)); declare function local:getParticipants($annot as element()) as map(*)* { - + let $participants := tokenize($annot/string(@plist), ' ') let $docs := distinct-values(for $p in $participants return @@ -44,18 +44,18 @@ declare function local:getParticipants($annot as element()) as map(*)* { if (source:isSource($doc)) then (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - + else if (teitext:isText($doc)) then (local:getTextParticipants($participants[starts-with(., $doc)], $doc)) - + else () }; declare function local:getTextParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - + for $participant in $participants let $id := substring-after($participant, '#') let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) @@ -99,14 +99,14 @@ declare function local:getTextNotePrecedingContent($elem as element()) as xs:str }; declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - + let $combs := local:groupParticipants($participants, $doc) - + return - + for $comb in distinct-values($combs) let $partIndices := tokenize($comb, '-') - + let $elems := for $p in distinct-values($partIndices) let $relevant.participant := $participants[starts-with(., $doc)][number($p)] @@ -117,16 +117,16 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a order by count($elem/preceding::*) return $elem - + where count($elems) gt 0 - + let $zones := for $elem in $elems return local:getZone($elem) - + let $type := local:getType($zones) let $label := local:getItemLabel($elems) - + let $mdiv := '' (: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) let $page := if ($zones[1]/parent::mei:surface/@label != '') then ($zones[1]/parent::mei:surface/string(@label)) @@ -134,20 +134,20 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a ($zones[1]/parent::mei:surface/string(@n)) let $sourceLabel := source:getLabel($doc, $edition) let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() - + let $part := string-join(distinct-values(for $e in $elems return $e/ancestor::mei:part/string(@label)), '-') - + let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] let $imgWidth := number($graphic/@width) let $imgHeight := number($graphic/@height) - + let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) let $rect := local:getBoundingZone($zones) - + let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) - + let $hiddenData := map { 'width': number($rect/@lrx) - number($rect/@ulx), 'height': number($rect/@lry) - number($rect/@uly), @@ -156,9 +156,9 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a 'origH': $imgHeight, 'origW': $imgWidth } - + let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) - + return map { 'type': $type, @@ -197,20 +197,20 @@ declare function local:getSourceLinkTarget($elems as node()*, $zones as node()*) }; declare function local:groupParticipants($participants as xs:string*, $doc as xs:string) as xs:string* { - + let $elems := for $p in $participants let $id := substring-after($p, '#') return doc($doc)/id($id) - + let $zones := for $elem in $elems return local:getZone($elem) - + let $combs := for $p at $i in $participants return local:getCombinations($elems, $zones, $i, count($zones)) - + return reverse( for $comb at $i in reverse($combs) @@ -231,7 +231,7 @@ declare function local:groupParticipants($participants as xs:string*, $doc as xs }; declare function local:getCombinations($elems as element()*, $zones as element()*, $i as xs:int, $total as xs:int) as xs:string { - + let $currentZone := $zones[$i] let $currentElem := $elems[$i] return @@ -256,7 +256,7 @@ declare function local:getCombinations($elems as element()*, $zones as element() }; declare function local:compareZones($zone1 as element(), $zone2 as element()) as xs:boolean { - + let $samePage := deep-equal($zone1/.., $zone2/..) let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) return @@ -266,7 +266,7 @@ declare function local:compareZones($zone1 as element(), $zone2 as element()) as declare function local:getElement($uri as xs:string) as element()? { let $doc := substring-before($uri, '#') let $id := substring-after($uri, '#') - + return doc($doc)/id($id) }; @@ -313,17 +313,17 @@ declare function local:getBoundingZone($zones as element()*) as element() { :) declare function local:getImageAreaPath($basePath as xs:string, $graphic as element()?) as xs:string { - + let $imagePath := string($graphic/@target) let $imgWidth := number($graphic/@width) let $imgHeight := number($graphic/@height) let $isAbsolute := starts-with($imagePath, 'http') - + let $fields := if ($imageserver = 'leaflet') then (substring-before($imagePath, '.')) else () - + return if ($isAbsolute) then @@ -354,17 +354,17 @@ declare function local:getImageAreaPath($basePath as xs:string, $graphic as elem :) declare function local:getImageAreaParams($zone as element()?, $imgWidth as xs:int, $imgHeight as xs:int) as xs:string { let $graphic := $zone/../mei:graphic[@type = 'facsimile'] - + let $imgX := number($zone/@ulx) let $imgY := number($zone/@uly) let $w := number($zone/@lrx) - number($zone/@ulx) let $h := number($zone/@lry) - number($zone/@uly) - + let $wx := $imgX div $imgWidth let $wy := $imgY div $imgHeight let $ww := $w div $imgWidth let $wh := $h div $imgHeight - + return concat('&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;mo=fit') }; @@ -405,9 +405,9 @@ declare function local:getItemLabel($elems as element()*) as xs:string { if (count($items) gt 1) then ( - + let $measureNs := distinct-values($items/ancestor::mei:measure/@n) - + let $label := if ($lang = 'de') then (if (count($measureNs) gt 1) then @@ -419,11 +419,11 @@ declare function local:getItemLabel($elems as element()*) as xs:string { (concat('Bars ', $measureNs[1], '-', $measureNs[last()])) else (concat('Bar ', $measureNs[1]))) - + return - + concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ', '), ')') - + ) else (concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')')) From 9c2bf40574968eab9fb206caee49566d56fe5194 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 14:26:27 +0200 Subject: [PATCH 090/107] fix xquery version --- add/data/xqm/edition.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index f41b9c5eb..cc755e6b7 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -1,4 +1,4 @@ -xquery version "3.0"; +xquery version "3.1"; (: Edirom Online Copyright (C) 2011 The Edirom Project From 6dd0bd1c569458ae3aff0a01fcf56b091760a9fa Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 14:26:53 +0200 Subject: [PATCH 091/107] format and indent --- add/data/xqm/edition.xqm | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index cc755e6b7..e0859ffc7 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -28,10 +28,10 @@ xquery version "3.1"; :) module namespace edition = "http://www.edirom.de/xquery/edition"; -declare namespace edirom="http://www.edirom.de/ns/1.3"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace edirom = "http://www.edirom.de/ns/1.3"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -import module namespace functx="http://www.functx.com"; +import module namespace functx = "http://www.functx.com"; (:~ : Returns a JSON representation of an Edition : @@ -44,10 +44,10 @@ declare function edition:toJSON($uri as xs:string) as xs:string { return concat(' {', - 'id: "', $edition/string(@xml:id), '", ', - 'doc: "', $uri, '", ', - 'name: "', $edition/edirom:editionName, '"', - '}') + 'id: "', $edition/string(@xml:id), '", ', + 'doc: "', $uri, '", ', + 'name: "', $edition/edirom:editionName, '"', + '}') }; (:~ @@ -58,7 +58,8 @@ declare function edition:toJSON($uri as xs:string) as xs:string { declare function edition:getUris() as xs:string* { for $edition in collection('/db/apps')//edirom:edition - return 'xmldb:exist://' || document-uri($edition/root()) + return + 'xmldb:exist://' || document-uri($edition/root()) }; (:~ @@ -104,15 +105,19 @@ declare function edition:getPreferencesURI($uri as xs:string) as xs:string { : @return The URI of the Edition file :) declare function edition:findEdition($editionID as xs:string) as xs:string { - if($editionID eq '') - then( + if ($editionID eq '') + then + ( let $edition := (collection('/db/apps')//edirom:edition)[1] - return 'xmldb:exist://' || document-uri($edition/root()) - ) - else ( + return + 'xmldb:exist://' || document-uri($edition/root()) + ) + else + ( let $edition := collection('/db/apps')//edirom:edition/id($editionID) - return 'xmldb:exist://' || document-uri($edition/root()) - ) + return + 'xmldb:exist://' || document-uri($edition/root()) + ) }; (:~ @@ -122,7 +127,7 @@ declare function edition:findEdition($editionID as xs:string) as xs:string { : @return the text contents of edirom:edition/edirom:editionName :) declare function edition:getName($uri as xs:string) as xs:string { - doc($uri)/edirom:edition/edirom:editionName => fn:normalize-space() + doc($uri)/edirom:edition/edirom:editionName => fn:normalize-space() }; (:~ From 164471c73e4be65da410e82c1bf425872ff6e500 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 14:27:20 +0200 Subject: [PATCH 092/107] whitespace linting --- add/data/xqm/edition.xqm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index e0859ffc7..d4b3bfcba 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -39,7 +39,7 @@ import module namespace functx = "http://www.functx.com"; : @return The JSON representation :) declare function edition:toJSON($uri as xs:string) as xs:string { - + let $edition := doc($uri)/edirom:edition return concat(' @@ -56,7 +56,7 @@ declare function edition:toJSON($uri as xs:string) as xs:string { : @return The list of URIs :) declare function edition:getUris() as xs:string* { - + for $edition in collection('/db/apps')//edirom:edition return 'xmldb:exist://' || document-uri($edition/root()) @@ -69,7 +69,7 @@ declare function edition:getUris() as xs:string* { : @return The list of URIs :) declare function edition:getWorkUris($uri as xs:string) as xs:string* { - + doc($uri)//edirom:work/@xlink:href ! string(.) }; @@ -81,7 +81,7 @@ declare function edition:getWorkUris($uri as xs:string) as xs:string* { : @return The URI :) declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:string) as xs:string { - + doc($uri)//edirom:language[@xml:lang eq $lang]/@xlink:href => string() }; @@ -92,7 +92,7 @@ declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:strin : @return The URI :) declare function edition:getPreferencesURI($uri as xs:string) as xs:string { - + doc($uri)//edirom:preferences/@xlink:href => string() }; From d2eee08050ed2366c6fed8fcb5cb7bb846c5aa7d Mon Sep 17 00:00:00 2001 From: bwbohl Date: Thu, 1 Jun 2023 14:27:45 +0200 Subject: [PATCH 093/107] format and indent --- add/data/xqm/edition.xqm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/add/data/xqm/edition.xqm b/add/data/xqm/edition.xqm index d4b3bfcba..e0859ffc7 100644 --- a/add/data/xqm/edition.xqm +++ b/add/data/xqm/edition.xqm @@ -39,7 +39,7 @@ import module namespace functx = "http://www.functx.com"; : @return The JSON representation :) declare function edition:toJSON($uri as xs:string) as xs:string { - + let $edition := doc($uri)/edirom:edition return concat(' @@ -56,7 +56,7 @@ declare function edition:toJSON($uri as xs:string) as xs:string { : @return The list of URIs :) declare function edition:getUris() as xs:string* { - + for $edition in collection('/db/apps')//edirom:edition return 'xmldb:exist://' || document-uri($edition/root()) @@ -69,7 +69,7 @@ declare function edition:getUris() as xs:string* { : @return The list of URIs :) declare function edition:getWorkUris($uri as xs:string) as xs:string* { - + doc($uri)//edirom:work/@xlink:href ! string(.) }; @@ -81,7 +81,7 @@ declare function edition:getWorkUris($uri as xs:string) as xs:string* { : @return The URI :) declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:string) as xs:string { - + doc($uri)//edirom:language[@xml:lang eq $lang]/@xlink:href => string() }; @@ -92,7 +92,7 @@ declare function edition:getLanguageFileURI($uri as xs:string, $lang as xs:strin : @return The URI :) declare function edition:getPreferencesURI($uri as xs:string) as xs:string { - + doc($uri)//edirom:preferences/@xlink:href => string() }; From 0d3746eed07c1c54a51f835687c84c8934ab1e9a Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 28 Jun 2023 13:59:34 +0200 Subject: [PATCH 094/107] Update add/data/xslt/teiBody2HTML.xsl --- add/data/xslt/teiBody2HTML.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xslt/teiBody2HTML.xsl b/add/data/xslt/teiBody2HTML.xsl index 9a97c4404..7088b1507 100644 --- a/add/data/xslt/teiBody2HTML.xsl +++ b/add/data/xslt/teiBody2HTML.xsl @@ -3,7 +3,7 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" exclude-result-prefixes="#default xs tei xhtml" version="2.0"> - + From 2080be643264a0d5240b1d6f5d30dcf7196e2fd2 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 28 Jun 2023 13:59:41 +0200 Subject: [PATCH 095/107] Update add/data/xslt/ediromOnline_functions.xsl --- add/data/xslt/ediromOnline_functions.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xslt/ediromOnline_functions.xsl b/add/data/xslt/ediromOnline_functions.xsl index b23021590..1f4b00481 100644 --- a/add/data/xslt/ediromOnline_functions.xsl +++ b/add/data/xslt/ediromOnline_functions.xsl @@ -14,7 +14,7 @@ - + From bcd416ed394ba09b6c46c4afd1c34e42197f84ea Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Tue, 11 Jul 2023 13:48:25 +0200 Subject: [PATCH 096/107] Update add/data/xql/getAnnotationPreviews.xql --- add/data/xql/getAnnotationPreviews.xql | 1 - 1 file changed, 1 deletion(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 3f3f8cf19..6b0add534 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -11,7 +11,6 @@ For LICENSE-Details please refer to the LICENSE file in the root directory of th :) -import module namespace functx = "http://www.functx.com"; declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare namespace request = "http://exist-db.org/xquery/request"; From 3b8a4ab04788af94c6012877366c9e2562722d69 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Tue, 11 Jul 2023 13:49:20 +0200 Subject: [PATCH 097/107] Update add/data/xql/getAnnotationPreviews.xql --- add/data/xql/getAnnotationPreviews.xql | 1 - 1 file changed, 1 deletion(-) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 6b0add534..577b3e3ea 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -11,7 +11,6 @@ For LICENSE-Details please refer to the LICENSE file in the root directory of th :) - declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare namespace request = "http://exist-db.org/xquery/request"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; From e4575c318c1fa27c0a7500d0d9745d10d71bf334 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Tue, 11 Jul 2023 13:53:27 +0200 Subject: [PATCH 098/107] Update add/data/xql/getAnnotationInfos.xql --- add/data/xql/getAnnotationInfos.xql | 1 - 1 file changed, 1 deletion(-) diff --git a/add/data/xql/getAnnotationInfos.xql b/add/data/xql/getAnnotationInfos.xql index 9b41a213a..4b5775baf 100644 --- a/add/data/xql/getAnnotationInfos.xql +++ b/add/data/xql/getAnnotationInfos.xql @@ -13,7 +13,6 @@ import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/ut declare option output:method "json"; declare option output:media-type "application/json"; -declare variable $lang := request:get-parameter('lang', ''); declare variable $uri := request:get-parameter('uri', ''); declare variable $edition := request:get-parameter('edition', ''); declare variable $edition_path := eutil:getPreference('edition_path', $edition); From 630e177df229c0a1f6e6cfa4c8f0500761454446 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 07:30:10 +0000 Subject: [PATCH 099/107] Bump actions/upload-artifact from 3.1.2 to 3.1.3 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3.1.2...v3.1.3) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 0308d2d9e..cfe4f5a9a 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -31,7 +31,7 @@ jobs: - name: Upload Artifacts to action run if: github.repository == 'Edirom/Edirom-Online' - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v3.1.3 with: # The name that the artifact will be made available under name: EdiromOnline_${{ steps.short-sha.outputs.sha }}.zip From 5db658e4c1145d3e1769ac751d5a1e637be5cbdb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 07:30:14 +0000 Subject: [PATCH 100/107] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 0308d2d9e..d3c913994 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Chekout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get short sha uses: benjlevesque/short-sha@v2.2 From 92bc79ccff7c1ae7c6b05921ae579f137f5b6979 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 18 Oct 2023 14:58:13 +0200 Subject: [PATCH 101/107] temp fix: making toolbar partly transparent --- resources/css/verovio-view.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/css/verovio-view.css b/resources/css/verovio-view.css index 333f23ba2..1ba61c69d 100644 --- a/resources/css/verovio-view.css +++ b/resources/css/verovio-view.css @@ -17,7 +17,7 @@ body { left: 0; right: 0; bottom: 0; - background-color: #cccccc; + background-color: rgba(0, 0, 0, 10%); text-align: center; line-height: 2em; } From 27be3aed535e3acf7b2505ec06011a0578e05203 Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 18 Oct 2023 14:58:46 +0200 Subject: [PATCH 102/107] add height of rendering view to verovio css --- resources/css/todo.css | 8 +------- resources/css/verovio-view.css | 4 ++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/resources/css/todo.css b/resources/css/todo.css index fd7fe2e2c..b94fb4654 100644 --- a/resources/css/todo.css +++ b/resources/css/todo.css @@ -400,10 +400,4 @@ span#workSwitch-btnInnerEl:before { .x-menu-item-active { background-color: rgb(36, 145, 235) !important; color: rgb(161, 209, 247) !important; -} - -/* Verovio view */ - -.renderingViewContent { - height: 100%; -} +} \ No newline at end of file diff --git a/resources/css/verovio-view.css b/resources/css/verovio-view.css index 1ba61c69d..34a5a711e 100644 --- a/resources/css/verovio-view.css +++ b/resources/css/verovio-view.css @@ -27,6 +27,10 @@ body { font-size: 0.8em; } +.renderingViewContent { + height: 100%; +} + .annotTip { margin: 10px; } From 031652a23b652f930137ea2eb0f2e0deed55aafc Mon Sep 17 00:00:00 2001 From: Dennis Ried Date: Wed, 18 Oct 2023 17:57:19 +0200 Subject: [PATCH 103/107] hard code height, does not work with css --- app/view/window/image/VerovioImage.js | 2 +- resources/css/verovio-view.css | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/view/window/image/VerovioImage.js b/app/view/window/image/VerovioImage.js index 77a0cee90..366d79acc 100644 --- a/app/view/window/image/VerovioImage.js +++ b/app/view/window/image/VerovioImage.js @@ -25,7 +25,7 @@ Ext.define('EdiromOnline.view.window.image.VerovioImage', { var me = this; - me.html = '
'; me.callParent(); diff --git a/resources/css/verovio-view.css b/resources/css/verovio-view.css index 34a5a711e..1ba61c69d 100644 --- a/resources/css/verovio-view.css +++ b/resources/css/verovio-view.css @@ -27,10 +27,6 @@ body { font-size: 0.8em; } -.renderingViewContent { - height: 100%; -} - .annotTip { margin: 10px; } From 7a2357b48cf20f55be88fb086a15c29455e80f75 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Bohl" Date: Wed, 8 Nov 2023 14:36:23 +0100 Subject: [PATCH 104/107] fix typo --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 80e39c2f8..b69558814 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ ## xqDoc -We use [xqDoc](https://xqdoc.org) for documenting the XQueries in this repository. Please refer to the section [xqDoc Comments](https://xqdoc.org/xqdoc_comments_doc.html) of the xyDoc-website for details on formatting the documentation comment blocks. +We use [xqDoc](https://xqdoc.org) for documenting the XQueries in this repository. Please refer to the section [xqDoc Comments](https://xqdoc.org/xqdoc_comments_doc.html) of the xqDoc-website for details on formatting the documentation comment blocks. * XQuery modules must have a library module xqDoc comment preceding the module declaration. * Function declarations must have a library module xqDoc function comment preceding the function. @@ -55,4 +55,4 @@ For LICENSE-Details please refer to the LICENSE file in the root directory of th ### XQuery body -* Strings: escape with U+00027 APOSTROPHE: `'` \ No newline at end of file +* Strings: escape with U+00027 APOSTROPHE: `'` From 0c3d13844e3d44e50fd180fc421a427a77431d37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 07:40:08 +0000 Subject: [PATCH 105/107] Bump actions/upload-artifact from 3.1.3 to 4.3.0 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.3 to 4.3.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3.1.3...v4.3.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 92c23a9b0..a46ad5129 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -31,7 +31,7 @@ jobs: - name: Upload Artifacts to action run if: github.repository == 'Edirom/Edirom-Online' - uses: actions/upload-artifact@v3.1.3 + uses: actions/upload-artifact@v4.3.0 with: # The name that the artifact will be made available under name: EdiromOnline_${{ steps.short-sha.outputs.sha }}.zip From a0c617b74f69029f368ef582c60d0fe3ab050cef Mon Sep 17 00:00:00 2001 From: bwbohl Date: Mon, 5 Feb 2024 22:52:11 +0100 Subject: [PATCH 106/107] improve: renderingView fitting to window * revert some changes from #342 * move style definitions to eoTheme sass --- app/view/window/image/VerovioImage.js | 26 +++++++++---------- packages/eoTheme/sass/etc/all.scss | 9 ++++--- .../sass/etc/renderingViewContent.scss | 7 +++++ 3 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 packages/eoTheme/sass/etc/renderingViewContent.scss diff --git a/app/view/window/image/VerovioImage.js b/app/view/window/image/VerovioImage.js index 366d79acc..d22b01b91 100644 --- a/app/view/window/image/VerovioImage.js +++ b/app/view/window/image/VerovioImage.js @@ -18,36 +18,36 @@ */ Ext.define('EdiromOnline.view.window.image.VerovioImage', { extend: 'Ext.panel.Panel', - + layout: 'fit', - + initComponent: function () { - + var me = this; - - me.html = '
'; - + + me.html = '
'; + me.callParent(); }, - + setIFrameURL: function (url) { var me = this; var contEl = me.el.getById(me.id + '_rendContIFrame'); contEl.set({ 'src': url }); - + }, - + showMovement: function (movementId) { var me = this; - + var iframe = Ext.fly(me.id + '_rendContIFrame').dom.contentWindow; iframe.showMovement(movementId); }, - - /* + + /* * Call showMeasure of corresponding iframe. * @param {string} movementId - The XML-ID of the selected movement. * @param {string} measureId - The XML-ID of the selected measure. diff --git a/packages/eoTheme/sass/etc/all.scss b/packages/eoTheme/sass/etc/all.scss index afcb277a4..50a944a2b 100644 --- a/packages/eoTheme/sass/etc/all.scss +++ b/packages/eoTheme/sass/etc/all.scss @@ -1,11 +1,11 @@ -@import 'webfonts.scss'; +@import 'webfonts.scss'; @import 'mixins.scss'; /*Edirom*/ @import 'facsimile.scss'; @import 'xml.scss'; @import 'toolbar.scss'; - + //@import 'textViewContent.scss'; @import 'textView.scss'; @import 'headerView.scss'; @@ -16,4 +16,7 @@ @import 'freidi.scss'; /*Annotations*/ -@import 'annotation.scss'; \ No newline at end of file +@import 'annotation.scss'; + +/*renderingView (Verovio)*/ +@import 'renderingViewContent.scss' diff --git a/packages/eoTheme/sass/etc/renderingViewContent.scss b/packages/eoTheme/sass/etc/renderingViewContent.scss new file mode 100644 index 000000000..a9ef7c70a --- /dev/null +++ b/packages/eoTheme/sass/etc/renderingViewContent.scss @@ -0,0 +1,7 @@ +/* make verovio iFrame fit Edirom window */ +.renderingViewContent, .renderingViewContent iframe { + width: 100%; + height: 100%; + border: none; + overflow: hidden; +} From 628dc2b91e39e2e1328d6ac2afc45e2db77cc6b8 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Mon, 5 Feb 2024 23:24:27 +0100 Subject: [PATCH 107/107] fix: Edirom failing when checking for overrides of some requests * introduces an array with requests defined as non-overrideable * only issues a getPreference call if url is not part of that array --- app/controller/AJAXController.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controller/AJAXController.js b/app/controller/AJAXController.js index 4258fc2b1..94573d820 100644 --- a/app/controller/AJAXController.js +++ b/app/controller/AJAXController.js @@ -45,8 +45,18 @@ Ext.define('EdiromOnline.controller.AJAXController', { var lang = window.getLanguage(); params = Ext.applyIf(params, {lang: lang}); - - var override = window.getPreference(url, true); + + // define some requests that will make Edirom Online fail if it looks for an override + var doNotOverride = [ + 'data/xql/getEditionURI.xql', + 'data/xql/getPreferences.xql', + 'data/xql/getWorkID.xql', + ]; + + var override = null; + + if(doNotOverride.indexOf(url) == -1) + override = window.getPreference(url, true); if(override != null) url = override;