Skip to content

Commit

Permalink
added getPosterCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Jul 12, 2018
1 parent 1d1d620 commit e95af36
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dist/client/manifesto.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,13 @@ var Manifesto;
}
return _this;
}
Manifest.prototype.getPosterCanvas = function () {
var posterCanvas = this.getProperty('posterCanvas');
if (posterCanvas) {
posterCanvas = new Manifesto.Canvas(posterCanvas, this.options);
}
return posterCanvas;
};
Manifest.prototype.getBehavior = function () {
var behavior = this.getProperty('behavior');
if (Array.isArray(behavior)) {
Expand Down
7 changes: 7 additions & 0 deletions dist/client/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,13 @@ var Manifesto;
}
return _this;
}
Manifest.prototype.getPosterCanvas = function () {
var posterCanvas = this.getProperty('posterCanvas');
if (posterCanvas) {
posterCanvas = new Manifesto.Canvas(posterCanvas, this.options);
}
return posterCanvas;
};
Manifest.prototype.getBehavior = function () {
var behavior = this.getProperty('behavior');
if (Array.isArray(behavior)) {
Expand Down
2 changes: 2 additions & 0 deletions dist/manifesto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ declare namespace Manifesto {
items: ISequence[];
private _topRanges;
constructor(jsonld?: any, options?: IManifestoOptions);
getPosterCanvas(): ICanvas | null;
getBehavior(): Behavior | null;
getDefaultTree(): ITreeNode;
private _getTopRanges();
Expand Down Expand Up @@ -809,6 +810,7 @@ declare namespace Manifesto {
getAllRanges(): IRange[];
getBehavior(): Behavior | null;
getManifestType(): ManifestType;
getPosterCanvas(): ICanvas | null;
getRangeById(id: string): Manifesto.IRange | null;
getRangeByPath(path: string): IRange | null;
getSequenceByIndex(index: number): ISequence;
Expand Down
7 changes: 7 additions & 0 deletions dist/server/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,13 @@ var Manifesto;
}
return _this;
}
Manifest.prototype.getPosterCanvas = function () {
var posterCanvas = this.getProperty('posterCanvas');
if (posterCanvas) {
posterCanvas = new Manifesto.Canvas(posterCanvas, this.options);
}
return posterCanvas;
};
Manifest.prototype.getBehavior = function () {
var behavior = this.getProperty('behavior');
if (Array.isArray(behavior)) {
Expand Down
1 change: 1 addition & 0 deletions src/IManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Manifesto {
getAllRanges(): IRange[];
getBehavior(): Behavior | null;
getManifestType(): ManifestType;
getPosterCanvas(): ICanvas | null;
getRangeById(id: string): Manifesto.IRange | null;
getRangeByPath(path: string): IRange | null;
getSequenceByIndex(index: number): ISequence;
Expand Down
10 changes: 10 additions & 0 deletions src/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ namespace Manifesto {
}
}

getPosterCanvas(): ICanvas | null {
let posterCanvas: any = this.getProperty('posterCanvas');

if (posterCanvas) {
posterCanvas = new Canvas(posterCanvas, this.options);
}

return posterCanvas;
}

getBehavior(): Behavior | null {
let behavior: any = this.getProperty('behavior');

Expand Down
52 changes: 49 additions & 3 deletions test/fixtures/loose-ends.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/loose-ends/C1685_98_p3.json",
"@context": [
"http://www.w3.org/ns/anno.jsonld",
"http://iiif.io/api/presentation/3/context.json"
],
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/loose-ends/C1685_98_P3.json",
"type": "Manifest",
"label": { "en": [ "C1685/98 Loose ends 17/7/99 No Nav" ] },
"metadata": [
Expand All @@ -14,6 +17,33 @@
"value": { "en": [ "<p>Correct Range implementation</p>" ] }
}
],
"posterCanvas": {
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/C1685_98_P3/poster",
"type": "Canvas",
"height": 962,
"width": 962,
"items": [
{
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/C1685_98_P3/poster/p1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/C1685_98_P3/poster/p1/anno",
"type": "Annotation",
"motivation": "painting",
"target": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/C1685_98_P3/poster",
"body": {
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/posters/pop.jpg",
"type": "Image",
"format": "image/jpeg",
"width": 962,
"height": 962
}
}
]
}
]
},
"behavior": ["auto-advance"],
"items": [
{
Expand Down Expand Up @@ -43,6 +73,14 @@
}
]
}
],
"seeAlso": [
{
"id": "https://edsilv.github.io/peaksjs-test/vdc_100052359795.0x000018.dat",
"type": "Dataset",
"format": "application/octet-stream",
"profile": "http://waveform.prototyping.bbc.co.uk"
}
]
}
]
Expand Down Expand Up @@ -76,6 +114,14 @@
}
]
}
],
"seeAlso": [
{
"id": "https://edsilv.github.io/peaksjs-test/vdc_100052359795.0x00001a.dat",
"type": "Dataset",
"format": "application/octet-stream",
"profile": "http://waveform.prototyping.bbc.co.uk"
}
]
}
]
Expand Down Expand Up @@ -213,4 +259,4 @@
]
}
]
}
}
28 changes: 28 additions & 0 deletions test/poster-canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var expect = require('chai').expect;
var manifesto = require('../dist/server/manifesto');
var should = require('chai').should();
var manifests = require('./fixtures/manifests');
require('./shared');

var manifest, canvas;

describe('poster canvas', function() {

it('loads successfully', function (done) {
manifesto.loadManifest(manifests.looseends).then(function(data) {
manifest = manifesto.create(data);
done();
});
});

it('has a poster canvas', function() {
canvas = manifest.getPosterCanvas();
expect(canvas).to.exist;
});

it('has image', function() {
const img = canvas.getContent()[0].getBody()[0].id;
expect(img).to.equal("https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/posters/pop.jpg");
});

});

0 comments on commit e95af36

Please sign in to comment.