@museumwnf/viewer-core 2.24.0 → 2.25.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@museumwnf/viewer-core",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "description": "Application engine for MWNF websites: turns a dataset.config.js into a mounted Vue application.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -42,10 +42,15 @@
42
42
  "devDependencies": {
43
43
  "@vitejs/plugin-vue": "^6.0.10",
44
44
  "@vue/test-utils": "^2.5.1",
45
- "jsdom": "^30.1.3",
46
- "vite": "^8.3.5",
45
+ "jsdom": "^31.0.0",
46
+ "vite": "^8.3.6",
47
47
  "vitest": "^5.1.0",
48
- "vue": "^3.5.44",
48
+ "vue": "^3.5.46",
49
49
  "vue-router": "^5.4.0"
50
+ },
51
+ "overrides": {
52
+ "glob": "^14.0.7",
53
+ "editorconfig": "^4.0.2",
54
+ "minimatch": "^11.0.10"
50
55
  }
51
56
  }
@@ -19,6 +19,18 @@ import { computed } from 'vue'
19
19
  // is the Solomon Islands, where legacy means the UAE and Serbia. Only
20
20
  // countries.json can name them correctly.
21
21
 
22
+ // A gallery package from inventory-app's pass 1 also ships `iso_code` on each
23
+ // country: its ISO 3166-1 alpha-2 code, derived by the exporter from the
24
+ // inventory's ISO-3 id. A site reads it first (`countryUrlCode`), lowercased,
25
+ // so the URL carries an inventory value; the legacy `code` is still matched,
26
+ // so a link shared with a legacy code keeps resolving while packages carry it.
27
+
28
+ /** The code a country stands for in a URL: its ISO code when the package has one, else the legacy code. */
29
+ export function countryUrlCode(country) {
30
+ if (!country) return null
31
+ return country.iso_code ? String(country.iso_code).toLowerCase() : (country.code ?? null)
32
+ }
33
+
22
34
  // Two legacy codes are not ISO 3166-1 alpha-2.
23
35
  const LEGACY_TO_ISO = { uk: 'GB', pa: 'PS' }
24
36
 
@@ -51,7 +63,7 @@ export function useLegacyCountryCodes({ countries, countryById, timelines, label
51
63
  // last segment in only the first — taking the last one yields `2` on the
52
64
  // second.
53
65
  function legacyCodeOf(timeline) {
54
- const fromPackage = countryById.value.get(timeline.country_id)?.code
66
+ const fromPackage = countryUrlCode(countryById.value.get(timeline.country_id))
55
67
  if (fromPackage) return fromPackage
56
68
  const parts = (timeline.backward_compatibility ?? '').split(':')
57
69
  const at = parts.indexOf('country')
@@ -85,7 +97,8 @@ export function useLegacyCountryCodes({ countries, countryById, timelines, label
85
97
  const timeline = (timelines.value ?? []).find((t) => legacyCodeOf(t) === code)
86
98
  if (timeline) return timeline.country_id
87
99
  // A country with no chronology: countries.json's own code.
88
- return (countries.value ?? []).find((c) => c.code === code)?.id ?? null
100
+ const list = countries.value ?? []
101
+ return (list.find((c) => countryUrlCode(c) === code) ?? list.find((c) => c.code === code))?.id ?? null
89
102
  }
90
103
 
91
104
  return { countryIdForCode, countryLabel }
@@ -1,4 +1,5 @@
1
1
  import { projectLabel } from '../../conventions.js'
2
+ import { countryUrlCode } from '../countryCodes.js'
2
3
  import { DATE_MODE, FACET_CATEGORIES, PAGE_SIZE } from '../shared.js'
3
4
 
4
5
  export { DATE_MODE, FACET_CATEGORIES, FACET_LABEL_KEYS, GALLERY_PAGE_SIZE, PAGE_SIZE, useFacetLabels } from '../shared.js'
@@ -53,7 +54,7 @@ export function useGalleryCollection(data, config = {}) {
53
54
  */
54
55
  const FACETS = {
55
56
  country: {
56
- values: (item) => countryById.value.get(item.country_id)?.code ?? null,
57
+ values: (item) => countryUrlCode(countryById.value.get(item.country_id)),
57
58
  label: (code) => labelOf('countries', countryIdForCode(code)),
58
59
  },
59
60
  ...Object.fromEntries(
@@ -125,8 +125,11 @@ export function useGalleryData(config = {}) {
125
125
  (gallery.value?.sibling_galleries ?? []).filter((g) => !g.hidden),
126
126
  )
127
127
 
128
- // A sibling with a new site links to it (inventory-app#2482).
128
+ // A sibling links to its site: the address the package ships (`url`, from
129
+ // the exporter's instance files), else, for an older package, its legacy
130
+ // host turned into the new site's address (inventory-app#2482).
129
131
  function siblingUrl(sibling) {
132
+ if (sibling?.url) return sibling.url
130
133
  return sibling?.legacy_host ? toNewSite(withScheme(sibling.legacy_host)) : null
131
134
  }
132
135
 
@@ -168,6 +168,16 @@ function publicationsRoute(path, url) {
168
168
  return null
169
169
  }
170
170
 
171
+ // A legacy address writes its language as legacy MWNF wrote it; the sites
172
+ // offer it as ISO 639-1. The two differ only for Swedish, Chinese and
173
+ // Slovenian; the other legacy codes are ISO already.
174
+ const LEGACY_LANGUAGES = { se: 'sv', ch: 'zh', si: 'sl' }
175
+ function isoLanguage(code) {
176
+ if (!/^[a-z]{2}$/i.test(code ?? '')) return null
177
+ const lang = code.toLowerCase()
178
+ return LEGACY_LANGUAGES[lang] ?? lang
179
+ }
180
+
171
181
  // Legacy travels.museumwnf.org's Exhibition Trails: a country's or a theme's
172
182
  // trails, a trail (`?id=<project>;<country>;<number>;<language>`) and an
173
183
  // itinerary (`?id=<project>;<country>;<roman number>;<language>;<trail>`),
@@ -183,7 +193,8 @@ const TRAIL_TABS = ['desc', 'its', 'cur']
183
193
  const ITINERARY_TABS = ['des', 'vl']
184
194
  function travelsQuery(url, tabs, language) {
185
195
  const tab = (url.searchParams.get('fl') ?? '').toLowerCase()
186
- const query = [tabs.includes(tab) ? `tab=${tab}` : null, /^[a-z]{2}$/i.test(language ?? '') ? `lang=${language.toLowerCase()}` : null]
196
+ const lang = isoLanguage(language)
197
+ const query = [tabs.includes(tab) ? `tab=${tab}` : null, lang ? `lang=${lang}` : null]
187
198
  const kept = query.filter(Boolean)
188
199
  return kept.length ? `?${kept.join('&')}` : ''
189
200
  }
@@ -252,7 +263,7 @@ function routeFor(row, url) {
252
263
  if (RECORD_PAGES[row.family]) return RECORD_PAGES[row.family](path, url)
253
264
  if (row.family === 'exhibition') {
254
265
  const rest = path.split('/').filter(Boolean).slice(1)
255
- const lang = /^[a-z]{2}$/.test(rest[0] ?? '') ? rest.shift() : null
266
+ const lang = /^[a-z]{2}$/.test(rest[0] ?? '') ? isoLanguage(rest.shift()) : null
256
267
  return `/${rest.join('/')}${lang ? `?lang=${lang}` : ''}`
257
268
  }
258
269
  if (row.family === 'islamicart') {