From 662b8d6177b754da992bc7f6ddac9cd1cb767881 Mon Sep 17 00:00:00 2001 From: edsilv Date: Wed, 8 Aug 2018 16:13:46 +0100 Subject: [PATCH] presentation 3 logo support --- dist/client/manifesto.bundle.js | 5 +- dist/client/manifesto.js | 7 +- dist/manifesto.d.ts | 2 +- dist/server/manifesto.js | 7 +- package.json | 2 +- src/IIIFResource.ts | 7 +- test/fixtures/logo.json | 205 ++++++++++++++++++++++++++++++++ test/fixtures/manifests.js | 1 + test/logo.js | 23 ++++ 9 files changed, 250 insertions(+), 9 deletions(-) create mode 100644 test/fixtures/logo.json create mode 100644 test/logo.js diff --git a/dist/client/manifesto.bundle.js b/dist/client/manifesto.bundle.js index 8d2b6bd4..2ea940d4 100644 --- a/dist/client/manifesto.bundle.js +++ b/dist/client/manifesto.bundle.js @@ -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); diff --git a/dist/client/manifesto.js b/dist/client/manifesto.js index a339ab4c..767e1bc7 100644 --- a/dist/client/manifesto.js +++ b/dist/client/manifesto.js @@ -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-1&&(this._keys.splice(e,1),this._values.splice(e,1),this.size--,!0)},e.prototype.entries=function(){var e=this;return r.range(0,this.size).select(function(r){return[e._keys[r],e._values[r]]})},e.prototype.forEach=function(r,e){null==e&&(e=this);for(var t=0,n=this._keys,o=this._values,u=n.length;t-1},e.prototype.keys=function(){return this._keys.en()},e.prototype.set=function(r,e){var t=this._keys.indexOf(r);t>-1?this._values[t]=e:(this._keys.push(r),this._values.push(e),this.size++)},e.prototype.values=function(){return this._values.en()},e}();r.Map3=e,r.Enumerable.prototype.toMap=function(r,t){for(var n=new e,o=this.getEnumerator();o.moveNext();)n.set(r(o.current),t(o.current));return n},r.List&&(r.List.prototype.toMap=r.Enumerable.prototype.toMap)}(exjs||(exjs={})),function(r){r.Map||(r.Map=exjs.Map3)}("undefined"==typeof window?global:window);var exjs;!function(r){function e(e){var t=new r.Enumerable;return t.getEnumerator=function(){var r={current:void 0,moveNext:function(){return e(r)}};return r},t}r.anonymous=e}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){var t,n,o=1,u={current:void 0,moveNext:function(){if(o<2){if(t=t||r.getEnumerator(),t.moveNext())return u.current=t.current,!0;o++}return n=n||e.en().getEnumerator(),n.moveNext()?(u.current=n.current,!0):(u.current=void 0,!1)}};return u}r.Enumerable.prototype.append=function(){for(var t=this,n=[],o=0;o=e?(t.current=void 0,!1):(t.current=r[n],!0)},t}function t(){return this&&Array.isArray(this)?new n(this):new r.Enumerable}var n=function(r){function t(t){var n=r.call(this)||this;return n.getEnumerator=function(){return e(t)},n.toArray=function(){return t.slice(0)},n}return __extends(t,r),t}(r.Enumerable);try{Object.defineProperty(Array.prototype,"en",{value:t,enumerable:!1,writable:!1,configurable:!1})}catch(r){Array.prototype.en=t}}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){var t,n=!1,o={current:void 0,moveNext:function(){return t||(t=r.getEnumerator()),o.current=void 0,t.moveNext()?(o.current=t.current,!0):!n&&(n=!0,t=e.getEnumerator(),!!t.moveNext()&&(o.current=t.current,!0))}};return o}r.Enumerable.prototype.concat=function(t){var n=this,o=t instanceof Array?t.en():t,u=new r.Enumerable;return u.getEnumerator=function(){return e(n,o)},u},r.List&&(r.List.prototype.concat=r.Enumerable.prototype.concat)}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){var t,n=[],o={current:void 0,moveNext:function(){if(t||(t=r.getEnumerator()),o.current=void 0,!e){for(;t.moveNext();)if(n.indexOf(t.current)<0)return n.push(o.current=t.current),!0;return!1}for(;t.moveNext();){for(var u=0,i=n.length,c=!1;u-1)){var i=t(r[u],this.$jsonMappings[u]);void 0!==i&&(n[u]=i,o.push(u))}for(var u in r)o.indexOf(u)>-1||(n[u]=r[u]);return n};var exjs;!function(r){function e(r,e,n){var o,u=0,i={current:void 0,moveNext:function(){return o||(o=t(r,e,n)),i.current=void 0,!(u>=o.length)&&(i.current=o[u],u++,!0)}};return i}function t(r,e,t){t=t||function(r,e){return r===e};for(var o,u=[],i=[],c=r.getEnumerator();c.moveNext();){o=e(c.current);for(var a=-1,p=0,f=i.length;p=e?(t.current=void 0,!1):(t.current=r[n],!0)},t},t.prototype.remove=function(r){return this.removeWhere(function(e){return e===r}).any()},t.prototype.removeWhere=function(r){for(var e,t=[],n=this.length-1;n>=0;n--)e=this[n],r(e,n)===!0&&(this.splice(n,1),t.push(e));return t.en().reverse()}}(exjs||(exjs={}));var exjs;!function(r){function e(r,e,n,o){return new t(r,e,n,o)}var t=function(e){function t(r,t,n,o){var u=e.call(this)||this;u.Source=r,o=o||function(r,e){return r>e?1:r=e.length)&&(u.current=e[o],o++,!0)}};return u},t.prototype.thenBy=function(r,e){return new n(this,r,!1,e)},t.prototype.thenByDescending=function(r,e){return new n(this,r,!0,e)},t}(r.Enumerable),n=function(r){function e(e,t,n,o){var u=r.call(this,e,t,n,o)||this,i=e.Sorter,c=u.Sorter;return u.Sorter=function(r,e){return i(r,e)||c(r,e)},u}return __extends(e,r),e}(t),o=r.Enumerable.prototype;o.orderBy=function(r,t){return e(this,r,!1,t)},o.orderByDescending=function(r,t){return e(this,r,!0,t)},r.List&&(r.List.prototype.orderBy=r.Enumerable.prototype.orderBy,r.List.prototype.orderByDescending=r.Enumerable.prototype.orderByDescending)}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){var t,n,o=1,u={current:void 0,moveNext:function(){if(o<2){if(t=t||e.en().getEnumerator(),t.moveNext())return u.current=t.current,!0;o++}return n=n||r.getEnumerator(),n.moveNext()?(u.current=n.current,!0):(u.current=void 0,!1)}};return u}r.Enumerable.prototype.prepend=function(){for(var t=this,n=[],o=0;o=e)&&(o.current=n,!0)}};return o}function t(t,n,o){if(t=t||0,n=n||0,t>n)throw new Error("Start cannot be greater than end.");null==o&&(o=1);var u=new r.Enumerable;return u.getEnumerator=function(){return e(t,n,o)},u}r.range=t}(exjs||(exjs={}));var exjs;!function(r){function e(e){var t,n=0,o={current:void 0,moveNext:function(){return t||(t=r.en(e).toArray(),n=t.length),n--,o.current=t[n],n>=0}};return o}r.Enumerable.prototype.reverse=function(){var t=this,n=new r.Enumerable;return n.getEnumerator=function(){return e(t)},n},r.List&&(r.List.prototype.reverse=r.Enumerable.prototype.reverse)}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){if(e=e||0,0===e)return Math.round(r);var t=Math.pow(10,e);return Math.round(r*t)/t}r.round=e}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){var t,n=0,o={current:void 0,moveNext:function(){return t||(t=r.getEnumerator()),!!t.moveNext()&&(o.current=e(t.current,n),n++,!0)}};return o}function t(e,t){var n,o,u={current:void 0,moveNext:function(){for(u.current=void 0,n||(n=e.getEnumerator());!o||!o.moveNext();){if(!n.moveNext())return!1;o=r.selectorEnumerator(t(n.current))}return u.current=o.current,!0}};return u}r.Enumerable.prototype.select=function(t){var n=this,o=new r.Enumerable;return o.getEnumerator=function(){return e(n,t)},o},r.Enumerable.prototype.selectMany=function(e){var n=this,o=new r.Enumerable;return o.getEnumerator=function(){return t(n,e)},o},r.List&&(r.List.prototype.select=r.Enumerable.prototype.select,r.List.prototype.selectMany=r.Enumerable.prototype.selectMany)}(exjs||(exjs={}));var exjs;!function(r){function e(r){return Array.isArray(r)?r.en().getEnumerator():null!=r&&"function"==typeof r.getEnumerator?r.getEnumerator():null}r.selectorEnumerator=e}(exjs||(exjs={}));var exjs;!function(r){function e(r,e){var t,n={current:void 0,moveNext:function(){if(!t){t=r.getEnumerator();for(var o=0;oe)&&(o.current=void 0,!!t.moveNext()&&(o.current=t.current,!0))}};return o}function t(r,e){var t,n=0,o={current:void 0,moveNext:function(){return t||(t=r.getEnumerator()),t.moveNext()&&e(t.current,n)?(n++,o.current=t.current,!0):(o.current=void 0,!1)}};return o}r.Enumerable.prototype.take=function(t){var n=this,o=new r.Enumerable;return o.getEnumerator=function(){return e(n,t)},o},r.Enumerable.prototype.takeWhile=function(e){var n=this,o=new r.Enumerable;return o.getEnumerator=function(){return t(n,e)},o},r.List&&(r.List.prototype.take=r.Enumerable.prototype.take,r.List.prototype.takeWhile=r.Enumerable.prototype.takeWhile)}(exjs||(exjs={}));var exjs;!function(r){function e(e,t){var n,o=!1,u=[],i={current:void 0,moveNext:function(){if(o){if(null==n)return!1;u.push(n),n=r.selectorEnumerator(t(i.current))}else n=e.getEnumerator(),o=!0;for(;!(n&&n.moveNext()||u.length<1);)n=u.pop();return i.current=null==n?void 0:n.current,void 0!==i.current}};return i}function t(e,t,n){var o,u=!1,i=[],c={current:void 0,moveNext:function(){if(u){if(null==o)return!1;i.push(o),o=r.selectorEnumerator(t(c.current))}else o=e.getEnumerator(),u=!0;do{for(;!(o&&o.moveNext()||i.length<1);)o=i.pop();c.current=null==o?void 0:o.current}while(n(c.current));return void 0!==c.current}};return c}r.Enumerable.prototype.traverse=function(t){var n=this,o=new r.Enumerable;return o.getEnumerator=function(){return e(n,t)},o},r.Enumerable.prototype.traverseUnique=function(e,n){var o=this,u=[],i=new r.Enumerable;return n?i.getEnumerator=function(){return t(o,e,function(r){return!!u.some(function(e){return n(r,e)})||(u.push(r),!1)})}:i.getEnumerator=function(){return t(o,e,function(r){return u.indexOf(r)>-1||(u.push(r),!1)})},i},r.List&&(r.List.prototype.traverse=r.Enumerable.prototype.traverse,r.List.prototype.traverseUnique=r.Enumerable.prototype.traverseUnique)}(exjs||(exjs={}));var exjs;!function(r){function e(e,t,n){n=n||function(r,e){return r===e};var o,u,i=[],c={current:void 0,moveNext:function(){if(o||(o=r.en(e).distinct().getEnumerator()),c.current=void 0,!u&&o.moveNext())return i.push(c.current=o.current),!0;for(u=u||r.en(t).distinct().getEnumerator();u.moveNext();){for(var a=0,p=!1,f=i.length;aCreative Commons Attribution licence

"]} + }, + { + "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":["Heritage Lottery Fund

"]} + }, + { + "label":{"en":["Identifier"]}, + "value":{"en":["WS0003"]} + }, + { + "label":{"en":["Shelfmark"]}, + "value":{"en":["WS0003"]} + }, + { + "label":{"en":["Link to catalogue"]}, + "value":{"en":["View the catalogue record"]} + } + ], + "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":["Creative Commons Attribution licence

"]} + }, + { + "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":["Heritage Lottery Fund

"]} + }, + { + "label":{"en":["Identifier"]}, + "value":{"en":["WS0003 C1"]} + }, + { + "label":{"en":["Shelfmark"]}, + "value":{"en":["WS0003"]} + }, + { + "label":{"en":["Link to catalogue"]}, + "value":{"en":["View the catalogue record"]} + }, + { + "label":{"en":["Description"]}, + "value":{"en":["copy or original: third generation copy"]} + } + ], + "type": "Range" + } + ], + "type": "Range" + } + ], + "type": "Manifest" +} \ No newline at end of file diff --git a/test/fixtures/manifests.js b/test/fixtures/manifests.js index 7f701470..53cf1823 100644 --- a/test/fixtures/manifests.js +++ b/test/fixtures/manifests.js @@ -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", diff --git a/test/logo.js b/test/logo.js new file mode 100644 index 00000000..ae995114 --- /dev/null +++ b/test/logo.js @@ -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'); + }); + +}); \ No newline at end of file