diff --git a/.gitignore b/.gitignore
index ec6ca00a..0ab9b85d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ edoc/rest2/v2.json
# node-reladted stuff
node_modules/
+.codex
diff --git a/.gitmodules b/.gitmodules
index 12fc6c69..e86326c7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
-[submodule "edoc/include/xstring"]
- path = edoc/include/xstring
- url = https://github.com/dariok/XStringUtils
[submodule "edoc/include/wdbmeta"]
path = edoc/include/wdbmeta
url = https://github.com/dariok/wdbmeta
diff --git a/addins/do-not-remove b/edoc/addins/do-not-remove
similarity index 100%
rename from addins/do-not-remove
rename to edoc/addins/do-not-remove
diff --git a/edoc/admin/global.xqm b/edoc/admin/global.xqm
index 30a91cec..ecc8b735 100644
--- a/edoc/admin/global.xqm
+++ b/edoc/admin/global.xqm
@@ -9,7 +9,7 @@ declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
declare namespace system = "http://exist-db.org/xquery/system";
declare function wdbGS:getRest ( $node as node(), $model as map(*) ) as element(meta) {
-
+ $config:restMetaElement
};
declare function wdbGS:body ( $node as node(), $model as map(*) ) {
diff --git a/edoc/admin/project-template/wdbmeta.xml b/edoc/admin/project-template/wdbmeta.xml
index 06f46d70..d74ff535 100644
--- a/edoc/admin/project-template/wdbmeta.xml
+++ b/edoc/admin/project-template/wdbmeta.xml
@@ -37,10 +37,12 @@
- resources/xsl/tei-transcript.xsl
+
+ resources/xsl/tei-transcript.xsl
+
-
\ No newline at end of file
+
diff --git a/edoc/admin/projects.xqm b/edoc/admin/projects.xqm
index 020eec30..e6401017 100644
--- a/edoc/admin/projects.xqm
+++ b/edoc/admin/projects.xqm
@@ -6,7 +6,6 @@ import module namespace config = "https://github.com/dariok/wdbplus/config" at
import module namespace sm = "http://exist-db.org/xquery/securitymanager";
import module namespace wdbFiles = "https://github.com/dariok/wdbplus/files" at "../modules/wdb-files.xqm";
import module namespace wdbs = "https://github.com/dariok/wdbplus/stats" at "../modules/stats.xqm";
-import module namespace xstring = "https://github.com/dariok/XStringUtils" at "../include/xstring/string-pack.xql";
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
@@ -29,8 +28,10 @@ declare function wdbPL:body ( $node as node(), $model as map(*) ) {
let $metaFile := doc($metaPath)
let $relativePath := substring-after($file, $model?pathToEd || '/')
- let $subColl := xstring:substring-before-last($file, '/')
- let $resource := xstring:substring-after-last($file, '/')
+ let $subColl := if (starts-with($file, '/'))
+ then '/' || string-join(tokenize(normalize-space($file), '/')[position() lt last()], '/')
+ else string-join(tokenize(normalize-space($file), '/')[position() lt last()], '/')
+ let $resource := tokenize(normalize-space($file), '/')[last()]
let $fileEntry := $metaFile//meta:file[@path = $relativePath]
let $xml := doc($file)
@@ -187,7 +188,7 @@ declare %private function wdbPL:getFileStat( $model as map(*), $id as xs:string
Eintrag in wdbmeta.xml vorhanden? |
{if ($entry/@path != '')
then OK |
- else fehlt hinzufügen |
+ else fehlt |
}
{if ($entry/@path != '')
@@ -196,28 +197,31 @@ declare %private function wdbPL:getFileStat( $model as map(*), $id as xs:string
UUID in wdbMeta |
{if ($entry/@uuid = $uuid)
then OK: {$uuid} |
- else {normalize-space($entry/@uuid)} UUID aktualisieren |
+ else {normalize-space($entry/@uuid)}
+
|
}
,
| externe PID |
{if ($entry/@pid = $pid)
then "OK: " || string($entry/@pid)
- else PID aus Datei übernehmen
+ else
} |
,
| Timestamp in wdbMeta |
{if ($entry/@date = $date)
then OK: {$date} |
- else {normalize-space($entry/@date)} Timestamp aktualisieren |
+ else {normalize-space($entry/@date)}
+
|
}
,
@xml:id in wdbMeta |
{if ($entry/@xml:id = $doc/tei:TEI/@xml:id)
then OK: {$entry/@xml:id/string()} |
- else {normalize-space($entry/@xml:id)} ID aktualisieren |
+ else {normalize-space($entry/@xml:id)}
+
|
}
)
@@ -303,7 +307,7 @@ declare %private function wdbPL:getFileStat( $model as map(*), $id as xs:string
if ($status = 'Kein Struktureintrag') then
$status
else
- let $link := umschalten
+ let $link :=
return ($status,
, $link)
}
diff --git a/edoc/config.xml b/edoc/config.xml
index ed17041e..391c2e40 100644
--- a/edoc/config.xml
+++ b/edoc/config.xml
@@ -29,7 +29,7 @@
http://localhost:8080/exist/restxq/edoc/
- https://localhost/exist/apps/edoc/api/v2/
+ https://localhost/exist/apps/edoc
diff --git a/edoc/config/edoc/data/collection.xconf b/edoc/config/edoc/data/collection.xconf
index 0a993258..aafe121e 100644
--- a/edoc/config/edoc/data/collection.xconf
+++ b/edoc/config/edoc/data/collection.xconf
@@ -3,44 +3,32 @@
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -51,15 +39,23 @@
-
+
+
-
-
+
+
+
+
+
+
+
+
+
diff --git a/edoc/controller.xql b/edoc/controller.xql
index 3a974fc5..0f10113a 100644
--- a/edoc/controller.xql
+++ b/edoc/controller.xql
@@ -5,30 +5,30 @@
:)
xquery version "3.1";
-import module namespace login = "http://exist-db.org/xquery/login" at "resource:org/exist/xquery/modules/persistentlogin/login.xql";
-import module namespace request = "http://exist-db.org/xquery/request" at "java:org.exist.xquery.functions.request.RequestModule";
+import module namespace request = "http://exist-db.org/xquery/request" at "java:org.exist.xquery.functions.request.RequestModule";
declare namespace config = "https://github.com/dariok/wdbplus/config";
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
+declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
-(: declare variable $exist:root external; :)
+declare variable $exist:root external;
declare variable $local:isget := request:get-method() = ("GET","get");
declare variable $local:config := doc("/db/apps/edoc/config.xml")/config:config;
-util:log("info", request:get-method() || " " || request:get-url() || ' ? ' || request:get-query-string() || " -> resource: " || $exist:resource),
+(: util:log("info", "Request-Path: " || $exist:path || "; Resource: " || $exist:resource || "; Controller: " || $exist:controller || "; Prefix: " || $exist:prefix || "; Root: " || $exist:root), :)
+util:log("info", request:get-method() || " " || request:get-url() || ' ? ' || request:get-query-string() || " → resource: " || $exist:resource),
(: static HTML page for API documentation should be served directly to make sure it is always accessible :)
-if (
- ( $local:isget and $exist:resource = ('v2.json', 'apiv2.html') )
-) then
+if ( $local:isget and $exist:resource = ('v2.json', 'v2.html', 'v2.yaml') ) then
+
(: login :)
else if ( $exist:resource = 'login' ) then
@@ -41,23 +41,37 @@ else if ( $exist:resource = 'logout' ) then
+
(: REST API :)
else if ( contains($exist:path, 'api/v2') ) then
-
+
+ {
+ (: we currently need this workaround here as Jetty snatches all OPTIONS requests before they can be parsed by roaster :)
+ if ( request:get-method() = ('options', 'OPTIONS') and $local:config//config:origin = request:get-header('origin') )
+ then (
+ ,
+ ,
+ ,
+
+ )
+ else ()
+ }
+
+
+(: global index.html :)
else if ( $exist:resource eq '' or $exist:resource eq 'index.html' ) then
+
(: admin pages :)
else if ( ends-with($exist:resource, ".html") and contains($exist:path, '/admin/') ) then
- { login:set-user("wd", substring-before(request:get-uri(), $exist:path), xs:dayTimeDuration("P2D"), false()) }
-
-
+
@@ -75,34 +89,41 @@ else if ( ends-with($exist:resource, ".html") ) then
}
+
+
+
+
- (: generic resources :)
- else if ( contains($exist:path, "/$shared/") ) then
-
-
- {
- for $header in $local:config//config:header
- return { $header/@* }
- }
-
-
- (: instance specific resources :)
- else if ( contains($exist:path, "/$global/") ) then
-
-
- {
- for $header in $local:config//config:header
- return { $header/@* }
- }
-
-
-else if ( ends-with($exist:path, ".xql") ) then
+
+(: generic resources :)
+else if ( contains($exist:path, "/$shared/") ) then
+
+
+ {
+ for $header in $local:config//config:header
+ return { $header/@* }
+ }
+
+
+(: instance specific resources :)
+else if ( contains($exist:path, "/$global/") ) then
+
+
+ {
+ for $header in $local:config//config:header
+ return { $header/@* }
+ }
+
+
+
+else if ( ends-with($exist:path, ".xql") or ends-with($exist:path, ".xq") ) then
-else
+
(: everything else is passed through :)
+else
diff --git a/edoc/data/wdbmeta.xml b/edoc/data/wdbmeta.xml
index ca2cd1d0..1a412122 100644
--- a/edoc/data/wdbmeta.xml
+++ b/edoc/data/wdbmeta.xml
@@ -24,7 +24,9 @@
-
+
+
+
diff --git a/edoc/expath-pkg.xml b/edoc/expath-pkg.xml
index a643779e..62d3e393 100644
--- a/edoc/expath-pkg.xml
+++ b/edoc/expath-pkg.xml
@@ -2,5 +2,5 @@
W. Digitale Bibliothek
-
+
diff --git a/edoc/include/xstring b/edoc/include/xstring
deleted file mode 160000
index 161fa524..00000000
--- a/edoc/include/xstring
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 161fa52464122bff89c45f2b467ebb9383d00431
diff --git a/edoc/index/index-projects.xq b/edoc/index/index-projects.xq
index 693cd545..ff08a3ff 100644
--- a/edoc/index/index-projects.xq
+++ b/edoc/index/index-projects.xq
@@ -23,4 +23,5 @@ for $project in collection('/db/apps/edoc/data')//meta:projectMD
if ( not(empty($file-entries)) )
then update insert $file-entries into doc("/db/apps/edoc/index/file-index.xml")/index:index
else ()
- )
+ ),
+xmldb:reindex("/db/apps/edoc/index")
diff --git a/edoc/modules/app.xqm b/edoc/modules/app.xqm
index 0394c3e9..31c7319b 100644
--- a/edoc/modules/app.xqm
+++ b/edoc/modules/app.xqm
@@ -15,7 +15,6 @@ import module namespace config = "https://github.com/dariok/wdbplus/config"
import module namespace wdbErr = "https://github.com/dariok/wdbplus/errors" at "error.xqm";
import module namespace wdbFiles = "https://github.com/dariok/wdbplus/files" at "wdb-files.xqm";
import module namespace wdbPF = "https://github.com/dariok/wdbplus/projectFiles" at "../data/instance.xqm";
-import module namespace xstring = "https://github.com/dariok/XStringUtils" at "../include/xstring/string-pack.xql";
declare namespace main = "https://github.com/dariok/wdbplus";
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
@@ -118,7 +117,12 @@ declare function wdb:getAbsolutePath ( $ed as xs:string, $path as xs:string ) {
: @return the path
:)
declare function wdb:getEdFromPath($path as xs:string, $absolute as xs:boolean) as xs:string {
- let $tok := tokenize(xstring:substring-after($path, $config:edocBaseDB||'/'), '/')
+ let $tok := tokenize(
+ if (contains($path, $config:edocBaseDB || '/'))
+ then substring-after($path, $config:edocBaseDB || '/')
+ else $path,
+ '/'
+ )
let $pa := for $i in 1 to count($tok)
let $t := $config:edocBaseDB || '.*' || string-join ($tok[position() < $i+1], '/')
@@ -206,7 +210,12 @@ declare function wdb:findProjectFile ( $path as xs:string, $fileName as xs:strin
else if ( substring-after($path, $config:data) = '' ) then
xs:anyURI("")
else
- wdb:findProjectFile(xstring:substring-before-last($path, '/'), $fileName)
+ wdb:findProjectFile(
+ if (starts-with($path, '/'))
+ then '/' || string-join(tokenize(normalize-space($path), '/')[position() lt last()], '/')
+ else string-join(tokenize(normalize-space($path), '/')[position() lt last()], '/'),
+ $fileName
+ )
};
(: END FUNCTIONS DEALING WITH PROJECTS AND RESOURCES :)
@@ -240,8 +249,10 @@ declare function wdb:eval($function as xs:string, $cache-flag as xs:boolean, $ex
: @param $infoFileLoc The location of the wdbmeta.xml file
: @param $view (optional) a view parameter for selecting the right process
:
- : @returns The path to the XSLT
+ : @returns A command (should be: a process with 1+ command)
:)
+(: TODO: rename to "getProcessFromWdbmeta" or simply "getProcess" :)
+(: TODO: change to actually get a process with 1+ command, see comment below :)
declare function wdb:getXslFromWdbMeta ( $infoFileLoc as xs:string, $id as xs:string, $target as xs:string ) as element(process)? {
wdb:getXslFromWdbMeta($infoFileLoc, $id, $target, "")
};
@@ -250,49 +261,46 @@ declare function wdb:getXslFromWdbMeta ( $infoFileLoc as xs:string, $id as xs:st
, $process := if ( $view != '' )
then $metaFile//meta:process[@target = $target and @view = $view]
else $metaFile//meta:process[@target = $target and not(@view)]
- , $base := if ( count($process) = 1 )
- then substring-before(base-uri($metaFile), 'wdbmeta.xml')
- else if ( count($process) = 0 )
- then error(
- QName('wdbRErr', 'wdb0002'),
- "no process found for id " || $id || ", target '" || $target || "' and view '" || $view || "' in " || $infoFileLoc
- )
- else error(
- QName('wdbRErr', 'wdb0012'),
- "multiple processes found for id " || $id || ", target '" || $target || "' and view '" || $view || "' in " || $infoFileLoc
- )
+ , $base := substring-before(base-uri($metaFile), 'wdbmeta.xml')
let $sel := if ( $process/meta:command )
then
+ (: A command contains 1+ steps; we check command/@* to find the correct command and return it :)
for $c in $process/meta:command
return if ( $c/@refs ) then
(: if a list of IDREFS is given, this command matches if $id is part of that list :)
let $map := tokenize($c/@refs, ' ')
- return if ( $map = $id ) then $base || $c else ()
+ return if ( $map = $id ) then $c else ()
else if ( $c/@regex and matches($id, $c/@regex) )
(: if a regex is given and $id matches that regex, the command matches :)
- then $base || $c
+ then $c
else if ( $c/@group and $metaFile/id($id)/parent::meta:filegroup/@xml:id = $c/@group )
- then $base || $c
+ then $c
else if ( not($c/@refs or $c/@regex or $c/@group) )
(: if no selection method is given, the command is considered the default :)
- then $base || $c
+ then $c
else () (: neither refs nor regex match and no default given :)
(: if no command is defined, traverse up the project ancestors :)
else if ( $metaFile/meta:projectMD/meta:struct/*[1][self::meta:import] ) then
- let $path := xstring:substring-before-last($infoFileLoc, '/')
+ let $path := if (starts-with($infoFileLoc, '/'))
+ then '/' || string-join(tokenize(normalize-space($infoFileLoc), '/')[position() lt last()], '/')
+ else string-join(tokenize(normalize-space($infoFileLoc), '/')[position() lt last()], '/')
, $parent := $metaFile/meta:projectMD/meta:struct/meta:import
return
wdb:getXslFromWdbMeta ($path || '/' || $parent/@path, $id, $target, $view)
else ()
- (: As we check from most specific to default, the first command in the sequence is the right one :)
- return if ( $sel[1] instance of element(meta:process) )
+ (: As we check from most specific to default, the first command in the sequence is the right one.
+ We add the base-uri as attribute to the command so the path can later be evaluated :)
+ return if ( $sel[1] instance of element(meta:command) )
+ then
+ {
+ for $step in $sel[1]/*
+ return { $base || normalize-space($step) }
+ }
+
+ else if ( $sel[1] instance of element(meta:process) )
then $sel[1]
- else if ( $sel[1] instance of xs:string )
- then
- {$sel[1]}
-
else
error(
QName('wdbRErr', 'wdb0002'),
@@ -314,8 +322,8 @@ declare function wdb:getXslFromWdbMeta ( $infoFileLoc as xs:string, $id as xs:st
: 2) instance resources
: 3) global resources
:)
-declare function wdb:applySpecificXsl ( $xml as node(), $edPath as xs:string, $name as xs:string ) as node() {
- wdb:applySpecificXsl($xml, $edPath, $name, ())
+declare function wdb:applySpecificXsl ( $xml as node(), $pathInfo as map(*), $name as xs:string ) as node() {
+ wdb:applySpecificXsl($xml, $pathInfo, $name, ())
};
(:~
: Apply a project specific XSLT to some XML
@@ -332,15 +340,15 @@ declare function wdb:applySpecificXsl ( $xml as node(), $edPath as xs:string, $n
: 2) instance resources
: 3) global resources
:)
-declare function wdb:applySpecificXsl ( $xml as node(), $edPath as xs:string, $name as xs:string, $parameters as element(parameters)? ) as node() {
- let $xsl := if ( doc-available($edPath || "/resources/xsl/" || $name) ) then
- doc($edPath || "/resources/xsl/" || $name)
+declare function wdb:applySpecificXsl ( $xml as node(), $pathInfo as map(*), $name as xs:string, $parameters as element(parameters)? ) as node() {
+ let $xsl := if ( doc-available($pathInfo?mainProject || "resources/xsl/" || $name) ) then
+ doc($pathInfo?mainProject || "resources/xsl/" || $name)
else if ( doc-available("/db/apps/edoc/data/resources/xsl/" || $name) ) then
doc("/db/apps/edoc/data/resources/xsl/" || $name)
else
doc("/db/apps/edoc/resources/xsl/" || $name)
-
- return transform:transform($xml, $xsl, $parameters)
+
+ return transform:transform($xml, $xsl, $parameters)
};
(: END LOCAL HELPER FUNCTIONS :)
diff --git a/edoc/modules/auth.xqm b/edoc/modules/auth.xqm
index a102274f..2f282a4d 100644
--- a/edoc/modules/auth.xqm
+++ b/edoc/modules/auth.xqm
@@ -9,7 +9,7 @@ declare function wdba:getAuth ( $node as node(), $model as map(*) ) as element(d
return if ( $current = 'guest' or $model?res = 'logout' ) then
-
+