diff --git a/src/Canvas.ts b/src/Canvas.ts index e56068ed..6dad329e 100644 --- a/src/Canvas.ts +++ b/src/Canvas.ts @@ -370,7 +370,9 @@ export class Canvas extends Resource { const on = resourceAnnotation.getProperty("on"); // IIIF v3 const target = resourceAnnotation.getProperty("target"); - if (!on || !target) { return undefined; } + if (!on || !target) { + return undefined; + } const fragmentMatch = (on || target).match(/xywh=(.*)$/); if (!fragmentMatch) return undefined; return fragmentMatch[1].split(",").map(str => parseInt(str, 10)); diff --git a/src/IIIFResource.ts b/src/IIIFResource.ts index cbbb67c0..f587368d 100644 --- a/src/IIIFResource.ts +++ b/src/IIIFResource.ts @@ -87,7 +87,9 @@ export class IIIFResource extends ManifestResource { return null; } - logo = provider.logo; + // get the first agent in the provider array with a logo + const agent = provider.find(item => item.logo !== undefined); + logo = typeof agent.logo === "undefined" ? null : agent.logo; } if (!logo) return null; @@ -105,6 +107,16 @@ export class IIIFResource extends ManifestResource { ); } + getRights(): string | null { + var rights = this.getProperty("rights"); + if (!rights) return null; + if (typeof rights === "string") return rights; + if (Array.isArray(rights) && rights.length) { + rights = rights[0]; + } + return rights["@id"] || rights.id; + } + getNavDate(): Date { return new Date(this.getProperty("navDate")); } diff --git a/test/index.js b/test/index.js index 75ada99d..8c18760e 100644 --- a/test/index.js +++ b/test/index.js @@ -55,7 +55,7 @@ importTest('rijksmuseum-image-api-v3-thumbnails', './tests/rijksmuseum-image-api // importTest('items-not-sequence', './tests/items-not-sequence'); // importTest('LabelValuePair', './tests/LabelValuePair.test'); // importTest('LanguageMap', './tests/LanguageMap.test'); -// importTest('logo', './tests/logo'); +importTest('logo', './tests/logo'); // importTest('lunchroommanners', './tests/lunchroommanners'); // importTest('manifest-with-thumbnail', './tests/manifest-with-thumbnail'); // importTest('members-collection', './tests/members-collection'); @@ -75,7 +75,7 @@ importTest('rijksmuseum-image-api-v3-thumbnails', './tests/rijksmuseum-image-api // importTest('pres3-collection3', './tests/pres3-collection3'); // importTest('pres3-collection4', './tests/pres3-collection4'); // importTest('pres3-pdf', './tests/pres3-pdf'); -// importTest('pres3', './tests/pres3'); +importTest('pres3', './tests/pres3'); // importTest('presentation2-paging', './tests/presentation2-paging'); // importTest('presentation3-paging', './tests/presentation3-paging'); // importTest('PropertyValue', './tests/PropertyValue.test') diff --git a/test/tests/pres3.js b/test/tests/pres3.js index adca8c6c..c8411a87 100644 --- a/test/tests/pres3.js +++ b/test/tests/pres3.js @@ -46,4 +46,14 @@ describe('presentation 3', function() { var labelValue = label.getValue(); expect(labelValue).to.equal('Page 1'); }); + + it('has a logo', function () { + var logo = manifest.getLogo(); + expect(logo).to.equal('https://example.org/logos/institution1.jpg'); + }); + + it('has a rights', function () { + var rights = manifest.getRights(); + expect(rights).to.equal('http://example.org/license.html'); + }); }); \ No newline at end of file