Skip to content

Commit

Permalink
Merge pull request #2914 from rwd/feat/otherContent-strings
Browse files Browse the repository at this point in the history
Infer sc:AnnotationList from otherContent strings
  • Loading branch information
mejackreed authored Dec 13, 2019
2 parents 5c9a377 + a61273b commit b0626e9
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 11 deletions.
110 changes: 110 additions & 0 deletions __tests__/fixtures/version-2/BibliographicResource_3000126341277.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"@type" : "sc:Manifest",
"@id" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/manifest",
"@context" : "http://iiif.io/api/presentation/2/context.json",
"within" : "http://data.theeuropeanlibrary.org/Collection/a0611",
"label" : [ {
"@value" : "Uusi Aura, nr: 274A - 1909-11-26"
} ],
"metadata" : [ {
"label" : "type",
"value" : [ {
"@value" : "http://schema.org/PublicationIssue"
}, {
"@language" : "en",
"@value" : "Analytic serial"
}, {
"@language" : "en",
"@value" : "Newspaper"
}, {
"@language" : "en",
"@value" : "Newspaper Issue"
} ]
}, {
"label" : "language",
"value" : [ {
"@value" : "fin"
} ]
}, {
"label" : "source",
"value" : [ {
"@value" : "http://digi.kansalliskirjasto.fi/sanomalehti/binding/803341"
} ]
} ],
"thumbnail" : {
"@type" : "dctypes:Image",
"@id" : "https://api.europeana.eu/api/v2/thumbnail-by-url.json?uri=https%3A%2F%2Fiiif.europeana.eu%2Fimage%2FZL7BQFMZHWA34ENQ6ZEWBTQK2R3ZWL3I5PS46AILJEODMY6UM4TA%2Fpresentation_images%2Fd461d710-02ca-11e6-a651-fa163e2dd531%2Fnode-4%2Fimage%2FNLF%2FUusi_Aura%2F1909%2F11%2F26%2F274B_1%2F19091126_274B_1-0001%2Ffull%2Ffull%2F0%2Fdefault.jpg&type=TEXT"
},
"navDate" : "1909-11-26T00:00:00Z",
"attribution" : "Uusi Aura, nr: 274A - 1909-11-26 - https://www.europeana.eu/portal/record/9200301/BibliographicResource_3000126341277.html. National Library of Finland. Public Domain Mark - http://creativecommons.org/publicdomain/mark/1.0/",
"license" : "http://creativecommons.org/publicdomain/mark/1.0/",
"logo" : "https://style.europeana.eu/images/europeana-logo-default.png",
"seeAlso" : [ {
"@id" : "https://www.europeana.eu/api/v2/record/9200301/BibliographicResource_3000126341277.json-ld",
"format" : "application/ld+json",
"profile" : "http://www.europeana.eu/schemas/edm/"
}, {
"@id" : "https://www.europeana.eu/api/v2/record/9200301/BibliographicResource_3000126341277.json",
"format" : "application/json",
"profile" : "http://www.europeana.eu/schemas/edm/"
}, {
"@id" : "https://www.europeana.eu/api/v2/record/9200301/BibliographicResource_3000126341277.rdf",
"format" : "application/rdf+xml",
"profile" : "http://www.europeana.eu/schemas/edm/"
} ],
"sequences" : [ {
"@type" : "sc:Sequence",
"@id" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/sequence/s1",
"label" : "Current Page Order",
"startCanvas" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/canvas/p1",
"canvases" : [ {
"@type" : "sc:Canvas",
"@id" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/canvas/p1",
"label" : "p. 1",
"height" : 2594,
"width" : 1890,
"attribution" : "Uusi Aura, nr: 274A - 1909-11-26 - https://www.europeana.eu/portal/record/9200301/BibliographicResource_3000126341277.html. National Library of Finland. Public Domain Mark - http://creativecommons.org/publicdomain/mark/1.0/",
"images" : [ {
"@type" : "oa:Annotation",
"@id" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/annotation/p1",
"motivation" : "sc:painting",
"resource" : {
"@type" : "dctypes:Image",
"@id" : "https://iiif.europeana.eu/image/ZL7BQFMZHWA34ENQ6ZEWBTQK2R3ZWL3I5PS46AILJEODMY6UM4TA/presentation_images/d461d710-02ca-11e6-a651-fa163e2dd531/node-4/image/NLF/Uusi_Aura/1909/11/26/274B_1/19091126_274B_1-0001/full/full/0/default.jpg",
"format" : "image/jpeg",
"service" : {
"@id" : "https://iiif.europeana.eu/image/ZL7BQFMZHWA34ENQ6ZEWBTQK2R3ZWL3I5PS46AILJEODMY6UM4TA/presentation_images/d461d710-02ca-11e6-a651-fa163e2dd531/node-4/image/NLF/Uusi_Aura/1909/11/26/274B_1/19091126_274B_1-0001",
"profile" : "http://iiif.io/api/image/2/level1.json",
"@context" : "http://iiif.io/api/image/2/context.json"
}
},
"on" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/canvas/p1"
} ],
"otherContent" : [ "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/annopage/1" ]
}, {
"@type" : "sc:Canvas",
"@id" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/canvas/p2",
"label" : "p. 2",
"height" : 2656,
"width" : 1882,
"attribution" : "Uusi Aura, nr: 274A - 1909-11-26 - https://www.europeana.eu/portal/record/9200301/BibliographicResource_3000126341277.html. National Library of Finland. Public Domain Mark - http://creativecommons.org/publicdomain/mark/1.0/",
"images" : [ {
"@type" : "oa:Annotation",
"@id" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/annotation/p2",
"motivation" : "sc:painting",
"resource" : {
"@type" : "dctypes:Image",
"@id" : "https://iiif.europeana.eu/image/ZL7BQFMZHWA34ENQ6ZEWBTQK2R3ZWL3I5PS46AILJEODMY6UM4TA/presentation_images/d461d710-02ca-11e6-a651-fa163e2dd531/node-4/image/NLF/Uusi_Aura/1909/11/26/274B_1/19091126_274B_1-0002/full/full/0/default.jpg",
"format" : "image/jpeg",
"service" : {
"@id" : "https://iiif.europeana.eu/image/ZL7BQFMZHWA34ENQ6ZEWBTQK2R3ZWL3I5PS46AILJEODMY6UM4TA/presentation_images/d461d710-02ca-11e6-a651-fa163e2dd531/node-4/image/NLF/Uusi_Aura/1909/11/26/274B_1/19091126_274B_1-0002",
"profile" : "http://iiif.io/api/image/2/level1.json",
"@context" : "http://iiif.io/api/image/2/context.json"
}
},
"on" : "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/canvas/p2"
} ],
"otherContent" : [ "https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/annopage/2" ]
} ]
} ]
}
30 changes: 22 additions & 8 deletions __tests__/src/lib/ManifestoCanvas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import imagev1Fixture from '../../fixtures/version-2/Osbornfa1.json';
import emptyCanvasFixture from '../../fixtures/version-2/emptyCanvas.json';
import serviceFixture from '../../fixtures/version-2/canvasService.json';
import otherContentFixture from '../../fixtures/version-2/299843.json';
import otherContentStringsFixture from '../../fixtures/version-2/BibliographicResource_3000126341277.json';

