Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
f2f3f96
automatic changes to workspace
dariok Apr 3, 2024
dd2f305
prep some stuff
dariok Apr 9, 2024
0bdeca5
no error handlet for calls to *.html
dariok Apr 9, 2024
c28fbb2
404 page if file ID not found
dariok Apr 9, 2024
0da4370
Improve selection of MD when getting file path
dariok Apr 10, 2024
32c4085
re-enable creating a view for meta:struct[@xml:id]
dariok Apr 10, 2024
e5f4ccd
remove unused file
dariok Apr 10, 2024
2c97c36
replace wdb:getEdPath() by wdbFiles:getFullPath() where possibl
dariok Apr 11, 2024
f0fe264
view of meta:struct : add struct ID to file name
dariok Apr 15, 2024
c945f8c
Apply config to /admin, too
dariok Apr 22, 2024
2d3e6a9
toc.html: full link to admin functions
dariok Apr 22, 2024
dc248cc
Fix typo in namespace prefix
dariok May 17, 2024
69de5fc
add “sponsors”
dariok May 17, 2024
b838126
wdbFile to wdbFiles
WunschK May 21, 2024
def6d94
Fix typo in module namespace prefix
dariok May 21, 2024
627c7eb
Merge branch '24Q2' of github.com:dariok/wdbplus into 24Q2
dariok May 21, 2024
f30cbe0
remove wdb:getProjectXQM()
dariok May 22, 2024
cac7643
Entity processing is done entirely in entity.xqm
dariok May 22, 2024
462735d
return index entries for books
dariok Jun 12, 2024
f818f42
view: prepare methods other than GET
dariok Jun 14, 2024
f63f488
revert typo in docu string
dariok Jul 1, 2024
f65913d
support HTTP HEAD method
dariok Jul 1, 2024
2087145
stylebook conformance
dariok Jul 1, 2024
2b83409
Merge pull request #558 from dariok/24Q2
dariok Jul 4, 2024
2599c04
improve positioning of marginalia
dariok Jul 4, 2024
12661b5
Admin: short stats for mass uploads
dariok Jul 31, 2024
7807b2b
Model for a project in function.xqm uses correct path data
dariok Jul 31, 2024
c845f29
fix wrong param in getFullPath() for collection
dariok Aug 2, 2024
2e9c414
bug fixes when using getPullPath()
dariok Aug 2, 2024
f34881b
provide module path for wdbFiles
dariok Aug 2, 2024
ccfd1d7
do not order collection search results
dariok Aug 2, 2024
8108252
find XSLT by traversing up the project tree
dariok Aug 20, 2024
160bd68
set basic variables from config file only
dariok Oct 23, 2024
1551dea
Use $ed for collection IDs
dariok Oct 23, 2024
d7912fe
A few additional REST tests
dariok Oct 23, 2024
1a40e73
Also include wdbmeta in project workspace
dariok Oct 23, 2024
f5c528e
Create index files for file and collection info
dariok Oct 24, 2024
f1ad06e
Use file or project index instead of collection() where possible
dariok Oct 24, 2024
92730b3
prepare openAPI description for REST v2
dariok Oct 30, 2024
a925bc6
openAPI: define methods
dariok Oct 30, 2024
590be29
OpenAPI: add summaries to methods
dariok Oct 30, 2024
960cc7f
openAPI: prepare operationIDs
dariok Oct 30, 2024
12ea837
add “delete file” to API definition
dariok Nov 6, 2024
5a6dc49
openAPI: prepare requestBody statements
dariok Nov 6, 2024
c0d0c8c
openAPI: use refs for common path parameters
dariok Nov 6, 2024
35de212
openAPI: define query parameters
dariok Nov 6, 2024
3aad747
openAPI: add optional query and header parameters
dariok Nov 6, 2024
24a3b48
basic design of API v2
dariok Nov 21, 2024
f12ba11
fix typo
dariok Dec 2, 2024
ea30f74
Merge pull request #562 from dariok/24Q3
dariok Dec 6, 2024
d5e9592
remove imports of app.xqm where it’s only used for variables
dariok Dec 6, 2024
2f7c6bc
replace console:log by util:log
dariok Dec 6, 2024
a533c27
make baseURL available for search results in HTML
dariok Dec 6, 2024
07185c3
typos and stylebook
dariok Dec 6, 2024
5657466
set a default for start of subsequence in searches
dariok Dec 6, 2024
003dee2
Undo some mistakes introduced when reducing $wdb
dariok Dec 10, 2024
c269eac
drop wdb:getProjectPathFromId #1
dariok Dec 10, 2024
a2d0d3d
fix creation of nav HTML
dariok Dec 11, 2024
b6a02d2
remove unnecessary JSON module import
dariok Dec 12, 2024
2b38508
generic XSLT: do not create button for pb without facsimile
dariok Dec 13, 2024
99962df
fix return type of KWIC callback
dariok Dec 13, 2024
935d5c5
search, project selection: always return “global”
dariok Dec 13, 2024
93bba55
Improve generation of html/@lang
dariok Dec 13, 2024
5727d7b
adjust admin functions to wdbFiles (I)
dariok Dec 13, 2024
e3e0ce8
som ebug fixing; removal of unused JS function
dariok Dec 13, 2024
22cad46
start project index with "data"
dariok Dec 16, 2024
f875789
bump version to 4.0 Beta 1
dariok Dec 16, 2024
77763ad
first draft for a basic search/list result from REST operation
dariok Dec 16, 2024
2c8af29
house keeping
dariok Dec 16, 2024
6d96cc7
Create/update entries in index when creating/uploading
dariok Dec 16, 2024
a6fa78c
idno as range index
dariok Dec 17, 2024
f3846cb
Checking XQuery module imports
dariok Dec 18, 2024
65d2f68
all functions use wdb-files.xqm
dariok Dec 18, 2024
507f9fd
more removal of unused imports and modules
dariok Dec 18, 2024
db30513
minor typos fixed
dariok Dec 18, 2024
1783f19
Merge pull request #564 from dariok/24Q4
dariok Dec 22, 2024
cd21776
remove namespace definition: module is being imported
dariok Jan 6, 2025
ae26d3a
getXsl: create relative path
dariok Jan 6, 2025
7bf70fb
Collection content: only list existing file entries
dariok Jan 20, 2025
f1def24
correctly add files an projects to lookup index
dariok Jan 29, 2025
3e3f8b7
[maint] remove git branch name from window title
dariok Jan 30, 2025
8d1d03a
move all functions called from templating to separate model
dariok Feb 3, 2025
e9bb3d1
populateModel is now a generalised function
dariok Feb 5, 2025
07ed900
Code maintenance: declare namespaces
dariok Feb 5, 2025
a5f7d77
HTML: pb→button only if URL is present
dariok Feb 5, 2025
72641a5
small bug fixes re extracting populateModel
dariok Feb 6, 2025
7dc1322
better handling of multiple file/project index entries
dariok Feb 6, 2025
cdee691
REST must not enter files/project into index
dariok Feb 6, 2025
9fb21c7
validation for XQuery
dariok Feb 6, 2025
5510486
grow/shrink main and aside in view
dariok Mar 17, 2025
04b6c60
import view.xqm in main view
dariok May 13, 2025
366c9d4
adjust extraction of document title
dariok May 13, 2025
d98ac64
add OAI-PMH and DTS endpoints to planned REST v2
dariok May 13, 2025
f1ed24e
Merge pull request #585 from dariok/25Q1
dariok May 22, 2025
a3eea68
improve nav
dariok Jul 12, 2025
15d842f
some local tests for endpoints (old API)
dariok Jul 12, 2025
39543f0
Merge pull request #596 from dariok/25Q2
dariok Jul 12, 2025
8b40fdf
button in coookie info to full height
dariok Jul 12, 2025
118e35b
start: licence info as div with heading
dariok Jul 12, 2025
bd2135f
extend error.xqm, expect numerical keys
dariok Jul 16, 2025
4df43c5
add path to xslt as meta
dariok Jul 16, 2025
9e298fd
add missing gt to make file wellformed
dariok Jul 16, 2025
63adbc9
use image instead of attrib balue in image link
dariok Jul 16, 2025
34137a9
use processes as wrapper for process as per current schema
dariok Jul 16, 2025
f852856
error: don’t set status code when in REST
dariok Jul 16, 2025
eadd118
revert grid columns to 1fr 1fr
dariok Jul 17, 2025
9a692b7
bug fixing in getResourceById and wdbfiles
dariok Jul 17, 2025
ad2255f
XSLT selection: use view parameter if one is present
dariok Jul 17, 2025
87c5316
populate model must pass view parameter to XSLT selection
dariok Jul 17, 2025
5afb855
search instance specific funstion.js in data/resources/js
dariok Jul 17, 2025
6b48e26
getXsl return process element
dariok Jul 17, 2025
8b9b42c
wdbmeta stub: use uniform path for xsl
dariok Jul 17, 2025
e9f843a
file transformations are in a separate module now
dariok Jul 17, 2025
af623ea
view.xqm now uses wdbProcess to get contents
dariok Jul 17, 2025
19a1602
add struct[@xml:id] to file index
dariok Jul 17, 2025
fa7d555
when creating a project, add option to create a subproject
dariok Jul 17, 2025
b93eb71
remove unused wddb:getFilePath
dariok Jul 17, 2025
87bbbaa
wdbmeta for sub-projets uses process inheritance
dariok Jul 18, 2025
dcf3049
Create new structure for all resources collections
dariok Jul 18, 2025
1462490
create new collection structure in data/resources and edoc/resources
dariok Jul 18, 2025
5afda59
new structure of resources: adjust loading CSS and JS
dariok Jul 18, 2025
f7b68c7
adjust to new resource structure for XSLTs
dariok Jul 18, 2025
c39390a
new structure of resources: adjust links to specific HTML
dariok Jul 18, 2025
b28f837
forgot an instance of CSS in new structure
dariok Jul 18, 2025
cc94318
project XSLT templates only import instance’s XSLTs
dariok Jul 18, 2025
e6ba900
porject.xqm is created of a main project but not sub-projects
dariok Jul 18, 2025
51e653f
prepared a list of main changes in README
dariok Jul 18, 2025
d2d4d04
Move wdbmeta to admin and include only necessary content
dariok Jul 21, 2025
a326e14
move to Xuery 3.1
dariok Jul 21, 2025
93c21c9
updated XString
dariok Jul 23, 2025
979529a
Create data/logs with general errors.xml for logging
dariok Jul 23, 2025
d3a312f
wirte errors to logs/error.xqm in addition to log4j
dariok Jul 23, 2025
1e987c8
fix model creation without ed or id (= for data)
dariok Jul 23, 2025
ffa1d7c
UUIDs are not always valid xs:id
dariok Jul 23, 2025
b581cce
prepare basics to use Roaster for RESTv2
dariok Sep 4, 2025
866732b
create project for documentation
dariok Sep 4, 2025
938a6ee
(for now) do not index documentation
dariok Sep 4, 2025
c78feec
REST2: list all projects
dariok Sep 4, 2025
10dfb4e
return JSON as useful JSON – no double serialization
dariok Sep 5, 2025
3d1160d
[RESTv2] GET projects
dariok Oct 23, 2025
4932e2c
global wdbmeta.xml must containt processes
dariok Oct 24, 2025
7ddb26c
[nav] empty struct must not throw errors
dariok Oct 24, 2025
d235138
host SwaggerUI files locally
dariok Oct 25, 2025
55b0bbf
[REST] handle login uniformly throught API (Roaster)
dariok Oct 25, 2025
a938bf8
unit testing for GET, OPTIONS projects
dariok Oct 28, 2025
e4543c7
Merge pull request #597 from dariok/25Q3
dariok Nov 1, 2025
e8d9d2b
REST2 projects: prepare "create project (POST)"
dariok Nov 19, 2025
c63e83e
login must make use of new API
dariok Dec 19, 2025
e96b284
make logs world-writable
dariok Dec 19, 2025
73d7d0a
build must use correct paths
dariok Dec 19, 2025
1164844
mover start.xsl to resources/xsl
dariok Dec 19, 2025
7ca8b26
(old API) do not insert import into wdbmeta.xml
dariok Dec 19, 2025
fa73329
[REST2] projects: create new project
dariok Dec 22, 2025
4892149
function page start: keep original error description
dariok Dec 22, 2025
9ca5c81
function.js: make call to new login endpoint
dariok Dec 22, 2025
ec5c9f5
[REST] when creating a new collection, always create texts
dariok Dec 22, 2025
466bac6
use correct path for login
dariok Dec 22, 2025
a740dec
[REST] new project via REST2
dariok Dec 22, 2025
739bd0b
Merge pull request #613 from dariok/25Q4
dariok Jan 7, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ __pycache__/
# internal
edoc/resources/xsl/xspec/
.existdb.json
edoc/rest2/v2.json

# node-reladted stuff
node_modules/
Expand Down
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,47 @@ This framework still lacks a good name. If you have an idea, please let me know!

## Incompatible changes

### 25Q3

Release 25Q3 dropped support for more unsued functions:
- `wdb:getFilePath ( $id as xs:string )`: use the map from `wdbFiles:getFullPath` instead
- the default layout of all `resources` collections has changed to group files by type. This also affects the main
project specific overrides, i.e. `project.js` and `project.css`. An XQuery is provided to move all files to their
appropriate new locations (TODO: add file name here).
This also affects `edoc/data/resources` and `edoc/resources` so you might have to change imports manually if you make
use of any file in these collections.

Changes in standard behaviour
- sub-projects will now make use of process inheritance; i.e., they only define empty `processes` with no `command`. A
`command` is then picked by traversing up through parent `wdbmeta.xml` (i.e., one that is pointed to by a
`struct/import`; worst case: data). This way, you can still have different `command` defined for sub-projects (and
their children) but do not need to change the path for every sub-project.
- as part of this, no XSLTs are being copied to `{$subproject}/resources` as inheritance is now the standard. This way,
surplus XSLTs do not have to be deleted or kept up to date. As said above, it is still possible to create a `command`
for this sub-project tree and create specific XSLTs (usually by including the main XSLTs)
- standard XSLTs for a new project are now bare: they only include `/edoc/data/resources/xslt/{$currentFileName}`, and
`tei-common.xsl` (unless it’s common itself).

### 24Q4

Release 24Q4 dropped another set of functions that were unused:
- `wdb:getEdFromFileID( $id as xs:string )`: `(wdbFiles:getFullPath($id))?projectPath` returns the base path to `wdbmeta.xml`
- `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
- `wdb:getMetaFile( $pathToEd )`: `(wdbFiles:getFullPath($ed))?projectPath` returns the base path to `wdbmeta.xml`
- `wdb:getProjectPathFromId ( $ed )`: use `(wdbFiles:getFullPath($ed))?projectPath` instead

### 24Q2

Release 24Q2 dropped functions `wdb:getEdPath( $ed as xs:string , $absolute as xs:boolean() )`,
`wdb:getEdPath( $ed as xs:string )`, and `wdb:findProjectXQM( $project )`. These queries can be replaced by
`(wdbFiles:getFullPath($id))` which returns a map with `projectPath` (the path to the project, i.e. the collection where
`wdbmeta.xml`¹ is stored), `collectionPath` (for the subcollection where a file is actually located), `mainProject` for
the path to the project containing `project.xqm`, and `fileName`.
1) (24Q4): this corrects a typo as previous versions incorrectly read `project.xqm`.

### 24Q1

Release 24Q1 dropped support for METS-based projects. As METS files can have a number of very different ways of encoding
information, especially when it comes to behaviours, native support is hard to achieve. At the same time, most
installations use wdb+’s native wdbmeta system as this is what the admin functions work with.
Expand Down Expand Up @@ -64,9 +105,11 @@ into `/db/apps/edoc` and want to put your projects into `/db/apps/edoc/data/your
<files>
<file path="pathTo.xml" xml:id="xml-id" />
</files>
<process target="html">
<command type="xsl">/db/apps/edoc/resources/xsl/tei-transcript.xsl</command>
</process>
<processes>
<process target="html">
<command type="xsl">/db/apps/edoc/resources/xsl/tei-transcript.xsl</command>
</process>
</processes>
<struct label="1722" order="1722">
<view file="xml-id" label="Title of File" />
</struct>
Expand Down Expand Up @@ -96,5 +139,12 @@ See the Wiki for details!
* Akademie der Wissenschaften, Heidelberg
* Theologenbriefwechsel
* ULB Darmstadt
* TUEditions
* WDM

