Skip to content

Commit

Permalink
added support for manifest behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Sep 29, 2018
1 parent b674487 commit a92bb1c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ export class Directory {
if (this.infoYml.description) {
this.indexJson.description = this.infoYml.description;
}

if (this.infoYml.behavior) {
this.indexJson.behavior = [];

if (Array.isArray(this.infoYml.behavior)) {
this.infoYml.behavior.forEach(behavior => {
this.indexJson.behavior.push(behavior);
});
} else {
this.indexJson.behavior.push(this.infoYml.behavior);
}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "biiif",
"version": "0.3.10",
"version": "0.3.11",
"description": "A CLI to build IIIF collections",
"main": "index.js",
"repository": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/behavior-paged.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports =
'behavior: paged'
4 changes: 4 additions & 0 deletions test/fixtures/multiple-behavior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports =
'behavior: \n\
- paged \n\
- unordered'
23 changes: 23 additions & 0 deletions test/tests/behavior-paged-manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const common = require("../common");
const assert = common.assert;
const build = common.build;
const Utils = common.Utils;

let manifestJson;
const manifest = '/behavior-paged-manifest';
const manifestUrl = 'http://test.com/behavior-paged-manifest';

it('can build manifest', async () => {
assert(await Utils.fileExists(manifest));
return build(manifest, manifestUrl, true);
}).timeout(1000); // should take less than a second

it('can find manifest index.json', async () => {
const file = '/behavior-paged-manifest/index.json';
assert(await Utils.fileExists(file));
manifestJson = await Utils.readJson(file);
});

it('has paged behavior', async () => {
assert(manifestJson.behavior[0] === 'paged');
});
24 changes: 24 additions & 0 deletions test/tests/multiple-behavior-manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const common = require("../common");
const assert = common.assert;
const build = common.build;
const Utils = common.Utils;

let manifestJson;
const manifest = '/multiple-behavior-manifest';
const manifestUrl = 'http://test.com/multiple-behavior-manifest';

it('can build manifest', async () => {
assert(await Utils.fileExists(manifest));
return build(manifest, manifestUrl, true);
}).timeout(1000); // should take less than a second

it('can find manifest index.json', async () => {
const file = '/multiple-behavior-manifest/index.json';
assert(await Utils.fileExists(file));
manifestJson = await Utils.readJson(file);
});

it('has paged and auto behavior', async () => {
assert(manifestJson.behavior[0] === 'paged');
assert(manifestJson.behavior[1] === 'unordered');
});
22 changes: 21 additions & 1 deletion test/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,24 @@ before(async () => {
'_canvas-with-presentation-3-image-service': {
'presentation-3-image-service.yml': require('./fixtures/presentation-3-image-service')
}
},
'/behavior-paged-manifest': {
'info.yml': require('./fixtures/behavior-paged'),
'_page-1': {
'file.jpg': new Buffer(require('./fixtures/cat-jpg'))
},
'_page-2': {
'file.jpg': new Buffer(require('./fixtures/cat-jpg'))
}
},
'/multiple-behavior-manifest': {
'info.yml': require('./fixtures/multiple-behavior'),
'_page-1': {
'file.jpg': new Buffer(require('./fixtures/cat-jpg'))
},
'_page-2': {
'file.jpg': new Buffer(require('./fixtures/cat-jpg'))
}
}
});
})
Expand All @@ -341,4 +359,6 @@ importTest('custom-annotations-manifest', './tests/custom-annotations-manifest')
importTest('generate-thumbs-manifest', './tests/generate-thumbs-manifest');
importTest('dat-gateway', './tests/dat-gateway');
importTest('canvas-with-dimensions-manifest', './tests/canvas-with-dimensions-manifest');
importTest('canvas-with-presentation-3-image-service-manifest', './tests/canvas-with-presentation-3-image-service-manifest');
importTest('canvas-with-presentation-3-image-service-manifest', './tests/canvas-with-presentation-3-image-service-manifest');
importTest('behavior-paged-manifest', './tests/behavior-paged-manifest');
importTest('multiple-behavior-manifest', './tests/multiple-behavior-manifest');

0 comments on commit a92bb1c

Please sign in to comment.