describe('ManifestoCanvas', () => {
let instance;
Expand All @@ -25,14 +26,27 @@ describe('ManifestoCanvas', () => {
});
});
describe('when annotationLists are present', () => {
it('returns an array of uris', () => {
const otherContentInstance = new ManifestoCanvas(
manifesto.create(otherContentFixture).getSequences()[0].getCanvases()[0],
);
expect(otherContentInstance.annotationListUris.length).toEqual(1);
expect(otherContentInstance.annotationListUris).toEqual([
'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
]);
describe('with items as objects', () => {
it('returns an array of uris', () => {
const otherContentInstance = new ManifestoCanvas(
manifesto.create(otherContentFixture).getSequences()[0].getCanvases()[0],
);
expect(otherContentInstance.annotationListUris.length).toEqual(1);
expect(otherContentInstance.annotationListUris).toEqual([
'https://iiif.harvardartmuseums.org/manifests/object/299843/list/47174896',
]);
});
});
describe('with items as strings', () => {
it('returns an array of uris', () => {
const otherContentInstance = new ManifestoCanvas(
manifesto.create(otherContentStringsFixture).getSequences()[0].getCanvases()[0],
);
expect(otherContentInstance.annotationListUris.length).toEqual(1);
expect(otherContentInstance.annotationListUris).toEqual([
'https://iiif.europeana.eu/presentation/9200301/BibliographicResource_3000126341277/annopage/1',
]);
});
});
});
});
Expand Down
12 changes: 9 additions & 3 deletions src/lib/ManifestoCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ export default class ManifestoCanvas {
return this.canvas.getWidth() / this.canvas.getHeight();
}

/** */
/**
* Fetches AnnotationList URIs from canvas's otherContent property
*
* Supported otherContent types:
* - Objects having @type property of "sc:AnnotationList" and URI in @id
* - Strings being the URIs
*/
get annotationListUris() {
return flatten(
new Array(this.canvas.__jsonld.otherContent), // eslint-disable-line no-underscore-dangle
)
.filter(otherContent => otherContent && otherContent['@type'] === 'sc:AnnotationList')
.map(otherContent => otherContent['@id']);
.filter(otherContent => otherContent && (typeof otherContent === 'string' || otherContent['@type'] === 'sc:AnnotationList'))
.map(otherContent => (typeof otherContent === 'string' ? otherContent : otherContent['@id']));
}

/** */
Expand Down

0 comments on commit b0626e9

Please sign in to comment.