@museumwnf/viewer-core 2.23.0 → 2.24.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/README.md +6 -5
- package/package.json +1 -1
- package/src/catalogue/timeline.js +14 -4
- package/src/dxa/exhibition/useExhibitionCollection.js +6 -2
- package/src/dxa/exhibition/useExhibitionData.js +9 -2
- package/src/dxa/exhibition/useExhibitionTimeline.js +19 -8
- package/src/index.js +1 -1
- package/src/legacySites.js +18 -0
package/README.md
CHANGED
|
@@ -398,13 +398,14 @@ is the site's.
|
|
|
398
398
|
|
|
399
399
|
Legacy's country chronology (`hcr`) is one merged, year-ordered list per
|
|
400
400
|
country, and an exhibition can carry its own narrative chronology instead
|
|
401
|
-
(`source: '
|
|
401
|
+
(`source: 'site'` on its `timelines.json` row, or legacy's `thg_local`) or split the merge by
|
|
402
402
|
which exhibition each event belongs to (Sharing History). Seven websites'
|
|
403
403
|
Timeline pages are all one of these three axes over the same event shape.
|
|
404
404
|
|
|
405
405
|
| Export | Meaning |
|
|
406
406
|
| --- | --- |
|
|
407
|
-
| `useTimelineEvents({ scope, countryLabel, countryIdForCode, tr, timelinesEntity, eventsEntity })` | `{ countries, yearRange, yearBuckets(t), hasTimeline, usesLocalTimeline, findEvents({ country, collection, begin, end }) }`. `scope` is `'country'` (the worldwide merge), `'local'` (an exhibition's own `
|
|
407
|
+
| `useTimelineEvents({ scope, countryLabel, countryIdForCode, tr, timelinesEntity, eventsEntity })` | `{ countries, yearRange, yearBuckets(t), hasTimeline, usesLocalTimeline, findEvents({ country, collection, begin, end }) }`. `scope` is `'country'` (the worldwide merge), `'local'` (an exhibition's own chronology, the row `isSiteTimeline` finds, in place of the merge — `countries` is empty, there is nothing to filter by) or `'collection'` (the merge again, plus a `collection` filter on the exhibition a timeline is bound to, `null` meaning the Permanent Collection). `countries` is one entry per country with a chronology, `{ value, label }`, alphabetized, with an `{ value: 'all', label: null }` marker first (never, for `'local'`) — the marker carries no label of its own so a picker names it through its own catalogue entry. `countryLabel(id)` labels a country; the DXA legacy 2-letter code table stays out of the engine (the DXA families' data layer carries it, `/dxa`), so a caller passing one instead resolves it through `countryIdForCode(code)`. `tr(id)` returns an event's translated fields, already resolved for entity and language, the same way a site's own data composable already binds it. `findEvents` returns the scope's events in `[begin, end]`, chronological, `display_order` breaking a tie on `year_from`, an event with no year at all last. |
|
|
408
|
+
| `isSiteTimeline(row)` | whether a `timelines.json` row is a site's own narrative chronology: `source: 'site'` (a package built from the inventory's own data, inventory-app#2727) or legacy's `thg_local` |
|
|
408
409
|
| `overlapsRange(event, begin, end)` | legacy `class.hcr.inc.php`'s overlap rule, standalone: a dated event overlaps once its known end is past `begin` and its start is before `end`; an open-ended event (no known end) overlaps on its start alone; an undated event matches nothing but an unbounded search. |
|
|
409
410
|
| `effectiveYearTo(event)` | `event.year_to`, or `null` when it is `0` or absent — legacy's convention for an open-ended period. |
|
|
410
411
|
| `eventDateLabel(event, text, t)` | the label under an event, trying in order: a narrative chronology's own period name (`text.name` — a sort key there, not a label), a curated description pair (`text.date_from_description` / `text.date_to_description`), and the derived year range through `eraLabel`, for the worldwide merge which has neither. |
|
|
@@ -563,9 +564,9 @@ below for whichever future site needs its own).
|
|
|
563
564
|
|
|
564
565
|
| Export (gallery / exhibition) | Reads | Returns |
|
|
565
566
|
| --- | --- | --- |
|
|
566
|
-
| `useGalleryData(config)` / `useExhibitionData(config)` | `config.eager` (entity names `loadEnglish` loads eagerly; default the family's own list, the exhibition's also carrying `themes`) | the family's whole data layer: `tr`/`md`/`mdInline`/`mdStrip`/`labelOf`/`loadEnglish`/`translations`, every entity and lookup map (`items`, `partners`, `countries`, `tags`, `dynasties`, `timelines`, `timelineEvents`, …), the routes (`itemRoute`, `partnerRoute`, `partnerObjectsRoute`), the legacy URL wrappers (`itemFromUidPath`, `partnerFromKey` — gallery only), the DXA legacy country code both ways (`countryIdForCode(code)`, idempotent on an id, and `countryLabel(countryId)`, one table the collection and the timeline both read), `chromeImage`, `manifest`, `defaultLang`, plus family-specific fields (gallery: `siblingGalleries`/`pickSiblings`; exhibition: `isHiddenPartner
|
|
567
|
-
| `useGalleryCollection(data, config)` / `useExhibitionCollection(data, config)` | the `data` object above; `config` unused today | `FACETS`, `tile(item, t)`, `collectionResults` (the `CatalogueResultsView` spec), plus the facet-value helpers (`countryIdForCode` — the data layer's —, `tagLabelForLegacy`, gallery's own `tagIdForLegacy`, `hasEveryTag`) |
|
|
568
|
-
| `useGalleryTimeline(data, collection, config)` / `useExhibitionTimeline(data, collection, config)` | `data`, the `collection` object above (for its `tile`); `config` unused today | the timeline specs (`timelineResults`/`timelineSpec`, `timelineGallery`/`timelineGallerySpec`), `timelineEvents` (viewer-core's `useTimelineEvents` engine — for an exhibition, the one its flags put in force, country or local), and the data layer's `countryLabel`/`countryIdForCode`; the gallery adds `timelineGalleryItems`, the exhibition `usesLocalTimeline` and `hasTimeline` for its local-vs-country chronology switch |
|
|
567
|
+
| `useGalleryData(config)` / `useExhibitionData(config)` | `config.eager` (entity names `loadEnglish` loads eagerly; default the family's own list, the exhibition's also carrying `themes`) | the family's whole data layer: `tr`/`md`/`mdInline`/`mdStrip`/`labelOf`/`loadEnglish`/`translations`, every entity and lookup map (`items`, `partners`, `countries`, `tags`, `dynasties`, `timelines`, `timelineEvents`, …), the routes (`itemRoute`, `partnerRoute`, `partnerObjectsRoute`), the legacy URL wrappers (`itemFromUidPath`, `partnerFromKey` — gallery only), the DXA legacy country code both ways (`countryIdForCode(code)`, idempotent on an id, and `countryLabel(countryId)`, one table the collection and the timeline both read), `chromeImage`, `manifest`, `defaultLang`, plus family-specific fields (gallery: `siblingGalleries`/`pickSiblings`; exhibition: `isHiddenPartner` (the site's `exhibition.hiddenPartners` when its config sets them, else the package's `hidden_partner_ids`), `isInstitution`, `projectName`, `exhibitionTitle`/`exhibitionSubtitle`/`exhibitionHeadline`/`bannerCaption`, `siblingSites`) |
|
|
568
|
+
| `useGalleryCollection(data, config)` / `useExhibitionCollection(data, config)` | the `data` object above; `config` unused today | `FACETS`, `tile(item, t)`, `collectionResults` (the `CatalogueResultsView` spec), plus the facet-value helpers (`countryIdForCode` — the data layer's —, `tagLabelForLegacy`, a tag facet keyed on the tag's `legacy_tag_id`, or on its own `id` when it has none, gallery's own `tagIdForLegacy`, `hasEveryTag`) |
|
|
569
|
+
| `useGalleryTimeline(data, collection, config)` / `useExhibitionTimeline(data, collection, config)` | `data`, the `collection` object above (for its `tile`); `config` unused today | the timeline specs (`timelineResults`/`timelineSpec`, `timelineGallery`/`timelineGallerySpec`), `timelineEvents` (viewer-core's `useTimelineEvents` engine — for an exhibition, the one its flags put in force, country or local), and the data layer's `countryLabel`/`countryIdForCode`; the gallery adds `timelineGalleryItems`, the exhibition `usesLocalTimeline` and `hasTimeline` for its local-vs-country chronology switch, decided by the site's `exhibition.timeline` (`'site'`, `'country'` or `false`) when its config sets one, else by the package's `has_timeline`/`has_country_timeline` |
|
|
569
570
|
| `useGalleryPartner(data, collection, config)` / `useExhibitionPartner(data, config)` | `data`, and (gallery only) `collection` for its `tile` | `partnerList`/`partnerListSpec`, `partnerSheet`/`partnerSheetSpec`, and (gallery only) `partnerObjects` — the exhibition shape's `partnerSpecs.js` never carried an objects-page spec |
|
|
570
571
|
| `useGallerySheet(data, config)` / `useExhibitionSheet(data, config)` | `data`; `config` unused today | `{ itemSheet }`, the `RecordView` spec — the exhibition shape's `citation.project` reads `data.projectName`, absent from the gallery shape |
|
|
571
572
|
| `PAGE_SIZE`, `DATE_MODE`, `FACET_CATEGORIES`, `FACET_LABEL_KEYS`, `useFacetLabels()` | — | the five THG catalogue facets, shared verbatim by both families (nine tiles a page, containment dates, `type`/`dynasty`/`subject`/`material`/`artist`) |
|
package/package.json
CHANGED
|
@@ -5,8 +5,9 @@ import { eraLabel, yearBucketsFromRange } from './dates.js'
|
|
|
5
5
|
// The country chronology (`hcr` in legacy) is one merged, year-ordered list
|
|
6
6
|
// per country, served by legacy `/v2/events` and reproduced identically on
|
|
7
7
|
// every gallery and standalone site. An exhibition can instead carry its own
|
|
8
|
-
// narrative chronology (`source: '
|
|
9
|
-
// which has no country of its own and is never interleaved
|
|
8
|
+
// narrative chronology (`source: 'site'`, or legacy's `thg_local` — its
|
|
9
|
+
// `/thg/timeline`), which has no country of its own and is never interleaved
|
|
10
|
+
// with the merge.
|
|
10
11
|
// Sharing History's Timeline additionally splits the merge by the exhibition
|
|
11
12
|
// each event belongs to (`collection_id` on its timeline row, `null` for the
|
|
12
13
|
// Permanent Collection). Every one of the seven websites' Timeline pages is
|
|
@@ -98,6 +99,15 @@ export function eventDateLabel(event, text, t) {
|
|
|
98
99
|
return yt !== null ? `${from} – ${eraLabel(yt, t)}` : `${from} –`
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Whether a `timelines.json` row is the site's own narrative chronology:
|
|
104
|
+
* `source: 'site'`, as a package built from the inventory's own data writes
|
|
105
|
+
* it (inventory-app#2727), or legacy's `thg_local`.
|
|
106
|
+
*/
|
|
107
|
+
export function isSiteTimeline(row) {
|
|
108
|
+
return row?.source === 'site' || row?.source === 'thg_local'
|
|
109
|
+
}
|
|
110
|
+
|
|
101
111
|
/**
|
|
102
112
|
* The engine of a Timeline results page, one implementation for the three
|
|
103
113
|
* axes legacy split across separate endpoints:
|
|
@@ -105,7 +115,7 @@ export function eventDateLabel(event, text, t) {
|
|
|
105
115
|
* - `'country'` — the worldwide country merge (galleries, and the standalone
|
|
106
116
|
* sites that offer only this axis);
|
|
107
117
|
* - `'local'` — an exhibition's own narrative chronology in place of the
|
|
108
|
-
* merge (the
|
|
118
|
+
* merge (the {@link isSiteTimeline} row), no country picker;
|
|
109
119
|
* - `'collection'` — the merge again, plus filtering by which exhibition an
|
|
110
120
|
* event's timeline is bound to (`null` = the Permanent Collection), for
|
|
111
121
|
* Sharing History's second axis.
|
|
@@ -135,7 +145,7 @@ export function useTimelineEvents({
|
|
|
135
145
|
// out of the merge by `source` rather than by the country filter — on "all
|
|
136
146
|
// countries" it would otherwise interleave into the worldwide list.
|
|
137
147
|
const localTimeline = computed(
|
|
138
|
-
() => (timelines.value ?? []).find(
|
|
148
|
+
() => (timelines.value ?? []).find(isSiteTimeline) ?? null,
|
|
139
149
|
)
|
|
140
150
|
|
|
141
151
|
const timelineById = computed(() => new Map((timelines.value ?? []).map((row) => [row.id, row])))
|
|
@@ -39,8 +39,12 @@ export function useExhibitionCollection(data, config = {}) {
|
|
|
39
39
|
// `countryIdForCode`), the legacy tag id for a facet: the values legacy's
|
|
40
40
|
// URLs carried, so a link shared then still resolves now.
|
|
41
41
|
|
|
42
|
+
// A tag a package built from the inventory's own data ships has no legacy
|
|
43
|
+
// id (inventory-app#2727): its facet value is the tag's own id.
|
|
44
|
+
const tagKey = (tag) => tag.legacy_tag_id ?? tag.id
|
|
45
|
+
|
|
42
46
|
function tagLabelForLegacy(legacyId) {
|
|
43
|
-
return (tags.value ?? []).find((t) => t
|
|
47
|
+
return (tags.value ?? []).find((t) => tagKey(t) === legacyId)?.label ?? legacyId
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
@@ -61,7 +65,7 @@ export function useExhibitionCollection(data, config = {}) {
|
|
|
61
65
|
(item.tag_ids ?? [])
|
|
62
66
|
.map((id) => tagById.value.get(id))
|
|
63
67
|
.filter((tag) => tag && tag.category === category)
|
|
64
|
-
.map(
|
|
68
|
+
.map(tagKey),
|
|
65
69
|
label: tagLabelForLegacy,
|
|
66
70
|
capitalize: true,
|
|
67
71
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed } from 'vue'
|
|
2
|
-
import { mediaUrl } from '../../siteConfig.js'
|
|
2
|
+
import { mediaUrl, useSiteConfig } from '../../siteConfig.js'
|
|
3
3
|
import { useCatalogueData } from '../../composables/useCatalogueData.js'
|
|
4
4
|
import { useDataPackage } from '../../composables/useDataPackage.js'
|
|
5
5
|
import { byId, entityRef } from '../../composables/useEntities.js'
|
|
@@ -58,7 +58,14 @@ export function useExhibitionData(config = {}) {
|
|
|
58
58
|
//
|
|
59
59
|
// So is a partner the package says has no text in any language: it has no
|
|
60
60
|
// name, and legacy lists no such partner, nor serves its page.
|
|
61
|
-
|
|
61
|
+
//
|
|
62
|
+
// The partners a site hides are its own choice: a site built from the
|
|
63
|
+
// inventory's own data lists them in its config
|
|
64
|
+
// (`exhibitionConfig({ hiddenPartners })`); a legacy site's package carries
|
|
65
|
+
// them on the exhibition record, read when the config is silent.
|
|
66
|
+
const hiddenPartnerIds = computed(() => new Set(
|
|
67
|
+
useSiteConfig().exhibition?.hiddenPartners ?? exhibition.value?.hidden_partner_ids ?? [],
|
|
68
|
+
))
|
|
62
69
|
function isHiddenPartner(partner) {
|
|
63
70
|
if (Array.isArray(partner?.languages) && partner.languages.length === 0) return true
|
|
64
71
|
return hiddenPartnerIds.value.has(partner?.id)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed } from 'vue'
|
|
2
2
|
import { eraLabel, roundOutward, yearBucketsFromRange } from '../../catalogue/dates.js'
|
|
3
|
-
import { useTimelineEvents } from '../../catalogue/timeline.js'
|
|
3
|
+
import { isSiteTimeline, useTimelineEvents } from '../../catalogue/timeline.js'
|
|
4
|
+
import { useSiteConfig } from '../../siteConfig.js'
|
|
4
5
|
import { PAGE_SIZE } from '../shared.js'
|
|
5
6
|
|
|
6
7
|
export { eraLabel, roundOutward }
|
|
@@ -35,13 +36,21 @@ export function useExhibitionTimeline(data, collection, config = {}) {
|
|
|
35
36
|
// possibly with no `thg_local` row at all. The flags gate NAVIGATION, not
|
|
36
37
|
// data.
|
|
37
38
|
const localTimeline = computed(
|
|
38
|
-
() => (timelines.value ?? []).find(
|
|
39
|
+
() => (timelines.value ?? []).find(isSiteTimeline) ?? null,
|
|
39
40
|
)
|
|
40
41
|
|
|
42
|
+
// A site built from the inventory's own data says which chronology it
|
|
43
|
+
// shows in its own config (`exhibitionConfig({ timeline })`: 'site',
|
|
44
|
+
// 'country' or false); a legacy site's package says it in the exhibition
|
|
45
|
+
// record's two flags, read when the config is silent.
|
|
46
|
+
const siteChoice = () => useSiteConfig().exhibition?.timeline
|
|
47
|
+
|
|
41
48
|
/** True when the Timeline section is the exhibition's own chronology. */
|
|
42
|
-
const usesLocalTimeline = computed(
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
const usesLocalTimeline = computed(() => {
|
|
50
|
+
const choice = siteChoice()
|
|
51
|
+
if (choice !== undefined) return choice === 'site' && Boolean(localTimeline.value)
|
|
52
|
+
return !exhibition.value?.has_country_timeline && Boolean(localTimeline.value)
|
|
53
|
+
})
|
|
45
54
|
|
|
46
55
|
/**
|
|
47
56
|
* Whether this site offers a Timeline at all — the one flag every piece
|
|
@@ -53,9 +62,11 @@ export function useExhibitionTimeline(data, collection, config = {}) {
|
|
|
53
62
|
* instance with both flags false still renders the page and its
|
|
54
63
|
* introduction. Only the links into it are withheld.
|
|
55
64
|
*/
|
|
56
|
-
const hasTimeline = computed(
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
const hasTimeline = computed(() => {
|
|
66
|
+
const choice = siteChoice()
|
|
67
|
+
if (choice !== undefined) return choice === 'site' || choice === 'country'
|
|
68
|
+
return Boolean(exhibition.value?.has_timeline || exhibition.value?.has_country_timeline)
|
|
69
|
+
})
|
|
59
70
|
|
|
60
71
|
const eventsTr = (id) => tr('timeline_events', id, defaultLang)
|
|
61
72
|
|
package/src/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export {
|
|
|
37
37
|
combineExpansions, countryExpansion, glossaryExpansion, parseBooleanQuery, useKeywordIndex,
|
|
38
38
|
} from './catalogue/keywordIndex.js'
|
|
39
39
|
export {
|
|
40
|
-
effectiveYearTo, eventDateLabel, overlapsRange, touchesRange, useTimelineEvents,
|
|
40
|
+
effectiveYearTo, eventDateLabel, isSiteTimeline, overlapsRange, touchesRange, useTimelineEvents,
|
|
41
41
|
} from './catalogue/timeline.js'
|
|
42
42
|
|
|
43
43
|
// The record page: the sheet engine and its derivations.
|
package/src/legacySites.js
CHANGED
|
@@ -122,6 +122,8 @@ const PAGES = {
|
|
|
122
122
|
'/hcr_home.php': '/timeline', '/dynasties/': '/dynasties',
|
|
123
123
|
'/isl_missionstatement.php': '/mission-statement', '/recommendedlinks.php': '/recommended-links',
|
|
124
124
|
'/atrium_sponsor_detail.php': '/sponsors', '/glossarysearch.php': '/glossary-spelling',
|
|
125
|
+
// The list of the virtual exhibitions; each one is a mini-site row above.
|
|
126
|
+
'/exhibitions/isl': '/exhibitions', '/exhibitions/isl/': '/exhibitions', '/exhibitions/isl/index.php': '/exhibitions',
|
|
125
127
|
},
|
|
126
128
|
baroqueart: {
|
|
127
129
|
'/': '/', '/index.php': '/',
|
|
@@ -206,6 +208,18 @@ function travelsRoute(path, url) {
|
|
|
206
208
|
return null
|
|
207
209
|
}
|
|
208
210
|
|
|
211
|
+
// Discover Islamic Art's partner page (`pm_partner.php?id=<partner>;<country>&type=museum|institution`),
|
|
212
|
+
// keyed as the importer keys a partner (`mwnf3:museums:…`, `mwnf3:institutions:…`). Travels' trails and the
|
|
213
|
+
// books link to it for their museums. Its other pages are PAGES above.
|
|
214
|
+
const PARTNER_KINDS = { museum: 'museums', institution: 'institutions' }
|
|
215
|
+
function islamicartRecordRoute(path, url) {
|
|
216
|
+
if (path.toLowerCase() !== '/pm_partner.php') return undefined
|
|
217
|
+
const [partner, country] = (url.searchParams.get('id') ?? '').split(';').map((part) => part.trim())
|
|
218
|
+
const kind = PARTNER_KINDS[(url.searchParams.get('type') ?? 'museum').toLowerCase()]
|
|
219
|
+
if (!partner || !country || !kind) return null
|
|
220
|
+
return `/partner/${legacyRecordId('partner', `mwnf3:${kind}:${partner}:${country}`)}`
|
|
221
|
+
}
|
|
222
|
+
|
|
209
223
|
// The families whose pages name a record or a page in their address.
|
|
210
224
|
const RECORD_PAGES = { publications: publicationsRoute, travels: travelsRoute }
|
|
211
225
|
|
|
@@ -241,6 +255,10 @@ function routeFor(row, url) {
|
|
|
241
255
|
const lang = /^[a-z]{2}$/.test(rest[0] ?? '') ? rest.shift() : null
|
|
242
256
|
return `/${rest.join('/')}${lang ? `?lang=${lang}` : ''}`
|
|
243
257
|
}
|
|
258
|
+
if (row.family === 'islamicart') {
|
|
259
|
+
const record = islamicartRecordRoute(path, url)
|
|
260
|
+
if (record !== undefined) return record
|
|
261
|
+
}
|
|
244
262
|
const route = PAGES[row.family]?.[pathname.toLowerCase()]
|
|
245
263
|
if (!route) return null
|
|
246
264
|
const keep = (KEPT_QUERY[route] ?? []).filter((key) => url.searchParams.has(key))
|