Skip to content

Commit

Permalink
Merge branch 'develop' into ftr/measure-label-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Dec 18, 2024
2 parents c9ed32f + 353f83a commit b45c7b5
Show file tree
Hide file tree
Showing 18 changed files with 912 additions and 1,989 deletions.
1 change: 0 additions & 1 deletion add/controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ return
(: forward index.html to index.xql :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="index.xql">
<set-header name="Set-Cookie" value="edirom-language={$langVal}" />
<add-parameter name="lang" value="{$langVal}"/>
</forward>
</dispatch>
Expand Down
15 changes: 8 additions & 7 deletions add/data/locale/edirom-lang-de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
<entry key="view.desktop.TaskBar_Desktop" value="Desktop {0}"/>
<entry key="view.desktop.TaskBar_searchWin" value="Öffne Suchfenster"/>
<entry key="view.desktop.TaskBar_Sort_grid" value="Im Raster anordnen"/>
<entry key="view.desktop.TaskBar_Sort_vertical" value="Übereinander anordnen"/>
<entry key="view.desktop.TaskBar_Sort_horizontal" value="Nebeneinander anordnen"/>
<entry key="view.desktop.TaskBar_Sort_vertical" value="Nebeneinander anordnen"/>
<entry key="view.desktop.TaskBar_Sort_horizontal" value="Übereinander anordnen"/>
<entry key="view.desktop.TopBar_homeBtnLabel" value="Edirom Online"/>
<entry key="view.window.AnnotationView_Title" value="Anmerkungen"/>
<entry key="view.window.AnnotationView_No" value="Nr."/>
Expand Down Expand Up @@ -138,14 +138,14 @@

<!-- naming gui elements -->
<entry key="view.desktop.Desktop" value="Desktop"/>
<entry key="view.desktop.TopBar" value="Symbolleiste"/>
<entry key="view.desktop.TopBar" value="Toolbar"/>
<entry key="view.desktop.TopBar_searchField" value="Suchfeld"/>
<entry key="view.desktop.TopBar_homeBtn" value="{key=view.desktop.TaskBar_home} Button"/>
<entry key="view.desktop.TaskBar" value="Task-Leiste"/>
<entry key="view.desktop.TaskBar" value="Taskbar"/>
<entry key="view.desktop.TaskBar_btnDesktop" value="Button der Task-Leiste"/>
<entry key="view.window.TopBar" value="Symbolleiste im Fenster"/>
<entry key="view.window.BottomBar" value="Task-Leiste im Fenster"/>
<entry key="view.navigator.Navigator" value="Navigator"/>
<entry key="view.window.TopBar" value="Fenster-Toolbar"/>
<entry key="view.window.BottomBar" value="Fenster-Taskleiste"/>
<entry key="view.navigator.Navigator" value="Inhaltsübersicht"/>
<entry key="global_appName" value="Edirom Online"/>
<entry key="clickAndHoldDragging" value="dragging"/>
<entry key="drag-and-drop" value="Drag-and-Drop"/>
Expand Down Expand Up @@ -178,6 +178,7 @@
<entry key="Annotation_plus_Title" value="Anmerkung: {0}"/>
<entry key="Bars_from_to" value="Takte {0} bis {1}"/>
<entry key="Bar_n" value="Takt {0}"/>
<entry key="Bar" value="Takt"/>
<!-- XSL-FO specific -->
<entry key="contentsWord" value="Inhaltsverzeichnis"/>

Expand Down
3 changes: 2 additions & 1 deletion add/data/locale/edirom-lang-en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<entry key="view.desktop.TaskBar_btnDesktop" value="Taskbar"/>
<entry key="view.window.TopBar" value="Window toolbar"/>
<entry key="view.window.BottomBar" value="Window taskbar"/>
<entry key="view.navigator.Navigator" value="Navigator"/>
<entry key="view.navigator.Navigator" value="Content overview"/>
<entry key="global_appName" value="Edirom Online"/>
<entry key="clickAndHoldDragging" value="dragging"/>
<entry key="drag-and-drop" value="drag-and-drop"/>
Expand Down Expand Up @@ -177,6 +177,7 @@
<entry key="Annotation_plus_Title" value="Annotation: {0}"/>
<entry key="Bars_from_to" value="Bars {0} to {1}"/>
<entry key="Bar_n" value="Bar {0}"/>
<entry key="Bar" value="bar"/>
<!-- XSL-FO specific -->
<entry key="contentsWord" value="Table of contents"/>

Expand Down
1 change: 1 addition & 0 deletions add/data/prefs/edirom-prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<entry key="image_server" value="digilib"/>
<entry key="edition_path" value="/db/apps/contents"/>
<entry key="start_documents_uri" value=""/>
<entry key="gotomenu_display" value="partwise"/>
</entries>
</prefs>
18 changes: 6 additions & 12 deletions add/data/xql/getAnnotationInfos.xql
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,28 @@ xquery version "3.1";
(: IMPORTS ================================================================= :)

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

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


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

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";


(: OPTION DECLARATIONS ===================================================== :)

declare option output:method "json";

declare option output:media-type "application/json";


(: VARIABLE DECLARATIONS =================================================== :)

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

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

declare variable $edition_path := eutil:getPreference('edition_path', $edition);


(: FUNCTION DECLARATIONS =================================================== :)

Expand Down Expand Up @@ -89,13 +83,13 @@ declare function local:getDistinctPriorities($annots as element()*) as xs:string

(: QUERY BODY ============================================================== :)

let $mei := doc($uri)/root()

let $annots := collection($edition_path)//mei:annot[matches(@plist, $uri)] | $mei//mei:annot
let $mei := doc($uri)
let $editionCollection := edition:collection($edition)
let $annots := $editionCollection//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 $categoryElement := ($editionCollection/id($category)[mei:label or mei:name])[1]
let $name := annotation:category_getName($categoryElement, eutil:getLanguage($edition))
order by $name
return
Expand All @@ -106,7 +100,7 @@ let $categories :=

let $prios :=
for $priority in local:getDistinctPriorities($annots)
let $name := annotation:getPriorityLabel((collection($edition_path)//id($priority)[mei:label or mei:name])[1])
let $name := annotation:getPriorityLabel(($editionCollection/id($priority)[mei:label or mei:name])[1])
order by $name
return
map {
Expand Down
9 changes: 6 additions & 3 deletions add/data/xql/getAnnotationsInText.xql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace request = "http://exist-db.org/xquery/request";
declare namespace xlink = "http://www.w3.org/1999/xlink";
declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
import module namespace eutil = "http://www.edirom.de/xquery/eutil" at "../xqm/eutil.xqm";


(: OPTION DECLARATIONS ===================================================== :)

Expand All @@ -29,10 +31,10 @@ declare option output:media-type "application/json";
@param $elems The elements to check (most likely measures and zones)
@returns A sequence of annotation elements
:)
declare function local:findAnnotations($uri as xs:string) as element(mei:annot)* {
declare function local:findAnnotations($uri as xs:string, $edition as xs:string) as element(mei:annot)* {

(: TODO: check if annotations hold URIs or IDRefs :)
collection('/db/contents')//mei:annot[matches(@plist, $uri)]
edition:collection($edition)//mei:annot[matches(@plist, $uri)]
};

declare function local:getAnnotations($uriSharp as xs:string, $annotations as element()*) as array(*)* {
Expand Down Expand Up @@ -65,9 +67,10 @@ declare function local:getAnnotations($uriSharp as xs:string, $annotations as el
}
};

let $edition := request:get-parameter('edition', '')
let $uri := request:get-parameter('uri', '')
let $uriSharp := concat($uri, '#')
let $annotations := local:findAnnotations($uri)
let $annotations := local:findAnnotations($uri,$edition)

return
local:getAnnotations($uriSharp, $annotations)
10 changes: 2 additions & 8 deletions add/data/xql/getAnnotationsOnPage.xql
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,24 @@ xquery version "3.1";

import module namespace functx = "http://www.functx.com";

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


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

declare namespace ft = "http://exist-db.org/xquery/lucene";

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 namespace svg = "http://www.w3.org/2000/svg";

declare namespace xlink = "http://www.w3.org/1999/xlink";

declare namespace xmldb = "http://exist-db.org/xquery/xmldb";


(: OPTION DECLARATIONS ===================================================== :)

declare option output:method "json";

declare option output:media-type "application/json";


Expand Down Expand Up @@ -108,7 +102,7 @@ declare function local:findAnnotations($edition as xs:string, $uri as xs:string,

(: TODO: search in other documents and in other collections :)
(: TODO: check if annotations hold URIs or IDRefs :)
let $annots := collection(eutil:getPreference('edition_path', $edition))//mei:annot
let $annots := edition:collection($edition)//mei:annot
let $ret :=
for $id in $elemIds

Expand Down
7 changes: 5 additions & 2 deletions add/data/xql/getHelp.xql
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ declare option output:omit-xml-declaration "yes";

let $lang := request:get-parameter('lang', 'en')
let $idPrefix := request:get-parameter('idPrefix', '')
let $contextPath := request:get-context-path()

let $base := replace(system:get-module-load-path(), 'embedded-eXist-server', '') (:TODO:)

let $doc := doc(concat('../../help/help_', $lang, '.xml'))
let $contextPath := if(starts-with(document-uri($doc), '/db'))
then substring-after(document-uri($doc), '/db')
else document-uri($doc)
let $contextPath := substring-before($contextPath, concat('help/help_', $lang, '.xml'))
let $contextPath := request:get-context-path() || $contextPath

let $xsl := doc('../xslt/edirom_langReplacement.xsl')
let $doc :=
Expand All @@ -43,7 +47,6 @@ let $doc :=
<param name="base" value="{concat($base, '/../xslt/')}"/>
<param name="lang" value="{$lang}"/>
<param name="tocDepth" value="1"/>
<param name="graphicsPrefix" value="help/"/>
<param name="contextPath" value="{$contextPath}"/>
(: == passing empty value for docUri (XSLT expects xs:anyURI, but ExtJS view does not provide value) -> github#480 == :)
<param name="docUri" value="''"/>
Expand Down
2 changes: 1 addition & 1 deletion add/data/xql/getLinkTarget.xql
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ declare function local:getViews($type as xs:string, $docUri as xs:string, $doc a
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
if (exists($doc//mei:mei) and exists($doc//(mei:workDesc|mei:workList)/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))
Expand Down
11 changes: 10 additions & 1 deletion add/data/xql/getMovements.xql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ let $movements as array(*)* :=
return
map {
'id': $movement/string(@xml:id),
'name': $movement/string(@label)
'name': $movement/string(@label),
'parts': array {
for $part in $movement//mei:part
return
map {
'id': $part/string(@xml:id),
'name': $part/string(@label)
}
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion add/data/xqm/annotation.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ declare function annotation:toJSON($anno as element(), $edition as xs:string) as
if(doc-available($p)) then
(doc($p))
else
(collection(eutil:getPreference('edition_path', $edition))//id($p)/root())
edition:collection($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())
Expand Down
30 changes: 17 additions & 13 deletions add/data/xqm/eutil.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,22 @@ declare function eutil:getLanguageString($key as xs:string, $values as xs:string
: @param $edition The current edition URI
: @return The preference value
:)
declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string {
declare function eutil:getPreference($key as xs:string, $edition as xs:string?) as xs:string? {

let $preferencesFile :=
(: Try to load a custom preferences file :)
let $prefFileCustom :=
try { doc(edition:getPreferencesURI($edition)) }
catch * { util:log-system-out('Failed to load preferences') }

catch * { util:log-system-out('Failed to load the custom preferences file') }
return
$preferencesFile//entry[@key = $key]/@value => string()

(: If there is a value for the key in the custom preferences file :)
if($prefFileCustom//entry/@key = $key) then
$prefFileCustom//entry[@key = $key]/@value => string()
(: If not, take the value for the key in the default preferences file :)
else
try { doc($edition:default-prefs-location)//entry[@key = $key]/@value => string() }
(: If the key is not in the default file, then there should be an error :)
catch * { util:log-system-out(concat('Failed to find the key `', $key, '` in default preferences file')) }
};

(:~
Expand All @@ -307,16 +314,13 @@ declare function eutil:getPreference($key as xs:string, $edition as xs:string?)
: @return The language key
:)
declare function eutil:getLanguage($edition as xs:string?) as xs:string {

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
else if(eutil:getPreference('application_language', edition:findEdition($edition))) then
eutil:getPreference('application_language', edition:findEdition($edition))

else
'de'
};

(:~
Expand Down
Loading

0 comments on commit b45c7b5

Please sign in to comment.