@canopy-iiif/app 1.6.0 → 1.6.2
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/lib/build/build.js +129 -69
- package/lib/build/iiif.js +340 -262
- package/lib/orchestrator.js +9 -0
- package/lib/search/search.js +30 -1
- package/package.json +1 -1
package/lib/orchestrator.js
CHANGED
|
@@ -131,6 +131,15 @@ function attachSignalHandlers() {
|
|
|
131
131
|
async function orchestrate(options = {}) {
|
|
132
132
|
const argv = options.argv || process.argv.slice(2);
|
|
133
133
|
const env = options.env || process.env;
|
|
134
|
+
if (
|
|
135
|
+
argv.includes('--debug-iiif') ||
|
|
136
|
+
argv.includes('--iiif-debug') ||
|
|
137
|
+
argv.includes('--debug')
|
|
138
|
+
) {
|
|
139
|
+
if (!env.CANOPY_IIIF_DEBUG) env.CANOPY_IIIF_DEBUG = '1';
|
|
140
|
+
if (!process.env.CANOPY_IIIF_DEBUG) process.env.CANOPY_IIIF_DEBUG = '1';
|
|
141
|
+
log('IIIF debug logging enabled');
|
|
142
|
+
}
|
|
134
143
|
|
|
135
144
|
process.title = 'canopy-app';
|
|
136
145
|
const mode = getMode(argv, env);
|
package/lib/search/search.js
CHANGED
|
@@ -284,7 +284,9 @@ async function buildSearchPage() {
|
|
|
284
284
|
canonical: searchHref,
|
|
285
285
|
},
|
|
286
286
|
};
|
|
287
|
-
const rendered = await mdx.compileMdxFile(searchLayoutPath, outPath, {
|
|
287
|
+
const rendered = await mdx.compileMdxFile(searchLayoutPath, outPath, null, {
|
|
288
|
+
page: pageDetails,
|
|
289
|
+
});
|
|
288
290
|
body = rendered && rendered.body ? rendered.body : '';
|
|
289
291
|
head = rendered && rendered.head ? rendered.head : '';
|
|
290
292
|
if (!body) throw new Error('Search: content/search/_layout.mdx produced empty output');
|
|
@@ -460,16 +462,43 @@ async function writeSearchIndex(records) {
|
|
|
460
462
|
console.warn('Search: index size is large (', Math.round(approxBytes / (1024 * 1024)), 'MB ). Consider narrowing sources.');
|
|
461
463
|
}
|
|
462
464
|
await fsp.writeFile(idxPath, indexJson, 'utf8');
|
|
465
|
+
try {
|
|
466
|
+
const { logLine } = require('./log');
|
|
467
|
+
const approxKb = Math.round(approxBytes / 1024);
|
|
468
|
+
logLine(
|
|
469
|
+
`• search-index.json written (${indexRecords.length} records, ${approxKb} KB)`,
|
|
470
|
+
'blue',
|
|
471
|
+
{ dim: true }
|
|
472
|
+
);
|
|
473
|
+
} catch (_) {}
|
|
463
474
|
|
|
464
475
|
const displayPath = path.join(apiDir, 'search-records.json');
|
|
465
476
|
const displayJson = JSON.stringify(displayRecords);
|
|
466
477
|
const displayBytes = Buffer.byteLength(displayJson, 'utf8');
|
|
467
478
|
await fsp.writeFile(displayPath, displayJson, 'utf8');
|
|
479
|
+
try {
|
|
480
|
+
const { logLine } = require('./log');
|
|
481
|
+
const approxKb = Math.round(displayBytes / 1024);
|
|
482
|
+
logLine(
|
|
483
|
+
`• search-records.json written (${displayRecords.length} entries, ${approxKb} KB)`,
|
|
484
|
+
'blue',
|
|
485
|
+
{ dim: true }
|
|
486
|
+
);
|
|
487
|
+
} catch (_) {}
|
|
468
488
|
let annotationsBytes = 0;
|
|
469
489
|
if (annotationRecords.length) {
|
|
470
490
|
const annotationsJson = JSON.stringify(annotationRecords);
|
|
471
491
|
annotationsBytes = Buffer.byteLength(annotationsJson, 'utf8');
|
|
472
492
|
await fsp.writeFile(annotationsPath, annotationsJson, 'utf8');
|
|
493
|
+
try {
|
|
494
|
+
const { logLine } = require('./log');
|
|
495
|
+
const approxKb = Math.round(annotationsBytes / 1024);
|
|
496
|
+
logLine(
|
|
497
|
+
`• search-index-annotations.json written (${annotationRecords.length} entries, ${approxKb} KB)`,
|
|
498
|
+
'blue',
|
|
499
|
+
{ dim: true }
|
|
500
|
+
);
|
|
501
|
+
} catch (_) {}
|
|
473
502
|
} else {
|
|
474
503
|
try {
|
|
475
504
|
if (fs.existsSync(annotationsPath)) await fsp.unlink(annotationsPath);
|