Skip to content
Snippets Groups Projects
Commit 45ba8066 authored by Christopher Hanna Johnson's avatar Christopher Hanna Johnson Committed by Christopher Johnson
Browse files

adds content negotiation and standard path/id semantics

splits fixtures in directories by api version
parent d75d85b0
No related branches found
No related tags found
No related merge requests found
Showing
with 509 additions and 16 deletions
{
"@context": "http://iiif.io/api/presentation/2/context.json",
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/manifest/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"@type": "sc:Manifest",
"label": "Bodleian Library Human Freaks 2 (33)",
"description": "[Handbill of Mr. Becket, [1787] ]",
"metadata": [
{
"label": "Homepage",
"value": "<span><a href=\"https://digital.bodleian.ox.ac.uk/inquire/p/9cca8fdd-4a61-4429-8ac1-f648764b4d6d\">View on Digital Bodleian</a></span>"
},
{
"label": "Title",
"value": "[Handbill of Mr. Becket, [1787] ]"
},
{
"label": "Other Titles",
"value": "To the nobility, gentry, and the curious for inspecting most extraordinary human beings, of the wild species born. Just arrived from abroad, and to be seen at Mr. Becket's, trunk maker, no. 31, Hay-market, ... three wonderful ph†nomena, wild-born, of the human species: these are two females and a male, of a very small stature, ..."
},
{
"label": "Creator",
"value": "Becket, Mr ([London], England) [author]"
},
{
"label": "Contributor",
"value": "Becket Mr [funder/Sponsor]"
},
{
"label": "Contributor",
"value": "Incledon, Charles Benjamin, 1763-1826 [performer]"
},
{
"label": "Language",
"value": "English"
},
{
"label": "Date Statement",
"value": "[1787]"
},
{
"label": "Description",
"value": "Handbill of Mr. Becket, [1787] announcing curiosities and wonders"
},
{
"label": "Collection",
"value": "Ephemera"
},
{
"label": "Collection",
"value": "Entertainment Ephemera"
},
{
"label": "Subject",
"value": "Curiosities and wonders"
},
{
"label": "Subject",
"value": "Dwarfs"
},
{
"label": "Subject",
"value": "Abnormalities, Human"
},
{
"label": "Subject",
"value": "Printed ephemera"
},
{
"label": "Subject",
"value": "Human curiosities"
},
{
"label": "Subject",
"value": "Dwarfs"
},
{
"label": "Subject",
"value": "Hills"
},
{
"label": "Subject",
"value": "Umbrellas"
},
{
"label": "Other Identifier",
"value": "Human Freaks 2 (33)"
},
{
"label": "Other Identifier",
"value": "003134"
},
{
"label": "Other Identifier",
"value": "t188499"
},
{
"label": "Record Created",
"value": "2015-07-10T00:00:00Z"
},
{
"label": "Holding Institution",
"value": "Bodleian Libraries, University of Oxford"
}
],
"rendering": {
"@id": "https://digital.bodleian.ox.ac.uk/inquire/p/9cca8fdd-4a61-4429-8ac1-f648764b4d6d",
"label": "View on Digital Bodleian",
"format": "text/html"
},
"attribution": "http://creativecommons.org/licenses/by-nc-sa/3.0/.",
"logo": {
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/image/b83fe9b4-3ffb-4890-aa3f-7d551dfd8b38/full/256,/0/default.jpg",
"service": {
"@context": "http://iiif.io/api/image/2/context.json",
"profile": "http://iiif.io/api/image/2/level1.json",
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/image/b83fe9b4-3ffb-4890-aa3f-7d551dfd8b38"
}
},
"thumbnail": {
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d/full/256,/0/default.jpg",
"service": {
"@context": "http://iiif.io/api/image/2/context.json",
"profile": "http://iiif.io/api/image/2/level1.json",
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d"
}
},
"viewingHint": "individuals",
"sequences": [
{
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/sequence/9cca8fdd-4a61-4429-8ac1-f648764b4d6d_default.json",
"@type": "sc:Sequence",
"label": "Default",
"canvases": [
{
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/canvas/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"@type": "sc:Canvas",
"label": "Whole Page",
"width": 5776,
"height": 9125,
"images": [
{
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/annotation/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"@type": "oa:Annotation",
"motivation": "sc:painting",
"on": "https://iiif.bodleian.ox.ac.uk/iiif/canvas/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"resource": {
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d",
"@type": "dctypes:Image",
"format": "image/jpeg",
"width": 5776,
"height": 9125,
"service": {
"@context": "http://iiif.io/api/image/2/context.json",
"profile": "http://iiif.io/api/image/2/level1.json",
"@id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d"
}
}
}
],
"metadata": [
{
"label": "Label",
"value": "Whole Page"
}
]
}
]
}
]
}
File moved
File moved
{
"@context": [
"http://www.w3.org/ns/anno.jsonld",
"http://iiif.io/api/presentation/3/context.json"
],
"id": "https://iiif.bodleian.ox.ac.uk/iiif/manifest/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"type": "Manifest",
"label": {
"en": [
"Bodleian Library: Human Freaks 2 (33)"
]
},
"summary": "[Handbill of Mr. Becket, [1787] ]",
"metadata": [
{
"label": {
"en": [
"Title"
]
},
"value": {
"en": [
"[Handbill of Mr. Becket, [1787] ]"
]
}
},
{
"label": {
"en": [
"Other Titles"
]
},
"value": {
"en": [
"To the nobility, gentry, and the curious for inspecting most extraordinary human beings, of the wild species born. Just arrived from abroad, and to be seen at Mr. Becket's, trunk maker, no. 31, Hay-market, ... three wonderful ph\u0086nomena, wild-born, of the human species: these are two females and a male, of a very small stature, ..."
]
}
},
{
"label": {
"en": [
"Creator"
]
},
"value": {
"en": [
"Becket, Mr ([London], England) [author]"
]
}
},
{
"label": {
"en": [
"Contributor"
]
},
"value": {
"en": [
"Becket Mr [funder/Sponsor]",
"Incledon, Charles Benjamin, 1763-1826 [performer]"
]
}
},
{
"label": {
"en": [
"Language"
]
},
"value": {
"en": [
"English"
]
}
},
{
"label": {
"en": [
"Date Statement"
]
},
"value": {
"en": [
"[1787]"
]
}
},
{
"label": {
"en": [
"Description"
]
},
"value": {
"en": [
"Handbill of Mr. Becket, [1787] announcing curiosities and wonders"
]
}
},
{
"label": {
"en": [
"Collection"
]
},
"value": {
"en": [
"Ephemera",
"Entertainment Ephemera"
]
}
},
{
"label": {
"en": [
"Subject"
]
},
"value": {
"en": [
"Curiosities and wonders",
"Dwarfs",
"Abnormalities, Human",
"Printed ephemera",
"Human curiosities",
"Dwarfs",
"Hills",
"Umbrellas"
]
}
},
{
"label": {
"en": [
"Other Identifier"
]
},
"value": {
"en": [
"Human Freaks 2 (33)",
"003134",
"t188499"
]
}
},
{
"label": {
"en": [
"Record Created"
]
},
"value": {
"en": [
"2015-07-10T00:00:00Z"
]
}
},
{
"label": {
"en": [
"Holding Institution"
]
},
"value": {
"en": [
"Bodleian Libraries, University of Oxford"
]
}
}
],
"homepage": [
{
"id": "https://digital.bodleian.ox.ac.uk/inquire/p/9cca8fdd-4a61-4429-8ac1-f648764b4d6d",
"type": "Text",
"label": {
"en": [
"View on Digital Bodleian"
]
},
"format": "text/html"
}
],
"logo": [
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/image/b83fe9b4-3ffb-4890-aa3f-7d551dfd8b38/full/256,/0/default.jpg",
"type": "Image",
"service": {
"type": "ImageService2",
"profile": "level1",
"id": "https://iiif.bodleian.ox.ac.uk/iiif/image/b83fe9b4-3ffb-4890-aa3f-7d551dfd8b38"
}
}
],
"thumbnail": [
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d/full/256,/0/default.jpg",
"service": {
"type": "ImageService2",
"profile": "level1",
"id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d"
}
}
],
"requiredStatement": {
"label": {
"en": [
"Terms of Use"
]
},
"value": {
"en": [
null
]
}
},
"partOf": [
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/collection/ephemera",
"type": "Collection",
"label": {
"en": [
"Ephemera"
]
}
},
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/collection/entertainment-ephemera",
"type": "Collection",
"label": {
"en": [
"Entertainment Ephemera"
]
}
}
],
"behavior": [
"individuals"
],
"items": [
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/canvas/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"type": "Canvas",
"label": "Whole Page",
"width": 5776,
"height": 9125,
"items": [
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/annotationpage/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.bodleian.ox.ac.uk/iiif/annotation/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"type": "Annotation",
"motivation": "painting",
"target": "https://iiif.bodleian.ox.ac.uk/iiif/canvas/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json",
"body": {
"id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d",
"type": "Image",
"format": "image/jpeg",
"width": 5776,
"height": 9125,
"service": {
"type": "ImageService2",
"profile": "level1",
"id": "https://iiif.bodleian.ox.ac.uk/iiif/image/9cca8fdd-4a61-4429-8ac1-f648764b4d6d"
}
}
}
]
}
],
"metadata": [
{
"label": {
"en": [
"Label"
]
},
"value": {
"en": [
"Whole Page"
]
}
}
]
}
]
}
...@@ -7,11 +7,11 @@ describe('Basic end to end Mirador', () => { ...@@ -7,11 +7,11 @@ describe('Basic end to end Mirador', () => {
expect(title).toBe('Mirador'); expect(title).toBe('Mirador');
}); });
it('loads a manifest and displays it', async () => { it('loads a manifest and displays it', async () => {
await expect(page).toFill('#manifestURL', 'http://localhost:5000/sn904cj3439.json'); await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/sn904cj3439');
await expect(page).toClick('#fetchBtn'); await expect(page).toClick('#fetchBtn');
// TODO: Refactor the app so we get rid of the wait // TODO: Refactor the app so we get rid of the wait
await page.waitFor(1000); await page.waitFor(1000);
await expect(page).toMatchElement('li', { text: 'http://localhost:5000/sn904cj3439.json' }); await expect(page).toMatchElement('li', { text: 'http://localhost:5000/api/sn904cj3439' });
await expect(page).toMatchElement( await expect(page).toMatchElement(
'h3', 'h3',
"Peter's San Francisco Locator. The Birds-Eye-View Map of the Exposition City. Published by Locator Publishing Co", "Peter's San Francisco Locator. The Birds-Eye-View Map of the Exposition City. Published by Locator Publishing Co",
......
const supertest = require('supertest');
describe('GET Negotiated API Response', () => {
let request;
beforeAll(() => {
request = supertest('http://localhost:5000');
});
it('responds with API v3 json', () => request
.get('/api/001')
.set('Accept', 'application/ld+json;profile="http://iiif.io/api/presentation/3/context.json"')
.expect(200)
.then((res) => {
expect(res.text).toMatch(/http:\/\/iiif\.io\/api\/presentation\/3\/context\.json/);
}));
it('responds with API v2 json', () => request
.get('/api/001')
.expect(200)
.then((res) => {
expect(res.text).toMatch(/http:\/\/iiif\.io\/api\/presentation\/2\/context\.json/);
}));
});
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
describe('Mirador plugin use', () => { describe('Mirador plugin use', () => {
beforeAll(async () => { beforeAll(async () => {
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/plugins.html'); await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/plugins.html');
await expect(page).toFill('#manifestURL', 'http://localhost:5000/sn904cj3439.json'); await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/sn904cj3439');
await expect(page).toClick('#fetchBtn'); await expect(page).toClick('#fetchBtn');
// TODO: Refactor the app so we get rid of the wait // TODO: Refactor the app so we get rid of the wait
await page.waitFor(1000); await page.waitFor(1000);
......
...@@ -3,7 +3,7 @@ describe('Window actions', () => { ...@@ -3,7 +3,7 @@ describe('Window actions', () => {
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/'); await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/');
}); });
it('opens a window and closes it', async () => { it('opens a window and closes it', async () => {
await expect(page).toFill('#manifestURL', 'http://localhost:5000/sn904cj3439.json'); await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/sn904cj3439');
await expect(page).toClick('#fetchBtn'); await expect(page).toClick('#fetchBtn');
// TODO: Refactor the app so we get rid of the wait // TODO: Refactor the app so we get rid of the wait
await page.waitFor(1000); await page.waitFor(1000);
......
...@@ -7,7 +7,7 @@ describe('Plain JavaScript example', () => { ...@@ -7,7 +7,7 @@ describe('Plain JavaScript example', () => {
expect(title).toBe('Examples'); expect(title).toBe('Examples');
}); });
it('loads a manifest and displays it', async () => { it('loads a manifest and displays it', async () => {
await expect(page).toFill('#manifestURL', 'http://localhost:5000/sn904cj3439.json'); await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/sn904cj3439');
await expect(page).toClick('#fetchBtn'); await expect(page).toClick('#fetchBtn');
// TODO: Refactor the app so we get rid of the wait // TODO: Refactor the app so we get rid of the wait
await page.waitFor(1000); await page.waitFor(1000);
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import Display from '../../../src/components/Display'; import Display from '../../../src/components/Display';
import ManifestMetadata from '../../../src/components/ManifestMetadata'; import ManifestMetadata from '../../../src/components/ManifestMetadata';
import fixture from '../../fixtures/2.json'; import fixture from '../../fixtures/version-2/002.json';
describe('Display', () => { describe('Display', () => {
it('renders without an error', () => { it('renders without an error', () => {
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { actions, store } from '../../../src/store'; import { actions, store } from '../../../src/store';
import ManifestMetadata from '../../../src/components/ManifestMetadata'; import ManifestMetadata from '../../../src/components/ManifestMetadata';
import fixture from '../../fixtures/2.json'; import fixture from '../../fixtures/version-2/002.json';
describe('ManifestMetadata', () => { describe('ManifestMetadata', () => {
let wrapper; let wrapper;
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { mount, shallow } from 'enzyme'; import { mount, shallow } from 'enzyme';
import { actions, store } from '../../../src/store'; import { actions, store } from '../../../src/store';
import Window from '../../../src/components/Window'; import Window from '../../../src/components/Window';
import fixture from '../../fixtures/24.json'; import fixture from '../../fixtures/version-2/024.json';
describe('Window', () => { describe('Window', () => {
let wrapper; let wrapper;
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { actions, store } from '../../../src/store'; import { actions, store } from '../../../src/store';
import WindowBackground from '../../../src/components/WindowBackground'; import WindowBackground from '../../../src/components/WindowBackground';
import fixture from '../../fixtures/24.json'; import fixture from '../../fixtures/version-2/024.json';
describe('WindowBackground', () => { describe('WindowBackground', () => {
let wrapper; let wrapper;
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import { actions, store } from '../../../src/store'; import { actions, store } from '../../../src/store';
import WindowViewer from '../../../src/components/WindowViewer'; import WindowViewer from '../../../src/components/WindowViewer';
import fixture from '../../fixtures/24.json'; import fixture from '../../fixtures/version-2/024.json';
describe('WindowViewer', () => { describe('WindowViewer', () => {
let wrapper; let wrapper;
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { actions, store } from '../../../src/store'; import { actions, store } from '../../../src/store';
import Workspace from '../../../src/components/Workspace'; import Workspace from '../../../src/components/Workspace';
import fixture from '../../fixtures/2.json'; import fixture from '../../fixtures/version-2/002.json';
describe('Workspace', () => { describe('Workspace', () => {
let wrapper; let wrapper;
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { actions, store } from '../../../src/store'; import { actions, store } from '../../../src/store';
import WorkspaceControlPanel from '../../../src/components/WorkspaceControlPanel'; import WorkspaceControlPanel from '../../../src/components/WorkspaceControlPanel';
import fixture from '../../fixtures/2.json'; import fixture from '../../fixtures/version-2/002.json';
describe('WorkspaceControlPanel', () => { describe('WorkspaceControlPanel', () => {
let wrapper; let wrapper;
......
const jsonServer = require('json-server'); // eslint-disable-line import/no-extraneous-dependencies const jsonServer = require('json-server'); // eslint-disable-line import/no-extraneous-dependencies
const server = jsonServer.create(); const server = jsonServer.create();
const router = jsonServer.router('./scripts/json-server/fixture-server-config.json'); const router = jsonServer.router('./scripts/json-server/routes.json');
const defaults = { const defaults = {
static: './__tests__/fixtures', static: './__tests__/fixtures',
}; };
const middlewares = jsonServer.defaults(defaults); const middlewares = jsonServer.defaults(defaults);
server.use(middlewares); server.use(middlewares);
const options = {
root: './__tests__/fixtures/',
};
server.get('/api/:id?', (req, res) => {
let apiVersion;
if (req.get('Accept') === 'application/ld+json;profile="http://iiif.io/api/presentation/3/context.json"') {
apiVersion = '3';
} else {
apiVersion = '2';
}
const fileId = req.params.id;
res.sendFile(`/version-${apiVersion}/${fileId}.json`, options);
});
server.use(router); server.use(router);
server.listen(5000, () => {}); server.listen(5000, () => {});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment