@museumwnf/viewer-core 2.17.0 → 2.19.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/package.json +1 -1
- package/src/createViewer.js +16 -0
- package/src/dxa/exhibition/useExhibitionData.js +18 -8
- package/src/dxa/exhibition/useExhibitionItemDetail.js +12 -6
- package/src/dxa/exhibition/useExhibitionSheet.js +32 -11
- package/src/dxa/gallery/useGalleryData.js +3 -1
- package/src/i18n/markdown.js +13 -4
- package/src/index.js +1 -0
- package/src/legacySites.js +235 -0
- package/src/record/derivations.js +3 -2
package/package.json
CHANGED
package/src/createViewer.js
CHANGED
|
@@ -7,6 +7,7 @@ import { connectLanguageToRouter, resolveInitialLanguage } from './i18n/language
|
|
|
7
7
|
import { VIEWER_CONFIG } from './injectionKeys.js'
|
|
8
8
|
import { createViewerRouter } from './router/index.js'
|
|
9
9
|
import { setSiteConfig } from './siteConfig.js'
|
|
10
|
+
import { watchNewSiteLinks } from './legacySites.js'
|
|
10
11
|
import './styles/base.css'
|
|
11
12
|
|
|
12
13
|
export function createViewer(config = {}) {
|
|
@@ -27,5 +28,20 @@ export function createViewer(config = {}) {
|
|
|
27
28
|
connectLanguageToRouter({ locale: i18n.locale, offered: languages, router })
|
|
28
29
|
bindDisplayLanguage(i18n.locale)
|
|
29
30
|
|
|
31
|
+
// Every link the site draws, its windows' included, goes to the new site
|
|
32
|
+
// of a legacy address that has one (inventory-app#2482).
|
|
33
|
+
const mount = app.mount.bind(app)
|
|
34
|
+
const unmount = app.unmount.bind(app)
|
|
35
|
+
let stopLinks = () => {}
|
|
36
|
+
app.mount = (...args) => {
|
|
37
|
+
const instance = mount(...args)
|
|
38
|
+
stopLinks = watchNewSiteLinks(typeof document === 'undefined' ? null : document.body)
|
|
39
|
+
return instance
|
|
40
|
+
}
|
|
41
|
+
app.unmount = () => {
|
|
42
|
+
stopLinks()
|
|
43
|
+
unmount()
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
return app
|
|
31
47
|
}
|
|
@@ -5,6 +5,7 @@ import { useDataPackage } from '../../composables/useDataPackage.js'
|
|
|
5
5
|
import { byId, entityRef } from '../../composables/useEntities.js'
|
|
6
6
|
import { projectLabel } from '../../conventions.js'
|
|
7
7
|
import { useLegacyCountryCodes } from '../countryCodes.js'
|
|
8
|
+
import { toNewSite, withScheme } from '../../legacySites.js'
|
|
8
9
|
|
|
9
10
|
// The data layer every DXA exhibition site (the-use-of-colours-in-art,
|
|
10
11
|
// water-in-islam, …) wrote for itself: the entities an exhibition reads,
|
|
@@ -147,13 +148,14 @@ export function useExhibitionData(config = {}) {
|
|
|
147
148
|
return { name: 'item', params: { id: item.id } }
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
// Institutions (monument owners) and museums both live in partners.json
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
151
|
+
// Institutions (monument owners) and museums both live in partners.json.
|
|
152
|
+
// Legacy's /partners lists every owner once (MWNF-621), and its client
|
|
153
|
+
// opens the institution's pages only for a record of legacy's mwnf3
|
|
154
|
+
// institutions table: a Sharing History partner is a partner whatever it
|
|
155
|
+
// holds, though the package types one holding monuments as an institution.
|
|
156
|
+
const INSTITUTIONS_TABLE = 'mwnf3:institutions:'
|
|
155
157
|
function isInstitution(partner) {
|
|
156
|
-
return partner?.
|
|
158
|
+
return String(partner?.backward_compatibility ?? '').startsWith(INSTITUTIONS_TABLE)
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
function partnerRoute(partner) {
|
|
@@ -203,6 +205,13 @@ export function useExhibitionData(config = {}) {
|
|
|
203
205
|
return projectLabel(manifest, item?.project_id, lang)
|
|
204
206
|
}
|
|
205
207
|
|
|
208
|
+
/** The record's project by its legacy code (`ISL`, `EPM`), which legacy's
|
|
209
|
+
* sheet keyed some labels on; '' when the manifest does not carry it. */
|
|
210
|
+
function projectCode(item) {
|
|
211
|
+
const key = manifest?.projects?.[item?.project_id]?.backward_compatibility
|
|
212
|
+
return key ? String(key).split(':').pop().toUpperCase() : ''
|
|
213
|
+
}
|
|
214
|
+
|
|
206
215
|
/** The exhibition's own per-language chrome text. */
|
|
207
216
|
function exhibitionTitle(lang = defaultLang) {
|
|
208
217
|
return exhibition.value?.titles?.[lang] ?? exhibition.value?.titles?.en ?? ''
|
|
@@ -231,8 +240,9 @@ export function useExhibitionData(config = {}) {
|
|
|
231
240
|
() => (exhibition.value?.sibling_sites ?? []).filter((s) => !s.hidden),
|
|
232
241
|
)
|
|
233
242
|
|
|
243
|
+
// A sibling with a new site links to it (inventory-app#2482).
|
|
234
244
|
function siblingUrl(sibling) {
|
|
235
|
-
return sibling?.legacy_host
|
|
245
|
+
return sibling?.legacy_host ? toNewSite(withScheme(sibling.legacy_host)) : null
|
|
236
246
|
}
|
|
237
247
|
|
|
238
248
|
return {
|
|
@@ -245,7 +255,7 @@ export function useExhibitionData(config = {}) {
|
|
|
245
255
|
chromeImage,
|
|
246
256
|
partnerById, countryById, tagById, dynastyById, glossaryById, languageByCode,
|
|
247
257
|
countryByCode, countryLabelFromCode, countryIdForCode, countryLabel,
|
|
248
|
-
itemRoute, isInstitution, partnerRoute, partnerObjectsRoute,
|
|
258
|
+
itemRoute, isInstitution, partnerRoute, partnerObjectsRoute, projectCode,
|
|
249
259
|
isExploreRecord, projectName,
|
|
250
260
|
exhibitionTitle, exhibitionSubtitle, exhibitionHeadline, bannerCaption,
|
|
251
261
|
siblingSites, siblingUrl,
|
|
@@ -26,13 +26,14 @@ import { useExhibitionSheet } from './useExhibitionSheet.js'
|
|
|
26
26
|
* `data.isHiddenPartner`, `data.labelOf`, `data.partnerById`,
|
|
27
27
|
* `data.partnerRoute`, `data.translations`, what `useExhibitionSheet` reads,
|
|
28
28
|
* and `timeline.countryIdForCode`, `timeline.hasTimeline`,
|
|
29
|
-
* `timeline.timelineEvents` (`countries`,
|
|
29
|
+
* `timeline.usesLocalTimeline`, `timeline.timelineEvents` (`countries`,
|
|
30
|
+
* `findEvents`), `timeline.timelineSpec`.
|
|
30
31
|
*/
|
|
31
32
|
export function useExhibitionItemDetail(data, timeline) {
|
|
32
33
|
const {
|
|
33
34
|
dynastyById, isExploreRecord, isHiddenPartner, labelOf, partnerById, partnerRoute, translations,
|
|
34
35
|
} = data
|
|
35
|
-
const { countryIdForCode, hasTimeline, timelineEvents, timelineSpec } = timeline
|
|
36
|
+
const { countryIdForCode, hasTimeline, usesLocalTimeline, timelineEvents, timelineSpec } = timeline
|
|
36
37
|
const { countries: timelineCountries, findEvents } = timelineEvents
|
|
37
38
|
const { itemSheet: platformSheet } = useExhibitionSheet(data)
|
|
38
39
|
|
|
@@ -107,13 +108,18 @@ export function useExhibitionItemDetail(data, timeline) {
|
|
|
107
108
|
records: dynastiesWithHistory(record, language),
|
|
108
109
|
tr: (d) => dynastyTr(d, language),
|
|
109
110
|
}),
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
111
|
+
// Legacy's sheet asked its own chronology (`/thg/timeline`) for the
|
|
112
|
+
// events of the item's period whatever the exhibition's timeline flags
|
|
113
|
+
// said, and drew the link when it answered any. So the link stays for
|
|
114
|
+
// an exhibition with a chronology of its own and both flags off (The
|
|
115
|
+
// Hijaz Railway); it is withheld when the exhibition has no chronology
|
|
116
|
+
// in force, when the item has no date to anchor a range on, or when no
|
|
117
|
+
// event falls in it.
|
|
113
118
|
timeline: (record, ctx) => {
|
|
114
|
-
if (!hasTimeline.value) return null
|
|
119
|
+
if (!hasTimeline.value && !usesLocalTimeline?.value) return null
|
|
115
120
|
const range = roundOutward(record.start_date, record.end_date)
|
|
116
121
|
if (range[0] == null) return null
|
|
122
|
+
if (findEvents({ begin: range[0], end: range[1] }).length === 0) return null
|
|
117
123
|
return {
|
|
118
124
|
heading: 'core.section.timeline',
|
|
119
125
|
countries: timelineCountries.value.map((c) => ({ value: c.value, label: c.label ?? ctx.t('timeline.form.allCountries') })),
|
|
@@ -33,12 +33,13 @@ import { artistLine, pictureCredits, picturesInLanguage, recordArtist } from '..
|
|
|
33
33
|
* The exhibition's item-sheet spec, over its data layer's `data`.
|
|
34
34
|
*
|
|
35
35
|
* Reads `data.defaultLang`, `data.itemRoute`, `data.labelOf`,
|
|
36
|
-
* `data.mdInline`, `data.mdStrip`, `data.partnerById`, `data.
|
|
37
|
-
* `data.tr`, `data.translations`. `config` carries
|
|
36
|
+
* `data.mdInline`, `data.mdStrip`, `data.partnerById`, `data.projectCode`,
|
|
37
|
+
* `data.projectName`, `data.tr`, `data.translations`. `config` carries
|
|
38
|
+
* nothing today.
|
|
38
39
|
*/
|
|
39
40
|
export function useExhibitionSheet(data, config = {}) {
|
|
40
41
|
void config
|
|
41
|
-
const { defaultLang, itemRoute, labelOf, mdInline, mdStrip, partnerById, projectName, tr, translations } = data
|
|
42
|
+
const { defaultLang, itemRoute, labelOf, mdInline, mdStrip, partnerById, projectCode, projectName, tr, translations } = data
|
|
42
43
|
|
|
43
44
|
const bothDescriptions = (c) => Boolean(c.text.description) && Boolean(c.text.short_description)
|
|
44
45
|
|
|
@@ -48,40 +49,60 @@ export function useExhibitionSheet(data, config = {}) {
|
|
|
48
49
|
.filter(Boolean)
|
|
49
50
|
.join(', ')
|
|
50
51
|
|
|
52
|
+
// Legacy's sheet printed a monument (a record with a `monumentId`) under
|
|
53
|
+
// its own labels and with the rows only a monument has; an object keeps
|
|
54
|
+
// the object's. Its architects row read "Architect(s) / Masterbuilder(s)"
|
|
55
|
+
// for a Discover Islamic Art or Explore record and "Artists" otherwise.
|
|
56
|
+
const monument = (c) => c.record.type === 'monument'
|
|
57
|
+
const object = (c) => !monument(c)
|
|
58
|
+
const islamicArt = (c) => ['ISL', 'EPM'].includes(projectCode(c.record))
|
|
59
|
+
|
|
51
60
|
const fields = [
|
|
52
|
-
{ key: 'name', label: 'sheet.field.name', value: 'name' },
|
|
53
|
-
{ key: '
|
|
61
|
+
{ key: 'name', label: 'sheet.field.name', value: 'name', when: object },
|
|
62
|
+
{ key: 'monumentName', label: 'sheet.dxa.monumentName', value: 'name', when: monument },
|
|
63
|
+
{ key: 'aka', label: 'sheet.field.alsoKnownAs', value: 'alternate_name', when: object },
|
|
64
|
+
{ key: 'monumentAka', label: 'sheet.dxa.monumentAlsoKnownAs', value: 'alternate_name', when: monument },
|
|
54
65
|
{ key: 'location', label: 'sheet.field.location', value: (c) => [c.text.location, labelOf('countries', c.record.country_id)].filter(Boolean).join(', ') },
|
|
55
66
|
// The holding museum, rendered by the wrapper's `museum` slot: the item's
|
|
56
67
|
// holder text, then the partner it refers to (decision D3,
|
|
57
68
|
// inventory-app#2015). The value is the partner's id when the package
|
|
58
69
|
// carries the partner, otherwise the holder text, so the row stays for an
|
|
59
|
-
// item whose holder has no partner page.
|
|
60
|
-
|
|
70
|
+
// item whose holder has no partner page. A monument has no holding
|
|
71
|
+
// museum: legacy printed its responsible institution as written.
|
|
72
|
+
{ key: 'museum', label: 'sheet.field.holdingMuseum', value: (c) => (partnerById.value.get(c.record.partner_id) ? c.record.partner_id : (c.text.holder ?? '')), render: 'custom', when: object },
|
|
73
|
+
{ key: 'institution', label: 'sheet.dxa.responsibleInstitution', value: (c) => c.text.institution || c.text.holder, when: monument },
|
|
61
74
|
{ key: 'originalOwner', label: 'sheet.field.originalOwner', value: 'initial_owner' },
|
|
62
75
|
{ key: 'currentOwner', label: 'sheet.field.currentOwner', value: 'owner' },
|
|
63
|
-
{ key: 'date', label: 'sheet.field.date', value: 'dates' },
|
|
76
|
+
{ key: 'date', label: 'sheet.field.date', value: 'dates', when: object },
|
|
77
|
+
{ key: 'monumentDate', label: 'sheet.field.dateOfMonument', value: 'dates', when: monument },
|
|
78
|
+
{ key: 'architects', label: 'sheet.field.architects', value: 'architects', when: islamicArt },
|
|
79
|
+
{ key: 'monumentArtists', label: 'sheet.dxa.monumentArtists', value: 'architects', when: (c) => !islamicArt(c) },
|
|
64
80
|
{ key: 'artist', label: 'sheet.field.artists', value: (c) => artistLine(recordArtist(c.record, c.text), c.text, { style: 'line' }) },
|
|
65
81
|
{ key: 'scribe', label: 'sheet.field.scribe', value: 'scriber' },
|
|
66
82
|
{ key: 'workshop', label: 'sheet.field.workshop', value: 'workshop' },
|
|
67
|
-
{ key: 'type', label: 'sheet.field.type', value: 'type' },
|
|
83
|
+
{ key: 'type', label: 'sheet.field.type', value: 'type', when: object },
|
|
84
|
+
{ key: 'monumentType', label: 'sheet.dxa.monumentType', value: 'type', when: monument },
|
|
68
85
|
{ key: 'inventoryNumber', label: 'sheet.field.inventoryNumber', value: (c) => c.record.owner_reference },
|
|
69
86
|
{ key: 'materials', label: 'sheet.field.materials', value: (c) => c.text.materials, join: '; ' },
|
|
70
87
|
{ key: 'dimensions', label: 'sheet.field.dimensions', value: 'dimensions' },
|
|
71
88
|
{ key: 'dynasty', label: 'sheet.field.periodDynasty', value: (c) => c.text?.dynasty || dynastyNames(c) },
|
|
89
|
+
{ key: 'patrons', label: 'sheet.field.patrons', value: 'patrons' },
|
|
72
90
|
{ key: 'production', label: 'sheet.field.placeOfProduction', value: 'place_of_production' },
|
|
73
91
|
{ key: 'provenance', label: 'sheet.field.provenance', value: 'provenance' },
|
|
74
92
|
{ key: 'binding', label: 'sheet.field.binding', value: 'binding_desc' },
|
|
93
|
+
{ key: 'history', label: 'sheet.field.history', value: 'history', render: 'block' },
|
|
75
94
|
{ key: 'description', label: 'sheet.field.description', value: 'description', render: 'block' },
|
|
76
95
|
// The only description there is, under the plain label; the toggled one
|
|
77
96
|
// is the view's, folded after `description` when both exist.
|
|
78
97
|
{ key: 'shortDescription', label: 'sheet.field.description', value: 'short_description', render: 'block', when: (c) => !bothDescriptions(c) },
|
|
79
98
|
{ key: 'catalogue', label: 'sheet.field.catalogueLink', value: 'linkcatalogs', render: 'link' },
|
|
99
|
+
{ key: 'datation', label: 'sheet.field.datationMethod', value: 'method_for_datation', when: object },
|
|
100
|
+
{ key: 'monumentDatation', label: 'sheet.field.monumentDatationMethod', value: 'method_for_datation', when: monument },
|
|
80
101
|
{ key: 'obtention', label: 'sheet.field.obtentionMethod', value: 'obtention' },
|
|
81
|
-
{ key: 'datation', label: 'sheet.field.datationMethod', value: 'method_for_datation' },
|
|
82
102
|
{ key: 'provenanceMethod', label: 'sheet.field.provenanceMethod', value: 'method_for_provenance' },
|
|
83
103
|
{ key: 'bibliography', label: 'sheet.field.bibliography', value: 'bibliography', render: 'block' },
|
|
84
|
-
{ key: 'copyright', label: 'sheet.field.copyrightInformation', value: 'copyright' },
|
|
104
|
+
{ key: 'copyright', label: 'sheet.field.copyrightInformation', value: 'copyright', when: object },
|
|
105
|
+
{ key: 'monumentCopyright', label: 'sheet.dxa.monumentCopyrightInformation', value: 'copyright', when: monument },
|
|
85
106
|
]
|
|
86
107
|
|
|
87
108
|
const itemSheet = {
|
|
@@ -4,6 +4,7 @@ import { useCatalogueData } from '../../composables/useCatalogueData.js'
|
|
|
4
4
|
import { useDataPackage } from '../../composables/useDataPackage.js'
|
|
5
5
|
import { itemFromUidPath as legacyItemFromUidPath, partnerFromKey as legacyPartnerFromKey } from '../../legacy/index.js'
|
|
6
6
|
import { useLegacyCountryCodes } from '../countryCodes.js'
|
|
7
|
+
import { toNewSite, withScheme } from '../../legacySites.js'
|
|
7
8
|
|
|
8
9
|
// The data layer every DXA gallery site (carpets, amulets, …) wrote for
|
|
9
10
|
// itself: the entities a gallery reads, the lookup maps over them, its
|
|
@@ -124,8 +125,9 @@ export function useGalleryData(config = {}) {
|
|
|
124
125
|
(gallery.value?.sibling_galleries ?? []).filter((g) => !g.hidden),
|
|
125
126
|
)
|
|
126
127
|
|
|
128
|
+
// A sibling with a new site links to it (inventory-app#2482).
|
|
127
129
|
function siblingUrl(sibling) {
|
|
128
|
-
return sibling?.legacy_host
|
|
130
|
+
return sibling?.legacy_host ? toNewSite(withScheme(sibling.legacy_host)) : null
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
/** Four at random, reshuffled per visit. */
|
package/src/i18n/markdown.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Marked } from 'marked'
|
|
2
|
+
import { toNewSite } from '../legacySites.js'
|
|
2
3
|
|
|
3
4
|
// One Markdown pipeline for every text on every website, configured here and
|
|
4
5
|
// nowhere else. Its own instance rather than the shared `marked` singleton, so
|
|
@@ -56,10 +57,18 @@ const noCode = {
|
|
|
56
57
|
// so a single newline means nothing. A record's field arrives from a database
|
|
57
58
|
// where a newline was typed to be a line break, and dropping it runs the lines
|
|
58
59
|
// together.
|
|
60
|
+
// A text's link to a legacy MWNF site that has a new one goes to the new site
|
|
61
|
+
// (inventory-app#2482); the text stays as it was written.
|
|
62
|
+
const newSiteLinks = {
|
|
63
|
+
walkTokens(token) {
|
|
64
|
+
if (token.type === 'link' && token.href) token.href = toNewSite(token.href)
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
const prose = new Marked({ async: false, gfm: true, breaks: false })
|
|
60
69
|
const record = new Marked({ async: false, gfm: true, breaks: true })
|
|
61
|
-
prose.use(escaping, noCode)
|
|
62
|
-
record.use(escaping, noCode)
|
|
70
|
+
prose.use(escaping, noCode, newSiteLinks)
|
|
71
|
+
record.use(escaping, noCode, newSiteLinks)
|
|
63
72
|
|
|
64
73
|
// `blankLines` keeps the number of blank lines between two blocks. Legacy's
|
|
65
74
|
// text pages were HTML, a blank line a `<br>`, and some put two blank lines
|
|
@@ -78,8 +87,8 @@ const blankLineSpacing = {
|
|
|
78
87
|
}
|
|
79
88
|
const proseLines = new Marked({ async: false, gfm: true, breaks: false })
|
|
80
89
|
const recordLines = new Marked({ async: false, gfm: true, breaks: true })
|
|
81
|
-
proseLines.use(escaping, noCode, blankLineSpacing)
|
|
82
|
-
recordLines.use(escaping, noCode, blankLineSpacing)
|
|
90
|
+
proseLines.use(escaping, noCode, blankLineSpacing, newSiteLinks)
|
|
91
|
+
recordLines.use(escaping, noCode, blankLineSpacing, newSiteLinks)
|
|
83
92
|
|
|
84
93
|
const pipeline = (breaks, blankLines = false) => {
|
|
85
94
|
if (blankLines) return breaks ? recordLines : proseLines
|
package/src/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export { defaultScrollBehavior, resolveViews } from './router/index.js'
|
|
|
20
20
|
export { mediaUrl, useSiteConfig } from './siteConfig.js'
|
|
21
21
|
export { bindDisplayLanguage, displayLanguage } from './displayLanguage.js'
|
|
22
22
|
export { siblingSiteUrl, sourceUrl, useSiteRights } from './rights.js'
|
|
23
|
+
export { LEGACY_SITES, toNewSite, watchNewSiteLinks, withScheme } from './legacySites.js'
|
|
23
24
|
|
|
24
25
|
// The list pages: query state, pagination, facets, dates, keyword search.
|
|
25
26
|
export { useListQuery } from './catalogue/listQuery.js'
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { siblingSiteUrl } from './rights.js'
|
|
2
|
+
|
|
3
|
+
// Links to legacy MWNF sites that have a new one (inventory-app#2482). The
|
|
4
|
+
// legacy sites linked to each other by address, and those addresses are in
|
|
5
|
+
// the texts a site shows (its package's, its locales', extracted from legacy
|
|
6
|
+
// as they were written) and in its configuration. A link to a legacy site
|
|
7
|
+
// that has a new site goes to the new one; the texts themselves stay as
|
|
8
|
+
// imported, and a link with no new site behind it stays as it is.
|
|
9
|
+
//
|
|
10
|
+
// The estate's legacy addresses, one row a site: a gallery, Explore, the
|
|
11
|
+
// galleries hub and the three products by host; an exhibition by host and
|
|
12
|
+
// its first path segment (they share a host); a mini-site by its own page
|
|
13
|
+
// (a Sharing History one by its `eId`). Built from the parity tool's sitemap
|
|
14
|
+
// (the legacy dumps) and the exporters' instance files; the parity `links`
|
|
15
|
+
// pass fails on a link this table misses.
|
|
16
|
+
export const LEGACY_SITES = [
|
|
17
|
+
{ host: 'amulets.museumwnf.org', slug: 'amulets', family: 'gallery' },
|
|
18
|
+
{ host: 'archaeology.museumwnf.org', slug: 'archaeology', family: 'gallery' },
|
|
19
|
+
{ host: 'architectural-elements.museumwnf.org', slug: 'architectural-elements', family: 'gallery' },
|
|
20
|
+
{ host: 'arms-armoury.museumwnf.org', slug: 'arms-armoury', family: 'gallery' },
|
|
21
|
+
{ host: 'exhibitions.museumwnf.org', path: '/arts_in_dialogue/', slug: 'arts-in-dialogue', family: 'exhibition' },
|
|
22
|
+
{ host: 'baroqueart.museumwnf.org', slug: 'baroqueart', family: 'baroqueart' },
|
|
23
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/absolutism/', slug: 'baroqueart-absolutism', family: 'minisite' },
|
|
24
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/bourgeoisie/', slug: 'baroqueart-bourgeoisie', family: 'minisite' },
|
|
25
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/devotion/', slug: 'baroqueart-devotion', family: 'minisite' },
|
|
26
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/enlightenment/', slug: 'baroqueart-enlightenment', family: 'minisite' },
|
|
27
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/ephemera/', slug: 'baroqueart-ephemera', family: 'minisite' },
|
|
28
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/languages_baroque/', slug: 'baroqueart-languages-baroque', family: 'minisite' },
|
|
29
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/reformation/', slug: 'baroqueart-reformation', family: 'minisite' },
|
|
30
|
+
{ host: 'baroqueart.museumwnf.org', path: '/exhibitions/bar/travelling_and_exotism/', slug: 'baroqueart-travelling-and-exotism', family: 'minisite' },
|
|
31
|
+
{ host: 'calligraphy.museumwnf.org', slug: 'calligraphy', family: 'gallery' },
|
|
32
|
+
{ host: 'carpets.museumwnf.org', slug: 'carpets', family: 'gallery' },
|
|
33
|
+
{ host: 'ceramics.museumwnf.org', slug: 'ceramics', family: 'gallery' },
|
|
34
|
+
{ host: 'clothing.museumwnf.org', slug: 'clothing', family: 'gallery' },
|
|
35
|
+
{ host: 'coins-medals.museumwnf.org', slug: 'coins-medals', family: 'gallery' },
|
|
36
|
+
{ host: 'communication.museumwnf.org', slug: 'communication', family: 'gallery' },
|
|
37
|
+
{ host: 'explore.museumwnf.org', slug: 'explore', family: 'explore' },
|
|
38
|
+
{ host: 'funerary-objects.museumwnf.org', slug: 'funerary-objects', family: 'gallery' },
|
|
39
|
+
{ host: 'galleries.museumwnf.org', slug: 'galleries', family: 'galleries' },
|
|
40
|
+
{ host: 'glass.museumwnf.org', slug: 'glass', family: 'gallery' },
|
|
41
|
+
{ host: 'gold-silver.museumwnf.org', slug: 'gold-silver', family: 'gallery' },
|
|
42
|
+
{ host: 'cars.museumwnf.org', slug: 'historical-cars', family: 'gallery' },
|
|
43
|
+
{ host: 'islamicart.museumwnf.org', slug: 'islamicart', family: 'islamicart' },
|
|
44
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/arabic_calligraphy/', slug: 'islamicart-arabic-calligraphy', family: 'minisite' },
|
|
45
|
+
{ host: 'islamicart.museumwnf.org', path: '/gai/isl/', slug: 'islamicart-artistic-introduction', family: 'minisite' },
|
|
46
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/crusader/', slug: 'islamicart-crusader', family: 'minisite' },
|
|
47
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/fatimids/', slug: 'islamicart-fatimids', family: 'minisite' },
|
|
48
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/figural/', slug: 'islamicart-figural', family: 'minisite' },
|
|
49
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/floral/', slug: 'islamicart-floral', family: 'minisite' },
|
|
50
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/geometric/', slug: 'islamicart-geometric', family: 'minisite' },
|
|
51
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/mudejar_art/', slug: 'islamicart-mudejar-art', family: 'minisite' },
|
|
52
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/muslim_west/', slug: 'islamicart-muslim-west', family: 'minisite' },
|
|
53
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/pilgrimage/', slug: 'islamicart-pilgrimage', family: 'minisite' },
|
|
54
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/siculo_norman/', slug: 'islamicart-siculo-norman', family: 'minisite' },
|
|
55
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/the_abbasids/', slug: 'islamicart-the-abbasids', family: 'minisite' },
|
|
56
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/the_ayyubids/', slug: 'islamicart-the-ayyubids', family: 'minisite' },
|
|
57
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/the_mamluks/', slug: 'islamicart-the-mamluks', family: 'minisite' },
|
|
58
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/the_ottomans/', slug: 'islamicart-the-ottomans', family: 'minisite' },
|
|
59
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/the_umayyads/', slug: 'islamicart-the-umayyads', family: 'minisite' },
|
|
60
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/water/', slug: 'islamicart-water', family: 'minisite' },
|
|
61
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/western_influence/', slug: 'islamicart-western-influence', family: 'minisite' },
|
|
62
|
+
{ host: 'islamicart.museumwnf.org', path: '/exhibitions/isl/women/', slug: 'islamicart-women', family: 'minisite' },
|
|
63
|
+
{ host: 'ivory.museumwnf.org', slug: 'ivory', family: 'gallery' },
|
|
64
|
+
{ host: 'jewellery.museumwnf.org', slug: 'jewellery', family: 'gallery' },
|
|
65
|
+
{ host: 'landscapes.museumwnf.org', slug: 'landscapes', family: 'gallery' },
|
|
66
|
+
{ host: 'leatherworks.museumwnf.org', slug: 'leatherworks', family: 'gallery' },
|
|
67
|
+
{ host: 'manuscripts.museumwnf.org', slug: 'manuscripts', family: 'gallery' },
|
|
68
|
+
{ host: 'metalwork.museumwnf.org', slug: 'metalwork', family: 'gallery' },
|
|
69
|
+
{ host: 'mosaics.museumwnf.org', slug: 'mosaics', family: 'gallery' },
|
|
70
|
+
{ host: 'musical-instruments.museumwnf.org', slug: 'musical-instruments', family: 'gallery' },
|
|
71
|
+
{ host: 'paintings.museumwnf.org', slug: 'paintings', family: 'gallery' },
|
|
72
|
+
{ host: 'photographs.museumwnf.org', slug: 'photographs', family: 'gallery' },
|
|
73
|
+
{ host: 'porcelain.museumwnf.org', slug: 'porcelain', family: 'gallery' },
|
|
74
|
+
{ host: 'portraits.museumwnf.org', slug: 'portraits', family: 'gallery' },
|
|
75
|
+
{ host: 'precious-stones.museumwnf.org', slug: 'precious-stones', family: 'gallery' },
|
|
76
|
+
{ host: 'prints-drawings.museumwnf.org', slug: 'prints-drawings', family: 'gallery' },
|
|
77
|
+
{ host: 'religious-life.museumwnf.org', slug: 'religious-life', family: 'gallery' },
|
|
78
|
+
{ host: 'scientific-objects.museumwnf.org', slug: 'scientific-objects', family: 'gallery' },
|
|
79
|
+
{ host: 'sculptures.museumwnf.org', slug: 'sculptures', family: 'gallery' },
|
|
80
|
+
{ host: 'sharinghistory.museumwnf.org', slug: 'sharinghistory', family: 'sharinghistory' },
|
|
81
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '3' }, slug: 'sharinghistory-cities-and-urban-spaces', family: 'minisite' },
|
|
82
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '6' }, slug: 'sharinghistory-economy-and-trade', family: 'minisite' },
|
|
83
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '5' }, slug: 'sharinghistory-fine-and-applied-arts', family: 'minisite' },
|
|
84
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '4' }, slug: 'sharinghistory-great-inventions-of-the-19th-century', family: 'minisite' },
|
|
85
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '7' }, slug: 'sharinghistory-international-exhibitions', family: 'minisite' },
|
|
86
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '8' }, slug: 'sharinghistory-migrations', family: 'minisite' },
|
|
87
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '9' }, slug: 'sharinghistory-music-literature-dance-and-fashion', family: 'minisite' },
|
|
88
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '1' }, slug: 'sharinghistory-rediscovering-the-past', family: 'minisite' },
|
|
89
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '10' }, slug: 'sharinghistory-reforms-and-social-changes', family: 'minisite' },
|
|
90
|
+
{ host: 'sharinghistory.museumwnf.org', path: '/exhibitions/awe/exh_items.php', query: { eId: '11' }, slug: 'sharinghistory-travelling', family: 'minisite' },
|
|
91
|
+
{ host: 'textiles.museumwnf.org', slug: 'textiles', family: 'gallery' },
|
|
92
|
+
{ host: 'upgrade-exhibitions.museumwnf.org', path: '/the_hijaz_railway/', slug: 'the-hijaz-railway', family: 'exhibition' },
|
|
93
|
+
{ host: 'exhibitions.museumwnf.org', path: '/the_table_is_set/', slug: 'the-table-is-set', family: 'exhibition' },
|
|
94
|
+
{ host: 'exhibitions.museumwnf.org', path: '/the_use_of_colours_in_art/', slug: 'the-use-of-colours-in-art', family: 'exhibition' },
|
|
95
|
+
{ host: 'theatre.museumwnf.org', slug: 'theatre', family: 'gallery' },
|
|
96
|
+
{ host: 'toys-games.museumwnf.org', slug: 'toys-games', family: 'gallery' },
|
|
97
|
+
{ host: 'wallpaintings.museumwnf.org', slug: 'wallpaintings', family: 'gallery' },
|
|
98
|
+
{ host: 'exhibitions.museumwnf.org', path: '/water_in_islam/', slug: 'water-in-islam', family: 'exhibition' },
|
|
99
|
+
{ host: 'weights-measures.museumwnf.org', slug: 'weights-measures', family: 'gallery' },
|
|
100
|
+
{ host: 'exhibitions.museumwnf.org', path: '/with_brush_and_qalam/', slug: 'with-brush-and-qalam', family: 'exhibition' },
|
|
101
|
+
{ host: 'woodwork.museumwnf.org', slug: 'woodwork', family: 'gallery' },
|
|
102
|
+
{ host: 'exhibitions.museumwnf.org', path: '/the_hijaz_railway/', slug: 'the-hijaz-railway', family: 'exhibition' },
|
|
103
|
+
// Legacy's three products also answered on their own domains.
|
|
104
|
+
{ host: 'discoverislamicart.org', slug: 'islamicart', family: 'islamicart' },
|
|
105
|
+
{ host: 'discoverbaroqueart.org', slug: 'baroqueart', family: 'baroqueart' },
|
|
106
|
+
{ host: 'sharinghistory.org', slug: 'sharinghistory', family: 'sharinghistory' },
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
// The new route of each legacy page the products and their siblings link
|
|
110
|
+
// to: legacy's script name → the route. A page that is not here stays on
|
|
111
|
+
// legacy (a page with no counterpart, or one that needs a record id).
|
|
112
|
+
const PAGES = {
|
|
113
|
+
islamicart: {
|
|
114
|
+
'/': '/', '/index.php': '/',
|
|
115
|
+
'/database.php': '/database', '/database_results.php': '/database/results',
|
|
116
|
+
'/partners.php': '/partners', '/pm_partner_list.php': '/partners/results', '/pm_partner_list_eiac.php': '/partners/explore',
|
|
117
|
+
'/pc_entrance.php': '/permanent-collection', '/pclist_all.php': '/permanent-collection/results',
|
|
118
|
+
'/hcr_home.php': '/timeline', '/dynasties/': '/dynasties',
|
|
119
|
+
'/isl_missionstatement.php': '/mission-statement', '/recommendedlinks.php': '/recommended-links',
|
|
120
|
+
'/atrium_sponsor_detail.php': '/sponsors', '/glossarysearch.php': '/glossary-spelling',
|
|
121
|
+
},
|
|
122
|
+
baroqueart: {
|
|
123
|
+
'/': '/', '/index.php': '/',
|
|
124
|
+
'/database.php': '/database', '/database_results.php': '/database/results',
|
|
125
|
+
'/partners.php': '/partners', '/pm_partner_list.php': '/partners/results',
|
|
126
|
+
'/pc_entrance.php': '/permanent-collection', '/pclist_all.php': '/permanent-collection/results',
|
|
127
|
+
'/hcr_home.php': '/timeline', '/atrium_sponsor_detail.php': '/sponsors', '/mwnf_credit.php': '/credits',
|
|
128
|
+
},
|
|
129
|
+
sharinghistory: {
|
|
130
|
+
'/': '/', '/index.php': '/',
|
|
131
|
+
'/about.php': '/about', '/about_team.php': '/about/team', '/about_chronology_list.php': '/about/chronology',
|
|
132
|
+
'/pc_home.php': '/permanent-collection', '/database_searchform.php': '/database',
|
|
133
|
+
'/historical_background.php': '/historical-background', '/hcr_home.php': '/timeline',
|
|
134
|
+
'/exhibitions/awe/index.php': '/exhibitions', '/partners.php': '/partners', '/pm_partner_list.php': '/partners/results',
|
|
135
|
+
'/sponsor_detail.php': '/sponsors', '/sponsor_detail_local.php': '/sponsors/local',
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
// The query keys a page's new route reads as legacy's did.
|
|
139
|
+
const KEPT_QUERY = { '/partners/results': ['type'] }
|
|
140
|
+
|
|
141
|
+
const bareHost = (host) => host.toLowerCase().replace(/^www\./, '')
|
|
142
|
+
|
|
143
|
+
function rowFor(url) {
|
|
144
|
+
const host = bareHost(url.host)
|
|
145
|
+
const path = url.pathname.toLowerCase().replace(/\/?$/, '/')
|
|
146
|
+
return LEGACY_SITES.filter(
|
|
147
|
+
(row) =>
|
|
148
|
+
row.host === host &&
|
|
149
|
+
path.startsWith((row.path ?? '/').replace(/\.php$/, '.php/')) &&
|
|
150
|
+
Object.entries(row.query ?? {}).every(([key, value]) => url.searchParams.get(key) === value),
|
|
151
|
+
).sort((a, b) => (b.path ?? '/').length - (a.path ?? '/').length)[0]
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The route on the new site that a legacy address of `row` lands on, or null
|
|
156
|
+
* when it has none. Galleries, Explore and the hub kept legacy's paths as
|
|
157
|
+
* routes (their legacy redirects); an exhibition drops its own segment and
|
|
158
|
+
* moves the language to the query; a mini-site opens on its home; a
|
|
159
|
+
* product's page goes through PAGES.
|
|
160
|
+
*/
|
|
161
|
+
function routeFor(row, url) {
|
|
162
|
+
// A legacy text may write the address with a space before its closing `>`.
|
|
163
|
+
const pathname = decodeURIComponent(url.pathname).trim() || '/'
|
|
164
|
+
const path = pathname.replace(/\/+$/, '') || '/'
|
|
165
|
+
if (row.family === 'gallery' || row.family === 'explore' || row.family === 'galleries') return `${path}${url.search}`
|
|
166
|
+
if (row.family === 'minisite') return '/'
|
|
167
|
+
if (row.family === 'exhibition') {
|
|
168
|
+
const rest = path.split('/').filter(Boolean).slice(1)
|
|
169
|
+
const lang = /^[a-z]{2}$/.test(rest[0] ?? '') ? rest.shift() : null
|
|
170
|
+
return `/${rest.join('/')}${lang ? `?lang=${lang}` : ''}`
|
|
171
|
+
}
|
|
172
|
+
const route = PAGES[row.family]?.[pathname.toLowerCase()]
|
|
173
|
+
if (!route) return null
|
|
174
|
+
const keep = (KEPT_QUERY[route] ?? []).filter((key) => url.searchParams.has(key))
|
|
175
|
+
return keep.length ? `${route}?${keep.map((key) => `${key}=${encodeURIComponent(url.searchParams.get(key))}`).join('&')}` : route
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function fixAnchor(anchor) {
|
|
179
|
+
const href = anchor.getAttribute('href')
|
|
180
|
+
const next = toNewSite(href)
|
|
181
|
+
if (next !== href) anchor.setAttribute('href', next)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function fixWithin(node) {
|
|
185
|
+
if (node.nodeType !== 1) return
|
|
186
|
+
if (node.matches('a[href]')) fixAnchor(node)
|
|
187
|
+
for (const anchor of node.querySelectorAll('a[href]')) fixAnchor(anchor)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Keeps every link under `root` on the new sites: each anchor drawn, or
|
|
192
|
+
* given a new `href`, whose address is a legacy site's that has a new one
|
|
193
|
+
* gets the new address. Components, Markdown and a site's own markup all
|
|
194
|
+
* link through it, so no family has to repeat the rule. Its own change
|
|
195
|
+
* fires once more and finds nothing to do. Returns the function that stops
|
|
196
|
+
* it.
|
|
197
|
+
*/
|
|
198
|
+
export function watchNewSiteLinks(root) {
|
|
199
|
+
if (!root || typeof MutationObserver === 'undefined') return () => {}
|
|
200
|
+
fixWithin(root)
|
|
201
|
+
const observer = new MutationObserver((records) => {
|
|
202
|
+
for (const record of records) {
|
|
203
|
+
if (record.type === 'attributes') fixAnchor(record.target)
|
|
204
|
+
else record.addedNodes.forEach(fixWithin)
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
observer.observe(root, { subtree: true, childList: true, attributes: true, attributeFilter: ['href'] })
|
|
208
|
+
return () => observer.disconnect()
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** An address as legacy stored a host (`ceramics.museumwnf.org`), with its scheme. */
|
|
212
|
+
export function withScheme(address) {
|
|
213
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(address) ? address : `https://${address}`
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* `href` on the new site when it is a legacy MWNF address of a site that has
|
|
218
|
+
* one, else `href` itself. Needs the site's declared origin (`site.origin`):
|
|
219
|
+
* without it every link stays as it is.
|
|
220
|
+
*/
|
|
221
|
+
export function toNewSite(href) {
|
|
222
|
+
if (typeof href !== 'string') return href
|
|
223
|
+
let url
|
|
224
|
+
try {
|
|
225
|
+
url = new URL(href.trim())
|
|
226
|
+
} catch {
|
|
227
|
+
return href
|
|
228
|
+
}
|
|
229
|
+
if (!/^https?:$/.test(url.protocol)) return href
|
|
230
|
+
const row = rowFor(url)
|
|
231
|
+
if (!row) return href
|
|
232
|
+
const route = routeFor(row, url)
|
|
233
|
+
if (route === null) return href
|
|
234
|
+
return siblingSiteUrl(row.slug, route) ?? href
|
|
235
|
+
}
|
|
@@ -247,7 +247,8 @@ export function recordArtist(record, text) {
|
|
|
247
247
|
* comma before the place, as it did there. Nothing without an artist.
|
|
248
248
|
* - `'line'` — the galleries' and exhibitions' `DatabaseItem.vue`
|
|
249
249
|
* (`returnArtistData`): on a line of its own under the artist,
|
|
250
|
-
* `1660, Chemnitz - 1736, Augsburg
|
|
250
|
+
* `1660, Chemnitz - 1736, Augsburg`, then the period of activity
|
|
251
|
+
* (`period_activity`) on a line of its own.
|
|
251
252
|
*
|
|
252
253
|
* Islamic Art's sheet printed the artist alone. '' when there is nothing
|
|
253
254
|
* to print.
|
|
@@ -261,7 +262,7 @@ export function artistLine(artist, text, { style = 'bracketed' } = {}) {
|
|
|
261
262
|
if (style === 'line') {
|
|
262
263
|
const birth = [born, bornAt].filter(Boolean).join(', ')
|
|
263
264
|
const death = [died, diedAt].filter(Boolean).join(', ')
|
|
264
|
-
return [name, [birth, death].filter(Boolean).join(' - ')].filter(Boolean).join(' \n')
|
|
265
|
+
return [name, [birth, death].filter(Boolean).join(' - '), lifePart(text?.period_activity)].filter(Boolean).join(' \n')
|
|
265
266
|
}
|
|
266
267
|
if (!name) return ''
|
|
267
268
|
if (!(born || bornAt || died || diedAt)) return name
|