Commit 72a555e0 authored by Wolfgang's avatar Wolfgang

Enhance DTS support to allow hierarchical collections

parent 655d7d88
......@@ -122,8 +122,7 @@
static get properties() {
return {
baseUri: {
type: String,
observer: '_configureEndpoint'
type: String
},
data: {
type: Object
......@@ -145,8 +144,11 @@
connectedCallback() {
super.connectedCallback();
this.collection = this.getParameter('id');
this.page = this.getParameter('page');
this.subscribeTo('dts-endpoint', (ev) => {
this.baseUri = ev.detail.endpoint;
this._setEndpoint(ev.detail.endpoint, ev.detail.reload);
});
this.subscribeTo('pb-load', (ev) => {
this.page = ev.detail.params.page;
......@@ -159,6 +161,15 @@
return item['@type'] == 'Collection';
}
_setEndpoint(endpoint, reload) {
this.baseUri = endpoint;
if (!reload) {
this.page = null;
this.collection = null;
}
this._configureEndpoint(endpoint);
}
_configureEndpoint(newBaseUri) {
if (newBaseUri) {
console.log('<dts-client> initializing connection to endpoint %s', newBaseUri);
......@@ -205,10 +216,15 @@
const params = {};
if (this.collection) {
params.id = this.collection;
this.setParameter('id', this.collection);
};
if (this.page) {
params.page = this.page + 1;
this.setParameter('page', this.page);
}
this.pushHistory('dts-client-navigate');
this.$.queryAPI.params = params;
this.$.queryAPI.url = this._collectionEndpoint;
this.$.queryAPI.generateRequest();
......@@ -217,9 +233,8 @@
_handleResponse() {
const json = this.$.queryAPI.lastResponse;
if (json['@type'] === 'EntryPoint') {
const newEndpoint = new URL(json.collections, this.baseUri).toString();
this._collectionEndpoint = new URL(json.collections, this.baseUri).toString();
this.page = null;
this.collection = null;
console.log('<dts-client> using collection endpoint: %s', this._collectionEndpoint);
this._update();
......
......@@ -53,7 +53,8 @@
this.setParameter('endpoint', newEndpoint);
this.pushHistory('dts-endpoint');
this.emitTo('dts-endpoint', {
endpoint: newEndpoint
endpoint: newEndpoint,
reload: !oldEndpoint
});
}
}
......
......@@ -280,28 +280,47 @@ declare variable $config:session-prefix := $config:expath-descriptor/@abbrev/str
declare variable $config:setup := doc($config:app-root || "/setup.xml")/setup;
declare variable $config:dts-collections := map {
"default": map {
"title": "TEI Publisher Default Collection",
"path": $config:data-default,
"members": function() {
nav:get-root((), map {
"leading-wildcard": "yes",
"filter-rewrite": "yes"
})
},
"metadata": function($doc as document-node()) {
let $properties := tpu:parse-pi($doc, ())
return
map:merge((
map:entry("title", nav:get-metadata($properties, $doc/*, "title")/string()),
"id": "default",
"title": "TEI Publisher Default Collection",
"memberCollections": (
map {
"id": "documents",
"title": "Document Collection",
"path": $config:data-default,
"members": function() {
nav:get-root((), map {
"leading-wildcard": "yes",
"filter-rewrite": "yes"
})
},
"metadata": function($doc as document-node()) {
let $properties := tpu:parse-pi($doc, ())
return
map:merge((
map:entry("title", nav:get-metadata($properties, $doc/*, "title")/string()),
map {
"dts:dublincore": map {
"dc:creator": string-join(nav:get-metadata($properties, $doc/*, "author"), "; "),
"dc:license": nav:get-metadata($properties, $doc/*, "license")
}
}
))
}
},
map {
"id": "odd",
"title": "ODD Collection",
"path": $config:odd-root,
"members": function() {
collection($config:odd-root)/tei:TEI
},
"metadata": function($doc as document-node()) {
map {
"dts:dublincore": map {
"dc:creator": string-join(nav:get-metadata($properties, $doc/*, "author"), "; ")
}
"title": string-join($doc//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title[not(@type)], "; ")
}
))
}
}
}
}
)
};
declare variable $config:dts-page-size := 10;
......
......@@ -272,6 +272,52 @@ declare variable $config:expath-descriptor := doc(concat($config:app-root, "/exp
declare variable $config:session-prefix := $config:expath-descriptor/@abbrev/string();
declare variable $config:dts-collections := map {
"id": "default",
"title": $config:expath-descriptor/expath:title/string(),
"memberCollections": (
map {
"id": "documents",
"title": "Document Collection",
"path": $config:data-default,
"members": function() {
nav:get-root((), map {
"leading-wildcard": "yes",
"filter-rewrite": "yes"
})
},
"metadata": function($doc as document-node()) {
let $properties := tpu:parse-pi($doc, ())
return
map:merge((
map:entry("title", nav:get-metadata($properties, $doc/*, "title")/string()),
map {
"dts:dublincore": map {
"dc:creator": string-join(nav:get-metadata($properties, $doc/*, "author"), "; "),
"dc:license": nav:get-metadata($properties, $doc/*, "license")
}
}
))
}
},
map {
"id": "odd",
"title": "ODD Collection",
"path": $config:odd-root,
"members": function() {
collection($config:odd-root)/tei:TEI
},
"metadata": function($doc as document-node()) {
map {
"title": string-join($doc//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title[not(@type)], "; ")
}
}
}
)
};
declare variable $config:dts-page-size := 10;
(:~
: Return an ID which may be used to look up a document. Change this if the xml:id
: which uniquely identifies a document is *not* attached to the root element.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment