Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Getting rid of Textgrid #467

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
};