From 3fea15a0eea80a1a4c2d767fa597cb5f8cc3e5a7 Mon Sep 17 00:00:00 2001 From: "Adam J. Arling" Date: Wed, 20 Sep 2023 14:30:10 +0000 Subject: [PATCH] Update manifest to include logo and provider properties Co-authored-by: mat --- src/api/response/iiif/manifest.js | 37 +++++++++++++++++--- test/unit/api/response/iiif/manifest.test.js | 30 ++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/api/response/iiif/manifest.js b/src/api/response/iiif/manifest.js index 4cd9e96e..816bca5e 100644 --- a/src/api/response/iiif/manifest.js +++ b/src/api/response/iiif/manifest.js @@ -15,6 +15,7 @@ const { function transform(response) { if (response.statusCode === 200) { const builder = new IIIFBuilder(); + const openSearchResponse = JSON.parse(response.body); const source = openSearchResponse._source; @@ -198,10 +199,6 @@ function transform(response) { ]); } - /** Add logo */ - - /** Add provider */ - /** Add items (Canvases) from a Work's Filesets */ source.file_sets .filter((fileSet) => fileSet.role === "Access") @@ -259,6 +256,38 @@ function transform(response) { } } + /** Add logo manually (w/o IIIF Builder) */ + const nulLogo = { + id: "https://iiif.dc.library.northwestern.edu/iiif/2/00000000-0000-0000-0000-000000000003/full/pct:50/0/default.webp", + type: "Image", + format: "image/webp", + height: 139, + width: 1190, + }; + jsonManifest.logo = [nulLogo]; + + /** Add provider manually (w/o IIIF Builder) */ + const provider = { + id: "https://www.library.northwestern.edu/", + type: "Agent", + label: { none: ["Northwestern University Libraries"] }, + homepage: [ + { + id: "https://dc.library.northwestern.edu/", + type: "Text", + label: { + none: [ + "Northwestern University Libraries Digital Collections Homepage", + ], + }, + format: "text/html", + language: ["en"], + }, + ], + logo: [nulLogo], + }; + jsonManifest.provider = [provider]; + return { statusCode: 200, headers: { diff --git a/test/unit/api/response/iiif/manifest.test.js b/test/unit/api/response/iiif/manifest.test.js index 082cc5ff..208a3ac8 100644 --- a/test/unit/api/response/iiif/manifest.test.js +++ b/test/unit/api/response/iiif/manifest.test.js @@ -103,6 +103,36 @@ describe("Image Work as IIIF Manifest response transformer", () => { expect(partOf.summary.none).to.be.an("array").that.is.not.empty; }); + it("populates Manifest logo", async () => { + const { manifest } = await setup(); + const logo = manifest.logo[0]; + expect(logo.id).to.eq( + "https://iiif.dc.library.northwestern.edu/iiif/2/00000000-0000-0000-0000-000000000003/full/pct:50/0/default.webp" + ); + }); + + it("populates Manifest provider", async () => { + const { manifest } = await setup(); + const provider = manifest.provider[0]; + expect(provider.id).to.eq("https://www.library.northwestern.edu/"); + expect(provider.label).to.deep.equal({ + none: ["Northwestern University Libraries"], + }); + expect(provider.homepage[0].id).to.eq( + "https://dc.library.northwestern.edu/" + ); + expect(provider.homepage[0].label).to.deep.eq({ + none: ["Northwestern University Libraries Digital Collections Homepage"], + }); + expect(provider.logo[0]).to.deep.eq({ + id: "https://iiif.dc.library.northwestern.edu/iiif/2/00000000-0000-0000-0000-000000000003/full/pct:50/0/default.webp", + type: "Image", + format: "image/webp", + height: 139, + width: 1190, + }); + }); + it("populates Manifest items (canvases)", async () => { const { source, manifest } = await setup(); expect(manifest.items.length).to.eq(3);