ochre-sdk 1.0.55 → 1.0.57
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.
|
@@ -878,10 +878,22 @@ function parseWebpage(webpageResource, options, context, slugPrefix) {
|
|
|
878
878
|
returnWebpage.properties.isSidebarDisplayed = pageReader.valueOr("sidebar-displayed", true);
|
|
879
879
|
returnWebpage.properties.isBreadcrumbsDisplayed = pageReader.valueOr("breadcrumbs-displayed", false);
|
|
880
880
|
returnWebpage.properties.isNavbarSearchBarDisplayed = pageReader.valueOr("navbar-search-bar-displayed", true);
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
881
|
+
const redirectValue = pageReader.valueNode("redirect-to");
|
|
882
|
+
const redirectTarget = parseWebsiteLinkTarget(redirectValue, context);
|
|
883
|
+
if (redirectTarget != null) if (redirectValue?.href == null && redirectValue?.uuid != null) returnWebpage.properties.redirect = {
|
|
884
|
+
type: "page",
|
|
885
|
+
slug: redirectTarget,
|
|
886
|
+
uuid: redirectValue.uuid
|
|
887
|
+
};
|
|
888
|
+
else returnWebpage.properties.redirect = {
|
|
889
|
+
type: "url",
|
|
890
|
+
href: redirectTarget,
|
|
891
|
+
isExternal: redirectTarget.startsWith("http")
|
|
892
|
+
};
|
|
893
|
+
else if (redirectValue?.uuid != null) returnWebpage.properties.redirect = {
|
|
894
|
+
type: "item",
|
|
895
|
+
uuid: redirectValue.uuid,
|
|
896
|
+
pageType: "item"
|
|
885
897
|
};
|
|
886
898
|
}
|
|
887
899
|
if (imageLink != null) returnWebpage.properties.backgroundImage = {
|
|
@@ -1127,14 +1139,14 @@ function parseWebBlock(blockResource, options, context) {
|
|
|
1127
1139
|
* @param properties - Array of raw website properties in OCHRE format
|
|
1128
1140
|
* @returns Parsed WebsiteProperties object
|
|
1129
1141
|
*/
|
|
1130
|
-
function parseWebsiteProperties(properties, websiteTree, sidebar, options) {
|
|
1142
|
+
function parseWebsiteProperties(properties, websiteTree, sidebar, options, parent) {
|
|
1131
1143
|
const websiteReader = websitePresentationReader(parseSimplifiedProperties({ property: properties }, options)).nested("presentation");
|
|
1132
1144
|
const returnProperties = {
|
|
1133
|
-
type: websiteReader.valueOr("webUI", "traditional"),
|
|
1134
|
-
status: websiteReader.valueOr("status", "development"),
|
|
1135
|
-
versionLabel: websiteReader.valueOr("version-label", "release"),
|
|
1136
|
-
privacy: websiteReader.valueOr("privacy", "public"),
|
|
1137
|
-
contact: null,
|
|
1145
|
+
type: websiteReader.valueOr("webUI", parent?.type ?? "traditional"),
|
|
1146
|
+
status: websiteReader.valueOr("status", parent?.status ?? "development"),
|
|
1147
|
+
versionLabel: websiteReader.valueOr("version-label", parent?.versionLabel ?? "release"),
|
|
1148
|
+
privacy: websiteReader.valueOr("privacy", parent?.privacy ?? "public"),
|
|
1149
|
+
contact: parent?.contact ?? null,
|
|
1138
1150
|
loadingVariant: "spinner",
|
|
1139
1151
|
theme: {
|
|
1140
1152
|
isThemeToggleDisplayed: true,
|
|
@@ -1151,33 +1163,33 @@ function parseWebsiteProperties(properties, websiteTree, sidebar, options) {
|
|
|
1151
1163
|
alignment: "start",
|
|
1152
1164
|
isProjectDisplayed: true,
|
|
1153
1165
|
searchBarBoundElementUuid: null,
|
|
1154
|
-
items: null
|
|
1166
|
+
items: parent?.navbar.items ?? null
|
|
1155
1167
|
},
|
|
1156
1168
|
footer: {
|
|
1157
1169
|
isDisplayed: true,
|
|
1158
1170
|
logoUuid: null,
|
|
1159
|
-
items: null
|
|
1171
|
+
items: parent?.footer.items ?? null
|
|
1160
1172
|
},
|
|
1161
|
-
sidebar,
|
|
1173
|
+
sidebar: sidebar ?? parent?.sidebar ?? null,
|
|
1162
1174
|
itemPage: {
|
|
1163
|
-
isMainContentDisplayed: true,
|
|
1164
|
-
isDescriptionDisplayed: true,
|
|
1165
|
-
isDocumentDisplayed: true,
|
|
1166
|
-
isNotesDisplayed: true,
|
|
1167
|
-
isEventsDisplayed: true,
|
|
1168
|
-
isPeriodsDisplayed: true,
|
|
1169
|
-
isPropertiesDisplayed: true,
|
|
1170
|
-
isBibliographyDisplayed: true,
|
|
1171
|
-
isPropertyValuesGrouped: true,
|
|
1172
|
-
isPublicationDateTimeDisplayed: true,
|
|
1173
|
-
isPersistentIdentifierDisplayed: true,
|
|
1174
|
-
iiifViewer: "universal-viewer"
|
|
1175
|
+
isMainContentDisplayed: parent?.itemPage.isMainContentDisplayed ?? true,
|
|
1176
|
+
isDescriptionDisplayed: parent?.itemPage.isDescriptionDisplayed ?? true,
|
|
1177
|
+
isDocumentDisplayed: parent?.itemPage.isDocumentDisplayed ?? true,
|
|
1178
|
+
isNotesDisplayed: parent?.itemPage.isNotesDisplayed ?? true,
|
|
1179
|
+
isEventsDisplayed: parent?.itemPage.isEventsDisplayed ?? true,
|
|
1180
|
+
isPeriodsDisplayed: parent?.itemPage.isPeriodsDisplayed ?? true,
|
|
1181
|
+
isPropertiesDisplayed: parent?.itemPage.isPropertiesDisplayed ?? true,
|
|
1182
|
+
isBibliographyDisplayed: parent?.itemPage.isBibliographyDisplayed ?? true,
|
|
1183
|
+
isPropertyValuesGrouped: parent?.itemPage.isPropertyValuesGrouped ?? true,
|
|
1184
|
+
isPublicationDateTimeDisplayed: parent?.itemPage.isPublicationDateTimeDisplayed ?? true,
|
|
1185
|
+
isPersistentIdentifierDisplayed: parent?.itemPage.isPersistentIdentifierDisplayed ?? true,
|
|
1186
|
+
iiifViewer: parent?.itemPage.iiifViewer ?? "universal-viewer"
|
|
1175
1187
|
},
|
|
1176
1188
|
options: {
|
|
1177
|
-
contextTree: null,
|
|
1178
|
-
scopes: null,
|
|
1179
|
-
labels: { title: null },
|
|
1180
|
-
stylesheets: { properties: [] }
|
|
1189
|
+
contextTree: parent?.options.contextTree ?? null,
|
|
1190
|
+
scopes: parent?.options.scopes ?? null,
|
|
1191
|
+
labels: { title: parent?.options.labels.title ?? null },
|
|
1192
|
+
stylesheets: { properties: parent?.options.stylesheets.properties ?? [] }
|
|
1181
1193
|
}
|
|
1182
1194
|
};
|
|
1183
1195
|
const contactProperty = websiteReader.property("contact");
|
|
@@ -1189,41 +1201,44 @@ function parseWebsiteProperties(properties, websiteTree, sidebar, options) {
|
|
|
1189
1201
|
};
|
|
1190
1202
|
else throw new Error(`Contact property must use “name;email”, got “${contactProperty.values[0]?.content}” (website uuid “${websiteTree.uuid}”)`, { cause: websiteTree });
|
|
1191
1203
|
}
|
|
1192
|
-
returnProperties.loadingVariant = websiteReader.valueOr("loading-variant", "spinner");
|
|
1193
|
-
returnProperties.theme.isThemeToggleDisplayed = websiteReader.valueOr("supports-theme-toggle", true);
|
|
1194
|
-
returnProperties.theme.defaultTheme = websiteReader.valueOr("default-theme", "system");
|
|
1195
|
-
returnProperties.icon.logoUuid = websiteReader.uuid("navbar-logo");
|
|
1196
|
-
returnProperties.icon.faviconUuid = websiteReader.uuid("favicon-ico");
|
|
1197
|
-
returnProperties.icon.appleTouchIconUuid = websiteReader.uuid("favicon-img");
|
|
1198
|
-
returnProperties.navbar.isDisplayed = websiteReader.valueOr("navbar-displayed", true);
|
|
1199
|
-
returnProperties.navbar.variant = websiteReader.valueOr("navbar-variant", "default");
|
|
1200
|
-
returnProperties.navbar.alignment = websiteReader.valueOr("navbar-alignment", "start");
|
|
1201
|
-
returnProperties.navbar.isProjectDisplayed = websiteReader.valueOr("navbar-project-displayed", true);
|
|
1202
|
-
returnProperties.navbar.searchBarBoundElementUuid = websiteReader.uuid("bound-element-navbar-search-bar");
|
|
1203
|
-
returnProperties.footer.isDisplayed = websiteReader.valueOr("footer-displayed", true);
|
|
1204
|
-
returnProperties.footer.logoUuid = websiteReader.uuid("footer-logo");
|
|
1204
|
+
returnProperties.loadingVariant = websiteReader.valueOr("loading-variant", parent?.loadingVariant ?? "spinner");
|
|
1205
|
+
returnProperties.theme.isThemeToggleDisplayed = websiteReader.valueOr("supports-theme-toggle", parent?.theme.isThemeToggleDisplayed ?? true);
|
|
1206
|
+
returnProperties.theme.defaultTheme = websiteReader.valueOr("default-theme", parent?.theme.defaultTheme ?? "system");
|
|
1207
|
+
returnProperties.icon.logoUuid = websiteReader.uuid("navbar-logo") ?? parent?.icon.logoUuid ?? null;
|
|
1208
|
+
returnProperties.icon.faviconUuid = websiteReader.uuid("favicon-ico") ?? parent?.icon.faviconUuid ?? null;
|
|
1209
|
+
returnProperties.icon.appleTouchIconUuid = websiteReader.uuid("favicon-img") ?? parent?.icon.appleTouchIconUuid ?? null;
|
|
1210
|
+
returnProperties.navbar.isDisplayed = websiteReader.valueOr("navbar-displayed", parent?.navbar.isDisplayed ?? true);
|
|
1211
|
+
returnProperties.navbar.variant = websiteReader.valueOr("navbar-variant", parent?.navbar.variant ?? "default");
|
|
1212
|
+
returnProperties.navbar.alignment = websiteReader.valueOr("navbar-alignment", parent?.navbar.alignment ?? "start");
|
|
1213
|
+
returnProperties.navbar.isProjectDisplayed = websiteReader.valueOr("navbar-project-displayed", parent?.navbar.isProjectDisplayed ?? true);
|
|
1214
|
+
returnProperties.navbar.searchBarBoundElementUuid = websiteReader.uuid("bound-element-navbar-search-bar") ?? parent?.navbar.searchBarBoundElementUuid ?? null;
|
|
1215
|
+
returnProperties.footer.isDisplayed = websiteReader.valueOr("footer-displayed", parent?.footer.isDisplayed ?? true);
|
|
1216
|
+
returnProperties.footer.logoUuid = websiteReader.uuid("footer-logo") ?? parent?.footer.logoUuid ?? null;
|
|
1205
1217
|
const itemPageReader = websiteReader.nestedByValue("page-type", "item-page");
|
|
1206
1218
|
if (itemPageReader.size > 0) {
|
|
1207
|
-
returnProperties.itemPage.isMainContentDisplayed = itemPageReader.valueOr("item-page-main-content-displayed",
|
|
1208
|
-
returnProperties.itemPage.isDescriptionDisplayed = itemPageReader.valueOr("item-page-description-displayed",
|
|
1209
|
-
returnProperties.itemPage.isDocumentDisplayed = itemPageReader.valueOr("item-page-document-displayed",
|
|
1210
|
-
returnProperties.itemPage.isNotesDisplayed = itemPageReader.valueOr("item-page-notes-displayed",
|
|
1211
|
-
returnProperties.itemPage.isEventsDisplayed = itemPageReader.valueOr("item-page-events-displayed",
|
|
1212
|
-
returnProperties.itemPage.isPeriodsDisplayed = itemPageReader.valueOr("item-page-periods-displayed",
|
|
1213
|
-
returnProperties.itemPage.isPropertiesDisplayed = itemPageReader.valueOr("item-page-properties-displayed",
|
|
1214
|
-
returnProperties.itemPage.isBibliographyDisplayed = itemPageReader.valueOr("item-page-bibliography-displayed",
|
|
1215
|
-
returnProperties.itemPage.isPropertyValuesGrouped = itemPageReader.valueOr("item-page-property-values-grouped",
|
|
1216
|
-
returnProperties.itemPage.isPublicationDateTimeDisplayed = itemPageReader.valueOr("item-page-publication-date-time-displayed",
|
|
1217
|
-
returnProperties.itemPage.isPersistentIdentifierDisplayed = itemPageReader.valueOr("item-page-persistent-identifier-displayed",
|
|
1218
|
-
returnProperties.itemPage.iiifViewer = itemPageReader.valueOr("item-page-iiif-viewer",
|
|
1219
|
+
returnProperties.itemPage.isMainContentDisplayed = itemPageReader.valueOr("item-page-main-content-displayed", returnProperties.itemPage.isMainContentDisplayed);
|
|
1220
|
+
returnProperties.itemPage.isDescriptionDisplayed = itemPageReader.valueOr("item-page-description-displayed", returnProperties.itemPage.isDescriptionDisplayed);
|
|
1221
|
+
returnProperties.itemPage.isDocumentDisplayed = itemPageReader.valueOr("item-page-document-displayed", returnProperties.itemPage.isDocumentDisplayed);
|
|
1222
|
+
returnProperties.itemPage.isNotesDisplayed = itemPageReader.valueOr("item-page-notes-displayed", returnProperties.itemPage.isNotesDisplayed);
|
|
1223
|
+
returnProperties.itemPage.isEventsDisplayed = itemPageReader.valueOr("item-page-events-displayed", returnProperties.itemPage.isEventsDisplayed);
|
|
1224
|
+
returnProperties.itemPage.isPeriodsDisplayed = itemPageReader.valueOr("item-page-periods-displayed", returnProperties.itemPage.isPeriodsDisplayed);
|
|
1225
|
+
returnProperties.itemPage.isPropertiesDisplayed = itemPageReader.valueOr("item-page-properties-displayed", returnProperties.itemPage.isPropertiesDisplayed);
|
|
1226
|
+
returnProperties.itemPage.isBibliographyDisplayed = itemPageReader.valueOr("item-page-bibliography-displayed", returnProperties.itemPage.isBibliographyDisplayed);
|
|
1227
|
+
returnProperties.itemPage.isPropertyValuesGrouped = itemPageReader.valueOr("item-page-property-values-grouped", returnProperties.itemPage.isPropertyValuesGrouped);
|
|
1228
|
+
returnProperties.itemPage.isPublicationDateTimeDisplayed = itemPageReader.valueOr("item-page-publication-date-time-displayed", returnProperties.itemPage.isPublicationDateTimeDisplayed);
|
|
1229
|
+
returnProperties.itemPage.isPersistentIdentifierDisplayed = itemPageReader.valueOr("item-page-persistent-identifier-displayed", returnProperties.itemPage.isPersistentIdentifierDisplayed);
|
|
1230
|
+
returnProperties.itemPage.iiifViewer = itemPageReader.valueOr("item-page-iiif-viewer", returnProperties.itemPage.iiifViewer);
|
|
1219
1231
|
}
|
|
1220
1232
|
if (websiteTree.options != null) {
|
|
1221
1233
|
const parsedOptions = parseWebsiteOptions(websiteTree.options, options);
|
|
1222
|
-
returnProperties.options.scopes = parsedOptions.scopes;
|
|
1223
|
-
returnProperties.options.contextTree = parsedOptions.contextTree;
|
|
1224
|
-
returnProperties.options.labels = parsedOptions.labels;
|
|
1234
|
+
returnProperties.options.scopes = (parsedOptions.scopes != null && parsedOptions.scopes.length > 0 ? parsedOptions : returnProperties.options).scopes;
|
|
1235
|
+
returnProperties.options.contextTree = parsedOptions.contextTree ?? returnProperties.options.contextTree;
|
|
1236
|
+
returnProperties.options.labels = { title: parsedOptions.labels.title ?? returnProperties.options.labels.title };
|
|
1237
|
+
}
|
|
1238
|
+
if ("styleOptions" in websiteTree && websiteTree.styleOptions != null) {
|
|
1239
|
+
const stylesheetProperties = parseStylesheets(websiteTree.styleOptions.style);
|
|
1240
|
+
if (stylesheetProperties.length > 0) returnProperties.options.stylesheets.properties = stylesheetProperties;
|
|
1225
1241
|
}
|
|
1226
|
-
if ("styleOptions" in websiteTree && websiteTree.styleOptions != null) returnProperties.options.stylesheets.properties = parseStylesheets(websiteTree.styleOptions.style);
|
|
1227
1242
|
return returnProperties;
|
|
1228
1243
|
}
|
|
1229
1244
|
function parseContextItem(contextItemToParse, options) {
|
|
@@ -1303,7 +1318,8 @@ function parseWebsiteTree(websiteTree, context, type, options, slugPrefix) {
|
|
|
1303
1318
|
pageSlugsByUuid
|
|
1304
1319
|
};
|
|
1305
1320
|
const sidebar = parseSidebar(resources, options, treeContext);
|
|
1306
|
-
const properties = parseWebsiteProperties(websiteTree.properties.property, websiteTree, sidebar, options);
|
|
1321
|
+
const properties = parseWebsiteProperties(websiteTree.properties.property, websiteTree, sidebar, options, context.parentProperties ?? null);
|
|
1322
|
+
const license = parseLicense(websiteTree.availability) ?? context.parentLicense ?? null;
|
|
1307
1323
|
return {
|
|
1308
1324
|
uuid: websiteTree.uuid,
|
|
1309
1325
|
type,
|
|
@@ -1312,8 +1328,12 @@ function parseWebsiteTree(websiteTree, context, type, options, slugPrefix) {
|
|
|
1312
1328
|
publicationDateTime: websiteTree.publicationDateTime ?? null,
|
|
1313
1329
|
identification: parseIdentification(websiteTree.identification, options),
|
|
1314
1330
|
creators: websiteTree.creators ? parsePersonList(websiteTree.creators.creator, options) : [],
|
|
1315
|
-
license
|
|
1316
|
-
items: parseWebpages(resources, options,
|
|
1331
|
+
license,
|
|
1332
|
+
items: parseWebpages(resources, options, {
|
|
1333
|
+
...treeContext,
|
|
1334
|
+
parentProperties: properties,
|
|
1335
|
+
parentLicense: license
|
|
1336
|
+
}, slugPrefix),
|
|
1317
1337
|
properties
|
|
1318
1338
|
};
|
|
1319
1339
|
}
|
package/dist/types/website.d.mts
CHANGED
|
@@ -203,8 +203,17 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
|
|
|
203
203
|
isDisplayedInNavbar: boolean;
|
|
204
204
|
isNavbarSearchBarDisplayed: boolean;
|
|
205
205
|
redirect: {
|
|
206
|
+
type: "url";
|
|
206
207
|
href: string;
|
|
207
208
|
isExternal: boolean;
|
|
209
|
+
} | {
|
|
210
|
+
type: "page";
|
|
211
|
+
slug: string;
|
|
212
|
+
uuid: string;
|
|
213
|
+
} | {
|
|
214
|
+
type: "item";
|
|
215
|
+
uuid: string;
|
|
216
|
+
pageType: "item" | "entry";
|
|
208
217
|
} | null;
|
|
209
218
|
backgroundImage: WebImage<T> | null;
|
|
210
219
|
sidebar: WebSidebar<T> | null;
|