Comparing version 1.0.0 to 1.0.1
@@ -167,5 +167,3 @@ "use strict"; | ||
} | ||
if (yml.value && | ||
!Utils_1.isURL(yml.value) && | ||
annotationJson.body.type) { | ||
if (yml.value && !Utils_1.isURL(yml.value) && annotationJson.body.type) { | ||
// get the path to the annotated file | ||
@@ -172,0 +170,0 @@ const dirName = path_1.dirname(file); |
@@ -184,3 +184,2 @@ "use strict"; | ||
const canvasJson = Utils_1.cloneJson(canvas_json_1.default); | ||
console.log(urljoin(this.url.href, "index.json/canvas", index)); | ||
canvasJson.id = urljoin(this.url.href, "index.json/canvas", index); | ||
@@ -187,0 +186,0 @@ canvasJson.items[0].id = urljoin(this.url.href, "index.json/canvas", index, "annotationpage/0"); |
14
index.js
@@ -14,3 +14,15 @@ "use strict"; | ||
if (!url) { | ||
throw new Error("You must pass a url parameter"); | ||
// if a url hasn't been passed, check if running on Netlify or Vercel and use the appropriate url | ||
if (process.env.NETLIFY) { | ||
url = | ||
process.env.PULL_REQUEST === "true" | ||
? process.env.DEPLOY_PRIME_URL | ||
: process.env.URL; | ||
} | ||
else if (process.env.VERCEL) { | ||
url = process.env.VERCEL_URL; | ||
} | ||
else { | ||
throw new Error("You must pass a url parameter"); | ||
} | ||
} | ||
@@ -17,0 +29,0 @@ const directory = new Directory_1.Directory(dir, url, virtualName); |
{ | ||
"name": "biiif", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A CLI to build IIIF collections", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"test": "mocha", | ||
"testbuild": "node --nolazy --inspect-brk=5858 -e \"require('./index').build('test/collection', 'https://moop-home.netlify.app')\"", | ||
"testbuild": "node --nolazy --inspect-brk=5858 -e \"require('./index').build('test/collection', 'https://sitename.netlify.app')\"", | ||
"serve": "serve test" | ||
@@ -17,0 +17,0 @@ }, |
@@ -22,3 +22,3 @@ # biiif (build iiif) 👷✨📃 | ||
Github template repo for hosting IIIF on Netlify: https://github.com/edsilv/biiif-template | ||
Github template repo for hosting IIIF on Netlify and Vercel: https://github.com/edsilv/biiif-template | ||
@@ -111,3 +111,3 @@ Building static sites with biiif workshop: https://github.com/edsilv/biiif-workshop | ||
If no thumb image is found in a canvas directory, and the `generateThumbs` parameter is set to `true`, biiif checks to see if an image is being annotated onto the canvas with a painting motivation. If so, a thumb is generated (100 x 100px) from that. | ||
If no thumb image is found in a canvas directory, biiif checks to see if an image is being annotated onto the canvas with a painting motivation. If so, a thumb is generated (100 x 100px) from that. | ||
@@ -173,7 +173,7 @@ ## Linked Manifests | ||
└── 2-the-return-of-the-king // manifest | ||
├── _page-1 // canvas | ||
├── _page-2 // canvas | ||
├── _page-n // canvas | ||
├── info.yml // manifest metadata | ||
└── thumb.jpg // manifest thumbnail | ||
├── _page-1 // canvas | ||
├── _page-2 // canvas | ||
├── _page-n // canvas | ||
├── info.yml // manifest metadata | ||
└── thumb.jpg // manifest thumbnail | ||
``` | ||
@@ -180,0 +180,0 @@ |
35
Utils.js
@@ -179,3 +179,3 @@ "use strict"; | ||
// there's alrady a thumbnail in the directory, add it to the canvas | ||
console.log(chalk_1.default.green("found thumbnail for: ") + fp); | ||
exports.log(`found thumbnail for: ${fp}`); | ||
let thumbnail = thumbnails[0]; | ||
@@ -196,4 +196,3 @@ const thumbnailJson = exports.cloneJson(thumbnail_json_1.default); | ||
if (body && | ||
item.motivation === | ||
exports.normaliseType(dist_commonjs_1.AnnotationMotivation.PAINTING)) { | ||
item.motivation === exports.normaliseType(dist_commonjs_1.AnnotationMotivation.PAINTING)) { | ||
// is it an image? (without an info.json) | ||
@@ -227,3 +226,5 @@ if (body.type.toLowerCase() === dist_commonjs_1.ExternalResourceType.IMAGE && | ||
try { | ||
await sharp(imagePath) | ||
await sharp(imagePath, { | ||
limitInputPixels: true, | ||
}) | ||
.resize({ | ||
@@ -237,10 +238,10 @@ width: _config.thumbnails.width, | ||
// thumb.write(pathToThumb, () => { | ||
console.log(chalk_1.default.green("generated thumbnail for: ") + fp); | ||
exports.log(`generated thumbnail for: ${fp}`); | ||
} | ||
catch (_a) { | ||
console.warn(chalk_1.default.red("unable to generate thumbnail for: ") + fp); | ||
exports.warn(`unable to generate thumbnail for: ${fp}`); | ||
} | ||
} | ||
else { | ||
console.log(chalk_1.default.green("found thumbnail for: ") + fp); | ||
exports.log(`found thumbnail for: ${fp}`); | ||
} | ||
@@ -271,3 +272,3 @@ } | ||
const getFileDimensions = async (type, file, canvasJson, annotationJson) => { | ||
console.log(chalk_1.default.green("getting file dimensions for: ") + file); | ||
exports.log(`getting file dimensions for: ${file}`); | ||
if (!exports.isJsonFile(file)) { | ||
@@ -278,3 +279,5 @@ switch (type.toLowerCase()) { | ||
try { | ||
const image = await sharp(file).metadata(); | ||
const image = await sharp(file, { | ||
limitInputPixels: true, | ||
}).metadata(); | ||
const width = image.width; | ||
@@ -287,4 +290,4 @@ const height = image.height; | ||
} | ||
catch (_a) { | ||
console.warn(chalk_1.default.red("getting file dimensions failed for: ") + file); | ||
catch (e) { | ||
exports.warn(`getting file dimensions failed for: ${file}`); | ||
} | ||
@@ -303,3 +306,3 @@ break; | ||
catch (error) { | ||
console.warn(`ffprobe couldn't load ${file}`, error); | ||
exports.warn(`ffprobe couldn't load ${file}`); | ||
} | ||
@@ -313,3 +316,3 @@ break; | ||
try { | ||
console.log(chalk_1.default.green("generating image tiles for: ") + image); | ||
exports.log(`generating image tiles for: ${image}`); | ||
const id = url_join_1.default(url, directoryName, "+tiles"); | ||
@@ -323,3 +326,5 @@ annotationJson.body.service = [ | ||
]; | ||
await sharp(image) | ||
await sharp(image, { | ||
limitInputPixels: true, | ||
}) | ||
.tile({ | ||
@@ -332,3 +337,3 @@ layout: "iiif", | ||
catch (_a) { | ||
console.warn(chalk_1.default.red("generating image tiles failed for: ") + image); | ||
exports.warn(`generating image tiles failed for: ${image}`); | ||
} | ||
@@ -335,0 +340,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
97143
1272
7