Skip to content

Commit 1783f19

Browse files
authored
Merge pull request #564 from dariok/24Q4
24Q4
2 parents ea30f74 + db30513 commit 1783f19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1569
-713
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ This framework still lacks a good name. If you have an idea, please let me know!
66

77
## Incompatible changes
88

9+
Release 24Q4 dropped another set of functions that were unused:
10+
- `wdb:getEdFromFileID( $id as xs:string )`: `(wdbFiles:getFullPath($id))?projectPath` returns the base path to `wdbmeta.xml`
11+
- `wdb:getMetaElementFromEd ( $ed as xs:string )`: use `doc( (doc("/db/apps/edoc/index/project-index.xml")/id($ed))/@path || '/wdbmeta.xml' )/id($ed)[self::meta:projectMD]` instead
12+
- `wdb:getMetaFile( $pathToEd )`: `(wdbFiles:getFullPath($ed))?projectPath` returns the base path to `wdbmeta.xml`
13+
- `wdb:getProjectPathFromId ( $ed )`: use `(wdbFiles:getFullPath($ed))?projectPath` instead
14+
915
Release 24Q2 dropped functions `wdb:getEdPath( $ed as xs:string , $absolute as xs:boolean() )`,
1016
`wdb:getEdPath( $ed as xs:string )`, and `wdb:findProjectXQM( $project )`. These queries can be replaced by
1117
`(wdbFiles:getFullPath($id))` which returns a map with `projectPath` (the path to the project, i.e. the collection where
12-
`project.xqm` is stored), `collectionPath` (for the subcollection where a file is actually located), `mainProject` for
18+
`wdbmeta.xml`¹ is stored), `collectionPath` (for the subcollection where a file is actually located), `mainProject` for
1319
the path to the project containing `project.xqm`, and `fileName`.
20+
1) (24Q4): this corrects a typo as previous versions incorrectly read `project.xqm`.
1421

1522
Release 24Q1 dropped support for METS-based projects. As METS files can have a number of very different ways of encoding
1623
information, especially when it comes to behaviours, native support is hard to achieve. At the same time, most

edoc/admin/admin.xqm

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ xquery version "3.1";
22

33
module namespace wdbAdmin = "https://github.com/dariok/wdbplus/Admin";
44

5-
(: note for code maintenance: as of 2024-04-10, this module uses the following exports from app.xqm:
6-
: - $wdb:data
7-
:)
8-
import module namespace templates = "http://exist-db.org/xquery/html-templating";
9-
import module namespace wdb = "https://github.com/dariok/wdbplus/wdb" at "/db/apps/edoc/modules/app.xqm";
10-
import module namespace wdbErr = "https://github.com/dariok/wdbplus/errors" at "/db/apps/edoc/modules/error.xqm";
11-
import module namespace wdbFiles = "https://github.com/dariok/wdbplus/files" at "/db/apps/edoc/modules/wdb-files.xqm";
5+
import module namespace config = "https://github.com/dariok/wdbplus/config" at "../modules/wdb-config.xml";
6+
import module namespace wdbErr = "https://github.com/dariok/wdbplus/errors" at "../modules/error.xqm";
7+
import module namespace wdbFiles = "https://github.com/dariok/wdbplus/files" at "../modules/wdb-files.xqm";
128

13-
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
14-
declare namespace sm = "http://exist-db.org/xquery/securitymanager";
9+
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
10+
declare namespace sm = "http://exist-db.org/xquery/securitymanager";
11+
declare namespace templates = "http://exist-db.org/xquery/html-templating";
12+
declare namespace wdb = "https://github.com/dariok/wdbplus/wdb";
1513

