Skip to content

Commit

Permalink
Update manifest to include logo and provider properties
Browse files Browse the repository at this point in the history
Co-authored-by: mat <[email protected]>
  • Loading branch information
adamjarling and mathewjordan committed Sep 21, 2023
1 parent 019436b commit 465fa2b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/api/response/iiif/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -259,6 +256,40 @@ 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: {
Expand Down
30 changes: 30 additions & 0 deletions test/unit/api/response/iiif/manifest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 465fa2b

Please sign in to comment.