If you use wdbplus for your editions, please drop me a message so I can add you to this list.

## Sponsoring

Development of wdb+ is chiefly done in projects funded by DFG and the German BMBF.
Additionally, we would like to say thank you to BrowserStack for giving us sponsored access!
42 changes: 22 additions & 20 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<xmlproperty file="edoc/expath-pkg.xml"/>

<target name="clean">
<delete dir="edoc/build/" />
<delete dir="build" />
</target>

<target name="compile" depends="clean">
<ant dir="edoc" antfile="build.xml" />
<move file="edoc/build" tofile="build" />
</target>

<target name="docker" depends="compile">
<copy file="build/${package(abbrev)}-${package(version)}.xar" tofile="docker/wdb.xar" />
<exec executable="docker" dir="docker">
<arg value="build" />
<arg value="--tag=wdbplus" />
<arg value="." />
</exec>
</target>
<xmlproperty file="edoc/expath-pkg.xml"/>
<property name="project.version" value="${package(version)}"/>
<property name="project.app" value="wdb"/>
<property name="build.dir" value="build"/>

<target name="clean">
<delete dir="build" />
</target>

<target name="compile" depends="clean">
<ant dir="edoc" antfile="build.xml" />
<move file="edoc/build" tofile="build" />
</target>

<target name="docker" depends="compile">
<copy file="build/${package(abbrev)}-${package(version)}.xar" tofile="docker/wdb.xar" />
<exec executable="docker" dir="docker">
<arg value="build" />
<arg value="--tag=wdbplus" />
<arg value="." />
</exec>
</target>
</project>
52 changes: 16 additions & 36 deletions edoc/admin/admin.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,26 @@ xquery version "3.1";

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

import module namespace console = "http://exist-db.org/xquery/console" at "java:org.exist.console.xquery.ConsoleModule";
import module namespace templates = "http://exist-db.org/xquery/html-templating";
import module namespace wdb = "https://github.com/dariok/wdbplus/wdb" at "/db/apps/edoc/modules/app.xqm";
import module namespace wdbErr = "https://github.com/dariok/wdbplus/errors" at "/db/apps/edoc/modules/error.xqm";
import module namespace config = "https://github.com/dariok/wdbplus/config" at "../modules/wdb-config.xqm";
import module namespace wdbErr = "https://github.com/dariok/wdbplus/errors" at "../modules/error.xqm";
import module namespace wdbFiles = "https://github.com/dariok/wdbplus/files" at "../modules/wdb-files.xqm";
import module namespace wdbm = "https://github.com/dariok/wdbplus/model" at "../modules/model.xqm";

declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
declare namespace sm = "http://exist-db.org/xquery/securitymanager";
declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
declare namespace sm = "http://exist-db.org/xquery/securitymanager";
declare namespace templates = "http://exist-db.org/xquery/html-templating";
declare namespace wdb = "https://github.com/dariok/wdbplus/wdb";

(:~
: populate the model for functions pages (similar but not identical to wdb:populateModel)
: populate the model for admin pages
:
: @param $ed The ID of a _project_
: @return The model
:)
declare
%templates:default("ed", "")
function wdbAdmin:start ( $node as node(), $model as map(*), $ed as xs:string ) {
try {
let $pathToEd := if ( $ed = "" )
then $wdb:data
else wdb:getEdPath($ed, true())

(: The meta data are taken from wdbmeta.xml :)
let $infoFileLoc := wdb:getMetaFile($pathToEd)
, $title := normalize-space((doc($infoFileLoc)//meta:title)[1])

return map {
"ed": if ( $pathToEd = $wdb:data ) then "data" else $ed,
"infoFileLoc": $infoFileLoc,
"page": substring-after(request:get-uri(), "admin/"),
"pathToEd": $pathToEd,
"title": $title,
"auth": sm:id()/sm:id
}
} catch * {
util:log("error", "No collection found for project ID " || $ed),
map {
"ed": ""
}
}
%templates:default("ed", "data")
function wdbAdmin:start ( $node as node(), $model as map(*), $ed as xs:string ) as item()* {
wdbm:populateModel((), $ed, "", "", "")
};

declare function wdbAdmin:getEd ( $node as node(), $model as map(*) ) as element(meta) {
Expand Down Expand Up @@ -89,10 +69,10 @@ declare function wdbAdmin:getAside ($node as node(), $model as map(*)) as elemen
};

declare function wdbAdmin:css ( $node as node(), $model as map(*) ) as element()* {
if ( unparsed-text-available($wdb:data || "/resources/wdb.css") )
then <link rel="stylesheet" type="text/css" href="../data/resources/wdb.css" />
if ( unparsed-text-available($config:data || "/resources/css/wdb.css") )
then <link rel="stylesheet" type="text/css" href="../data/resources/css/wdb.css" />
else (),
if ( unparsed-text-available($wdb:data || "/resources/admin.css") )
then <link rel="stylesheet" type="text/css" href="../data/resources/admin.css" />
if ( unparsed-text-available($config:data || "/resources/css/admin.css") )
then <link rel="stylesheet" type="text/css" href="../data/resources/css/admin.css" />
else ()
};
45 changes: 21 additions & 24 deletions edoc/admin/global.xqm
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
xquery version "3.0";
xquery version "3.1";

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

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

declare namespace config = "https://github.com/dariok/wdbplus/config";
declare namespace exgit = "http://exist-db.org/xquery/exgit";
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(*) ) {
<meta name="rest" content="{$wdb:restURL}" />
declare function wdbGS:getRest ( $node as node(), $model as map(*) ) as element(meta) {
<meta name="rest" content="{ $config:restURL }" />
};

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

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

case 'title' return
local:titleForm($metaFile)
local:titleForm($config:configFile)

case 'chgTitle' return
let $u1 := update replace $metaFile//config:meta/config:name
let $u1 := update replace $config:configFile//config:meta/config:name
with <name xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('longTitle', '')}</name>
let $u1 := update replace $metaFile//config:meta/config:short
let $u1 := update replace $config:configFile//config:meta/config:short
with <short xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('shortTitle', '')}</short>
return local:titleForm($metaFile)
return local:titleForm($config:configFile)

case 'role' return
local:roleForm($metaFile)
local:roleForm($config:configFile)

case 'chgRole' return
let $u1 := update replace $metaFile//config:role/config:type
let $u1 := update replace $config:configFile//config:role/config:type
with <type xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('role', '')}</type>
let $u1 := update replace $metaFile//config:role/config:other
let $u1 := update replace $config:configFile//config:role/config:other
with <other xmlns="https://github.com/dariok/wdbplus/config">{request:get-parameter('other', '')}</other>
return local:roleForm($metaFile)
return local:roleForm($config:configFile)

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