1614
(:~
1715
: populate the model for functions pages (similar but not identical to wdb:populateModel)
@@ -20,19 +18,17 @@ declare namespace sm = "http://exist-db.org/xquery/securitymanager";
2018
: @return The model
2119
:)
2220
declare
23-
%templates:default("ed", "")
21+
%templates:default("ed", "data")
2422
function wdbAdmin:start ( $node as node(), $model as map(*), $ed as xs:string ) {
2523
try {
26-
let $pathToEd := if ( $ed = "" )
27-
then $wdb:data
28-
else (wdbFiles:getFullPath($ed))?projectPath
24+
let $pathToEd := (wdbFiles:getFullPath($ed))?projectPath
2925

3026
(: The meta data are taken from wdbmeta.xml :)
3127
let $infoFileLoc := $pathToEd || "/wdbmeta.xml"
3228
, $title := normalize-space((doc($infoFileLoc)//meta:title)[1])
3329

3430
return map {
35-
"ed": if ( $pathToEd = $wdb:data ) then "data" else $ed,
31+
"ed": $ed,
3632
"infoFileLoc": $infoFileLoc,
3733
"page": substring-after(request:get-uri(), "admin/"),
3834
"pathToEd": $pathToEd,
@@ -92,10 +88,10 @@ declare function wdbAdmin:getAside ($node as node(), $model as map(*)) as elemen
9288
};
9389

9490
declare function wdbAdmin:css ( $node as node(), $model as map(*) ) as element()* {
95-
if ( unparsed-text-available($wdb:data || "/resources/wdb.css") )
91+
if ( unparsed-text-available($config:data || "/resources/wdb.css") )
9692
then <link rel="stylesheet" type="text/css" href="../data/resources/wdb.css" />
9793
else (),
98-
if ( unparsed-text-available($wdb:data || "/resources/admin.css") )
94+
if ( unparsed-text-available($config:data || "/resources/admin.css") )
9995
then <link rel="stylesheet" type="text/css" href="../data/resources/admin.css" />
10096
else ()
10197
};

edoc/admin/global.xqm

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@ xquery version "3.0";
22

33
module namespace wdbGS = "https://github.com/dariok/wdbplus/GlobalSettings";
44

5-
import module namespace wdb = "https://github.com/dariok/wdbplus/wdb" at "../modules/app.xqm";
6-
import module namespace console = "http://exist-db.org/xquery/console";
5+
import module namespace config = "https://github.com/dariok/wdbplus/config" at "../modules/wdb-config.xqm";
76

8-
declare namespace config = "https://github.com/dariok/wdbplus/config";
97
declare namespace exgit = "http://exist-db.org/xquery/exgit";
108
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
119
declare namespace system = "http://exist-db.org/xquery/system";
1210

13-
declare function wdbGS:getRest ( $node as node(), $model as map(*) ) {
14-
<meta name="rest" content="{$wdb:restURL}" />
11+
declare function wdbGS:getRest ( $node as node(), $model as map(*) ) as element(meta) {
12+
<meta name="rest" content="{ $config:restURL }" />
1513
};
1614

1715
declare function wdbGS:body ( $node as node(), $model as map(*) ) {
1816
let $param := request:get-parameter('job', 'main')
19-
let $metaFile := doc('../config.xml')
2017

2118
return switch ( $param )
2219
case 'main' return
@@ -32,24 +29,24 @@ declare function wdbGS:body ( $node as node(), $model as map(*) ) {
3229
</div>
3330

3431
case 'title' return
35-
local:titleForm($metaFile)
32+
local:titleForm($config:configFile)
3633

3734
case 'chgTitle' return
38-
let $u1 := update replace $metaFile//config:meta/config:name
35+
let $u1 := update replace $config:configFile//config:meta/config:name
3936
with <name xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('longTitle', '')}</name>
40-
let $u1 := update replace $metaFile//config:meta/config:short
37+
let $u1 := update replace $config:configFile//config:meta/config:short
4138
with <short xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('shortTitle', '')}</short>
42-
return local:titleForm($metaFile)
39+
return local:titleForm($config:configFile)
4340

4441
case 'role' return
45-
local:roleForm($metaFile)
42+
local:roleForm($config:configFile)
4643

4744
case 'chgRole' return
48-
let $u1 := update replace $metaFile//config:role/config:type
45+
let $u1 := update replace $config:configFile//config:role/config:type
4946
with <type xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('role', '')}</type>
50-
let $u1 := update replace $metaFile//config:role/config:other
47+
let $u1 := update replace $config:configFile//config:role/config:other
5148
with <other xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('other', '')}</other>
52-
return local:roleForm($metaFile)
49+
return local:roleForm($config:configFile)
5350

5451
default return
5552
<div>
@@ -58,23 +55,23 @@ declare function wdbGS:body ( $node as node(), $model as map(*) ) {
5855
</div>
5956
};
6057

61-
declare function local:titleForm($metaFile) {
58+
declare function local:titleForm($config:configFile) {
6259
<div>
6360
<h3>Titeldaten verändern</h3>
6461
<form action="global.html">
6562
<input type="hidden" name="job" value="chgTitle" />
6663
<label style="width: 100%">Titel: <input type="text" name="longTitle"
67-
value="{$metaFile//config:meta/config:name}" /></label><br />
64+
value="{$config:configFile//config:meta/config:name}" /></label><br />
6865
<label style="width: 100%">Kurztitel: <input type="text" name="shortTitle"
69-
value="{$metaFile//config:meta/config:short}" /></label><br />
66+
value="{$config:configFile//config:meta/config:short}" /></label><br />
7067
<input type="submit" />
7168
</form>
7269
</div>
7370
};
7471

75-
declare function local:roleForm($metaFile) {
76-
let $role := $metaFile//config:role/config:type
77-
let $other := $metaFile//config:role/config:other
72+
declare function local:roleForm($config:configFile) {
73+
let $role := $config:configFile//config:role/config:type
74+
let $other := $config:configFile//config:role/config:other
7875

7976
return
8077
<div>
@@ -85,7 +82,7 @@ declare function local:roleForm($metaFile) {
8582
<select name="role">
8683
<option value="standalone">{if ($role = 'standalone') then attribute selected {'selected'} else () }Standalone</option>
8784
<option value="workbench">{if ($role = 'workbench') then attribute selected {'selected'} else () }Workbench</option>
88-
<option value="publisher">{if ($role = 'publisher') then attribute selected {'selected'} else ()}Publikationsumgebung</option>
85+
<option value="publisher">{if ($role = 'publisher') then attribute selected {'selected'} else () }Publikationsumgebung</option>
8986
</select>
9087
</label><br />
9188
<label>zugehörige Instanz: <input type="text" name="other" value="{$other}" /></label><br />
@@ -95,5 +92,5 @@ declare function local:roleForm($metaFile) {
9592
};
9693

9794
declare function wdbGS:ingest($node as node(), $model as map(*)) {
98-
<a href="directoryForm.html?ed={doc($wdb:data || '/wdbmeta.xml')/meta:projectMD/@xml:id}">bestehendes Projekt hochladen</a>
99-
};
95+
<a href="directoryForm.html?ed={doc($config:data || '/wdbmeta.xml')/meta:projectMD/@xml:id}">bestehendes Projekt hochladen</a>
96+
};

edoc/admin/modelFunctions.xql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ xquery version "3.1";
22

33
module namespace trigger="http://exist-db.org/xquery/trigger";
44

5+
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
6+
declare namespace index = "https://github.com/dariok/wdbplus/index";
7+
58
declare function trigger:after-update-document ( $uri as xs:anyURI ) as xs:string {
69
if ( ends-with($uri, 'instance.xqm') or ends-with($uri, 'project.xqm') ) then
710
let $projectPath := if ( ends-with($uri, 'instance.xqm') )
@@ -12,5 +15,16 @@ declare function trigger:after-update-document ( $uri as xs:anyURI ) as xs:strin
1215
else 'project-functions.xml'
1316

1417
return xmldb:store($projectPath, $statFileName, inspect:inspect-module($uri))
18+
else if ( ends-with($uri, '.xml') and not(ends-with($uri, 'wdbmeta.xml')) ) then
19+
let $id := doc($uri)/*/@xml:id
20+
, $present := doc("/db/apps/edoc/index/file-index.xml")/id($id)
21+
, $entry := <file xmlns="https://github.com/dariok/wdbplus/index"
22+
xml:id="{ $id }"
23+
project="{ collection('/db/apps/edoc/data')/id($id)[self::meta:file] => base-uri() }"
24+
/>
25+
, $insert := if ( $present )
26+
then update replace $present with $entry
27+
else update insert $entry into doc("/db/apps/edoc/index/file-index.xml")/*
28+
return $uri
1529
else ""
1630
};

edoc/admin/new.xqm

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ xquery version "3.0";
22

33
module namespace wdbPN = "https://github.com/dariok/wdbplus/ProjectNew";
44

5-
import module namespace wdb = "https://github.com/dariok/wdbplus/wdb" at "/db/apps/edoc/modules/app.xqm";
6-
import module namespace wdbRc = "https://github.com/dariok/wdbplus/RestCollections" at "/db/apps/edoc/rest/rest-coll.xql";
7-
import module namespace sm = "http://exist-db.org/xquery/securitymanager";
5+
import module namespace config = "https://github.com/dariok/wdbplus/config" at "../modules/wdb-config.xqm";
6+
import module namespace wdbRc = "https://github.com/dariok/wdbplus/RestCollections" at "../rest/rest-coll.xql";
7+
import module namespace sm = "http://exist-db.org/xquery/securitymanager";
88

9-
declare namespace config = "https://github.com/dariok/wdbplus/config";
109
declare namespace http = "http://expath.org/ns/http-client";
1110
declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
1211
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
@@ -50,11 +49,11 @@ declare function wdbPN:body ( $node as node(), $model as map(*), $pName as xs:st
5049

5150
let $copy := if (system:function-available(xs:QName("xmldb:copy-collection"), 2))
5251
then util:eval("xmldb:copy-collection($source, $destination)", false(), (
53-
xs:QName("source"), $wdb:edocBaseDB || "/resources/xsl",
52+
xs:QName("source"), $config:edocBaseDB || "/resources/xsl",
5453
xs:QName("destination"), $collection-uri
5554
))
5655
else util:eval("xmldb:copy($source, $destination)", false(), (
57-
xs:QName("source"), $wdb:edocBaseDB || "/resources/xsl",
56+
xs:QName("source"), $config:edocBaseDB || "/resources/xsl",
5857
xs:QName("destination"), $collection-uri
5958
))
6059

0 commit comments

Comments
 (0)