Skip to content

Commit

Permalink
presentation 3 logo support
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Aug 8, 2018
1 parent b2a9b03 commit 662b8d6
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 9 deletions.
5 changes: 4 additions & 1 deletion dist/client/manifesto.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,10 @@ var Manifesto;
return null;
if (typeof (logo) === 'string')
return logo;
return logo['@id'];
if (Array.isArray(logo) && logo.length) {
logo = logo[0];
}
return logo['@id'] || logo.id;
};
IIIFResource.prototype.getLicense = function () {
return Manifesto.Utils.getLocalisedValue(this.getProperty('license'), this.options.locale);
Expand Down
7 changes: 5 additions & 2 deletions dist/client/manifesto.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manifesto v2.2.30 https://github.com/iiif-commons/manifesto
// manifesto v2.2.31 https://github.com/iiif-commons/manifesto
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.manifesto = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){

Expand Down Expand Up @@ -1063,7 +1063,10 @@ var Manifesto;
return null;
if (typeof (logo) === 'string')
return logo;
return logo['@id'];
if (Array.isArray(logo) && logo.length) {
logo = logo[0];
}
return logo['@id'] || logo.id;
};
IIIFResource.prototype.getLicense = function () {
return Manifesto.Utils.getLocalisedValue(this.getProperty('license'), this.options.locale);
Expand Down
2 changes: 1 addition & 1 deletion dist/manifesto.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manifesto v2.2.30 https://github.com/iiif-commons/manifesto
// manifesto v2.2.31 https://github.com/iiif-commons/manifesto

declare namespace Manifesto {
class StringValue {
Expand Down
7 changes: 5 additions & 2 deletions dist/server/manifesto.js

Large diffs are not rendered by default.

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": "2.2.30",
"version": "2.2.31",
"description": "IIIF Presentation API utility library for client and server",
"main": "./dist/server/manifesto.js",
"types": "./dist/manifesto.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions src/IIIFResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ namespace Manifesto {
}

getLogo(): string | null {
const logo: any = this.getProperty('logo');
let logo: any = this.getProperty('logo');
if (!logo) return null;
if (typeof(logo) === 'string') return logo;
return logo['@id'];
if (Array.isArray(logo) && logo.length) {
logo = logo[0];
}
return logo['@id'] || logo.id;
}

getLicense(): string | null {
Expand Down
205 changes: 205 additions & 0 deletions test/fixtures/logo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"@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/WS0003.json",
"label": { "en": [ "WS0003 Aburria aburri r1" ] },
"metadata": [
{
"label":{"en":["Full Title"]},
"value":{"en":["Aburria aburri r1"]}
},
{
"label":{"en":["Collection"]},
"value":{"en":["Wildlife species reels"]}
},
{
"label":{"en":["Format"]},
"value":{"en":["1 tape reel 18 cm mono"]}
},
{
"label":{"en":["Usage"]},
"value":{"en":["<span>Creative Commons Attribution licence<br/><br/><img src=\"https://i.creativecommons.org/l/by/4.0/88x31.png\"/></span>"]}
},
{
"label":{"en":["Held by"]},
"value":{"en":["The British Library"]}
},
{
"label":{"en":["Digitised by"]},
"value":{"en":["The British Library, 2017"]}
},
{
"label":{"en":["Digitisation funded by"]},
"value":{"en":["<span>Heritage Lottery Fund<br/><br/><img src=\"https://www.hlf.org.uk/sites/default/files/styles/col-9/public/media/logos/english_compact_cmyk.jpg\"/></span>"]}
},
{
"label":{"en":["Identifier"]},
"value":{"en":["WS0003"]}
},
{
"label":{"en":["Shelfmark"]},
"value":{"en":["WS0003"]}
},
{
"label":{"en":["Link to catalogue"]},
"value":{"en":["<a href='http://explore.bl.uk/BLVU1:LSCOP-ALL:BLLSA4968576'>View the catalogue record</a>"]}
}
],
"logo":[{"id":"https://www.bl.uk/images/bl_logo_100.gif","type":"Image"}],
"rights":"https://creativecommons.org/licenses/by/4.0",
"posterCanvas": {
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/WS0003/poster",
"type": "Canvas",
"height": 962,
"width": 962,
"items": [
{
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/WS0003/poster/p1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/WS0003/poster/p1/anno",
"type": "Annotation",
"motivation": "painting",
"target": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/WS0003/poster",
"body": {
"id": "https://iiif-commons.github.io/iiif-av-component/examples/data/bl/sounds-tests/posters/world.jpg",
"type": "Image",
"format": "image/jpeg",
"width": 962,
"height": 962
}
}
]
}
]
},
"items": [
{
"items": [
{
"id": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000004/anno",
"items": [
{
"body": [
{
"items": [
{
"format": "audio/mp4",
"id": "https://resources.digirati.com/bl/WS0003/vdc_100048002902.0x000009.mp4",
"type": "Audio"
}
],
"type": "Choice"
}
],
"id": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000004/anno/",
"motivation": "painting",
"target": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000004",
"timeMode": "trim",
"type": "Annotation",
"seeAlso": [
{
"id": "http://iiif-waveforms.s3.amazonaws.com/vdc_100048002902.0x000008.dat",
"type": "Dataset",
"format": "application/octet-stream",
"profile": "http://waveform.prototyping.bbc.co.uk"
}
]
}
],
"type": "AnnotationPage"
}
],
"duration": 20.84,
"id": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000004",
"label": "Tape 1 Side 1",
"type": "Canvas"
}
],
"structures": [
{
"id": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000002/top",
"label": { "en": [ "Aburria aburri r1" ] },
"items": [
{
"id": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000005",
"label": { "en": [ "Aburria aburri : Wattled Guan - Cracidae" ] },
"items": [
{
"id": "https://api.bl.uk/metadata/iiif/ark:/81055/vdc_100048002902.0x000004#t=0,20.84",
"type": "Canvas"
}
],
"metadata": [
{
"label":{"en":["Full Title"]},
"value":{"en":["Aburria aburri : Wattled Guan - Cracidae"]}
},
{
"label":{"en":["Creator"]},
"value":{"en":["Krabbe, Niels (sound recordist)"]}
},
{
"label":{"en":["Date"]},
"value":{"en":["1983-09-09 (recorded)"]}
},
{
"label":{"en":["Place of creation"]},
"value":{"en":["Peru San Martin Yurimaguas Road 21Km E of Tarapoto Altitude 1050 (recorded)"]}
},
{
"label":{"en":["Duration"]},
"value":{"en":["0 min. 12 sec."]}
},
{
"label":{"en":["Collection"]},
"value":{"en":["Wildlife species reels"]}
},
{
"label":{"en":["Wildlife Sound Category"]},
"value":{"en":["calls"]}
},
{
"label":{"en":["Usage"]},
"value":{"en":["<span>Creative Commons Attribution licence<br/><br/><img src=\"https://i.creativecommons.org/l/by/4.0/88x31.png\"/></span>"]}
},
{
"label":{"en":["Held by"]},
"value":{"en":["The British Library"]}
},
{
"label":{"en":["Digitised by"]},
"value":{"en":["The British Library, 2017"]}
},
{
"label":{"en":["Digitisation funded by"]},
"value":{"en":["<span>Heritage Lottery Fund<br/><br/><img src=\"https://www.hlf.org.uk/sites/default/files/styles/col-9/public/media/logos/english_compact_cmyk.jpg\"/></span>"]}
},
{
"label":{"en":["Identifier"]},
"value":{"en":["WS0003 C1"]}
},
{
"label":{"en":["Shelfmark"]},
"value":{"en":["WS0003"]}
},
{
"label":{"en":["Link to catalogue"]},
"value":{"en":["<a href='http://explore.bl.uk/BLVU1:LSCOP-ALL:BLLSA4999240'>View the catalogue record</a>"]}
},
{
"label":{"en":["Description"]},
"value":{"en":["copy or original: third generation copy"]}
}
],
"type": "Range"
}
],
"type": "Range"
}
],
"type": "Manifest"
}
1 change: 1 addition & 0 deletions test/fixtures/manifests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
"horriblemurders": "http://localhost:3001/horriblemurders.json",
"illustrationsofchina": "http://localhost:3001/illustrationsofchina.json",
"lunchroommanners": "http://localhost:3001/lunchroom-manners.json",
"logo": "http://localhost:3001/logo.json",
"looseends": "http://localhost:3001/loose-ends.json",
"manifestwiththumbnail": "http://localhost:3001/manifest-with-thumbnail.json",
"members": "http://localhost:3001/members.json",
Expand Down
23 changes: 23 additions & 0 deletions test/logo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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, logo;

describe('#logo', function() {

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

it('has a logo', function () {
logo = manifest.getLogo();
expect(logo).to.equal('https://www.bl.uk/images/bl_logo_100.gif');
});

});

0 comments on commit 662b8d6

Please sign in to comment.