Skip to content

Commit

Permalink
added qatar test
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Dec 9, 2015
1 parent 01387b3 commit eb8a494
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifesto",
"version": "0.1.20",
"version": "0.1.21",
"homepage": "https://github.com/edsilv/manifesto",
"authors": [
"edsilv <[email protected]>"
Expand Down
9 changes: 9 additions & 0 deletions dist/client/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,12 @@ var Manifesto;
Manifest.prototype.isMultiSequence = function () {
return this.getTotalSequences() > 1;
};
Manifest.prototype.getViewingDirection = function () {
if (this.getProperty('viewingDirection')) {
return new Manifesto.ViewingDirection(this.getProperty('viewingDirection'));
}
return Manifesto.ViewingDirection.LEFTTORIGHT;
};
return Manifest;
})(Manifesto.IIIFResource);
Manifesto.Manifest = Manifest;
Expand Down Expand Up @@ -1292,6 +1298,9 @@ var Manifesto;
if (this.getProperty('viewingDirection')) {
return new Manifesto.ViewingDirection(this.getProperty('viewingDirection'));
}
else if (this.options.resource.getViewingDirection) {
return this.options.resource.getViewingDirection();
}
return Manifesto.ViewingDirection.LEFTTORIGHT;
};
Sequence.prototype.getViewingHint = function () {
Expand Down
2 changes: 2 additions & 0 deletions dist/manifesto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ declare module Manifesto {
private _parseTreeNode(node, range);
getManifestType(): ManifestType;
isMultiSequence(): boolean;
getViewingDirection(): ViewingDirection;
}
}
declare module Manifesto {
Expand Down Expand Up @@ -490,6 +491,7 @@ declare module Manifesto {
getTotalSequences(): number;
getTree(): TreeNode;
getManifestType(): ManifestType;
getViewingDirection(): Manifesto.ViewingDirection;
isMultiSequence(): boolean;
rootRange: IRange;
}
Expand Down
9 changes: 9 additions & 0 deletions dist/server/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,12 @@ var Manifesto;
Manifest.prototype.isMultiSequence = function () {
return this.getTotalSequences() > 1;
};
Manifest.prototype.getViewingDirection = function () {
if (this.getProperty('viewingDirection')) {
return new Manifesto.ViewingDirection(this.getProperty('viewingDirection'));
}
return Manifesto.ViewingDirection.LEFTTORIGHT;
};
return Manifest;
})(Manifesto.IIIFResource);
Manifesto.Manifest = Manifest;
Expand Down Expand Up @@ -1291,6 +1297,9 @@ var Manifesto;
if (this.getProperty('viewingDirection')) {
return new Manifesto.ViewingDirection(this.getProperty('viewingDirection'));
}
else if (this.options.resource.getViewingDirection) {
return this.options.resource.getViewingDirection();
}
return Manifesto.ViewingDirection.LEFTTORIGHT;
};
Sequence.prototype.getViewingHint = function () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifesto.js",
"version": "0.1.20",
"version": "0.1.21",
"description": "IIIF Presentation API utility library for client and server",
"main": "dist/server/manifesto.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/IManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Manifesto {
getTotalSequences(): number;
getTree(): TreeNode;
getManifestType(): ManifestType;
getViewingDirection(): Manifesto.ViewingDirection;
isMultiSequence(): boolean;
rootRange: IRange;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,13 @@ module Manifesto {
isMultiSequence(): boolean{
return this.getTotalSequences() > 1;
}

getViewingDirection(): ViewingDirection {
if (this.getProperty('viewingDirection')){
return new ViewingDirection(this.getProperty('viewingDirection'));
}

return ViewingDirection.LEFTTORIGHT;
}
}
}
2 changes: 2 additions & 0 deletions src/Sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ module Manifesto {
getViewingDirection(): ViewingDirection {
if (this.getProperty('viewingDirection')){
return new ViewingDirection(this.getProperty('viewingDirection'));
} else if ((<IManifest>this.options.resource).getViewingDirection){
return (<IManifest>this.options.resource).getViewingDirection();
}

return ViewingDirection.LEFTTORIGHT;
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/manifests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
"plato": "http://localhost:3000/plato.json",
"potterselectric": "http://localhost:3000/potterselectric.json",
"pseudoalbert": "http://localhost:3000/pseudoalbert.json",
"qatarRightToLeft": "http://localhost:3000/qatar-right-to-left.json",
"riksarkivetscblarge": "http://localhost:3000/riksarkivetscblarge.json",
"storyofwellcome": "http://localhost:3000/storyofwellcome.json",
"tankeryshouse": "http://localhost:3000/tankeryshouse.json",
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/qatar-right-to-left.json

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions test/qatarrighttoleft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// root service is string (only references to root services may be strings)

var _isDate = require("lodash.isdate");
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, sequence;

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

describe('#hasSequence', function() {
it('has a sequence', function () {
sequence = manifest.getSequenceByIndex(0);
expect(sequence).to.exist;
});
});

describe('#hasViewingDirection', function() {
it('has a viewingdirection of right-to-left', function () {
var viewingDirection = sequence.getViewingDirection();
expect(viewingDirection.toString()).to.equal("right-to-left");
});
});

0 comments on commit eb8a494

Please sign in to comment.