declare function local:titleForm($metaFile) {
declare function local:titleForm($config:configFile) {
<div>
<h3>Titeldaten verändern</h3>
<form action="global.html">
<input type="hidden" name="job" value="chgTitle" />
<label style="width: 100%">Titel: <input type="text" name="longTitle"
value="{$metaFile//config:meta/config:name}" /></label><br />
value="{$config:configFile//config:meta/config:name}" /></label><br />
<label style="width: 100%">Kurztitel: <input type="text" name="shortTitle"
value="{$metaFile//config:meta/config:short}" /></label><br />
value="{$config:configFile//config:meta/config:short}" /></label><br />
<input type="submit" />
</form>
</div>
};

declare function local:roleForm($metaFile) {
let $role := $metaFile//config:role/config:type
let $other := $metaFile//config:role/config:other
declare function local:roleForm($config:configFile) {
let $role := $config:configFile//config:role/config:type
let $other := $config:configFile//config:role/config:other

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

declare function wdbGS:ingest($node as node(), $model as map(*)) {
<a href="directoryForm.html?ed={doc($wdb:data || '/wdbmeta.xml')/meta:projectMD/@xml:id}">bestehendes Projekt hochladen</a>
};
<a href="directoryForm.html?ed={doc($config:data || '/wdbmeta.xml')/meta:projectMD/@xml:id}">bestehendes Projekt hochladen</a>
};
57 changes: 57 additions & 0 deletions edoc/admin/modelFunctions.xql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ xquery version "3.1";

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

declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta";
declare namespace index = "https://github.com/dariok/wdbplus/index";

declare function trigger:after-update-document ( $uri as xs:anyURI ) as xs:string {
if ( ends-with($uri, 'instance.xqm') or ends-with($uri, 'project.xqm') ) then
let $projectPath := if ( ends-with($uri, 'instance.xqm') )
Expand All @@ -12,5 +15,59 @@ declare function trigger:after-update-document ( $uri as xs:anyURI ) as xs:strin
else 'project-functions.xml'

return xmldb:store($projectPath, $statFileName, inspect:inspect-module($uri))
else if ( ends-with($uri, 'wdbmeta.xml') ) then
let $meta := doc($uri)
, $projectId := $meta/meta:projectMD/@xml:id
, $files := $meta//meta:file
, $title := $meta//meta:title[@type='main']
, $projectIndex := doc("/db/apps/edoc/index/project-index.xml")
, $fileIndex := doc("/db/apps/edoc/index/file-index.xml")
, $projectEntry := <project xmlns="https://github.com/dariok/wdbplus/index"
xml:id="{ $projectId }"
path="{ substring-before($uri, '/wdbmeta.xml') }"
title="{ $title }"
/>

(: enter or update project :)
let $insertProject := if ( exists($projectIndex/id($projectId)) )
then update replace $projectIndex/id($projectId) with $projectEntry
else update insert $projectEntry into $projectIndex/index:index

(: enter or update files entries :)
let $entries := for $file in $files
let $id := $file/@xml:id
, $entry := <file xmlns="https://github.com/dariok/wdbplus/index"
xml:id="{ $id }"
project="{ $meta => base-uri() }"
/>

return if ( exists($fileIndex/id($id)) )
then update replace $fileIndex/id($id) with $entry
else update insert $entry into $fileIndex/index:index

(: enter or update subcorpora :)
let $subcorpora := for $subcorpus in $meta//meta:struct[@xml:id]
let $id := $subcorpus/@xml:id
, $entry := <file xmlns="https://github.com/dariok/wdbplus/index"
xml:id="{ $id }"
project="{ $meta => base-uri() }"
/>

return if ( exists($fileIndex/id($id)) )
then update replace $fileIndex/id($id) with $entry
else update insert $entry into $fileIndex/index:index

return $uri
(: else if ( ends-with($uri, '.xml') ) then
let $id := doc($uri)/*/@xml:id
, $present := doc("/db/apps/edoc/index/file-index.xml")/id($id)
, $entry := <file xmlns="https://github.com/dariok/wdbplus/index"
xml:id="{ $id }"
project="{ collection('/db/apps/edoc/data')/id($id)[self::meta:file] => base-uri() }"
/>
, $insert := if ( $present )
then update replace $present with $entry
else update insert $entry into doc("/db/apps/edoc/index/file-index.xml")/*
return $uri :)
else ""
};
Loading
Loading