Comparing version 0.3.13 to 0.3.14
@@ -53,3 +53,3 @@ "use strict"; | ||
let hasPaintingAnnotation = false; | ||
await Promise.all(customAnnotationFiles.map(async (file) => { | ||
for (const file of customAnnotationFiles) { | ||
let directoryName = dirname(file); | ||
@@ -150,3 +150,3 @@ directoryName = directoryName.substr(directoryName.lastIndexOf('/')); | ||
canvasJson.items[0].items.push(annotationJson); | ||
})); | ||
} | ||
if (!hasPaintingAnnotation) { | ||
@@ -179,3 +179,3 @@ // for each jpg/pdf/mp4/obj in the canvas directory | ||
async _annotateFiles(canvasJson, files) { | ||
await Promise.all(files.map(async (file) => { | ||
for (let file of files) { | ||
file = Utils_1.Utils.normaliseFilePath(file); | ||
@@ -215,3 +215,3 @@ const extName = extname(file); | ||
} | ||
})); | ||
} | ||
} | ||
@@ -218,0 +218,0 @@ async _getInfo() { |
@@ -40,6 +40,11 @@ "use strict"; | ||
}); | ||
await Promise.all(canvases.map(async (canvas) => { | ||
// example of parallel processing | ||
//await Promise.all(canvases.map(async (canvas: string) => { ... }); | ||
// dropped parallel processing in favour of "deterministic" results | ||
// also, a lot of tasks in parallel can use too much memory: | ||
// https://blog.lavrton.com/javascript-loops-how-to-handle-async-await-6252dd3c795 | ||
for (const canvas of canvases) { | ||
console.log(chalk.green('creating canvas for: ') + canvas); | ||
this.items.push(new Canvas_1.Canvas(canvas, this)); | ||
})); | ||
} | ||
// directories not starting with an underscore | ||
@@ -58,3 +63,3 @@ // these can be child manifests or child collections | ||
}); | ||
await Promise.all(directories.map(async (directory) => { | ||
for (const directory of directories) { | ||
console.log(chalk.green('creating directory for: ') + directory); | ||
@@ -66,3 +71,3 @@ const name = basename(directory); | ||
this.directories.push(newDirectory); | ||
})); | ||
} | ||
// if there are no canvas, manifest, or collection directories to read, | ||
@@ -127,3 +132,3 @@ // but there are paintable files in the current directory, | ||
// for each child directory, add a collectionitem or manifestitem json boilerplate to items. | ||
await Promise.all(this.directories.map(async (directory) => { | ||
for (const directory of this.directories) { | ||
let itemJson; | ||
@@ -140,3 +145,3 @@ if (directory.isCollection) { | ||
this.indexJson.items.push(itemJson); | ||
})); | ||
} | ||
// check for manifests.yml. if it exists, parse and add to items | ||
@@ -186,3 +191,4 @@ const hasManifestsYml = await Utils_1.Utils.hasManifestsYml(this.directoryPath); | ||
// for each canvas, add canvas json | ||
await Promise.all(this.items.map(async (canvas, index) => { | ||
let index = 0; | ||
for (const canvas of this.items) { | ||
const canvasJson = Utils_1.Utils.cloneJson(canvasBoilerplate); | ||
@@ -194,3 +200,4 @@ canvasJson.id = urljoin(this.url.href, 'index.json/canvas', index); | ||
this.indexJson.items.push(canvasJson); | ||
})); | ||
index++; | ||
} | ||
this.indexJson.items.sort((a, b) => { | ||
@@ -197,0 +204,0 @@ return Utils_1.Utils.compare(a.id, b.id); |
{ | ||
"name": "biiif", | ||
"version": "0.3.13", | ||
"version": "0.3.14", | ||
"description": "A CLI to build IIIF collections", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"test": "tsc && mocha", | ||
"testbuild": "node --nolazy --inspect-brk=5858 -e \"require('./index').build('collection', 'https://edsilv.github.io/biiif-test-manifests/sound-manifest')\"" | ||
"testbuild": "node --nolazy --inspect-brk=5858 -e \"require('./index').build('collection', 'https://edsilv.github.io/biiif-test-manifests/sort-files-numeric-manifest', true)\"" | ||
}, | ||
@@ -15,0 +15,0 @@ "engines": { |
14
Utils.js
@@ -147,3 +147,2 @@ "use strict"; | ||
if (json.items && json.items.length && json.items[0].items) { | ||
console.log(chalk.green('generating thumbnail for: ') + fp); | ||
// find an annotation with a painting motivation of type image. | ||
@@ -175,5 +174,12 @@ const items = json.items[0].items; | ||
pathToThumb += image.getExtension(); | ||
thumb.write(pathToThumb, () => { | ||
console.log(chalk.green('generated thumbnail for: ') + fp); | ||
}); | ||
// a thumbnail may already exist at this path (when generating from a flat collection of images) | ||
const thumbExists = await Utils.fileExists(pathToThumb); | ||
if (!thumbExists) { | ||
thumb.write(pathToThumb, () => { | ||
console.log(chalk.green('generated thumbnail for: ') + fp); | ||
}); | ||
} | ||
else { | ||
console.log(chalk.green('found thumbnail for: ') + fp); | ||
} | ||
} | ||
@@ -180,0 +186,0 @@ else { |
54294
990