Skip to content

Commit

Permalink
Getting rid of Textgrid (#467)
Browse files Browse the repository at this point in the history
## Description, Context and related Issue
- Removed the function "eutil:getDoc" which is not necessary anymore
without Textgrid
- Removed Textgrid case from "eutil:getDoc" 
- Removed Textgrid case in an OR statement

<!--- This project only accepts pull requests related to open issues.
Please link to the issue here: -->
#322

## How Has This Been Tested?
Tested with the EditionExample.

## Types of changes
- Cleaning up

## Overview
- I have performed a self-review of my code, according to the [style
guide](https://github.com/Edirom/Edirom-Online/blob/develop/STYLE-GUIDE.md)
- I have read the
[CONTRIBUTING](https://github.com/Edirom/Edirom-Online/blob/develop/CONTRIBUTING.md)
document.
  • Loading branch information
DennisFriedl authored Nov 20, 2024
2 parents f8abab6 + 81e757e commit f1fd8ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
20 changes: 8 additions & 12 deletions add/data/xqm/util.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,19 @@ declare function eutil:getLocalizedTitle($node as node(), $lang as xs:string?) a
('[No title found!]')

};

(:~
: Returns a document
:
: @param $uri The URIs of the documents to process
: @return The document
:)
declare function eutil:getDoc($uri) {

if(starts-with($uri, 'textgrid:')) then(
let $session := request:get-cookie-value('edirom_online_textgrid_sessionId')
return
doc('http://textgridlab.org/1.0/tgcrud/rest/' || $uri || '/data?sessionId=' || $session)

) else (
doc($uri)
)

declare function eutil:getDoc($uri as xs:string?) as document-node()? {
if(empty($uri) or ($uri eq ""))
then util:log("warn", "No document URI provided")
else if(doc-available($uri))
then doc($uri)
else util:log("warn", "Unable to load document at " || $uri)
};

(:~
Expand Down Expand Up @@ -268,7 +264,7 @@ declare function eutil:getLanguageString($key as xs:string, $values as xs:string
declare function eutil:getLanguageString($key as xs:string, $values as xs:string*, $lang as xs:string) as xs:string {

let $base := system:get-module-load-path()
let $file := doc(concat($base, '/../locale/edirom-lang-', $lang, '.xml'))
let $file := eutil:getDoc(concat($base, '/../locale/edirom-lang-', $lang, '.xml'))

let $string := $file//entry[@key = $key]/string(@value)
let $string := functx:replace-multi($string, for $i in (0 to (count($values) - 1)) return concat('\{',$i,'\}'), $values)
Expand Down
2 changes: 1 addition & 1 deletion app/controller/LinkController.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Ext.define('EdiromOnline.controller.LinkController', {
}else if(singleUri.match(/^edirom:\/\//)) {
this.parseEdiromLink(singleUri);

}else if(singleUri.match(/^xmldb:exist:\/\//) || singleUri.match(/^textgrid:/)) {
}else if(singleUri.match(/^xmldb:exist:\/\//)) {

if(config['useExisting']) {
var win = existingWindows.findBy(function(win) {
Expand Down
11 changes: 11 additions & 0 deletions testing/XQSuite/eutil-tests.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ declare
function eut:test-getLocalizedTitle($node as element(), $lang as xs:string?) as xs:string {
eutil:getLocalizedTitle($node, $lang)
};

declare
%test:arg("uri") %test:assertEmpty
%test:arg("uri", "") %test:assertEmpty
%test:args("foo") %test:assertEmpty
%test:args("https://edirom.de") %test:assertXPath("/html")
%test:args("xmldb:exist://db/apps/Edirom-Online/data/locale/edirom-lang-de.xml") %test:assertXPath("/langFile")
%test:args("/db/apps/Edirom-Online/data/locale/edirom-lang-de.xml") %test:assertXPath("/langFile")
function eut:test-getDoc($uri as xs:string?) as document-node()? {
eutil:getDoc($uri)
};

0 comments on commit f1fd8ce

Please sign in to comment.