@teipublisher/pb-components 2.26.1-next.3 → 3.0.0-next-4.1
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/docker-cypress.yml +54 -0
- package/.github/workflows/main.yml +6 -4
- package/.github/workflows/node.js.yml +56 -21
- package/.github/workflows/release.js.yml +19 -17
- package/.releaserc.json +1 -1
- package/CHANGELOG.md +346 -11
- package/Dockerfile +78 -70
- package/README.md +112 -4
- package/css/components.css +5 -5
- package/css/gridjs/mermaid.min.css +1 -1
- package/css/leaflet/Control.Geocoder.css +1 -126
- package/css/leaflet/images/layers.png +0 -0
- package/css/tify/tify.css +6 -5
- package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
- package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css.map +1 -0
- package/css/tom-select/tom-select.min.css +1 -1
- package/cypress.config.js +84 -0
- package/dist/api.html +1 -1
- package/dist/css/design-system.css +607 -0
- package/dist/demo/bundle-test.html +4 -3
- package/dist/demo/components.css +46 -1
- package/dist/demo/design-system.html +710 -0
- package/dist/demo/dts-client.html +2 -2
- package/dist/demo/pb-autocomplete.html +23 -11
- package/dist/demo/pb-autocomplete2.html +66 -55
- package/dist/demo/pb-autocomplete3.html +17 -8
- package/dist/demo/pb-blacklab-highlight.html +28 -11
- package/dist/demo/pb-blacklab-results.html +3 -2
- package/dist/demo/pb-browse-docs.html +24 -24
- package/dist/demo/pb-browse-docs2.html +3 -3
- package/dist/demo/pb-clipboard.html +32 -28
- package/dist/demo/pb-code-editor.html +6 -6
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-codepen.html +1 -1
- package/dist/demo/pb-collapse.html +1 -1
- package/dist/demo/pb-collapse2.html +2 -2
- package/dist/demo/pb-combo-box.html +135 -130
- package/dist/demo/pb-custom-form.html +64 -55
- package/dist/demo/pb-dialog.html +12 -6
- package/dist/demo/pb-document.html +1 -1
- package/dist/demo/pb-download.html +68 -59
- package/dist/demo/pb-drawer.html +67 -46
- package/dist/demo/pb-drawer2.html +65 -58
- package/dist/demo/pb-edit-app.html +2 -2
- package/dist/demo/pb-edit-xml.html +1 -1
- package/dist/demo/pb-facsimile-2.html +26 -11
- package/dist/demo/pb-facsimile-3.html +25 -10
- package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
- package/dist/demo/pb-facsimile-dedup-test.html +48 -0
- package/dist/demo/pb-facsimile.html +4 -4
- package/dist/demo/pb-formula.html +1 -1
- package/dist/demo/pb-grid.html +22 -8
- package/dist/demo/pb-highlight.html +2 -2
- package/dist/demo/pb-i18n-simple.html +1 -0
- package/dist/demo/pb-i18n.html +15 -5
- package/dist/demo/pb-image-strip-standalone.html +2 -2
- package/dist/demo/pb-image-strip-view.html +2 -2
- package/dist/demo/pb-leaflet-map.html +3 -3
- package/dist/demo/pb-leaflet-map2.html +2 -2
- package/dist/demo/pb-leaflet-map3.html +3 -3
- package/dist/demo/pb-link.html +1 -1
- package/dist/demo/pb-load.html +2 -6
- package/dist/demo/pb-login.html +1 -3
- package/dist/demo/pb-manage-odds.html +9 -4
- package/dist/demo/pb-markdown.html +1 -1
- package/dist/demo/pb-media-query.html +2 -2
- package/dist/demo/pb-mei.html +2 -2
- package/dist/demo/pb-mei2.html +2 -2
- package/dist/demo/pb-message.html +2 -3
- package/dist/demo/pb-odd-editor.html +54 -52
- package/dist/demo/pb-page-header.html +27 -0
- package/dist/demo/pb-popover.html +1 -1
- package/dist/demo/pb-print-preview.html +2 -2
- package/dist/demo/pb-progress.html +4 -4
- package/dist/demo/pb-repeat.html +32 -36
- package/dist/demo/pb-search.html +16 -5
- package/dist/demo/pb-search2.html +4 -4
- package/dist/demo/pb-search3.html +3 -3
- package/dist/demo/pb-search4.html +3 -3
- package/dist/demo/pb-select-feature.html +4 -4
- package/dist/demo/pb-select-feature2.html +4 -4
- package/dist/demo/pb-select-feature3.html +2 -2
- package/dist/demo/pb-select-i18n.html +58 -53
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-select.html +190 -75
- package/dist/demo/pb-select2.html +91 -37
- package/dist/demo/pb-select3.html +109 -41
- package/dist/demo/pb-svg.html +1 -1
- package/dist/demo/pb-table-grid.html +26 -15
- package/dist/demo/pb-tabs.html +15 -7
- package/dist/demo/pb-tify.html +7 -7
- package/dist/demo/pb-timeline.html +1 -1
- package/dist/demo/pb-timeline2.html +1 -1
- package/dist/demo/pb-toggle-feature.html +26 -23
- package/dist/demo/pb-toggle-feature2.html +4 -4
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-toggle-feature4.html +56 -54
- package/dist/demo/pb-version.html +2 -2
- package/dist/demo/pb-view.html +78 -40
- package/dist/demo/pb-view2.html +69 -46
- package/dist/demo/pb-view3.html +53 -48
- package/dist/demo/pb-view4.html +70 -49
- package/dist/demo/pb-zoom.html +2 -2
- package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
- package/dist/focus-mixin-VCsFap6b.js +768 -0
- package/dist/images/icons.svg +217 -0
- package/dist/jinn-codemirror-DETLdm08.js +1 -0
- package/dist/lib/openseadragon.min.js +80 -0
- package/dist/lib/openseadragon.min.js.map +1 -0
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +414 -3225
- package/dist/pb-components-bundle.js +3046 -4402
- package/dist/pb-dialog-tklYGWfc.js +121 -0
- package/dist/pb-edit-app.js +208 -107
- package/dist/pb-elements.json +716 -249
- package/dist/pb-facsimile.js +46 -0
- package/dist/pb-i18n-C0NDma4h.js +1 -0
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +152 -134
- package/dist/pb-mixin-DHoWQheB.js +1 -0
- package/dist/pb-odd-editor.js +1671 -1231
- package/dist/pb-tify.js +1 -27
- package/dist/unsafe-html-D5VGo9Oq.js +1 -0
- package/dist/urls-BEONu_g4.js +1 -0
- package/eslint.config.mjs +92 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/images/icons.svg +217 -0
- package/index.html +0 -5
- package/lib/leaflet-src.js.map +1 -0
- package/lib/leaflet.markercluster-src.js.map +1 -0
- package/lib/openseadragon.min.js +6 -6
- package/package.json +56 -81
- package/pb-elements.json +716 -249
- package/rollup.config.mjs +312 -0
- package/src/assets/components.css +5 -5
- package/src/assets/design-system.css +607 -0
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +70 -27
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +136 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -68
- package/src/authority/registry.js +4 -4
- package/src/docs/demo-utils.js +91 -0
- package/src/docs/pb-component-docs.js +287 -147
- package/src/docs/pb-component-view.js +380 -273
- package/src/docs/pb-components-list.js +115 -51
- package/src/docs/pb-demo-snippet.js +199 -174
- package/src/dts-client.js +306 -303
- package/src/dts-select-endpoint.js +125 -85
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +175 -173
- package/src/pb-authority-lookup.js +198 -158
- package/src/pb-autocomplete.js +731 -313
- package/src/pb-blacklab-highlight.js +266 -260
- package/src/pb-blacklab-results.js +230 -225
- package/src/pb-browse-docs.js +601 -484
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +97 -76
- package/src/pb-code-editor.js +111 -103
- package/src/pb-code-highlight.js +234 -204
- package/src/pb-codepen.js +81 -73
- package/src/pb-collapse.js +265 -152
- package/src/pb-combo-box.js +191 -191
- package/src/pb-components-bundle.js +1 -7
- package/src/pb-components.js +2 -6
- package/src/pb-custom-form.js +230 -141
- package/src/pb-dialog.js +99 -63
- package/src/pb-document.js +118 -91
- package/src/pb-download.js +214 -198
- package/src/pb-drawer.js +146 -149
- package/src/pb-edit-app.js +471 -240
- package/src/pb-edit-xml.js +101 -98
- package/src/pb-events.js +126 -107
- package/src/pb-facs-link.js +130 -101
- package/src/pb-facsimile.js +494 -410
- package/src/pb-fetch.js +389 -0
- package/src/pb-formula.js +152 -154
- package/src/pb-geolocation.js +130 -132
- package/src/pb-grid-action.js +59 -56
- package/src/pb-grid.js +388 -228
- package/src/pb-highlight.js +142 -142
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +115 -127
- package/src/pb-icon-button.js +108 -0
- package/src/pb-icon.js +283 -0
- package/src/pb-image-strip.js +85 -79
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +551 -483
- package/src/pb-link.js +132 -126
- package/src/pb-load.js +495 -428
- package/src/pb-login.js +303 -248
- package/src/pb-manage-odds.js +384 -338
- package/src/pb-map-icon.js +90 -90
- package/src/pb-map-layer.js +86 -86
- package/src/pb-markdown.js +107 -110
- package/src/pb-media-query.js +75 -73
- package/src/pb-mei.js +523 -303
- package/src/pb-message.js +144 -98
- package/src/pb-mixin.js +268 -265
- package/src/pb-navigation.js +83 -96
- package/src/pb-observable.js +39 -39
- package/src/pb-odd-editor.js +1209 -948
- package/src/pb-odd-elementspec-editor.js +375 -310
- package/src/pb-odd-model-editor.js +1189 -941
- package/src/pb-odd-parameter-editor.js +269 -170
- package/src/pb-odd-rendition-editor.js +184 -131
- package/src/pb-page.js +451 -422
- package/src/pb-paginate.js +260 -178
- package/src/pb-panel.js +217 -183
- package/src/pb-popover-themes.js +16 -9
- package/src/pb-popover.js +297 -288
- package/src/pb-print-preview.js +128 -128
- package/src/pb-progress.js +52 -52
- package/src/pb-repeat.js +141 -108
- package/src/pb-restricted.js +85 -78
- package/src/pb-search.js +258 -230
- package/src/pb-select-feature.js +210 -126
- package/src/pb-select-odd.js +184 -118
- package/src/pb-select-template.js +113 -78
- package/src/pb-select.js +330 -229
- package/src/pb-split-list.js +181 -176
- package/src/pb-svg.js +81 -80
- package/src/pb-table-column.js +55 -55
- package/src/pb-table-grid.js +334 -205
- package/src/pb-tabs.js +238 -61
- package/src/pb-tify.js +3331 -126
- package/src/pb-timeline.js +394 -255
- package/src/pb-toggle-feature.js +196 -188
- package/src/pb-upload.js +201 -176
- package/src/pb-version.js +22 -34
- package/src/pb-view-annotate.js +138 -102
- package/src/pb-view.js +1722 -1272
- package/src/pb-zoom.js +144 -46
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +14 -22
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +403 -289
- package/src/utils.js +53 -51
- package/vite.config.js +86 -0
- package/css/pb-styles.css +0 -51
- package/dist/iron-form-3b8dcaa7.js +0 -210
- package/dist/jinn-codemirror-da0e2d1f.js +0 -1
- package/dist/paper-checkbox-515a5284.js +0 -1597
- package/dist/paper-icon-button-b1d31571.js +0 -398
- package/dist/paper-listbox-a3b7175c.js +0 -1265
- package/dist/pb-i18n-0611135a.js +0 -1
- package/dist/pb-mixin-b1caa22e.js +0 -158
- package/dist/polymer-hack.js +0 -1
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/lib/Control.Geocoder.min.js +0 -2
- package/lib/Control.Geocoder.min.js.map +0 -1
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
- package/src/polymer-hack.js +0 -6
package/src/authority/gnd.js
CHANGED
|
@@ -7,7 +7,7 @@ function _details(item) {
|
|
|
7
7
|
professions = item.professionOrOccupation.map(p => p.label).join(', ');
|
|
8
8
|
}
|
|
9
9
|
if (item.biographicalOrHistoricalInformation) {
|
|
10
|
-
|
|
10
|
+
professions = `${professions}; ${item.biographicalOrHistoricalInformation.join(', ')}`;
|
|
11
11
|
}
|
|
12
12
|
const dates = [];
|
|
13
13
|
if (item.dateOfBirth && item.dateOfBirth.length > 0) {
|
|
@@ -27,7 +27,6 @@ function _details(item) {
|
|
|
27
27
|
* Uses https://lobid.org to query the German GND
|
|
28
28
|
*/
|
|
29
29
|
export class GND extends Registry {
|
|
30
|
-
|
|
31
30
|
query(key) {
|
|
32
31
|
const results = [];
|
|
33
32
|
let filter;
|
|
@@ -41,32 +40,39 @@ export class GND extends Registry {
|
|
|
41
40
|
case 'organization':
|
|
42
41
|
filter = 'CorporateBody';
|
|
43
42
|
break;
|
|
43
|
+
case 'work':
|
|
44
|
+
filter = 'Work';
|
|
45
|
+
break;
|
|
44
46
|
default:
|
|
45
47
|
filter = 'Person';
|
|
46
48
|
break;
|
|
47
49
|
}
|
|
48
|
-
return new Promise(
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
return new Promise(resolve => {
|
|
51
|
+
fetch(
|
|
52
|
+
`https://lobid.org/gnd/search?q=${encodeURIComponent(
|
|
53
|
+
key,
|
|
54
|
+
)}&filter=%2B%28type%3A${filter}%29&format=json&size=100`,
|
|
55
|
+
)
|
|
56
|
+
.then(response => response.json())
|
|
57
|
+
.then(json => {
|
|
58
|
+
json.member.forEach(item => {
|
|
53
59
|
const result = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
register: this._register,
|
|
61
|
+
id: this._prefix ? `${this._prefix}-${item.gndIdentifier}` : item.gndIdentifier,
|
|
62
|
+
label: item.preferredName,
|
|
63
|
+
link: item.id,
|
|
64
|
+
details: _details(item),
|
|
65
|
+
strings: [item.preferredName].concat(item.variantName),
|
|
66
|
+
provider: 'GND',
|
|
61
67
|
};
|
|
62
68
|
results.push(result);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
})
|
|
69
|
+
});
|
|
70
|
+
resolve({
|
|
71
|
+
totalItems: json.totalItems,
|
|
72
|
+
items: results,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
/**
|
|
@@ -78,14 +84,14 @@ export class GND extends Registry {
|
|
|
78
84
|
async getRecord(key) {
|
|
79
85
|
const id = this._prefix ? key.substring(this._prefix.length + 1) : key;
|
|
80
86
|
return fetch(`https://lobid.org/gnd/${id}.json`)
|
|
81
|
-
.then(
|
|
87
|
+
.then(response => {
|
|
82
88
|
if (response.ok) {
|
|
83
89
|
return response.json();
|
|
84
90
|
}
|
|
85
91
|
return Promise.reject();
|
|
86
92
|
})
|
|
87
|
-
.then(
|
|
88
|
-
const output =
|
|
93
|
+
.then(json => {
|
|
94
|
+
const output = { ...json };
|
|
89
95
|
output.name = json.preferredName;
|
|
90
96
|
output.link = json.id;
|
|
91
97
|
if (json.dateOfBirth && json.dateOfBirth.length > 0) {
|
|
@@ -98,7 +104,7 @@ export class GND extends Registry {
|
|
|
98
104
|
output.note = json.biographicalOrHistoricalInformation.join('; ');
|
|
99
105
|
}
|
|
100
106
|
if (json.professionOrOccupation && json.professionOrOccupation.length > 0) {
|
|
101
|
-
output.profession = json.professionOrOccupation.map(
|
|
107
|
+
output.profession = json.professionOrOccupation.map(prof => prof.label);
|
|
102
108
|
}
|
|
103
109
|
return output;
|
|
104
110
|
})
|
|
@@ -111,38 +117,40 @@ export class GND extends Registry {
|
|
|
111
117
|
}
|
|
112
118
|
return new Promise((resolve, reject) => {
|
|
113
119
|
this.getRecord(key)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
.then(json => {
|
|
121
|
+
let info;
|
|
122
|
+
if (json.type.indexOf('SubjectHeading') > -1) {
|
|
123
|
+
info = this.infoSubject(json);
|
|
124
|
+
} else if (json.type.indexOf('AuthorityResource') > -1) {
|
|
125
|
+
info = this.infoPerson(json);
|
|
126
|
+
}
|
|
127
|
+
const output = `
|
|
122
128
|
<h3 class="label">
|
|
123
129
|
<a href="https://${json.id}" target="_blank"> ${json.preferredName} </a>
|
|
124
130
|
</h3>
|
|
125
131
|
${info}
|
|
126
132
|
`;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
container.innerHTML = output;
|
|
134
|
+
resolve({
|
|
135
|
+
id: this._prefix ? `${this._prefix}-${json.gndIdentifier}` : json.gndIdentifier,
|
|
136
|
+
strings: [json.preferredName].concat(json.variantName),
|
|
137
|
+
});
|
|
138
|
+
})
|
|
139
|
+
.catch(() => reject());
|
|
134
140
|
});
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
infoPerson(json) {
|
|
138
|
-
const professions = json.professionOrOccuption
|
|
144
|
+
const professions = json.professionOrOccuption
|
|
145
|
+
? json.professionOrOccupation.map(prof => prof.label)
|
|
146
|
+
: [];
|
|
139
147
|
return `<p>${json.dateOfBirth} - ${json.dateOfDeath}</p>
|
|
140
148
|
<p>${professions.join(' ')}</p>`;
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
infoSubject(json) {
|
|
144
152
|
if (json.broaderTermGeneral) {
|
|
145
|
-
const terms = json.broaderTermGeneral.map(
|
|
153
|
+
const terms = json.broaderTermGeneral.map(term => term.label);
|
|
146
154
|
return `<p>${terms.join(', ')}</p>`;
|
|
147
155
|
}
|
|
148
156
|
return '';
|
package/src/authority/kbga.js
CHANGED
|
@@ -1,156 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Registry } from "./registry.js";
|
|
1
|
+
import { Registry } from './registry.js';
|
|
3
2
|
|
|
4
3
|
export class KBGA extends Registry {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
4
|
+
constructor(configElem) {
|
|
5
|
+
super(configElem);
|
|
6
|
+
this._api = configElem.getAttribute('api');
|
|
7
|
+
this._limit = configElem.getAttribute('limit') || 999999;
|
|
8
|
+
}
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const register = this.getRegister();
|
|
16
|
-
const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
|
|
17
|
-
const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(key)}&perPage=${this._limit}`;
|
|
18
|
-
const label = this.getLabelField();
|
|
19
|
-
return new Promise((resolve) => {
|
|
20
|
-
fetch(url)
|
|
21
|
-
.then(response => response.json())
|
|
22
|
-
.then(json => {
|
|
23
|
-
json.data.forEach(item => {
|
|
24
|
-
|
|
25
|
-
if ((this._register === 'organization' && item.authority_type !== 'organisation') ||
|
|
26
|
-
(this._register === 'person' && item.authority_type !== 'person')) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const result = {
|
|
30
|
-
register: this._register,
|
|
31
|
-
id: (this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id']),
|
|
32
|
-
label: typeof label === "string" ? item[label] : label(item),
|
|
33
|
-
details: `${item['full-id']}`,
|
|
34
|
-
link: `https://meta.karl-barth.ch/${register}/${item.id}`,
|
|
35
|
-
strings: [typeof label === "string" ? item[label] : label(item)],
|
|
36
|
-
provider: 'KBGA'
|
|
37
|
-
};
|
|
38
|
-
results.push(result);
|
|
39
|
-
});
|
|
40
|
-
resolve({
|
|
41
|
-
totalItems: json.meta.total,
|
|
42
|
-
items: results,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
})
|
|
46
|
-
}
|
|
10
|
+
async query(key) {
|
|
11
|
+
const results = [];
|
|
47
12
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
13
|
+
const register = this.getRegister();
|
|
14
|
+
const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
|
|
15
|
+
const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(
|
|
16
|
+
key,
|
|
17
|
+
)}&perPage=${this._limit}`;
|
|
18
|
+
const label = this.getLabelField();
|
|
19
|
+
return new Promise(resolve => {
|
|
20
|
+
fetch(url)
|
|
21
|
+
.then(response => response.json())
|
|
55
22
|
.then(json => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
23
|
+
json.data.forEach(item => {
|
|
24
|
+
if (
|
|
25
|
+
(this._register === 'organization' && item.authority_type !== 'organisation') ||
|
|
26
|
+
(this._register === 'person' && item.authority_type !== 'person')
|
|
27
|
+
) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const result = {
|
|
31
|
+
register: this._register,
|
|
32
|
+
id: this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id'],
|
|
33
|
+
label: typeof label === 'string' ? item[label] : label(item),
|
|
34
|
+
details: `${item['full-id']}`,
|
|
35
|
+
link: `https://meta.karl-barth.ch/${register}/${item.id}`,
|
|
36
|
+
strings: [typeof label === 'string' ? item[label] : label(item)],
|
|
37
|
+
provider: 'KBGA',
|
|
38
|
+
};
|
|
39
|
+
results.push(result);
|
|
40
|
+
});
|
|
41
|
+
resolve({
|
|
42
|
+
totalItems: json.meta.total,
|
|
43
|
+
items: results,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
info(key, container) {
|
|
50
|
+
if (!key) {
|
|
51
|
+
return Promise.resolve({});
|
|
52
|
+
}
|
|
53
|
+
const label = this.getLabelField();
|
|
54
|
+
return new Promise(resolve => {
|
|
55
|
+
this.getRecord(key).then(json => {
|
|
56
|
+
const died = json.data.death ? `† ${json.data.death}` : '';
|
|
57
|
+
const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
|
|
58
|
+
const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
|
|
59
|
+
const output = `
|
|
60
|
+
<h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${
|
|
61
|
+
typeof label === 'string' ? json.data[label] : label(json.data)
|
|
62
|
+
}</a></h3>
|
|
61
63
|
${dates}
|
|
62
64
|
${note}
|
|
63
65
|
`;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
66
|
+
container.innerHTML = output;
|
|
67
|
+
resolve({
|
|
68
|
+
id: json.data['full-id'],
|
|
69
|
+
strings: [typeof label === 'string' ? json.data[label] : label(json.data)],
|
|
69
70
|
});
|
|
70
71
|
});
|
|
71
|
-
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
/**
|
|
74
76
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
75
|
-
*
|
|
77
|
+
*
|
|
76
78
|
* @param {string} key the key to look up
|
|
77
79
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
78
80
|
*/
|
|
79
81
|
async getRecord(key) {
|
|
80
|
-
const id = key.replace(/^.*-([^-]+)$/, '$1')
|
|
82
|
+
const id = key.replace(/^.*-([^-]+)$/, '$1');
|
|
81
83
|
return fetch(`https://meta.karl-barth.ch/api/${this.getRegister()}/${id}`)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
case 'place':
|
|
88
|
-
output.country = json.data.country;
|
|
89
|
-
output.location = json.data.location.coordinates;
|
|
90
|
-
output.links = json.data.links.map((link) => link.url);
|
|
91
|
-
break;
|
|
92
|
-
case 'person':
|
|
93
|
-
output.birth = json.data.birth;
|
|
94
|
-
output.death = json.data.death;
|
|
95
|
-
output.note = json.data.note_bio;
|
|
96
|
-
output.links = [`https://${json.wikipediaURL}`];
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
return output;
|
|
102
|
-
})
|
|
103
|
-
.catch((reason) => Promise.reject(reason));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getLabelField() {
|
|
107
|
-
let label;
|
|
108
|
-
switch (this._register) {
|
|
84
|
+
.then(response => response.json())
|
|
85
|
+
.then(json => {
|
|
86
|
+
const output = { ...json };
|
|
87
|
+
output.name = json.data[this.getLabelField()];
|
|
88
|
+
switch (this._register) {
|
|
109
89
|
case 'place':
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
label = 'asHtml';
|
|
121
|
-
break;
|
|
90
|
+
output.country = json.data.country;
|
|
91
|
+
output.location = json.data.location.coordinates;
|
|
92
|
+
output.links = json.data.links.map(link => link.url);
|
|
93
|
+
break;
|
|
94
|
+
case 'person':
|
|
95
|
+
output.birth = json.data.birth;
|
|
96
|
+
output.death = json.data.death;
|
|
97
|
+
output.note = json.data.note_bio;
|
|
98
|
+
output.links = [`https://${json.wikipediaURL}`];
|
|
99
|
+
break;
|
|
122
100
|
default:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return output;
|
|
104
|
+
})
|
|
105
|
+
.catch(reason => Promise.reject(reason));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getLabelField() {
|
|
109
|
+
let label;
|
|
110
|
+
switch (this._register) {
|
|
111
|
+
case 'place':
|
|
112
|
+
label = 'placeName_full';
|
|
113
|
+
break;
|
|
114
|
+
case 'term':
|
|
115
|
+
label = 'fullLabel';
|
|
116
|
+
break;
|
|
117
|
+
case 'abbreviation':
|
|
118
|
+
label = 'label';
|
|
119
|
+
break;
|
|
120
|
+
case 'bibl':
|
|
121
|
+
case 'songs':
|
|
122
|
+
label = 'asHtml';
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
label = 'persName_full';
|
|
126
|
+
break;
|
|
127
127
|
}
|
|
128
|
+
return label;
|
|
129
|
+
}
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
let register;
|
|
134
|
-
switch(this._register) {
|
|
135
|
-
case 'person':
|
|
136
|
-
case 'organization':
|
|
137
|
-
register = 'actors';
|
|
138
|
-
break;
|
|
139
|
-
case 'place':
|
|
140
|
-
register = 'places';
|
|
141
|
-
break;
|
|
142
|
-
case 'term':
|
|
143
|
-
register = 'terms';
|
|
144
|
-
break;
|
|
145
|
-
case 'abbreviation':
|
|
146
|
-
register = 'abbreviations';
|
|
147
|
-
break;
|
|
148
|
-
case 'bibl':
|
|
149
|
-
register = 'bibls';
|
|
150
|
-
break;
|
|
151
|
-
default:
|
|
152
|
-
register = this._register;
|
|
153
|
-
}
|
|
154
|
-
return register;
|
|
131
|
+
getRegister() {
|
|
132
|
+
if (this._api) {
|
|
133
|
+
return this._api;
|
|
155
134
|
}
|
|
156
|
-
|
|
135
|
+
let register;
|
|
136
|
+
switch (this._register) {
|
|
137
|
+
case 'person':
|
|
138
|
+
case 'organization':
|
|
139
|
+
register = 'actors';
|
|
140
|
+
break;
|
|
141
|
+
case 'place':
|
|
142
|
+
register = 'places';
|
|
143
|
+
break;
|
|
144
|
+
case 'term':
|
|
145
|
+
register = 'terms';
|
|
146
|
+
break;
|
|
147
|
+
case 'abbreviation':
|
|
148
|
+
register = 'abbreviations';
|
|
149
|
+
break;
|
|
150
|
+
case 'bibl':
|
|
151
|
+
register = 'bibls';
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
register = this._register;
|
|
155
|
+
}
|
|
156
|
+
return register;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -2,42 +2,40 @@
|
|
|
2
2
|
import { Registry } from './registry.js';
|
|
3
3
|
|
|
4
4
|
export class Metagrid extends Registry {
|
|
5
|
-
|
|
6
5
|
async query(key) {
|
|
7
6
|
const query = key.replace(/[^\w\s]+/g, '');
|
|
8
7
|
const results = [];
|
|
9
8
|
const url = `https://api.metagrid.ch/search?query=${encodeURIComponent(query)}`;
|
|
10
|
-
|
|
11
|
-
return new Promise(
|
|
12
|
-
|
|
13
|
-
.then(
|
|
14
|
-
.then(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
fetch(url)
|
|
12
|
+
.then(response => response.json())
|
|
13
|
+
.then(json => {
|
|
14
|
+
json.resources.forEach(item => {
|
|
15
|
+
const name = `${item.metadata.last_name}, ${item.metadata.first_name} `;
|
|
16
|
+
const result = {
|
|
17
|
+
register: this._register,
|
|
18
|
+
id: `${item.provider.slug}-${item.identifier}`,
|
|
19
|
+
label: name,
|
|
20
|
+
details: `${item.metadata.birth_date} - ${item.metadata.death_date}`,
|
|
21
|
+
link: item.link.uri,
|
|
22
|
+
provider: item.provider.slug,
|
|
23
|
+
};
|
|
24
|
+
results.push(result);
|
|
25
|
+
});
|
|
26
|
+
resolve({
|
|
27
|
+
totalItems: json.meta.total,
|
|
28
|
+
items: results,
|
|
29
|
+
});
|
|
31
30
|
});
|
|
32
|
-
})
|
|
31
|
+
});
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
info(key, container) {
|
|
36
35
|
const p = key.indexOf('-');
|
|
37
36
|
const slug = key.substring(0, p);
|
|
38
|
-
return new Promise(
|
|
39
|
-
this.getRecord(key)
|
|
40
|
-
.then(json => {
|
|
37
|
+
return new Promise(resolve => {
|
|
38
|
+
this.getRecord(key).then(json => {
|
|
41
39
|
const output = `
|
|
42
40
|
<h3 class="label">
|
|
43
41
|
<a href="https://${json.link.uri}" target="_blank">
|
|
@@ -49,37 +47,37 @@ export class Metagrid extends Registry {
|
|
|
49
47
|
container.innerHTML = output;
|
|
50
48
|
resolve({
|
|
51
49
|
id: `${slug}-${json.identifier}`,
|
|
52
|
-
strings: [`${json.metadata.first_name} ${json.metadata.last_name}`]
|
|
53
|
-
})
|
|
50
|
+
strings: [`${json.metadata.first_name} ${json.metadata.last_name}`],
|
|
51
|
+
});
|
|
54
52
|
});
|
|
55
53
|
});
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
/**
|
|
59
57
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
60
|
-
*
|
|
58
|
+
*
|
|
61
59
|
* @param {string} key the key to look up
|
|
62
60
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
63
61
|
*/
|
|
64
|
-
|
|
62
|
+
async getRecord(key) {
|
|
65
63
|
const p = key.indexOf('-');
|
|
66
64
|
const slug = key.substring(0, p);
|
|
67
65
|
const id = key.substring(p + 1);
|
|
68
66
|
return fetch(`https://api.metagrid.ch/search?slug=${slug}&query=${id}`)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
67
|
+
.then(response => response.json())
|
|
68
|
+
.then(json => {
|
|
69
|
+
const item = json.resources[0];
|
|
70
|
+
const output = { ...item };
|
|
71
|
+
output.name = `${item.metadata.first_name} ${item.metadata.last_name}`;
|
|
72
|
+
output.links = [`https://${item.link.uri}`];
|
|
73
|
+
if (item.metadata.birth_date && item.metadata.birth_date.length > 0) {
|
|
74
|
+
output.birth = item.metadata.birth_date;
|
|
75
|
+
}
|
|
76
|
+
if (item.metadata.death_date && item.metadata.death_date.length > 0) {
|
|
77
|
+
output.death = item.metadata.death_date;
|
|
78
|
+
}
|
|
79
|
+
return output;
|
|
80
|
+
})
|
|
81
|
+
.catch(reason => Promise.reject(reason));
|
|
82
|
+
}
|
|
85
83
|
}
|