Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Sep 1, 2017
2 parents 2a68a24 + 9193957 commit 70c42d1
Show file tree
Hide file tree
Showing 19 changed files with 584 additions and 302 deletions.
104 changes: 56 additions & 48 deletions dist/client/manifesto.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ var Manifesto;
IIIFResourceType.prototype.sequence = function () {
return new IIIFResourceType(IIIFResourceType.SEQUENCE.toString());
};
IIIFResourceType.ANNOTATION = new IIIFResourceType("oa:annotation");
IIIFResourceType.CANVAS = new IIIFResourceType("sc:canvas");
IIIFResourceType.COLLECTION = new IIIFResourceType("sc:collection");
IIIFResourceType.MANIFEST = new IIIFResourceType("sc:manifest");
IIIFResourceType.RANGE = new IIIFResourceType("sc:range");
IIIFResourceType.SEQUENCE = new IIIFResourceType("sc:sequence");
IIIFResourceType.ANNOTATION = new IIIFResourceType("annotation");
IIIFResourceType.CANVAS = new IIIFResourceType("canvas");
IIIFResourceType.COLLECTION = new IIIFResourceType("collection");
IIIFResourceType.MANIFEST = new IIIFResourceType("manifest");
IIIFResourceType.RANGE = new IIIFResourceType("range");
IIIFResourceType.SEQUENCE = new IIIFResourceType("sequence");
return IIIFResourceType;
}(Manifesto.StringValue));
Manifesto.IIIFResourceType = IIIFResourceType;
Expand Down Expand Up @@ -708,7 +708,7 @@ var Manifesto;
return _this;
}
ManifestResource.prototype.getIIIFResourceType = function () {
return new Manifesto.IIIFResourceType(this.getProperty('@type'));
return new Manifesto.IIIFResourceType(Manifesto.Utils.normaliseType(this.getProperty('type')));
};
ManifestResource.prototype.getLabel = function () {
return Manifesto.TranslationCollection.parse(this.getProperty('label'), this.options.locale);
Expand Down Expand Up @@ -1030,12 +1030,7 @@ var Manifesto;
return [];
};
IIIFResource.prototype.getIIIFResourceType = function () {
var type = this.getProperty('type');
if (type) {
return new Manifesto.IIIFResourceType(type);
}
type = this.getProperty('@type');
return new Manifesto.IIIFResourceType(type);
return new Manifesto.IIIFResourceType(Manifesto.Utils.normaliseType(this.getProperty('type')));
};
IIIFResource.prototype.getLogo = function () {
var logo = this.getProperty('logo');
Expand Down Expand Up @@ -1070,19 +1065,13 @@ var Manifesto;
return this.defaultTree;
};
IIIFResource.prototype.isCollection = function () {
if (this.getIIIFResourceType().toString().toLowerCase() === 'collection') {
return true;
}
else if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.COLLECTION.toString()) {
if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.COLLECTION.toString()) {
return true;
}
return false;
};
IIIFResource.prototype.isManifest = function () {
if (this.getIIIFResourceType().toString().toLowerCase() === 'manifest') {
return true;
}
else if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.MANIFEST.toString()) {
if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.MANIFEST.toString()) {
return true;
}
return false;
Expand Down Expand Up @@ -1183,7 +1172,7 @@ var Manifesto;
if (this.__jsonld.structures && this.__jsonld.structures.length) {
for (var i = 0; i < this.__jsonld.structures.length; i++) {
var r = this.__jsonld.structures[i];
if (r['@id'] === id) {
if (r['@id'] === id || r.id === id) {
return r;
}
}
Expand Down Expand Up @@ -1215,25 +1204,26 @@ var Manifesto;
else {
parentRange.members.push(range);
}
if (r.ranges) {
for (var i = 0; i < r.ranges.length; i++) {
this._parseRanges(r.ranges[i], path + '/' + i, range);
}
}
if (r.members) {
var _loop_1 = function (i) {
for (var i = 0; i < r.members.length; i++) {
var child = r.members[i];
// only add to members if not already parsed from backwards-compatible ranges/canvases arrays
if (r.members.en().where(function (m) { return m.id === child.id; }).first()) {
return "continue";
// todo: use constants
if (child['@type'] && child['@type'].toLowerCase() === 'sc:range' || child['type'] && child['type'].toLowerCase() === 'range') {
this._parseRanges(child, path + '/' + i, range);
}
if (child['@type'].toLowerCase() === 'sc:range') {
this_1._parseRanges(child, path + '/' + i, range);
else if (child['@type'] && child['@type'].toLowerCase() === 'sc:canvas' || child['type'] && child['type'].toLowerCase() === 'canvas') {
// store the ids on the __jsonld object to be used by Range.getCanvasIds()
if (!range.canvases) {
range.canvases = [];
}
var id_1 = child['@id'] || child.id;
range.canvases.push(id_1);
}
};
var this_1 = this;
for (var i = 0; i < r.members.length; i++) {
_loop_1(i);
}
}
else if (r.ranges) {
for (var i = 0; i < r.ranges.length; i++) {
this._parseRanges(r.ranges[i], path + '/' + i, range);
}
}
};
Expand Down Expand Up @@ -1443,23 +1433,26 @@ var Manifesto;
__extends(Range, _super);
function Range(jsonld, options) {
var _this = _super.call(this, jsonld, options) || this;
_this._canvases = null;
_this._ranges = null;
_this.canvases = null;
_this.members = [];
return _this;
}
Range.prototype.getCanvasIds = function () {
if (this.__jsonld.canvases) {
return this.__jsonld.canvases;
}
return [];
};
Range.prototype.getCanvases = function () {
if (this._canvases) {
return this._canvases;
else if (this.canvases) {
return this.canvases;
}
return this._canvases = this.members.en().where(function (m) { return m.isCanvas(); }).toArray();
return [];
};
// getCanvases(): ICanvas[] {
// if (this._canvases) {
// return this._canvases;
// }
// return this._canvases = <ICanvas[]>this.members.en().where(m => m.isCanvas()).toArray();
// }
Range.prototype.getRanges = function () {
if (this._ranges) {
return this._ranges;
Expand Down Expand Up @@ -1576,7 +1569,9 @@ var Manifesto;
Sequence.prototype.getCanvasById = function (id) {
for (var i = 0; i < this.getTotalCanvases(); i++) {
var canvas = this.getCanvasByIndex(i);
if (canvas.id === id) {
// normalise canvas id
var canvasId = Manifesto.Utils.normaliseUrl(canvas.id);
if (Manifesto.Utils.normaliseUrl(id) === canvasId) {
return canvas;
}
}
Expand Down Expand Up @@ -2166,10 +2161,23 @@ var Manifesto;
Utils.generateTreeNodeIds(n, i);
}
};
Utils.normaliseType = function (type) {
type = type.toLowerCase();
if (type.indexOf(':') !== -1) {
var split = type.split(':');
return split[1];
}
return type;
};
Utils.normaliseUrl = function (url) {
url = url.substr(url.indexOf('://'));
if (url.indexOf('#') !== -1) {
url = url.split('#')[0];
}
return url;
};
Utils.normalisedUrlsMatch = function (url1, url2) {
var url1norm = url1.substr(url1.indexOf('://'));
var url2norm = url1.substr(url1.indexOf('://'));
return url1norm === url2norm;
return Utils.normaliseUrl(url1) === Utils.normaliseUrl(url2);
};
Utils.isImageProfile = function (profile) {
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Expand Down
104 changes: 56 additions & 48 deletions dist/client/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ var Manifesto;
IIIFResourceType.prototype.sequence = function () {
return new IIIFResourceType(IIIFResourceType.SEQUENCE.toString());
};
IIIFResourceType.ANNOTATION = new IIIFResourceType("oa:annotation");
IIIFResourceType.CANVAS = new IIIFResourceType("sc:canvas");
IIIFResourceType.COLLECTION = new IIIFResourceType("sc:collection");
IIIFResourceType.MANIFEST = new IIIFResourceType("sc:manifest");
IIIFResourceType.RANGE = new IIIFResourceType("sc:range");
IIIFResourceType.SEQUENCE = new IIIFResourceType("sc:sequence");
IIIFResourceType.ANNOTATION = new IIIFResourceType("annotation");
IIIFResourceType.CANVAS = new IIIFResourceType("canvas");
IIIFResourceType.COLLECTION = new IIIFResourceType("collection");
IIIFResourceType.MANIFEST = new IIIFResourceType("manifest");
IIIFResourceType.RANGE = new IIIFResourceType("range");
IIIFResourceType.SEQUENCE = new IIIFResourceType("sequence");
return IIIFResourceType;
}(Manifesto.StringValue));
Manifesto.IIIFResourceType = IIIFResourceType;
Expand Down Expand Up @@ -635,7 +635,7 @@ var Manifesto;
return _this;
}
ManifestResource.prototype.getIIIFResourceType = function () {
return new Manifesto.IIIFResourceType(this.getProperty('@type'));
return new Manifesto.IIIFResourceType(Manifesto.Utils.normaliseType(this.getProperty('type')));
};
ManifestResource.prototype.getLabel = function () {
return Manifesto.TranslationCollection.parse(this.getProperty('label'), this.options.locale);
Expand Down Expand Up @@ -957,12 +957,7 @@ var Manifesto;
return [];
};
IIIFResource.prototype.getIIIFResourceType = function () {
var type = this.getProperty('type');
if (type) {
return new Manifesto.IIIFResourceType(type);
}
type = this.getProperty('@type');
return new Manifesto.IIIFResourceType(type);
return new Manifesto.IIIFResourceType(Manifesto.Utils.normaliseType(this.getProperty('type')));
};
IIIFResource.prototype.getLogo = function () {
var logo = this.getProperty('logo');
Expand Down Expand Up @@ -997,19 +992,13 @@ var Manifesto;
return this.defaultTree;
};
IIIFResource.prototype.isCollection = function () {
if (this.getIIIFResourceType().toString().toLowerCase() === 'collection') {
return true;
}
else if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.COLLECTION.toString()) {
if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.COLLECTION.toString()) {
return true;
}
return false;
};
IIIFResource.prototype.isManifest = function () {
if (this.getIIIFResourceType().toString().toLowerCase() === 'manifest') {
return true;
}
else if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.MANIFEST.toString()) {
if (this.getIIIFResourceType().toString() === Manifesto.IIIFResourceType.MANIFEST.toString()) {
return true;
}
return false;
Expand Down Expand Up @@ -1110,7 +1099,7 @@ var Manifesto;
if (this.__jsonld.structures && this.__jsonld.structures.length) {
for (var i = 0; i < this.__jsonld.structures.length; i++) {
var r = this.__jsonld.structures[i];
if (r['@id'] === id) {
if (r['@id'] === id || r.id === id) {
return r;
}
}
Expand Down Expand Up @@ -1142,25 +1131,26 @@ var Manifesto;
else {
parentRange.members.push(range);
}
if (r.ranges) {
for (var i = 0; i < r.ranges.length; i++) {
this._parseRanges(r.ranges[i], path + '/' + i, range);
}
}
if (r.members) {
var _loop_1 = function (i) {
for (var i = 0; i < r.members.length; i++) {
var child = r.members[i];
// only add to members if not already parsed from backwards-compatible ranges/canvases arrays
if (r.members.en().where(function (m) { return m.id === child.id; }).first()) {
return "continue";
// todo: use constants
if (child['@type'] && child['@type'].toLowerCase() === 'sc:range' || child['type'] && child['type'].toLowerCase() === 'range') {
this._parseRanges(child, path + '/' + i, range);
}
if (child['@type'].toLowerCase() === 'sc:range') {
this_1._parseRanges(child, path + '/' + i, range);
else if (child['@type'] && child['@type'].toLowerCase() === 'sc:canvas' || child['type'] && child['type'].toLowerCase() === 'canvas') {
// store the ids on the __jsonld object to be used by Range.getCanvasIds()
if (!range.canvases) {
range.canvases = [];
}
var id_1 = child['@id'] || child.id;
range.canvases.push(id_1);
}
};
var this_1 = this;
for (var i = 0; i < r.members.length; i++) {
_loop_1(i);
}
}
else if (r.ranges) {
for (var i = 0; i < r.ranges.length; i++) {
this._parseRanges(r.ranges[i], path + '/' + i, range);
}
}
};
Expand Down Expand Up @@ -1370,23 +1360,26 @@ var Manifesto;
__extends(Range, _super);
function Range(jsonld, options) {
var _this = _super.call(this, jsonld, options) || this;
_this._canvases = null;
_this._ranges = null;
_this.canvases = null;
_this.members = [];
return _this;
}
Range.prototype.getCanvasIds = function () {
if (this.__jsonld.canvases) {
return this.__jsonld.canvases;
}
return [];
};
Range.prototype.getCanvases = function () {
if (this._canvases) {
return this._canvases;
else if (this.canvases) {
return this.canvases;
}
return this._canvases = this.members.en().where(function (m) { return m.isCanvas(); }).toArray();
return [];
};
// getCanvases(): ICanvas[] {
// if (this._canvases) {
// return this._canvases;
// }
// return this._canvases = <ICanvas[]>this.members.en().where(m => m.isCanvas()).toArray();
// }
Range.prototype.getRanges = function () {
if (this._ranges) {
return this._ranges;
Expand Down Expand Up @@ -1503,7 +1496,9 @@ var Manifesto;
Sequence.prototype.getCanvasById = function (id) {
for (var i = 0; i < this.getTotalCanvases(); i++) {
var canvas = this.getCanvasByIndex(i);
if (canvas.id === id) {
// normalise canvas id
var canvasId = Manifesto.Utils.normaliseUrl(canvas.id);
if (Manifesto.Utils.normaliseUrl(id) === canvasId) {
return canvas;
}
}
Expand Down Expand Up @@ -2093,10 +2088,23 @@ var Manifesto;
Utils.generateTreeNodeIds(n, i);
}
};
Utils.normaliseType = function (type) {
type = type.toLowerCase();
if (type.indexOf(':') !== -1) {
var split = type.split(':');
return split[1];
}
return type;
};
Utils.normaliseUrl = function (url) {
url = url.substr(url.indexOf('://'));
if (url.indexOf('#') !== -1) {
url = url.split('#')[0];
}
return url;
};
Utils.normalisedUrlsMatch = function (url1, url2) {
var url1norm = url1.substr(url1.indexOf('://'));
var url2norm = url1.substr(url1.indexOf('://'));
return url1norm === url2norm;
return Utils.normaliseUrl(url1) === Utils.normaliseUrl(url2);
};
Utils.isImageProfile = function (profile) {
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Expand Down
Loading

0 comments on commit 70c42d1

Please sign in to comment.