@teipublisher/pb-components 2.26.1-next.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +4 -4
- package/.releaserc.json +2 -2
- package/CHANGELOG.md +262 -11
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/css/leaflet/images/layers.png +0 -0
- package/dist/demo/components.css +46 -1
- package/dist/demo/pb-browse-docs2.html +1 -1
- package/dist/demo/pb-dialog.html +3 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-facsimile.html +2 -2
- package/dist/demo/pb-grid.html +19 -6
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-login.html +0 -2
- package/dist/demo/pb-message.html +1 -2
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-search.html +7 -4
- package/dist/demo/pb-search3.html +1 -1
- package/dist/demo/pb-search4.html +2 -2
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
- package/dist/paper-checkbox-645e1077.js +200 -0
- package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
- package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
- package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +68 -64
- package/dist/pb-components-bundle.js +1983 -2293
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +176 -120
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +1023 -782
- package/dist/pb-tify.js +2 -2
- package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +6 -6
- package/package.json +3 -3
- package/pb-elements.json +176 -120
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +158 -171
- package/src/pb-authority-lookup.js +191 -156
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +211 -151
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-components.js +1 -0
- package/src/pb-custom-form.js +173 -153
- package/src/pb-dialog.js +98 -62
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +212 -196
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +100 -97
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +474 -410
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -429
- package/src/pb-login.js +299 -244
- package/src/pb-manage-odds.js +352 -336
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +139 -97
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -95
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1054 -958
- package/src/pb-odd-elementspec-editor.js +349 -298
- package/src/pb-odd-model-editor.js +1075 -909
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -422
- package/src/pb-paginate.js +228 -179
- package/src/pb-panel.js +198 -182
- package/src/pb-popover-themes.js +15 -8
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +256 -228
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +382 -249
- package/src/pb-toggle-feature.js +195 -187
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +135 -98
- package/src/pb-view.js +1282 -1270
- package/src/pb-zoom.js +127 -45
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
- package/css/pb-styles.css +0 -51
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Global component theme stylesheet
|
|
3
|
-
*
|
|
4
|
-
* Styles defined here are injected into a components' shadow DOM.
|
|
5
|
-
*/
|
|
1
|
+
/*
|
|
2
|
+
* Global component theme stylesheet
|
|
3
|
+
*
|
|
4
|
+
* Styles defined here are injected into a components' shadow DOM.
|
|
5
|
+
*/
|
|
@@ -4,11 +4,11 @@ import { resolveURL } from '../utils.js';
|
|
|
4
4
|
|
|
5
5
|
function expandTemplate(template = '', options) {
|
|
6
6
|
return template.replace(/\${([^}]+)}/g, (match, p) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
let replacement;
|
|
8
|
+
if (options[p]) {
|
|
9
|
+
replacement = options[p];
|
|
10
|
+
}
|
|
11
|
+
return replacement || '';
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -23,7 +23,6 @@ function getTemplate(configElem, selector) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export class Airtable extends Registry {
|
|
26
|
-
|
|
27
26
|
constructor(configElem) {
|
|
28
27
|
super(configElem);
|
|
29
28
|
this.apiKey = configElem.getAttribute('api-key');
|
|
@@ -45,7 +44,7 @@ export class Airtable extends Registry {
|
|
|
45
44
|
this.tokenize = [this.fields[0]];
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
this.tokenizeChars = configElem.getAttribute('tokenize-regex') ||
|
|
47
|
+
this.tokenizeChars = configElem.getAttribute('tokenize-regex') || '\\W';
|
|
49
48
|
|
|
50
49
|
this.infoExpr = getTemplate(configElem, '.info');
|
|
51
50
|
this.detailExpr = getTemplate(configElem, '.detail');
|
|
@@ -54,14 +53,12 @@ export class Airtable extends Registry {
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
_init() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{ once: true },
|
|
64
|
-
);
|
|
56
|
+
window.ESGlobalBridge.requestAvailability();
|
|
57
|
+
const path = resolveURL('../lib/airtable.browser.js');
|
|
58
|
+
window.ESGlobalBridge.instance.load('airtable', path);
|
|
59
|
+
window.addEventListener('es-bridge-airtable-loaded', this._initAirtable.bind(this), {
|
|
60
|
+
once: true,
|
|
61
|
+
});
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
_initAirtable() {
|
|
@@ -76,7 +73,7 @@ export class Airtable extends Registry {
|
|
|
76
73
|
const options = {
|
|
77
74
|
fields: this.fields,
|
|
78
75
|
// Selecting the first 3 records in Grid view:
|
|
79
|
-
maxRecords: 100
|
|
76
|
+
maxRecords: 100,
|
|
80
77
|
};
|
|
81
78
|
if (this.view) {
|
|
82
79
|
options.view = this.view;
|
|
@@ -95,13 +92,15 @@ export class Airtable extends Registry {
|
|
|
95
92
|
}
|
|
96
93
|
records.forEach(record => {
|
|
97
94
|
const data = {};
|
|
98
|
-
this.fields.forEach(
|
|
95
|
+
this.fields.forEach(field => {
|
|
96
|
+
data[field] = record.get(field);
|
|
97
|
+
});
|
|
99
98
|
const result = {
|
|
100
99
|
register: this._register,
|
|
101
100
|
id: record.id,
|
|
102
101
|
label: expandTemplate(this.labelExpr, data),
|
|
103
102
|
details: expandTemplate(this.detailExpr, data),
|
|
104
|
-
provider: 'airtable'
|
|
103
|
+
provider: 'airtable',
|
|
105
104
|
};
|
|
106
105
|
results.push(result);
|
|
107
106
|
});
|
|
@@ -133,7 +132,7 @@ export class Airtable extends Registry {
|
|
|
133
132
|
}
|
|
134
133
|
let strings = [];
|
|
135
134
|
const data = {};
|
|
136
|
-
this.fields.forEach(
|
|
135
|
+
this.fields.forEach(field => {
|
|
137
136
|
const value = record.get(field);
|
|
138
137
|
if (value) {
|
|
139
138
|
data[field] = value;
|
|
@@ -141,7 +140,7 @@ export class Airtable extends Registry {
|
|
|
141
140
|
}
|
|
142
141
|
});
|
|
143
142
|
const regex = new RegExp(this.tokenizeChars);
|
|
144
|
-
this.tokenize.forEach(
|
|
143
|
+
this.tokenize.forEach(key => {
|
|
145
144
|
if (data[key]) {
|
|
146
145
|
strings = strings.concat(data[key].split(regex));
|
|
147
146
|
}
|
|
@@ -152,7 +151,7 @@ export class Airtable extends Registry {
|
|
|
152
151
|
|
|
153
152
|
resolve({
|
|
154
153
|
id: record.id,
|
|
155
|
-
strings
|
|
154
|
+
strings,
|
|
156
155
|
});
|
|
157
156
|
});
|
|
158
157
|
});
|
package/src/authority/anton.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { Registry } from
|
|
1
|
+
import { Registry } from './registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Connector for the corporate archive of Georgfischer AG.
|
|
5
5
|
*/
|
|
6
6
|
export class Anton extends Registry {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
7
|
+
constructor(configElem) {
|
|
8
|
+
super(configElem);
|
|
9
|
+
this._url = configElem.getAttribute('url') || `https://archives.georgfischer.com/api`;
|
|
10
|
+
this._api = configElem.getAttribute('api');
|
|
11
|
+
this._limit = configElem.getAttribute('limit') || 999999;
|
|
12
|
+
this._provider = configElem.getAttribute('provider') || configElem.getAttribute('connector');
|
|
13
|
+
}
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const register = this.getRegister();
|
|
20
|
-
const url = `${this._url}/${register}?search=${encodeURIComponent(key)}&perPage=${this._limit}`;
|
|
21
|
-
const label = this.getLabelField();
|
|
22
|
-
return new Promise((resolve) => {
|
|
23
|
-
fetch(url)
|
|
24
|
-
.then(response => response.json())
|
|
25
|
-
.then(json => {
|
|
26
|
-
if (!json.data) {
|
|
27
|
-
resolve({
|
|
28
|
-
totalItems: 0,
|
|
29
|
-
items: []
|
|
30
|
-
});
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
json.data.forEach(item => {
|
|
34
|
-
if ((this._register === 'organization' && item.authority_type === 'Person') ||
|
|
35
|
-
(this._register === 'person' && item.authority_type !== 'Person')) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const result = {
|
|
39
|
-
register: this._register,
|
|
40
|
-
id: (this._prefix ? `${this._prefix}-${item.id}` : item.id),
|
|
41
|
-
label: item[label],
|
|
42
|
-
details: `${item.id}`,
|
|
43
|
-
link: `${this._url}/${register}/${item.id}`,
|
|
44
|
-
strings: [item[label]],
|
|
45
|
-
provider: this._provider
|
|
46
|
-
};
|
|
47
|
-
results.push(result);
|
|
48
|
-
});
|
|
49
|
-
resolve({
|
|
50
|
-
totalItems: json.meta.total,
|
|
51
|
-
items: results,
|
|
52
|
-
});
|
|
53
|
-
})
|
|
54
|
-
.catch((reason) => Promise.reject(reason));
|
|
55
|
-
})
|
|
56
|
-
}
|
|
15
|
+
async query(key) {
|
|
16
|
+
const results = [];
|
|
57
17
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return new Promise((resolve) => {
|
|
65
|
-
this.getRecord(id)
|
|
18
|
+
const register = this.getRegister();
|
|
19
|
+
const url = `${this._url}/${register}?search=${encodeURIComponent(key)}&perPage=${this._limit}`;
|
|
20
|
+
const label = this.getLabelField();
|
|
21
|
+
return new Promise(resolve => {
|
|
22
|
+
fetch(url)
|
|
23
|
+
.then(response => response.json())
|
|
66
24
|
.then(json => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
25
|
+
if (!json.data) {
|
|
26
|
+
resolve({
|
|
27
|
+
totalItems: 0,
|
|
28
|
+
items: [],
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
json.data.forEach(item => {
|
|
33
|
+
if (
|
|
34
|
+
(this._register === 'organization' && item.authority_type === 'Person') ||
|
|
35
|
+
(this._register === 'person' && item.authority_type !== 'Person')
|
|
36
|
+
) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const result = {
|
|
40
|
+
register: this._register,
|
|
41
|
+
id: this._prefix ? `${this._prefix}-${item.id}` : item.id,
|
|
42
|
+
label: item[label],
|
|
43
|
+
details: `${item.id}`,
|
|
44
|
+
link: `${this._url}/${register}/${item.id}`,
|
|
45
|
+
strings: [item[label]],
|
|
46
|
+
provider: this._provider,
|
|
47
|
+
};
|
|
48
|
+
results.push(result);
|
|
49
|
+
});
|
|
50
|
+
resolve({
|
|
51
|
+
totalItems: json.meta.total,
|
|
52
|
+
items: results,
|
|
53
|
+
});
|
|
54
|
+
})
|
|
55
|
+
.catch(reason => Promise.reject(reason));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
info(key, container) {
|
|
60
|
+
if (!key) {
|
|
61
|
+
return Promise.resolve({});
|
|
62
|
+
}
|
|
63
|
+
const id = this._prefix ? key.substring(this._prefix.length + 1) : key;
|
|
64
|
+
const label = this.getLabelField();
|
|
65
|
+
return new Promise(resolve => {
|
|
66
|
+
this.getRecord(id).then(json => {
|
|
67
|
+
const died = json.data.death ? `† ${json.data.death}` : '';
|
|
68
|
+
const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
|
|
69
|
+
const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
|
|
70
|
+
const output = `
|
|
71
71
|
<h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${json.data[label]}</a></h3>
|
|
72
72
|
${dates}
|
|
73
73
|
${note}
|
|
74
74
|
`;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
75
|
+
container.innerHTML = output;
|
|
76
|
+
resolve({
|
|
77
|
+
id: this._prefix ? `${this._prefix}-${json.data.id}` : json.data.id,
|
|
78
|
+
strings: [json.data[label]],
|
|
80
79
|
});
|
|
81
80
|
});
|
|
82
|
-
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
85
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
86
|
-
*
|
|
86
|
+
*
|
|
87
87
|
* @param {string} key the key to look up
|
|
88
88
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
89
89
|
*/
|
|
@@ -91,68 +91,68 @@ export class Anton extends Registry {
|
|
|
91
91
|
const id = key.replace(/^.*-([^-]+)$/, '$1');
|
|
92
92
|
const url = `${this._url}/${this.getRegister()}/${id}`;
|
|
93
93
|
return fetch(url)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
94
|
+
.then(response => response.json())
|
|
95
|
+
.then(json => {
|
|
96
|
+
const output = { ...json };
|
|
97
|
+
output.name = json.data[this.getLabelField()];
|
|
98
|
+
switch (this._register) {
|
|
99
|
+
case 'place':
|
|
100
|
+
output.country = json.data.country;
|
|
101
|
+
if (json.data.location && json.data.location.coordinates) {
|
|
102
|
+
output.location = json.data.location.coordinates;
|
|
103
|
+
}
|
|
104
|
+
output.links = json.data.links.map(link => link.url);
|
|
105
|
+
break;
|
|
106
|
+
case 'person':
|
|
107
|
+
output.birth = json.data.birth;
|
|
108
|
+
output.death = json.data.death;
|
|
109
|
+
output.note = json.data.note_bio;
|
|
110
|
+
output.links = [`https://${json.wikipediaURL}`];
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return output;
|
|
116
|
+
})
|
|
117
|
+
.catch(reason => Promise.reject(reason));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
return label;
|
|
120
|
+
getLabelField() {
|
|
121
|
+
let label;
|
|
122
|
+
switch (this._register) {
|
|
123
|
+
case 'term':
|
|
124
|
+
label = 'label';
|
|
125
|
+
break;
|
|
126
|
+
default:
|
|
127
|
+
label = 'fullname';
|
|
128
|
+
break;
|
|
131
129
|
}
|
|
130
|
+
return label;
|
|
131
|
+
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
let register;
|
|
138
|
-
switch(this._register) {
|
|
139
|
-
case 'person':
|
|
140
|
-
case 'organization':
|
|
141
|
-
register = 'actors';
|
|
142
|
-
break;
|
|
143
|
-
case 'origPlace':
|
|
144
|
-
case 'place':
|
|
145
|
-
register = 'places';
|
|
146
|
-
break;
|
|
147
|
-
case 'term':
|
|
148
|
-
register = 'keywords';
|
|
149
|
-
break;
|
|
150
|
-
case 'abbreviation':
|
|
151
|
-
register = 'abbreviations';
|
|
152
|
-
break;
|
|
153
|
-
default:
|
|
154
|
-
register = this._register;
|
|
155
|
-
}
|
|
156
|
-
return register;
|
|
133
|
+
getRegister() {
|
|
134
|
+
if (this._api) {
|
|
135
|
+
return this._api;
|
|
157
136
|
}
|
|
137
|
+
let register;
|
|
138
|
+
switch (this._register) {
|
|
139
|
+
case 'person':
|
|
140
|
+
case 'organization':
|
|
141
|
+
register = 'actors';
|
|
142
|
+
break;
|
|
143
|
+
case 'origPlace':
|
|
144
|
+
case 'place':
|
|
145
|
+
register = 'places';
|
|
146
|
+
break;
|
|
147
|
+
case 'term':
|
|
148
|
+
register = 'keywords';
|
|
149
|
+
break;
|
|
150
|
+
case 'abbreviation':
|
|
151
|
+
register = 'abbreviations';
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
register = this._register;
|
|
155
|
+
}
|
|
156
|
+
return register;
|
|
157
|
+
}
|
|
158
158
|
}
|
package/src/authority/custom.js
CHANGED
|
@@ -3,13 +3,12 @@ import { Registry } from './registry.js';
|
|
|
3
3
|
import { createConnectors } from './connectors.js';
|
|
4
4
|
|
|
5
5
|
export class Custom extends Registry {
|
|
6
|
-
|
|
7
6
|
constructor(endpoint, configElem) {
|
|
8
7
|
super(configElem);
|
|
9
8
|
this._editable = configElem.hasAttribute('edit');
|
|
10
9
|
this._endpoint = endpoint;
|
|
11
10
|
this._connectors = createConnectors(endpoint, configElem);
|
|
12
|
-
this._connectors.forEach(
|
|
11
|
+
this._connectors.forEach(connector => {
|
|
13
12
|
connector.name = this.name;
|
|
14
13
|
});
|
|
15
14
|
console.log(
|
|
@@ -39,7 +38,7 @@ export class Custom extends Registry {
|
|
|
39
38
|
label: item.label,
|
|
40
39
|
link: item.link,
|
|
41
40
|
details: item.details,
|
|
42
|
-
provider: 'local'
|
|
41
|
+
provider: 'local',
|
|
43
42
|
});
|
|
44
43
|
localResults.add(item.id);
|
|
45
44
|
});
|
|
@@ -48,7 +47,7 @@ export class Custom extends Registry {
|
|
|
48
47
|
for (const connector of this._connectors) {
|
|
49
48
|
// eslint-disable-next-line no-await-in-loop
|
|
50
49
|
const dr = await connector.query(key);
|
|
51
|
-
results = results.concat(dr.items.filter(
|
|
50
|
+
results = results.concat(dr.items.filter(result => !localResults.has(result.id)));
|
|
52
51
|
totalItems += dr.totalItems;
|
|
53
52
|
}
|
|
54
53
|
resolve({
|
|
@@ -65,15 +64,15 @@ export class Custom extends Registry {
|
|
|
65
64
|
}
|
|
66
65
|
const id = key;
|
|
67
66
|
return new Promise((resolve, reject) => {
|
|
68
|
-
fetch(`${this._endpoint}/api/register/${this._register}/${encodeURIComponent(id)}`)
|
|
69
|
-
|
|
67
|
+
fetch(`${this._endpoint}/api/register/${this._register}/${encodeURIComponent(id)}`).then(
|
|
68
|
+
async response => {
|
|
70
69
|
if (response.ok) {
|
|
71
70
|
const json = await response.json();
|
|
72
71
|
container.innerHTML = json.details;
|
|
73
72
|
resolve({
|
|
74
73
|
id: json.id,
|
|
75
74
|
strings: json.strings,
|
|
76
|
-
editable: this._editable
|
|
75
|
+
editable: this._editable,
|
|
77
76
|
});
|
|
78
77
|
return;
|
|
79
78
|
}
|
|
@@ -87,17 +86,18 @@ export class Custom extends Registry {
|
|
|
87
86
|
}
|
|
88
87
|
} catch (e) {
|
|
89
88
|
// not found: continue
|
|
90
|
-
}
|
|
89
|
+
}
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
reject();
|
|
94
|
-
}
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param {any} item
|
|
99
|
+
*
|
|
100
|
+
* @param {any} item
|
|
101
101
|
* @returns {Promise}
|
|
102
102
|
*/
|
|
103
103
|
async select(item) {
|
|
@@ -112,16 +112,18 @@ export class Custom extends Registry {
|
|
|
112
112
|
if (!entry) {
|
|
113
113
|
return Promise.resolve(item);
|
|
114
114
|
}
|
|
115
|
-
return fetch(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
return fetch(
|
|
116
|
+
`${this._endpoint}/api/register/${this._register}/${encodeURIComponent(item.id)}`,
|
|
117
|
+
{
|
|
118
|
+
method: 'POST',
|
|
119
|
+
mode: 'cors',
|
|
120
|
+
credentials: 'same-origin',
|
|
121
|
+
headers: {
|
|
122
|
+
'Content-Type': 'application/json',
|
|
123
|
+
},
|
|
124
|
+
body: JSON.stringify(entry),
|
|
125
|
+
},
|
|
126
|
+
).then(response => {
|
|
125
127
|
if (response.ok) {
|
|
126
128
|
return response.json();
|
|
127
129
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Registry } from './registry.js';
|
|
2
2
|
|
|
3
3
|
export class GeoNames extends Registry {
|
|
4
|
-
|
|
5
4
|
constructor(configElem) {
|
|
6
5
|
super(configElem);
|
|
7
6
|
this.user = configElem.getAttribute('user');
|
|
@@ -26,7 +25,7 @@ export class GeoNames extends Registry {
|
|
|
26
25
|
details: `${item.fcodeName} - ${item.adminName1}, ${item.countryName}`,
|
|
27
26
|
link: `https://www.geonames.org/${item.geonameId}`,
|
|
28
27
|
strings: [item.toponymName],
|
|
29
|
-
provider: 'geonames.org'
|
|
28
|
+
provider: 'geonames.org',
|
|
30
29
|
};
|
|
31
30
|
results.push(result);
|
|
32
31
|
});
|
|
@@ -43,24 +42,25 @@ export class GeoNames extends Registry {
|
|
|
43
42
|
return Promise.resolve({});
|
|
44
43
|
}
|
|
45
44
|
return new Promise((resolve, reject) => {
|
|
46
|
-
this.getRecord(key)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
this.getRecord(key)
|
|
46
|
+
.then(json => {
|
|
47
|
+
if (json.status) {
|
|
48
|
+
reject(json.status.message);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const output = `
|
|
52
52
|
<h3 class="label">
|
|
53
53
|
<a href="${json.link}" target="_blank">${json.name}</a>
|
|
54
54
|
</h3>
|
|
55
55
|
<p class="fcode">${json.note} - ${json.region}, ${json.country}</p>
|
|
56
56
|
`;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
container.innerHTML = output;
|
|
58
|
+
resolve({
|
|
59
|
+
id: this._prefix ? `${this._prefix}-${json.geonameId}` : json.geonameId,
|
|
60
|
+
strings: [json.name],
|
|
61
|
+
});
|
|
62
|
+
})
|
|
63
|
+
.catch(() => reject());
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -73,22 +73,28 @@ export class GeoNames extends Registry {
|
|
|
73
73
|
async getRecord(key) {
|
|
74
74
|
const id = this._prefix ? key.substring(this._prefix.length + 1) : key;
|
|
75
75
|
return fetch(
|
|
76
|
-
`https://secure.geonames.org/getJSON?geonameId=${encodeURIComponent(id)}&username=${
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
`https://secure.geonames.org/getJSON?geonameId=${encodeURIComponent(id)}&username=${
|
|
77
|
+
this.user
|
|
78
|
+
}`,
|
|
79
|
+
)
|
|
80
|
+
.then(response => {
|
|
81
|
+
if (response.ok) {
|
|
82
|
+
return response.json();
|
|
83
|
+
}
|
|
84
|
+
return Promise.reject(response.status);
|
|
85
|
+
})
|
|
86
|
+
.then(json => {
|
|
87
|
+
const output = { ...json };
|
|
88
|
+
output.name = json.toponymName;
|
|
89
|
+
output.country = json.countryName;
|
|
90
|
+
output.region = json.adminName1;
|
|
91
|
+
output.note = json.fcodeName;
|
|
92
|
+
output.links = [
|
|
93
|
+
`https://www.geonames.org/${json.geonameId}`,
|
|
94
|
+
`https://${json.wikipediaURL}`,
|
|
95
|
+
];
|
|
96
|
+
return output;
|
|
97
|
+
})
|
|
98
|
+
.catch(() => Promise.reject());
|
|
93
99
|
}
|
|
94
100
|
}
|