@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
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,159 @@
|
|
|
1
|
-
import { internalProperty } from
|
|
2
|
-
import { Registry } from
|
|
1
|
+
import { internalProperty } from 'lit-element';
|
|
2
|
+
import { Registry } from './registry.js';
|
|
3
3
|
|
|
4
4
|
export class KBGA extends Registry {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
constructor(configElem) {
|
|
6
|
+
super(configElem);
|
|
7
|
+
this._api = configElem.getAttribute('api');
|
|
8
|
+
this._limit = configElem.getAttribute('limit') || 999999;
|
|
9
|
+
}
|
|
11
10
|
|
|
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
|
-
}
|
|
11
|
+
async query(key) {
|
|
12
|
+
const results = [];
|
|
47
13
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
14
|
+
const register = this.getRegister();
|
|
15
|
+
const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
|
|
16
|
+
const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(
|
|
17
|
+
key,
|
|
18
|
+
)}&perPage=${this._limit}`;
|
|
19
|
+
const label = this.getLabelField();
|
|
20
|
+
return new Promise(resolve => {
|
|
21
|
+
fetch(url)
|
|
22
|
+
.then(response => response.json())
|
|
55
23
|
.then(json => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
24
|
+
json.data.forEach(item => {
|
|
25
|
+
if (
|
|
26
|
+
(this._register === 'organization' && item.authority_type !== 'organisation') ||
|
|
27
|
+
(this._register === 'person' && item.authority_type !== 'person')
|
|
28
|
+
) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const result = {
|
|
32
|
+
register: this._register,
|
|
33
|
+
id: this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id'],
|
|
34
|
+
label: typeof label === 'string' ? item[label] : label(item),
|
|
35
|
+
details: `${item['full-id']}`,
|
|
36
|
+
link: `https://meta.karl-barth.ch/${register}/${item.id}`,
|
|
37
|
+
strings: [typeof label === 'string' ? item[label] : label(item)],
|
|
38
|
+
provider: 'KBGA',
|
|
39
|
+
};
|
|
40
|
+
results.push(result);
|
|
41
|
+
});
|
|
42
|
+
resolve({
|
|
43
|
+
totalItems: json.meta.total,
|
|
44
|
+
items: results,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
info(key, container) {
|
|
51
|
+
if (!key) {
|
|
52
|
+
return Promise.resolve({});
|
|
53
|
+
}
|
|
54
|
+
const label = this.getLabelField();
|
|
55
|
+
return new Promise(resolve => {
|
|
56
|
+
this.getRecord(key).then(json => {
|
|
57
|
+
const died = json.data.death ? `† ${json.data.death}` : '';
|
|
58
|
+
const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
|
|
59
|
+
const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
|
|
60
|
+
const output = `
|
|
61
|
+
<h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${
|
|
62
|
+
typeof label === 'string' ? json.data[label] : label(json.data)
|
|
63
|
+
}</a></h3>
|
|
61
64
|
${dates}
|
|
62
65
|
${note}
|
|
63
66
|
`;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
67
|
+
container.innerHTML = output;
|
|
68
|
+
resolve({
|
|
69
|
+
id: json.data['full-id'],
|
|
70
|
+
strings: [typeof label === 'string' ? json.data[label] : label(json.data)],
|
|
69
71
|
});
|
|
70
72
|
});
|
|
71
|
-
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
/**
|
|
74
77
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
75
|
-
*
|
|
78
|
+
*
|
|
76
79
|
* @param {string} key the key to look up
|
|
77
80
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
78
81
|
*/
|
|
79
82
|
async getRecord(key) {
|
|
80
|
-
const id = key.replace(/^.*-([^-]+)$/, '$1')
|
|
83
|
+
const id = key.replace(/^.*-([^-]+)$/, '$1');
|
|
81
84
|
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) {
|
|
85
|
+
.then(response => response.json())
|
|
86
|
+
.then(json => {
|
|
87
|
+
const output = { ...json };
|
|
88
|
+
output.name = json.data[this.getLabelField()];
|
|
89
|
+
switch (this._register) {
|
|
109
90
|
case 'place':
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
label = 'asHtml';
|
|
121
|
-
break;
|
|
91
|
+
output.country = json.data.country;
|
|
92
|
+
output.location = json.data.location.coordinates;
|
|
93
|
+
output.links = json.data.links.map(link => link.url);
|
|
94
|
+
break;
|
|
95
|
+
case 'person':
|
|
96
|
+
output.birth = json.data.birth;
|
|
97
|
+
output.death = json.data.death;
|
|
98
|
+
output.note = json.data.note_bio;
|
|
99
|
+
output.links = [`https://${json.wikipediaURL}`];
|
|
100
|
+
break;
|
|
122
101
|
default:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
return output;
|
|
105
|
+
})
|
|
106
|
+
.catch(reason => Promise.reject(reason));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getLabelField() {
|
|
110
|
+
let label;
|
|
111
|
+
switch (this._register) {
|
|
112
|
+
case 'place':
|
|
113
|
+
label = 'placeName_full';
|
|
114
|
+
break;
|
|
115
|
+
case 'term':
|
|
116
|
+
label = 'fullLabel';
|
|
117
|
+
break;
|
|
118
|
+
case 'abbreviation':
|
|
119
|
+
label = 'label';
|
|
120
|
+
break;
|
|
121
|
+
case 'bibl':
|
|
122
|
+
case 'songs':
|
|
123
|
+
label = 'asHtml';
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
label = 'persName_full';
|
|
127
|
+
break;
|
|
127
128
|
}
|
|
129
|
+
return label;
|
|
130
|
+
}
|
|
128
131
|
|
|
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;
|
|
132
|
+
getRegister() {
|
|
133
|
+
if (this._api) {
|
|
134
|
+
return this._api;
|
|
155
135
|
}
|
|
156
|
-
|
|
136
|
+
let register;
|
|
137
|
+
switch (this._register) {
|
|
138
|
+
case 'person':
|
|
139
|
+
case 'organization':
|
|
140
|
+
register = 'actors';
|
|
141
|
+
break;
|
|
142
|
+
case 'place':
|
|
143
|
+
register = 'places';
|
|
144
|
+
break;
|
|
145
|
+
case 'term':
|
|
146
|
+
register = 'terms';
|
|
147
|
+
break;
|
|
148
|
+
case 'abbreviation':
|
|
149
|
+
register = 'abbreviations';
|
|
150
|
+
break;
|
|
151
|
+
case 'bibl':
|
|
152
|
+
register = 'bibls';
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
register = this._register;
|
|
156
|
+
}
|
|
157
|
+
return register;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -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
|
}
|