@annotation-studio/redux
Advanced tools
Comparing version 1.0.0-next.42ca5e47 to 1.0.0-next.51ce670e
@@ -44,11 +44,21 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
return annotation.body.purpose === 'editing'; | ||
}; | ||
} | ||
export function createDraft(scope, emptyInput, template) { | ||
var motivation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'tagging'; | ||
var selectors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; | ||
var draftDefaults = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
var immutableSelector = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; | ||
var path = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : []; | ||
var name = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null; | ||
export function createDraft(scope, _ref) { | ||
var emptyInput = _ref.emptyInput, | ||
template = _ref.template, | ||
_ref$motivation = _ref.motivation, | ||
motivation = _ref$motivation === undefined ? 'tagging' : _ref$motivation, | ||
_ref$selectors = _ref.selectors, | ||
selectors = _ref$selectors === undefined ? null : _ref$selectors, | ||
_ref$draftDefaults = _ref.draftDefaults, | ||
draftDefaults = _ref$draftDefaults === undefined ? null : _ref$draftDefaults, | ||
_ref$immutableSelecto = _ref.immutableSelector, | ||
immutableSelector = _ref$immutableSelecto === undefined ? null : _ref$immutableSelecto, | ||
_ref$path = _ref.path, | ||
path = _ref$path === undefined ? [] : _ref$path, | ||
_ref$name = _ref.name, | ||
name = _ref$name === undefined ? null : _ref$name, | ||
_ref$partOf = _ref.partOf, | ||
partOf = _ref$partOf === undefined ? null : _ref$partOf; | ||
@@ -59,3 +69,3 @@ return function (dispatch, getState) { | ||
// Create draft. | ||
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path)); | ||
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path, null, partOf)); | ||
// And select it straight away. | ||
@@ -83,3 +93,7 @@ dispatch(selectDraft(scope, id)); | ||
} else { | ||
dispatch(chooseSelector('WholeCanvasSelector', { template: currentTemplate.id, scope: scope, draft: draftId })); | ||
dispatch(chooseSelector('WholeCanvasSelector', { | ||
template: currentTemplate.id, | ||
scope: scope, | ||
draft: draftId | ||
})); | ||
} | ||
@@ -92,14 +106,11 @@ } | ||
// desiredLifecycle must be one of these constants. | ||
return [DRAFT_LIFECYCLE_CHANGED, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ].indexOf(desiredLifecycle) === -1 ? | ||
// If not, the default lifecycle. | ||
defaultLifecycle ? defaultLifecycle : | ||
// Defaulting to new. | ||
DRAFT_LIFECYCLE_NEW | ||
// If its valid, use it. | ||
: desiredLifecycle; | ||
return [DRAFT_LIFECYCLE_CHANGED, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ].indexOf(desiredLifecycle) === -1 ? // If not, the default lifecycle. | ||
defaultLifecycle ? defaultLifecycle : // Defaulting to new. | ||
DRAFT_LIFECYCLE_NEW : // If its valid, use it. | ||
desiredLifecycle; | ||
} | ||
export function changeFingerPrintLifecyle(_ref, desiredLifecycle) { | ||
var fingerprint = _ref.fingerprint, | ||
draft = _objectWithoutProperties(_ref, ['fingerprint']); | ||
export function changeFingerPrintLifecyle(_ref2, desiredLifecycle) { | ||
var fingerprint = _ref2.fingerprint, | ||
draft = _objectWithoutProperties(_ref2, ['fingerprint']); | ||
@@ -109,38 +120,55 @@ var lifecycle = getValidLifecycle(desiredLifecycle, draft.lifecycle); | ||
return _extends({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, lifecycle, fingerprint.source, fingerprint.creator) | ||
fingerprint: createFingerprint(_extends({}, fingerprint, { | ||
lifecycle: lifecycle | ||
})) | ||
}); | ||
} | ||
export function changeFingerPrintCreator(_ref2, creator) { | ||
var fingerprint = _ref2.fingerprint, | ||
draft = _objectWithoutProperties(_ref2, ['fingerprint']); | ||
export function changeFingerPrintCreator(_ref3, creator) { | ||
var fingerprint = _ref3.fingerprint, | ||
draft = _objectWithoutProperties(_ref3, ['fingerprint']); | ||
return _extends({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, creator) | ||
fingerprint: createFingerprint(_extends({}, fingerprint, { | ||
creator: creator | ||
})) | ||
}); | ||
} | ||
export function changeFingerprintSource(_ref3, source) { | ||
var fingerprint = _ref3.fingerprint, | ||
draft = _objectWithoutProperties(_ref3, ['fingerprint']); | ||
export function changeFingerprintSource(_ref4, source) { | ||
var fingerprint = _ref4.fingerprint, | ||
draft = _objectWithoutProperties(_ref4, ['fingerprint']); | ||
return _extends({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, source, fingerprint.creator) | ||
fingerprint: createFingerprint(_extends({}, fingerprint, { | ||
source: source | ||
})) | ||
}); | ||
} | ||
export function changeFingerprintIdentity(_ref4, identity) { | ||
var fingerprint = _ref4.fingerprint, | ||
draft = _objectWithoutProperties(_ref4, ['fingerprint']); | ||
export function changeFingerprintIdentity(_ref5, identity) { | ||
var fingerprint = _ref5.fingerprint, | ||
draft = _objectWithoutProperties(_ref5, ['fingerprint']); | ||
return _extends({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, fingerprint.creator) | ||
fingerprint: createFingerprint(_extends({}, fingerprint, { | ||
identity: identity | ||
})) | ||
}); | ||
} | ||
export function createFingerprint(scope, path, identity) { | ||
var created = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
var lifecycle = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; | ||
var source = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
var creator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; | ||
export function createFingerprint(_ref6) { | ||
var scope = _ref6.scope, | ||
path = _ref6.path, | ||
identity = _ref6.identity, | ||
_ref6$created = _ref6.created, | ||
created = _ref6$created === undefined ? null : _ref6$created, | ||
_ref6$lifecycle = _ref6.lifecycle, | ||
lifecycle = _ref6$lifecycle === undefined ? null : _ref6$lifecycle, | ||
_ref6$source = _ref6.source, | ||
source = _ref6$source === undefined ? null : _ref6$source, | ||
_ref6$creator = _ref6.creator, | ||
creator = _ref6$creator === undefined ? null : _ref6$creator, | ||
_ref6$partOf = _ref6.partOf, | ||
partOf = _ref6$partOf === undefined ? null : _ref6$partOf; | ||
@@ -154,3 +182,4 @@ return { | ||
source: source ? source : 'memory', // memory | elucidate | localStorage | ||
creator: creator ? creator : 'unknown' | ||
creator: creator ? creator : 'unknown', | ||
partOf: partOf ? partOf : null // Usually manifest. | ||
}; | ||
@@ -164,2 +193,3 @@ } | ||
var created = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null; | ||
var partOf = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null; | ||
@@ -174,3 +204,9 @@ return { | ||
motivation: motivation, | ||
fingerprint: createFingerprint(scope, path, null, created, null, null, 'you') | ||
fingerprint: createFingerprint({ | ||
scope: scope, | ||
path: path, | ||
created: created, | ||
creator: 'you', | ||
partOf: partOf | ||
}) | ||
} | ||
@@ -247,3 +283,9 @@ }; | ||
return { type: DRAFT_UPDATE_FIELD_SELECTOR, payload: { id: id, selectors: (_selectors = {}, _selectors[fieldId] = _extends({}, selectorCompat(selector), { name: name }), _selectors) } }; | ||
return { | ||
type: DRAFT_UPDATE_FIELD_SELECTOR, | ||
payload: { | ||
id: id, | ||
selectors: (_selectors = {}, _selectors[fieldId] = _extends({}, selectorCompat(selector), { name: name }), _selectors) | ||
} | ||
}; | ||
} | ||
@@ -331,3 +373,6 @@ | ||
markDraftAs(id, DRAFT_LIFECYCLE_READ, DRAFT_LIFECYCLE_CHANGED)(dispatch, getState); | ||
dispatch({ type: DRAFT_UPDATE_SELECTOR, payload: { id: id, selector: _extends({}, selectorCompat(selector), { name: name }) } }); | ||
dispatch({ | ||
type: DRAFT_UPDATE_SELECTOR, | ||
payload: { id: id, selector: _extends({}, selectorCompat(selector), { name: name }) } | ||
}); | ||
}; | ||
@@ -334,0 +379,0 @@ } |
@@ -34,4 +34,8 @@ import md5 from 'blueimp-md5'; | ||
return function (dispatch, state) { | ||
dispatch({ type: ELUCIDATE_CREATE_COLLECTION, payload: { label: label, resourceId: resourceId } }); | ||
dispatch({ | ||
type: ELUCIDATE_CREATE_COLLECTION, | ||
payload: { label: label, resourceId: resourceId } | ||
}); | ||
var elucidateServer = getServer(state()); | ||
return createElucidateCollection(elucidateServer, label, md5(resourceId)).then(function (collection) { | ||
@@ -52,3 +56,6 @@ dispatch(setCollection(resourceId, collection)); | ||
export function addElucidateAnnotation(annotation) { | ||
return { type: ELUCIDATE_ADD_ANNOTATION, payload: { id: annotation.id, annotation: annotation } }; | ||
return { | ||
type: ELUCIDATE_ADD_ANNOTATION, | ||
payload: { id: annotation.id, annotation: annotation } | ||
}; | ||
} | ||
@@ -67,14 +74,14 @@ | ||
var collection = getCollectionId(state()); | ||
return postAnnotation(collection, annotation).then(function (annotation) { | ||
if (isSavedDraft(annotation)) { | ||
var draft = JSON.parse(annotation.body.value); | ||
var id = annotation.id; | ||
return postAnnotation(collection, annotation).then(function (postedAnnotation) { | ||
if (isSavedDraft(postedAnnotation)) { | ||
var draft = JSON.parse(postedAnnotation.body.value); | ||
var id = postedAnnotation.id; | ||
var identity = id.substr(id.length - 1) === '/' ? id.substr(0, id.length - 1).split('/').pop() : id.split('/').pop(); | ||
if (draft) { | ||
dispatch(importDraft(identity, changeFingerPrintCreator(changeFingerprintIdentity(draft, identity), annotation.creator && annotation.creator.name ? annotation.creator.name : 'unknown'))); | ||
dispatch(importDraft(identity, changeFingerPrintCreator(changeFingerprintIdentity(draft, identity), postedAnnotation.creator && postedAnnotation.creator.name ? postedAnnotation.creator.name : 'unknown'))); | ||
} | ||
} | ||
dispatch(addElucidateAnnotation(annotation)); | ||
return annotation; | ||
dispatch(addElucidateAnnotation(postedAnnotation)); | ||
return postedAnnotation; | ||
}); | ||
@@ -90,4 +97,4 @@ }; | ||
annotation.id = annoationId; | ||
return putAnnotation(annoationId, annotation).then(function (annotation) { | ||
return dispatch(addElucidateAnnotation(annotation)); | ||
return putAnnotation(annoationId, annotation).then(function (postedAnnotation) { | ||
return dispatch(addElucidateAnnotation(postedAnnotation)); | ||
}); | ||
@@ -102,3 +109,6 @@ }; | ||
return function (dispatch, state) { | ||
dispatch({ type: ELUCIDATE_SEND_ANNOTATION, payload: { annotation: { body: body, target: target, motivation: motivation, label: label } } }); | ||
dispatch({ | ||
type: ELUCIDATE_SEND_ANNOTATION, | ||
payload: { annotation: { body: body, target: target, motivation: motivation, label: label } } | ||
}); | ||
var collection = getCollectionId(state()); | ||
@@ -105,0 +115,0 @@ return sendAnnotationToServer(collection, body, target, motivation, label).then(function (annotation) { |
@@ -12,5 +12,3 @@ export var MANIFEST_ADD = 'MANIFEST_ADD'; | ||
dispatch({ type: MANIFEST_REQUEST, payload: { url: url } }); | ||
return fetch(url, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}).then(function (response) { | ||
return fetch(url).then(function (response) { | ||
return response.json(); | ||
@@ -17,0 +15,0 @@ }).then(function (body) { |
@@ -80,7 +80,11 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
export function importResourceTree(tree) { | ||
if (!(tree.id && (tree.type === 'choice' || tree.type === 'captureModel') /*&& | ||
(tree.type === 'choice' ? (tree.choice && Object.keys(tree.choice).length > 1) : true)*/ | ||
)) { | ||
return { type: IMPORT_RESOURCE_TREE, error: true, payload: new Error('Not a valid tree') }; | ||
} | ||
if (!(tree.id && (tree.type === 'choice' || tree.type === 'captureModel')) /*&& | ||
(tree.type === 'choice' ? (tree.choice && Object.keys(tree.choice).length > 1) : true)*/ | ||
) { | ||
return { | ||
type: IMPORT_RESOURCE_TREE, | ||
error: true, | ||
payload: new Error('Not a valid tree') | ||
}; | ||
} | ||
@@ -87,0 +91,0 @@ return { type: IMPORT_RESOURCE_TREE, payload: { id: tree.id, tree: tree } }; |
@@ -49,3 +49,12 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
meta: { fromViewer: true }, | ||
payload: { type: type, source: source, defaults: selectorCompat(_extends({}, defaults, { x: x, y: y, width: maxX - x, height: maxY - y })) } | ||
payload: { | ||
type: type, | ||
source: source, | ||
defaults: selectorCompat(_extends({}, defaults, { | ||
x: x, | ||
y: y, | ||
width: maxX - x, | ||
height: maxY - y | ||
})) | ||
} | ||
}); | ||
@@ -52,0 +61,0 @@ if (done) { |
@@ -14,2 +14,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
import { richAnnotationList } from './query/elucidateQuery'; | ||
import { currentManifest } from './query/manifestQuery'; | ||
import { setViewer, withViewer } from './actions/viewer'; | ||
@@ -50,8 +51,12 @@ import { currentSelectorIsSecondary, isSelecting } from './query/selectorQuery'; | ||
} | ||
var currentDraft = getDraftById(state, currentDraftId); | ||
if (!currentDraft) { | ||
var scopedDraft = getDraftById(state, currentDraftId); | ||
if (!scopedDraft) { | ||
return []; | ||
} | ||
Object.keys(currentDraft.selectors).forEach(function (k) { | ||
selectors.push(_extends({}, currentDraft.selectors[k], { id: k, isSecondary: true, name: currentDraft.name })); | ||
Object.keys(scopedDraft.selectors).forEach(function (k) { | ||
selectors.push(_extends({}, scopedDraft.selectors[k], { | ||
id: k, | ||
isSecondary: true, | ||
name: scopedDraft.name | ||
})); | ||
}); | ||
@@ -68,2 +73,3 @@ return selectors; | ||
currentResource: currentResource, | ||
currentManifest: currentManifest(state), | ||
isSelecting: isSelecting(state), | ||
@@ -70,0 +76,0 @@ isSelectingPrimary: isSelecting(state) && currentSelectorIsSecondary(state) === false, |
@@ -6,18 +6,18 @@ import Annotation from '../Annotation'; | ||
const source = { | ||
"@context": "http://www.w3.org/ns/anno.jsonld", | ||
'id': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8', | ||
'type': 'Annotation', | ||
'label': 'test', | ||
'body': { | ||
'value': '{"@context":{"foaf:name":"http://xmlns.com/foaf/name","schema:birthDate":"https://schema.org/birthDate","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"test","schema:birthDate":"2017-06-27T18:50:20.000Z","jobTitle":"Web Developer","Description":"51.5073509,-0.12775829999998223"}', | ||
'format': 'text/plain', | ||
'type': [ | ||
'TextualBody', | ||
'Dataset', | ||
], | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
id: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8', | ||
type: 'Annotation', | ||
label: 'test', | ||
body: { | ||
value: | ||
'{"@context":{"foaf:name":"http://xmlns.com/foaf/name","schema:birthDate":"https://schema.org/birthDate","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"test","schema:birthDate":"2017-06-27T18:50:20.000Z","jobTitle":"Web Developer","Description":"51.5073509,-0.12775829999998223"}', | ||
format: 'text/plain', | ||
type: ['TextualBody', 'Dataset'], | ||
}, | ||
'target': 'http://dams.llgc.org.uk/iiif/2.0/4693064/canvas/4693065.json#xywh=1186,2148,532,610', | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'Tagging', | ||
target: | ||
'http://dams.llgc.org.uk/iiif/2.0/4693064/canvas/4693065.json#xywh=1186,2148,532,610', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'Tagging', | ||
}, | ||
@@ -27,3 +27,5 @@ }; | ||
expect(annotation.id).toEqual('https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8'); | ||
expect(annotation.id).toEqual( | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8' | ||
); | ||
expect(annotation.body.TextualBody).toContain('@context'); | ||
@@ -36,7 +38,3 @@ expect(annotation.body.Dataset.jobTitle).toEqual('Web Developer'); | ||
expect( | ||
JSON.parse( | ||
JSON.stringify(annotation, null, 4), | ||
), | ||
).toEqual(source); | ||
expect(JSON.parse(JSON.stringify(annotation, null, 4))).toEqual(source); | ||
@@ -46,8 +44,4 @@ annotation.target.selector.x = 10000; | ||
expect( | ||
JSON.parse( | ||
JSON.stringify(annotation, null, 4), | ||
), | ||
).not.toEqual(source); | ||
expect(JSON.parse(JSON.stringify(annotation, null, 4))).not.toEqual(source); | ||
}); | ||
}); |
import Annotation from '../Annotation'; | ||
import { | ||
createAnnotationFromCaptureModelAndDraft, createExternalResourceAnnotationBody, | ||
createAnnotationFromCaptureModelAndDraft, | ||
createExternalResourceAnnotationBody, | ||
createHumanReadableAnnotationBody, | ||
@@ -16,3 +17,4 @@ } from '../mapping'; | ||
{ | ||
'@id': 'https://omeka.dlcs-ida.org/api/complete?class=entity:person', | ||
'@id': | ||
'https://omeka.dlcs-ida.org/api/complete?class=entity:person', | ||
'o:label': 'autocomplete', | ||
@@ -31,6 +33,3 @@ }, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -110,7 +109,11 @@ id: null, | ||
describe('lib/annotation/annotation#ida', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
@@ -120,21 +123,22 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'type': 'Annotation', | ||
'label': 'san pablo', | ||
'body': [ | ||
type: 'Annotation', | ||
label: 'san pablo', | ||
body: [ | ||
{ | ||
'source': 'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}, | ||
{ | ||
'value': 'san pablo', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'san pablo', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}, | ||
], | ||
'generator': 'http://omeka.dlcs-ida.org/api/item_sets/719', | ||
'target': 'http://manifest', | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'Tagging', | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/719', | ||
target: 'http://manifest', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'Tagging', | ||
}, | ||
@@ -146,9 +150,10 @@ }); | ||
const bodies = jsonify( | ||
createExternalResourceAnnotationBody(captureModel, draft), | ||
createExternalResourceAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'source': 'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}); | ||
@@ -159,11 +164,11 @@ }); | ||
const bodies = jsonify( | ||
createHumanReadableAnnotationBody(captureModel, draft), | ||
createHumanReadableAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'value': 'san pablo', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'san pablo', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}); | ||
}); | ||
}); |
@@ -70,6 +70,3 @@ import { | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -100,6 +97,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -130,6 +124,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -160,6 +151,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -190,6 +178,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -239,6 +224,10 @@ id: 'oa:TextualBody', | ||
describe('lib/annotation/annotation#person-draft', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should parse label correctly', () => { | ||
const label = getLabelFromDraft(captureModel.metaData.labelParts, captureModel, draft); | ||
const label = getLabelFromDraft( | ||
captureModel.metaData.labelParts, | ||
captureModel, | ||
draft | ||
); | ||
expect(label).toEqual('John Doe'); | ||
@@ -248,5 +237,3 @@ }); | ||
it('should parse serialized annotation bodies correctly', () => { | ||
const body = jsonify( | ||
createSerializedAnnotationBody(captureModel, draft), | ||
); | ||
const body = jsonify(createSerializedAnnotationBody(captureModel, draft)); | ||
@@ -265,3 +252,4 @@ expect(body.type).toEqual('Dataset'); | ||
expect(body).toEqual({ | ||
value: '{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
value: | ||
'{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
type: 'Dataset', | ||
@@ -274,3 +262,7 @@ format: 'text/plain', | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
@@ -280,18 +272,18 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'label': 'John Doe', | ||
'type': 'Annotation', | ||
'body': { | ||
'format': 'text/plain', | ||
'type': 'Dataset', | ||
'value': '{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
label: 'John Doe', | ||
type: 'Annotation', | ||
body: { | ||
format: 'text/plain', | ||
type: 'Dataset', | ||
value: | ||
'{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
}, | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
'generator': 'http://nlw-omeka.digtest.co.uk/api/item_sets/63', | ||
'target': 'http://manifest#xywh=5459,974,0,0', | ||
generator: 'http://nlw-omeka.digtest.co.uk/api/item_sets/63', | ||
target: 'http://manifest#xywh=5459,974,0,0', | ||
}); | ||
}); | ||
}); |
import Annotation from '../Annotation'; | ||
import { | ||
createAnnotationFromCaptureModelAndDraft, createExternalResourceAnnotationBody, | ||
createAnnotationFromCaptureModelAndDraft, | ||
createExternalResourceAnnotationBody, | ||
createHumanReadableAnnotationBody, | ||
@@ -26,6 +27,3 @@ } from '../mapping'; | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -83,3 +81,4 @@ id: null, | ||
label: 'Testing annotation', | ||
url: 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
url: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
}, | ||
@@ -111,7 +110,12 @@ }, | ||
describe('lib/annotation/annotation#tagging-draft', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
partOf: 'http://some-manifest', | ||
}) | ||
); | ||
@@ -121,22 +125,27 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'type': 'Annotation', | ||
'label': 'Testing annotation', | ||
'body': [ | ||
type: 'Annotation', | ||
label: 'Testing annotation', | ||
body: [ | ||
{ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}, | ||
{ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}, | ||
], | ||
'generator': 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
'target': 'http://manifest', | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
target: { | ||
'dcterms:isPartOf': 'http://some-manifest', | ||
type: 'Canvas', | ||
id: 'http://manifest', | ||
}, | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
}); | ||
@@ -147,9 +156,10 @@ }); | ||
const bodies = jsonify( | ||
createExternalResourceAnnotationBody(captureModel, draft), | ||
createExternalResourceAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}); | ||
@@ -160,11 +170,11 @@ }); | ||
const bodies = jsonify( | ||
createHumanReadableAnnotationBody(captureModel, draft), | ||
createHumanReadableAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}); | ||
}); | ||
}); |
@@ -6,14 +6,16 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping'; | ||
input: { | ||
'http://localhost:8888/api/items/1338': 'Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870\' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent\' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school\' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.' | ||
'http://localhost:8888/api/items/1338': | ||
"Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.", | ||
}, | ||
selectors: { | ||
'http://localhost:8888/api/items/1338': { | ||
type: null | ||
} | ||
type: null, | ||
}, | ||
}, | ||
template: 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
template: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
motivation: { | ||
id: 'oa:describing', | ||
label: 'describing', | ||
instance: 'describing' | ||
instance: 'describing', | ||
}, | ||
@@ -25,7 +27,9 @@ isPublishing: true, | ||
source: { | ||
template: 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
scope: 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
draft: '1ac1107c-ec0e-4ed5-b2fd-d6dbb97a3ad6' | ||
} | ||
} | ||
template: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
scope: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
draft: '1ac1107c-ec0e-4ed5-b2fd-d6dbb97a3ad6', | ||
}, | ||
}, | ||
}; | ||
@@ -123,3 +127,4 @@ | ||
vocabulary_id: '12', | ||
vocabulary_label: 'Crowds: Crowd Source Vocabulary for defining capture models.', | ||
vocabulary_label: | ||
'Crowds: Crowd Source Vocabulary for defining capture models.', | ||
}, | ||
@@ -172,7 +177,11 @@ schema: { | ||
describe('lib/annotation/annotation#transcription', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
@@ -182,15 +191,17 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'body': { | ||
'format': 'text/plain', | ||
'purpose': 'describing', | ||
'type': 'TextualBody', | ||
'value': 'Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870\' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent\' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school\' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.', | ||
body: { | ||
format: 'text/plain', | ||
purpose: 'describing', | ||
type: 'TextualBody', | ||
value: | ||
"Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.", | ||
}, | ||
'generator': 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
'label': 'unknown', | ||
'motivation': { 'id': 'oa:describing', 'label': 'describing' }, | ||
'target': 'http://manifest', | ||
'type': 'Annotation', | ||
generator: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
label: 'unknown', | ||
motivation: { id: 'oa:describing', label: 'describing' }, | ||
target: 'http://manifest', | ||
type: 'Annotation', | ||
}); | ||
}); | ||
}); |
@@ -6,13 +6,20 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping'; | ||
input: { | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381': 'my custom name of local tribunal', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382': '123', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431': 'Stephen', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384': '80', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381': | ||
'my custom name of local tribunal', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382': | ||
'123', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431': | ||
'Stephen', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384': | ||
'80', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/385': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386': 'Blacksmith', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387': 'Digirati', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386': | ||
'Blacksmith', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387': | ||
'Digirati', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/388': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/389': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/390': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391': 'Temporary', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391': | ||
'Temporary', | ||
}, | ||
@@ -150,3 +157,4 @@ selectors: { | ||
}, | ||
template: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
template: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
motivation: { | ||
@@ -162,4 +170,6 @@ id: 'oa:tagging', | ||
source: { | ||
template: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
scope: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/538', | ||
template: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
scope: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/538', | ||
draft: 'e3af9515-fe1f-440c-add5-a4573d2121c7', | ||
@@ -174,10 +184,8 @@ }, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381', | ||
inputType: 'madoc:dropdown', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -218,10 +226,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -262,10 +268,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -286,3 +290,4 @@ id: null, | ||
title: 'Name', | ||
description: 'Name (in full) of man in respect of whom the application is made', | ||
description: | ||
'Name (in full) of man in respect of whom the application is made', | ||
conformsTo: { | ||
@@ -307,10 +312,8 @@ id: 'http://xmlns.com/foaf/name', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -331,3 +334,4 @@ id: null, | ||
title: 'Age', | ||
description: 'Age of man (in respect of whom the application is being made)', | ||
description: | ||
'Age of man (in respect of whom the application is being made)', | ||
conformsTo: { | ||
@@ -352,10 +356,8 @@ id: 'http://xmlns.com/foaf/spec/#term_age', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/385', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/385', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -376,3 +378,4 @@ id: null, | ||
title: 'Address', | ||
description: 'Address (in full) of man in respect of whom the application is made', | ||
description: | ||
'Address (in full) of man in respect of whom the application is made', | ||
conformsTo: { | ||
@@ -397,10 +400,8 @@ id: 'schema:address', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -421,3 +422,4 @@ id: null, | ||
title: 'Occupation', | ||
description: 'Occupation, profession, or business of man on behalf of whom the application is made', | ||
description: | ||
'Occupation, profession, or business of man on behalf of whom the application is made', | ||
conformsTo: { | ||
@@ -442,10 +444,8 @@ id: 'https://schema.org/jobTitle', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -486,10 +486,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/388', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/388', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -530,10 +528,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/389', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/389', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -574,10 +570,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/390', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/390', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -618,10 +612,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -642,3 +634,4 @@ id: null, | ||
title: 'Nature of Application', | ||
description: 'Nature of Application, e.g. Conditional, Absolute, Temporary.', | ||
description: | ||
'Nature of Application, e.g. Conditional, Absolute, Temporary.', | ||
conformsTo: { | ||
@@ -663,3 +656,4 @@ id: 'http://ndl.go.jp/dcndl/terms/transcription', | ||
type: 'captureModel', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
title: 'R. 41 : Page 1 [pre mid 1916]', | ||
@@ -683,28 +677,29 @@ description: 'First page of beige R41 form, pre mid-1916.', | ||
describe('lib/annotation/annotation#ww1tribunal', () => { | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify(createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft)); | ||
const [ | ||
nameAnnotation, | ||
] = annotation; | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
const [nameAnnotation] = annotation; | ||
expect(annotation.length).toEqual(7); | ||
expect(nameAnnotation).toEqual({ | ||
"@context": "http://www.w3.org/ns/anno.jsonld", | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
type: 'Annotation', | ||
label: 'my custom name of local tribunal', | ||
body: | ||
{ | ||
value: '{"@context":{"Title":"http://dublincore.org/documents/dcmi-terms/#terms-title"},"schema:AdministrativeArea":"my custom name of local tribunal","Title":"Name of Local Tribunal"}', | ||
type: 'Dataset', | ||
purpose: 'oa:identifying', | ||
format: 'text/plain', | ||
}, | ||
body: { | ||
value: | ||
'{"@context":{"Title":"http://dublincore.org/documents/dcmi-terms/#terms-title"},"schema:AdministrativeArea":"my custom name of local tribunal","Title":"Name of Local Tribunal"}', | ||
type: 'Dataset', | ||
purpose: 'oa:identifying', | ||
format: 'text/plain', | ||
}, | ||
target: 'http://manifest#xywh=2320,444,840,230', | ||
}); | ||
}); | ||
}); |
@@ -7,3 +7,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
var Annotation = function () { | ||
// Serialized fields | ||
@@ -10,0 +9,0 @@ function Annotation(id, label, body, target, motivation, generator) { |
@@ -0,1 +1,2 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
@@ -16,3 +17,3 @@ | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) { | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) { | ||
_classCallCheck(this, AnnotationSelector); | ||
@@ -30,9 +31,9 @@ | ||
this.textDirection = textDirection; | ||
this.selector = AnnotationSelector.parseTarget(id, scale, selector); | ||
this.selector = AnnotationSelector.parseTarget(id, scale, selector, partOf); | ||
} | ||
AnnotationSelector.fromTarget = function fromTarget(target, selector) { | ||
AnnotationSelector.fromTarget = function fromTarget(target, selector, partOf) { | ||
var annotationSelector = new AnnotationSelector(); | ||
annotationSelector.source = target; | ||
annotationSelector.selector = selector; | ||
annotationSelector.selector = AnnotationSelector.parseTarget(selector, 1, null, partOf); | ||
return annotationSelector; | ||
@@ -48,5 +49,9 @@ }; | ||
if (text['dcterms:isPartOf']) { | ||
text.partOf = text['dcterms:isPartOf']; | ||
} | ||
// https://www.w3.org/TR/annotation-model/#bodies-and-targets | ||
if (text.id) { | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection); | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text.partOf); | ||
} | ||
@@ -56,3 +61,3 @@ | ||
if (text.source) { | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector); | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text.partOf); | ||
} | ||
@@ -67,2 +72,3 @@ | ||
var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
@@ -96,9 +102,11 @@ var toParse = source; | ||
return source.split('#')[0]; | ||
} | ||
}, | ||
partOf: partOf | ||
}; | ||
} | ||
return source; | ||
return _extends({}, source, { partOf: partOf }); | ||
}; | ||
AnnotationSelector.prototype.toJSON = function toJSON() { | ||
AnnotationSelector.prototype.getStringSelector = function getStringSelector() { | ||
if (!this.selector || this.selector.x === null || isNaN(Math.floor(this.selector.x)) || this.selector.y === null || isNaN(Math.floor(this.selector.y))) { | ||
@@ -115,2 +123,16 @@ return this.source; | ||
AnnotationSelector.prototype.toJSON = function toJSON() { | ||
// If we have a part of, we can't reduce to string. | ||
if (this.selector && this.selector.partOf) { | ||
// This is the target field. | ||
return { | ||
id: this.getStringSelector(), | ||
type: 'Canvas', | ||
'dcterms:isPartOf': this.selector.partOf | ||
}; | ||
} | ||
return this.getStringSelector(); | ||
}; | ||
AnnotationSelector.prototype.toString = function toString() { | ||
@@ -117,0 +139,0 @@ return this.id; |
@@ -10,5 +10,5 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
// Draft value is {id: 'http://..'} | ||
export var FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
export var FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
// Draft value is {label: 'human readable'} | ||
export var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
export var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
@@ -130,3 +130,2 @@ export function createCombinedAnnotationBody(captureModel, draft) { | ||
export function createExternalResourceAnnotationBody(captureModel, draft) { | ||
var fieldIds = Object.keys(draft.input); | ||
@@ -159,5 +158,4 @@ var fields = getModelFields(fieldIds, captureModel.fields); | ||
}).reduce(function (state, field) { | ||
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && field.inputType === 'madoc:textarea') { | ||
var body = new AnnotationBody(null, draft.input[field.id], 'text/plain', 'TextualBody'); | ||
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && (field.inputType === 'madoc:textarea' || field.inputType === 'madoc:htmlfield')) { | ||
var body = new AnnotationBody(null, draft.input[field.id], field.inputType === 'madoc:textarea' ? 'text/plain' : 'text/html', 'TextualBody'); | ||
body.purpose = field.omekaMetaData.purpose ? field.omekaMetaData.purpose.label : null; | ||
@@ -205,3 +203,6 @@ state.push(body); | ||
var captureModelField = captureModel.fields[field.id]; | ||
var captureModelField = Object.values(captureModel.fields).find(function (_ref2) { | ||
var id = _ref2.id; | ||
return id === field.id; | ||
}); | ||
if (!(captureModelField && (captureModelField.metaData || captureModelField.omekaMeta))) { | ||
@@ -293,3 +294,9 @@ console.warn('createMultipleAnnotations', 'Looks like you have set derivedAnnoCombine to "False" without selectors on the fields, are you sure this is correct?', captureModelField); | ||
export function createAnnotationFromCaptureModelAndDraft(target, captureModel, draft, customDraftSelector) { | ||
export function createAnnotationFromCaptureModelAndDraft(_ref3) { | ||
var target = _ref3.target, | ||
captureModel = _ref3.captureModel, | ||
draft = _ref3.draft, | ||
customDraftSelector = _ref3.customDraftSelector, | ||
partOf = _ref3.partOf; | ||
var bodies = []; | ||
@@ -356,3 +363,3 @@ var label = 'unknown'; | ||
return new Annotation(null, label, AnnotationBodyList.fromJsonLD(bodies), AnnotationSelector.fromTarget(target, draftSelector), motivation, generator); | ||
return new Annotation(null, label, AnnotationBodyList.fromJsonLD(bodies), AnnotationSelector.fromTarget(target, draftSelector, partOf), motivation, generator); | ||
} |
@@ -0,1 +1,2 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
@@ -12,3 +13,3 @@ | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) { | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) { | ||
_classCallCheck(this, AnnotationSelector); | ||
@@ -28,3 +29,3 @@ | ||
this.textDirection = textDirection; | ||
this.target = AnnotationSelector.parseTarget(id, scale, selector); | ||
this.target = AnnotationSelector.parseTarget(id, scale, selector, partOf); | ||
} | ||
@@ -41,3 +42,3 @@ | ||
if (text.id) { | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection); | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text['dcterms:isPartOf']); | ||
} | ||
@@ -47,3 +48,3 @@ | ||
if (text.source) { | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector); | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text['dcterms:isPartOf']); | ||
} | ||
@@ -58,2 +59,3 @@ | ||
var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
@@ -75,2 +77,3 @@ var toParse = source; | ||
height: parseInt(match[5], 10) * scale, | ||
partOf: partOf, | ||
toString: function toString() { | ||
@@ -82,3 +85,3 @@ // @todo maybe something else? | ||
} | ||
return source; | ||
return _extends({}, source, { partOf: partOf }); | ||
}; | ||
@@ -85,0 +88,0 @@ |
@@ -8,4 +8,4 @@ import _asyncIterator from 'babel-runtime/helpers/asyncIterator'; | ||
var fetchPageCollection = function () { | ||
var _ref3 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref4, item; | ||
var _ref4 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref5, item; | ||
@@ -43,3 +43,3 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
case 8: | ||
_ref4 = _iterator2[_i2++]; | ||
_ref5 = _iterator2[_i2++]; | ||
_context2.next = 15; | ||
@@ -59,6 +59,6 @@ break; | ||
case 14: | ||
_ref4 = _i2.value; | ||
_ref5 = _i2.value; | ||
case 15: | ||
item = _ref4; | ||
item = _ref5; | ||
_context2.next = 18; | ||
@@ -87,4 +87,4 @@ return item; | ||
return function fetchPageCollection(_x5) { | ||
return _ref3.apply(this, arguments); | ||
return function fetchPageCollection(_x6) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
@@ -107,2 +107,5 @@ }(); | ||
var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}, | ||
withoutCredentials = _ref.withoutCredentials; | ||
return fetch(uri, { | ||
@@ -112,4 +115,3 @@ method: method, | ||
body: JSON.stringify(body), | ||
credentials: process.env.NODE_ENV === 'production' ? 'include' : null, | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit', | ||
redirect: 'follow' | ||
@@ -128,3 +130,8 @@ }).then(function (response) { | ||
export function get(uri, body) { | ||
return makeRequest('GET', uri, body); | ||
try { | ||
return makeRequest('GET', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('GET', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -135,3 +142,10 @@ | ||
return makeRequest('POST', uri, body, headers); | ||
try { | ||
return makeRequest('POST', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('POST', uri, body, headers, { | ||
withoutCredentials: true | ||
}); | ||
} | ||
} | ||
@@ -142,3 +156,8 @@ | ||
return makeRequest('PUT', uri, body, headers); | ||
try { | ||
return makeRequest('PUT', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('PUT', uri, body, headers, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -151,4 +170,4 @@ | ||
export var getAllAnnotationsFromCollection = function () { | ||
var _ref = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref2, item, collection, _item; | ||
var _ref2 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref3, item, collection, _item; | ||
@@ -185,3 +204,3 @@ return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 7: | ||
_ref2 = _iterator[_i++]; | ||
_ref3 = _iterator[_i++]; | ||
_context.next = 14; | ||
@@ -201,6 +220,6 @@ break; | ||
case 13: | ||
_ref2 = _i.value; | ||
_ref3 = _i.value; | ||
case 14: | ||
item = _ref2; | ||
item = _ref3; | ||
_context.next = 17; | ||
@@ -253,4 +272,4 @@ return item; | ||
return function getAllAnnotationsFromCollection(_x4) { | ||
return _ref.apply(this, arguments); | ||
return function getAllAnnotationsFromCollection(_x5) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
@@ -257,0 +276,0 @@ }(); |
@@ -45,3 +45,6 @@ import thunk from 'redux-thunk'; | ||
if (showUntilQueue[action.type]) { | ||
store.dispatch({ type: 'SHOW_UNTIL_REMOVED', payload: { names: showUntilQueue[action.type] } }); | ||
store.dispatch({ | ||
type: 'SHOW_UNTIL_REMOVED', | ||
payload: { names: showUntilQueue[action.type] } | ||
}); | ||
showUntilQueue[action.type] = []; | ||
@@ -48,0 +51,0 @@ } |
@@ -25,4 +25,4 @@ import _extends from "babel-runtime/helpers/extends"; | ||
var drafts = state.drafts.list; | ||
return Object.values(drafts).reduce(function (state, draft) { | ||
if (state) return state; | ||
return Object.values(drafts).reduce(function (found, draft) { | ||
if (found) return found; | ||
if (draft.id !== id && draft.fingerprint.identity === identity) { | ||
@@ -29,0 +29,0 @@ return draft; |
import _extends from 'babel-runtime/helpers/extends'; | ||
import { AnnotationSelector } from '../lib/elucidate/index'; | ||
import { isV3Manifest } from '../utility'; | ||
export function getServer(state) { | ||
@@ -16,6 +17,18 @@ return state.elucidate.server; | ||
export function getCanvasFromManifest(manifest, canvasId) { | ||
if (!(manifest || manifest.sequences || manifest.sequences[0] || manifest.sequences[0].canvases)) { | ||
if (!manifest) { | ||
return null; | ||
} | ||
var canvases = manifest.sequences[0].canvases; | ||
var canvases = null; | ||
var idProperty = null; | ||
try { | ||
if (isV3Manifest(manifest)) { | ||
canvases = manifest.items; | ||
idProperty = 'id'; | ||
} else { | ||
canvases = manifest.sequences[0].canvases; | ||
idProperty = '@id'; | ||
} | ||
} catch (ex) { | ||
return null; | ||
} | ||
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
@@ -35,3 +48,3 @@ var _ref; | ||
if (canvas['@id'] === canvasId) { | ||
if (canvas[idProperty] === canvasId) { | ||
return canvas; | ||
@@ -38,0 +51,0 @@ } |
@@ -6,3 +6,7 @@ export function getHelpByType(type, state) { | ||
return Object.keys(state.help[type]).map(function (key) { | ||
return { type: type, key: key, content: state.help[type][key] }; | ||
return { | ||
type: type, | ||
key: key, | ||
content: state.help[type][key] | ||
}; | ||
}); | ||
@@ -9,0 +13,0 @@ } |
@@ -0,1 +1,3 @@ | ||
import { isV3Manifest } from '../utility'; | ||
export function currentManifest(state) { | ||
@@ -6,13 +8,18 @@ return manifestById(state, state.manifest.current); | ||
export function getImageServiceFromCanvas(canvas) { | ||
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) { | ||
return canvas.images[0].resource.service['@id'] + '/info.json'; | ||
} | ||
if (canvas.hasOwnProperty('type') && canvas.type === 'Canvas') { | ||
if (canvas.items && canvas.items[0] && canvas.items[0].items && canvas.items[0].items[0] && canvas.items[0].items[0].body && canvas.items[0].items[0].body.service && canvas.items[0].items[0].body.service[0] && canvas.items[0].items[0].body.service[0].id) { | ||
return canvas.items[0].items[0].body.service[0].id + '/info.json'; | ||
} | ||
} else { | ||
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) { | ||
return canvas.images[0].resource.service['@id'] + '/info.json'; | ||
} | ||
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) { | ||
return canvas.thumbnail.service['@id'] + '/info.json'; | ||
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) { | ||
return canvas.thumbnail.service['@id'] + '/info.json'; | ||
} | ||
if (canvas.thumbnail && canvas.thumbnail['@id']) { | ||
return canvas.thumbnail['@id']; | ||
} | ||
} | ||
if (canvas.thumbnail && canvas.thumbnail['@id']) { | ||
return canvas.thumbnail['@id']; | ||
} | ||
return null; | ||
@@ -33,6 +40,18 @@ } | ||
var canvasId = state.manifest.currentCanvas; | ||
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) { | ||
return null; | ||
var canvases = null; | ||
var idProperty = null; | ||
if (isV3Manifest(manifest)) { | ||
if (!manifest.hasOwnProperty('items')) { | ||
return null; | ||
} | ||
canvases = manifest.items; | ||
idProperty = 'id'; | ||
} else { | ||
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) { | ||
return null; | ||
} | ||
canvases = manifest.sequences[0].canvases; | ||
idProperty = '@id'; | ||
} | ||
var canvases = manifest.sequences[0].canvases; | ||
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
@@ -52,3 +71,3 @@ var _ref; | ||
if (canvas['@id'] === canvasId) { | ||
if (canvas[idProperty] === canvasId) { | ||
return canvas; | ||
@@ -55,0 +74,0 @@ } |
@@ -27,7 +27,7 @@ import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
var draftDefaultKeys = Object.keys(draftDefaults); | ||
var filledInputs = Object.keys(input).reduce(function (input, url) { | ||
var filledInputs = Object.keys(input).reduce(function (allInputs, url) { | ||
if (fields && fields[url] && fields[url].metaData && fields[url].metaData.conformsTo && fields[url].metaData.conformsTo.label && draftDefaultKeys.indexOf(fields[url].metaData.conformsTo.label) !== -1) { | ||
input[url] = draftDefaults[fields[url].metaData.conformsTo.label]; | ||
allInputs[url] = draftDefaults[fields[url].metaData.conformsTo.label]; | ||
} | ||
return input; | ||
return allInputs; | ||
}, input); | ||
@@ -34,0 +34,0 @@ |
@@ -71,3 +71,5 @@ import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
list: (_list5 = {}, _list5[action.payload.id] = { | ||
selector: { $set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector } | ||
selector: { | ||
$set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector | ||
} | ||
}, _list5) | ||
@@ -151,5 +153,4 @@ }); | ||
}); | ||
} | ||
return state; | ||
} |
@@ -46,3 +46,5 @@ import update from 'immutability-helper'; | ||
collection: { | ||
$set: Object.assign({}, action.payload.collection, { loading: false }) | ||
$set: Object.assign({}, action.payload.collection, { | ||
loading: false | ||
}) | ||
} | ||
@@ -49,0 +51,0 @@ }); |
@@ -18,3 +18,2 @@ import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
switch (action.type) { | ||
@@ -21,0 +20,0 @@ case HELP_INFO_ADD: |
@@ -18,5 +18,3 @@ import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
switch (action.type) { | ||
case MANIFEST_ADD: | ||
@@ -23,0 +21,0 @@ return update(state, { |
@@ -35,3 +35,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
switch (action.type) { | ||
case RESOURCE_NAV_FORWARD: | ||
@@ -52,5 +51,7 @@ if (!state.currentPaths[action.payload.tree]) { | ||
return update(state, { | ||
currentPaths: (_currentPaths2 = {}, _currentPaths2[action.payload.tree] = { $apply: function $apply(path) { | ||
currentPaths: (_currentPaths2 = {}, _currentPaths2[action.payload.tree] = { | ||
$apply: function $apply(path) { | ||
return path.length > 0 ? path.slice(0, -1) : []; | ||
} }, _currentPaths2) | ||
} | ||
}, _currentPaths2) | ||
}); | ||
@@ -77,3 +78,5 @@ | ||
return update(state, { | ||
list: (_list = {}, _list[action.payload.id] = { $set: _extends({}, captureModelDefaults, action.payload.resource) }, _list) | ||
list: (_list = {}, _list[action.payload.id] = { | ||
$set: _extends({}, captureModelDefaults, action.payload.resource) | ||
}, _list) | ||
}); | ||
@@ -80,0 +83,0 @@ |
@@ -14,3 +14,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
switch (action.type) { | ||
@@ -43,3 +42,2 @@ case SELECTOR_SET_AVAILABLE: | ||
}); | ||
} | ||
@@ -46,0 +44,0 @@ |
@@ -52,2 +52,22 @@ var SHOW_LOGS = false; | ||
return item; | ||
} | ||
var CONTEXT_V3 = 'http://iiif.io/api/presentation/3/context.json'; | ||
export function isV3Manifest(manifest) { | ||
if (!manifest) { | ||
return false; | ||
} | ||
var context = manifest['@context']; | ||
if (!context) { | ||
return false; | ||
} | ||
switch (context.constructor) { | ||
case Array: | ||
return context.includes(CONTEXT_V3); | ||
case String: | ||
return context === CONTEXT_V3; | ||
default: | ||
return false; | ||
} | ||
} |
@@ -98,11 +98,21 @@ 'use strict'; | ||
return annotation.body.purpose === 'editing'; | ||
}; | ||
} | ||
function createDraft(scope, emptyInput, template) { | ||
var motivation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'tagging'; | ||
var selectors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; | ||
var draftDefaults = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
var immutableSelector = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; | ||
var path = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : []; | ||
var name = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null; | ||
function createDraft(scope, _ref) { | ||
var emptyInput = _ref.emptyInput, | ||
template = _ref.template, | ||
_ref$motivation = _ref.motivation, | ||
motivation = _ref$motivation === undefined ? 'tagging' : _ref$motivation, | ||
_ref$selectors = _ref.selectors, | ||
selectors = _ref$selectors === undefined ? null : _ref$selectors, | ||
_ref$draftDefaults = _ref.draftDefaults, | ||
draftDefaults = _ref$draftDefaults === undefined ? null : _ref$draftDefaults, | ||
_ref$immutableSelecto = _ref.immutableSelector, | ||
immutableSelector = _ref$immutableSelecto === undefined ? null : _ref$immutableSelecto, | ||
_ref$path = _ref.path, | ||
path = _ref$path === undefined ? [] : _ref$path, | ||
_ref$name = _ref.name, | ||
name = _ref$name === undefined ? null : _ref$name, | ||
_ref$partOf = _ref.partOf, | ||
partOf = _ref$partOf === undefined ? null : _ref$partOf; | ||
@@ -113,3 +123,3 @@ return function (dispatch, getState) { | ||
// Create draft. | ||
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path)); | ||
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path, null, partOf)); | ||
// And select it straight away. | ||
@@ -137,3 +147,7 @@ dispatch(selectDraft(scope, id)); | ||
} else { | ||
dispatch((0, _selectors2.chooseSelector)('WholeCanvasSelector', { template: currentTemplate.id, scope: scope, draft: draftId })); | ||
dispatch((0, _selectors2.chooseSelector)('WholeCanvasSelector', { | ||
template: currentTemplate.id, | ||
scope: scope, | ||
draft: draftId | ||
})); | ||
} | ||
@@ -146,14 +160,11 @@ } | ||
// desiredLifecycle must be one of these constants. | ||
return [DRAFT_LIFECYCLE_CHANGED, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ].indexOf(desiredLifecycle) === -1 ? | ||
// If not, the default lifecycle. | ||
defaultLifecycle ? defaultLifecycle : | ||
// Defaulting to new. | ||
DRAFT_LIFECYCLE_NEW | ||
// If its valid, use it. | ||
: desiredLifecycle; | ||
return [DRAFT_LIFECYCLE_CHANGED, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ].indexOf(desiredLifecycle) === -1 ? // If not, the default lifecycle. | ||
defaultLifecycle ? defaultLifecycle : // Defaulting to new. | ||
DRAFT_LIFECYCLE_NEW : // If its valid, use it. | ||
desiredLifecycle; | ||
} | ||
function changeFingerPrintLifecyle(_ref, desiredLifecycle) { | ||
var fingerprint = _ref.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref, ['fingerprint']); | ||
function changeFingerPrintLifecyle(_ref2, desiredLifecycle) { | ||
var fingerprint = _ref2.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref2, ['fingerprint']); | ||
@@ -163,38 +174,55 @@ var lifecycle = getValidLifecycle(desiredLifecycle, draft.lifecycle); | ||
return (0, _extends3.default)({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, lifecycle, fingerprint.source, fingerprint.creator) | ||
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, { | ||
lifecycle: lifecycle | ||
})) | ||
}); | ||
} | ||
function changeFingerPrintCreator(_ref2, creator) { | ||
var fingerprint = _ref2.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref2, ['fingerprint']); | ||
function changeFingerPrintCreator(_ref3, creator) { | ||
var fingerprint = _ref3.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref3, ['fingerprint']); | ||
return (0, _extends3.default)({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, creator) | ||
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, { | ||
creator: creator | ||
})) | ||
}); | ||
} | ||
function changeFingerprintSource(_ref3, source) { | ||
var fingerprint = _ref3.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref3, ['fingerprint']); | ||
function changeFingerprintSource(_ref4, source) { | ||
var fingerprint = _ref4.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref4, ['fingerprint']); | ||
return (0, _extends3.default)({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, source, fingerprint.creator) | ||
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, { | ||
source: source | ||
})) | ||
}); | ||
} | ||
function changeFingerprintIdentity(_ref4, identity) { | ||
var fingerprint = _ref4.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref4, ['fingerprint']); | ||
function changeFingerprintIdentity(_ref5, identity) { | ||
var fingerprint = _ref5.fingerprint, | ||
draft = (0, _objectWithoutProperties3.default)(_ref5, ['fingerprint']); | ||
return (0, _extends3.default)({}, draft, { | ||
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, fingerprint.creator) | ||
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, { | ||
identity: identity | ||
})) | ||
}); | ||
} | ||
function createFingerprint(scope, path, identity) { | ||
var created = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
var lifecycle = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; | ||
var source = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
var creator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; | ||
function createFingerprint(_ref6) { | ||
var scope = _ref6.scope, | ||
path = _ref6.path, | ||
identity = _ref6.identity, | ||
_ref6$created = _ref6.created, | ||
created = _ref6$created === undefined ? null : _ref6$created, | ||
_ref6$lifecycle = _ref6.lifecycle, | ||
lifecycle = _ref6$lifecycle === undefined ? null : _ref6$lifecycle, | ||
_ref6$source = _ref6.source, | ||
source = _ref6$source === undefined ? null : _ref6$source, | ||
_ref6$creator = _ref6.creator, | ||
creator = _ref6$creator === undefined ? null : _ref6$creator, | ||
_ref6$partOf = _ref6.partOf, | ||
partOf = _ref6$partOf === undefined ? null : _ref6$partOf; | ||
@@ -208,3 +236,4 @@ return { | ||
source: source ? source : 'memory', // memory | elucidate | localStorage | ||
creator: creator ? creator : 'unknown' | ||
creator: creator ? creator : 'unknown', | ||
partOf: partOf ? partOf : null // Usually manifest. | ||
}; | ||
@@ -218,2 +247,3 @@ } | ||
var created = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null; | ||
var partOf = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null; | ||
@@ -228,3 +258,9 @@ return { | ||
motivation: motivation, | ||
fingerprint: createFingerprint(scope, path, null, created, null, null, 'you') | ||
fingerprint: createFingerprint({ | ||
scope: scope, | ||
path: path, | ||
created: created, | ||
creator: 'you', | ||
partOf: partOf | ||
}) | ||
} | ||
@@ -301,3 +337,9 @@ }; | ||
return { type: DRAFT_UPDATE_FIELD_SELECTOR, payload: { id: id, selectors: (_selectors = {}, _selectors[fieldId] = (0, _extends3.default)({}, (0, _utility.selectorCompat)(selector), { name: name }), _selectors) } }; | ||
return { | ||
type: DRAFT_UPDATE_FIELD_SELECTOR, | ||
payload: { | ||
id: id, | ||
selectors: (_selectors = {}, _selectors[fieldId] = (0, _extends3.default)({}, (0, _utility.selectorCompat)(selector), { name: name }), _selectors) | ||
} | ||
}; | ||
} | ||
@@ -385,3 +427,6 @@ | ||
markDraftAs(id, DRAFT_LIFECYCLE_READ, DRAFT_LIFECYCLE_CHANGED)(dispatch, getState); | ||
dispatch({ type: DRAFT_UPDATE_SELECTOR, payload: { id: id, selector: (0, _extends3.default)({}, (0, _utility.selectorCompat)(selector), { name: name }) } }); | ||
dispatch({ | ||
type: DRAFT_UPDATE_SELECTOR, | ||
payload: { id: id, selector: (0, _extends3.default)({}, (0, _utility.selectorCompat)(selector), { name: name }) } | ||
}); | ||
}; | ||
@@ -388,0 +433,0 @@ } |
@@ -60,4 +60,8 @@ 'use strict'; | ||
return function (dispatch, state) { | ||
dispatch({ type: ELUCIDATE_CREATE_COLLECTION, payload: { label: label, resourceId: resourceId } }); | ||
dispatch({ | ||
type: ELUCIDATE_CREATE_COLLECTION, | ||
payload: { label: label, resourceId: resourceId } | ||
}); | ||
var elucidateServer = (0, _elucidateQuery.getServer)(state()); | ||
return (0, _elucidate.createElucidateCollection)(elucidateServer, label, (0, _blueimpMd2.default)(resourceId)).then(function (collection) { | ||
@@ -78,3 +82,6 @@ dispatch(setCollection(resourceId, collection)); | ||
function addElucidateAnnotation(annotation) { | ||
return { type: ELUCIDATE_ADD_ANNOTATION, payload: { id: annotation.id, annotation: annotation } }; | ||
return { | ||
type: ELUCIDATE_ADD_ANNOTATION, | ||
payload: { id: annotation.id, annotation: annotation } | ||
}; | ||
} | ||
@@ -93,14 +100,14 @@ | ||
var collection = (0, _elucidateQuery.getCollectionId)(state()); | ||
return (0, _elucidate.postAnnotation)(collection, annotation).then(function (annotation) { | ||
if ((0, _drafts.isSavedDraft)(annotation)) { | ||
var draft = JSON.parse(annotation.body.value); | ||
var id = annotation.id; | ||
return (0, _elucidate.postAnnotation)(collection, annotation).then(function (postedAnnotation) { | ||
if ((0, _drafts.isSavedDraft)(postedAnnotation)) { | ||
var draft = JSON.parse(postedAnnotation.body.value); | ||
var id = postedAnnotation.id; | ||
var identity = id.substr(id.length - 1) === '/' ? id.substr(0, id.length - 1).split('/').pop() : id.split('/').pop(); | ||
if (draft) { | ||
dispatch((0, _drafts.importDraft)(identity, (0, _drafts.changeFingerPrintCreator)((0, _drafts.changeFingerprintIdentity)(draft, identity), annotation.creator && annotation.creator.name ? annotation.creator.name : 'unknown'))); | ||
dispatch((0, _drafts.importDraft)(identity, (0, _drafts.changeFingerPrintCreator)((0, _drafts.changeFingerprintIdentity)(draft, identity), postedAnnotation.creator && postedAnnotation.creator.name ? postedAnnotation.creator.name : 'unknown'))); | ||
} | ||
} | ||
dispatch(addElucidateAnnotation(annotation)); | ||
return annotation; | ||
dispatch(addElucidateAnnotation(postedAnnotation)); | ||
return postedAnnotation; | ||
}); | ||
@@ -116,4 +123,4 @@ }; | ||
annotation.id = annoationId; | ||
return (0, _elucidate.putAnnotation)(annoationId, annotation).then(function (annotation) { | ||
return dispatch(addElucidateAnnotation(annotation)); | ||
return (0, _elucidate.putAnnotation)(annoationId, annotation).then(function (postedAnnotation) { | ||
return dispatch(addElucidateAnnotation(postedAnnotation)); | ||
}); | ||
@@ -128,3 +135,6 @@ }; | ||
return function (dispatch, state) { | ||
dispatch({ type: ELUCIDATE_SEND_ANNOTATION, payload: { annotation: { body: body, target: target, motivation: motivation, label: label } } }); | ||
dispatch({ | ||
type: ELUCIDATE_SEND_ANNOTATION, | ||
payload: { annotation: { body: body, target: target, motivation: motivation, label: label } } | ||
}); | ||
var collection = (0, _elucidateQuery.getCollectionId)(state()); | ||
@@ -131,0 +141,0 @@ return (0, _elucidate.sendAnnotationToServer)(collection, body, target, motivation, label).then(function (annotation) { |
@@ -20,5 +20,3 @@ 'use strict'; | ||
dispatch({ type: MANIFEST_REQUEST, payload: { url: url } }); | ||
return fetch(url, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}).then(function (response) { | ||
return fetch(url).then(function (response) { | ||
return response.json(); | ||
@@ -25,0 +23,0 @@ }).then(function (body) { |
@@ -105,7 +105,11 @@ 'use strict'; | ||
function importResourceTree(tree) { | ||
if (!(tree.id && (tree.type === 'choice' || tree.type === 'captureModel') /*&& | ||
(tree.type === 'choice' ? (tree.choice && Object.keys(tree.choice).length > 1) : true)*/ | ||
)) { | ||
return { type: IMPORT_RESOURCE_TREE, error: true, payload: new Error('Not a valid tree') }; | ||
} | ||
if (!(tree.id && (tree.type === 'choice' || tree.type === 'captureModel')) /*&& | ||
(tree.type === 'choice' ? (tree.choice && Object.keys(tree.choice).length > 1) : true)*/ | ||
) { | ||
return { | ||
type: IMPORT_RESOURCE_TREE, | ||
error: true, | ||
payload: new Error('Not a valid tree') | ||
}; | ||
} | ||
@@ -112,0 +116,0 @@ return { type: IMPORT_RESOURCE_TREE, payload: { id: tree.id, tree: tree } }; |
@@ -73,3 +73,12 @@ 'use strict'; | ||
meta: { fromViewer: true }, | ||
payload: { type: type, source: source, defaults: (0, _utility.selectorCompat)((0, _extends3.default)({}, defaults, { x: x, y: y, width: maxX - x, height: maxY - y })) } | ||
payload: { | ||
type: type, | ||
source: source, | ||
defaults: (0, _utility.selectorCompat)((0, _extends3.default)({}, defaults, { | ||
x: x, | ||
y: y, | ||
width: maxX - x, | ||
height: maxY - y | ||
})) | ||
} | ||
}); | ||
@@ -76,0 +85,0 @@ if (done) { |
@@ -35,2 +35,4 @@ 'use strict'; | ||
var _manifestQuery = require('./query/manifestQuery'); | ||
var _viewer = require('./actions/viewer'); | ||
@@ -74,8 +76,12 @@ | ||
} | ||
var currentDraft = (0, _draftQuery.getDraftById)(state, currentDraftId); | ||
if (!currentDraft) { | ||
var scopedDraft = (0, _draftQuery.getDraftById)(state, currentDraftId); | ||
if (!scopedDraft) { | ||
return []; | ||
} | ||
Object.keys(currentDraft.selectors).forEach(function (k) { | ||
selectors.push((0, _extends3.default)({}, currentDraft.selectors[k], { id: k, isSecondary: true, name: currentDraft.name })); | ||
Object.keys(scopedDraft.selectors).forEach(function (k) { | ||
selectors.push((0, _extends3.default)({}, scopedDraft.selectors[k], { | ||
id: k, | ||
isSecondary: true, | ||
name: scopedDraft.name | ||
})); | ||
}); | ||
@@ -92,2 +98,3 @@ return selectors; | ||
currentResource: currentResource, | ||
currentManifest: (0, _manifestQuery.currentManifest)(state), | ||
isSelecting: (0, _selectorQuery.isSelecting)(state), | ||
@@ -94,0 +101,0 @@ isSelectingPrimary: (0, _selectorQuery.isSelecting)(state) && (0, _selectorQuery.currentSelectorIsSecondary)(state) === false, |
@@ -6,18 +6,18 @@ import Annotation from '../Annotation'; | ||
const source = { | ||
"@context": "http://www.w3.org/ns/anno.jsonld", | ||
'id': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8', | ||
'type': 'Annotation', | ||
'label': 'test', | ||
'body': { | ||
'value': '{"@context":{"foaf:name":"http://xmlns.com/foaf/name","schema:birthDate":"https://schema.org/birthDate","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"test","schema:birthDate":"2017-06-27T18:50:20.000Z","jobTitle":"Web Developer","Description":"51.5073509,-0.12775829999998223"}', | ||
'format': 'text/plain', | ||
'type': [ | ||
'TextualBody', | ||
'Dataset', | ||
], | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
id: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8', | ||
type: 'Annotation', | ||
label: 'test', | ||
body: { | ||
value: | ||
'{"@context":{"foaf:name":"http://xmlns.com/foaf/name","schema:birthDate":"https://schema.org/birthDate","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"test","schema:birthDate":"2017-06-27T18:50:20.000Z","jobTitle":"Web Developer","Description":"51.5073509,-0.12775829999998223"}', | ||
format: 'text/plain', | ||
type: ['TextualBody', 'Dataset'], | ||
}, | ||
'target': 'http://dams.llgc.org.uk/iiif/2.0/4693064/canvas/4693065.json#xywh=1186,2148,532,610', | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'Tagging', | ||
target: | ||
'http://dams.llgc.org.uk/iiif/2.0/4693064/canvas/4693065.json#xywh=1186,2148,532,610', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'Tagging', | ||
}, | ||
@@ -27,3 +27,5 @@ }; | ||
expect(annotation.id).toEqual('https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8'); | ||
expect(annotation.id).toEqual( | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/ee1fa103-cfbf-468c-8c87-d9afb7f3a4c8' | ||
); | ||
expect(annotation.body.TextualBody).toContain('@context'); | ||
@@ -36,7 +38,3 @@ expect(annotation.body.Dataset.jobTitle).toEqual('Web Developer'); | ||
expect( | ||
JSON.parse( | ||
JSON.stringify(annotation, null, 4), | ||
), | ||
).toEqual(source); | ||
expect(JSON.parse(JSON.stringify(annotation, null, 4))).toEqual(source); | ||
@@ -46,8 +44,4 @@ annotation.target.selector.x = 10000; | ||
expect( | ||
JSON.parse( | ||
JSON.stringify(annotation, null, 4), | ||
), | ||
).not.toEqual(source); | ||
expect(JSON.parse(JSON.stringify(annotation, null, 4))).not.toEqual(source); | ||
}); | ||
}); |
import Annotation from '../Annotation'; | ||
import { | ||
createAnnotationFromCaptureModelAndDraft, createExternalResourceAnnotationBody, | ||
createAnnotationFromCaptureModelAndDraft, | ||
createExternalResourceAnnotationBody, | ||
createHumanReadableAnnotationBody, | ||
@@ -16,3 +17,4 @@ } from '../mapping'; | ||
{ | ||
'@id': 'https://omeka.dlcs-ida.org/api/complete?class=entity:person', | ||
'@id': | ||
'https://omeka.dlcs-ida.org/api/complete?class=entity:person', | ||
'o:label': 'autocomplete', | ||
@@ -31,6 +33,3 @@ }, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -110,7 +109,11 @@ id: null, | ||
describe('lib/annotation/annotation#ida', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
@@ -120,21 +123,22 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'type': 'Annotation', | ||
'label': 'san pablo', | ||
'body': [ | ||
type: 'Annotation', | ||
label: 'san pablo', | ||
body: [ | ||
{ | ||
'source': 'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}, | ||
{ | ||
'value': 'san pablo', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'san pablo', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}, | ||
], | ||
'generator': 'http://omeka.dlcs-ida.org/api/item_sets/719', | ||
'target': 'http://manifest', | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'Tagging', | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/719', | ||
target: 'http://manifest', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'Tagging', | ||
}, | ||
@@ -146,9 +150,10 @@ }); | ||
const bodies = jsonify( | ||
createExternalResourceAnnotationBody(captureModel, draft), | ||
createExternalResourceAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'source': 'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://omeka.dlcs-ida.org/s/ida/page/topics/virtual:gpe/san+pablo', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}); | ||
@@ -159,11 +164,11 @@ }); | ||
const bodies = jsonify( | ||
createHumanReadableAnnotationBody(captureModel, draft), | ||
createHumanReadableAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'value': 'san pablo', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'san pablo', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}); | ||
}); | ||
}); |
@@ -70,6 +70,3 @@ import { | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -100,6 +97,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -130,6 +124,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -160,6 +151,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -190,6 +178,3 @@ id: 'oa:TextualBody', | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
bodyType: { | ||
@@ -239,6 +224,10 @@ id: 'oa:TextualBody', | ||
describe('lib/annotation/annotation#person-draft', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should parse label correctly', () => { | ||
const label = getLabelFromDraft(captureModel.metaData.labelParts, captureModel, draft); | ||
const label = getLabelFromDraft( | ||
captureModel.metaData.labelParts, | ||
captureModel, | ||
draft | ||
); | ||
expect(label).toEqual('John Doe'); | ||
@@ -248,5 +237,3 @@ }); | ||
it('should parse serialized annotation bodies correctly', () => { | ||
const body = jsonify( | ||
createSerializedAnnotationBody(captureModel, draft), | ||
); | ||
const body = jsonify(createSerializedAnnotationBody(captureModel, draft)); | ||
@@ -265,3 +252,4 @@ expect(body.type).toEqual('Dataset'); | ||
expect(body).toEqual({ | ||
value: '{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
value: | ||
'{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
type: 'Dataset', | ||
@@ -274,3 +262,7 @@ format: 'text/plain', | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
@@ -280,18 +272,18 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'label': 'John Doe', | ||
'type': 'Annotation', | ||
'body': { | ||
'format': 'text/plain', | ||
'type': 'Dataset', | ||
'value': '{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
label: 'John Doe', | ||
type: 'Annotation', | ||
body: { | ||
format: 'text/plain', | ||
type: 'Dataset', | ||
value: | ||
'{"@context":{"foaf:name":"http://xmlns.com/foaf/name","jobTitle":"https://schema.org/jobTitle","Description":"http://dublincore.org/documents/dcmi-terms/#terms-description"},"foaf:name":"John Doe","jobTitle":"Blacksmith","Description":"Description of the person","schema:Place":"Glasgow"}', | ||
}, | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
'generator': 'http://nlw-omeka.digtest.co.uk/api/item_sets/63', | ||
'target': 'http://manifest#xywh=5459,974,0,0', | ||
generator: 'http://nlw-omeka.digtest.co.uk/api/item_sets/63', | ||
target: 'http://manifest#xywh=5459,974,0,0', | ||
}); | ||
}); | ||
}); |
import Annotation from '../Annotation'; | ||
import { | ||
createAnnotationFromCaptureModelAndDraft, createExternalResourceAnnotationBody, | ||
createAnnotationFromCaptureModelAndDraft, | ||
createExternalResourceAnnotationBody, | ||
createHumanReadableAnnotationBody, | ||
@@ -26,6 +27,3 @@ } from '../mapping'; | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -83,3 +81,4 @@ id: null, | ||
label: 'Testing annotation', | ||
url: 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
url: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
}, | ||
@@ -111,7 +110,12 @@ }, | ||
describe('lib/annotation/annotation#tagging-draft', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
partOf: 'http://some-manifest', | ||
}) | ||
); | ||
@@ -121,22 +125,27 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'type': 'Annotation', | ||
'label': 'Testing annotation', | ||
'body': [ | ||
type: 'Annotation', | ||
label: 'Testing annotation', | ||
body: [ | ||
{ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}, | ||
{ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}, | ||
], | ||
'generator': 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
'target': 'http://manifest', | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
target: { | ||
'dcterms:isPartOf': 'http://some-manifest', | ||
type: 'Canvas', | ||
id: 'http://manifest', | ||
}, | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
}); | ||
@@ -147,9 +156,10 @@ }); | ||
const bodies = jsonify( | ||
createExternalResourceAnnotationBody(captureModel, draft), | ||
createExternalResourceAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'source': 'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
'type': 'SpecificResource', | ||
'format': 'application/json', | ||
source: | ||
'https://nlw-elucidate.digtest.co.uk/annotation/w3c/9e2391c545618f375e6d8e1bd705c936/66c62780-23d4-4d92-9017-8baa4f586ffb', | ||
type: 'SpecificResource', | ||
format: 'application/json', | ||
}); | ||
@@ -160,11 +170,11 @@ }); | ||
const bodies = jsonify( | ||
createHumanReadableAnnotationBody(captureModel, draft), | ||
createHumanReadableAnnotationBody(captureModel, draft) | ||
); | ||
expect(bodies.length).toBe(1); | ||
expect(bodies[0]).toEqual({ | ||
'value': 'Testing annotation', | ||
'type': 'Text', | ||
'format': 'text/plain', | ||
value: 'Testing annotation', | ||
type: 'Text', | ||
format: 'text/plain', | ||
}); | ||
}); | ||
}); |
@@ -6,14 +6,16 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping'; | ||
input: { | ||
'http://localhost:8888/api/items/1338': 'Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870\' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent\' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school\' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.' | ||
'http://localhost:8888/api/items/1338': | ||
"Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.", | ||
}, | ||
selectors: { | ||
'http://localhost:8888/api/items/1338': { | ||
type: null | ||
} | ||
type: null, | ||
}, | ||
}, | ||
template: 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
template: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
motivation: { | ||
id: 'oa:describing', | ||
label: 'describing', | ||
instance: 'describing' | ||
instance: 'describing', | ||
}, | ||
@@ -25,7 +27,9 @@ isPublishing: true, | ||
source: { | ||
template: 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
scope: 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
draft: '1ac1107c-ec0e-4ed5-b2fd-d6dbb97a3ad6' | ||
} | ||
} | ||
template: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
scope: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
draft: '1ac1107c-ec0e-4ed5-b2fd-d6dbb97a3ad6', | ||
}, | ||
}, | ||
}; | ||
@@ -123,3 +127,4 @@ | ||
vocabulary_id: '12', | ||
vocabulary_label: 'Crowds: Crowd Source Vocabulary for defining capture models.', | ||
vocabulary_label: | ||
'Crowds: Crowd Source Vocabulary for defining capture models.', | ||
}, | ||
@@ -172,7 +177,11 @@ schema: { | ||
describe('lib/annotation/annotation#transcription', () => { | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
@@ -182,15 +191,17 @@ | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
'body': { | ||
'format': 'text/plain', | ||
'purpose': 'describing', | ||
'type': 'TextualBody', | ||
'value': 'Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870\' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent\' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school\' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.', | ||
body: { | ||
format: 'text/plain', | ||
purpose: 'describing', | ||
type: 'TextualBody', | ||
value: | ||
"Santa Fe Indian School The Santa Fe Indian School was opened in November 1890 to provide off- reservation Industrial training for children from IndLan reservations in Arizona and New Mexico. Before this time the federal government had been slow to establish Indian schoo in the southwest. Until 1870 Indian education was almost entirely carried on by missionary groups Small day schools at the larger pueblos were established in the 1870' s, but toward the end of that decade BIA officials decided that day schools contributed 11ttle and should be replaced by government boarding schools, on the model of the Carlisle Indian School opened by Captain R. H. Pratt in 1879 at the old military post near Carlisle, PA The Santa Fe Indian School was one of a number of large boarding schools for Indians that were established in the southwest in the 10- 15 year period following 1879. In the same year that the Santa Fe school was founded, the Fort Moja chool in Arizona and the Carson School in Nevada were also opened stablishment in 1890, the Santa Fe Indian School had responsibility for the industrial training of Pueblo Indians in what is presently New Mexico and Arizona. In 1900 this responsibility was narrowed to the following pueblos in northe New Mexico: Cochi ti, Jemez, Nambe Pojoaque, San , Picuris, Ildefonso, San Juan, Santa Clara, Santo Domingo, Taos, Tesuque, and Za At the same time, however, the superintendent' s educe ional and other duties expanded. In addition to the Sante Fe the day schools were under the superintendent. He was also responsible for issuing supplies to Indians, leasing reser vation and, supervising the deposit of Indian money, deve loping the agricultural resources of the pueblos, and providing medical care. In 1914 the Superintendent of the Santa Fe Indian School was again responsible only for the school The Santa Fe School was not a reservation School and as such could receive students from any surrounding or remote tribe as long as room could be found for them. The Indian boarding school was an independent jurisdiction that normally reported directly to the Commissioner of Indian Affairs in Washington. Funds for the operation of the boarding schools were provided by Congress usually as a separate ten in the Indian appropriath acts The Santa Fe School recruited its pupils principally from the pueblos under the school' s jurisdiction. But it also taught, at any given time, about 100 students from other reser rations, the majority of them from the Navajo, Mescalero and Jicarilla, and, to a lesser extent, Pima reservations. The Idents were housed in dormitories under the supervision of a matron.", | ||
}, | ||
'generator': 'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
'label': 'unknown', | ||
'motivation': { 'id': 'oa:describing', 'label': 'describing' }, | ||
'target': 'http://manifest', | ||
'type': 'Annotation', | ||
generator: | ||
'http://localhost:8888/s/ida/annotation-studio/open/transcriber/1337', | ||
label: 'unknown', | ||
motivation: { id: 'oa:describing', label: 'describing' }, | ||
target: 'http://manifest', | ||
type: 'Annotation', | ||
}); | ||
}); | ||
}); |
@@ -6,13 +6,20 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping'; | ||
input: { | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381': 'my custom name of local tribunal', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382': '123', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431': 'Stephen', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384': '80', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381': | ||
'my custom name of local tribunal', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382': | ||
'123', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431': | ||
'Stephen', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384': | ||
'80', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/385': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386': 'Blacksmith', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387': 'Digirati', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386': | ||
'Blacksmith', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387': | ||
'Digirati', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/388': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/389': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/390': null, | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391': 'Temporary', | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391': | ||
'Temporary', | ||
}, | ||
@@ -150,3 +157,4 @@ selectors: { | ||
}, | ||
template: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
template: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
motivation: { | ||
@@ -162,4 +170,6 @@ id: 'oa:tagging', | ||
source: { | ||
template: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
scope: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/538', | ||
template: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
scope: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/538', | ||
draft: 'e3af9515-fe1f-440c-add5-a4573d2121c7', | ||
@@ -174,10 +184,8 @@ }, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/381', | ||
inputType: 'madoc:dropdown', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -218,10 +226,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/382', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -262,10 +268,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/431', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -286,3 +290,4 @@ id: null, | ||
title: 'Name', | ||
description: 'Name (in full) of man in respect of whom the application is made', | ||
description: | ||
'Name (in full) of man in respect of whom the application is made', | ||
conformsTo: { | ||
@@ -307,10 +312,8 @@ id: 'http://xmlns.com/foaf/name', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/384', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -331,3 +334,4 @@ id: null, | ||
title: 'Age', | ||
description: 'Age of man (in respect of whom the application is being made)', | ||
description: | ||
'Age of man (in respect of whom the application is being made)', | ||
conformsTo: { | ||
@@ -352,10 +356,8 @@ id: 'http://xmlns.com/foaf/spec/#term_age', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/385', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/385', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -376,3 +378,4 @@ id: null, | ||
title: 'Address', | ||
description: 'Address (in full) of man in respect of whom the application is made', | ||
description: | ||
'Address (in full) of man in respect of whom the application is made', | ||
conformsTo: { | ||
@@ -397,10 +400,8 @@ id: 'schema:address', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/386', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -421,3 +422,4 @@ id: null, | ||
title: 'Occupation', | ||
description: 'Occupation, profession, or business of man on behalf of whom the application is made', | ||
description: | ||
'Occupation, profession, or business of man on behalf of whom the application is made', | ||
conformsTo: { | ||
@@ -442,10 +444,8 @@ id: 'https://schema.org/jobTitle', | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/387', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -486,10 +486,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/388', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/388', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -530,10 +528,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/389', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/389', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -574,10 +570,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/390', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/390', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -618,10 +612,8 @@ id: null, | ||
type: 'field', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/items/391', | ||
inputType: 'madoc:textbox', | ||
annotationMetaData: {}, | ||
omekaMetaData: { | ||
type: [ | ||
'o:Item', | ||
'dctype:InteractiveResource', | ||
], | ||
type: ['o:Item', 'dctype:InteractiveResource'], | ||
group: { | ||
@@ -642,3 +634,4 @@ id: null, | ||
title: 'Nature of Application', | ||
description: 'Nature of Application, e.g. Conditional, Absolute, Temporary.', | ||
description: | ||
'Nature of Application, e.g. Conditional, Absolute, Temporary.', | ||
conformsTo: { | ||
@@ -663,3 +656,4 @@ id: 'http://ndl.go.jp/dcndl/terms/transcription', | ||
type: 'captureModel', | ||
id: 'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
id: | ||
'http://ec2-54-194-185-179.eu-west-1.compute.amazonaws.com:8100/api/item_sets/392', | ||
title: 'R. 41 : Page 1 [pre mid 1916]', | ||
@@ -683,28 +677,29 @@ description: 'First page of beige R41 form, pre mid-1916.', | ||
describe('lib/annotation/annotation#ww1tribunal', () => { | ||
const jsonify = t => JSON.parse(JSON.stringify(t)); | ||
const jsonify = (t) => JSON.parse(JSON.stringify(t)); | ||
it('should create annotation', () => { | ||
const annotation = jsonify(createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft)); | ||
const [ | ||
nameAnnotation, | ||
] = annotation; | ||
const annotation = jsonify( | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
}) | ||
); | ||
const [nameAnnotation] = annotation; | ||
expect(annotation.length).toEqual(7); | ||
expect(nameAnnotation).toEqual({ | ||
"@context": "http://www.w3.org/ns/anno.jsonld", | ||
'@context': 'http://www.w3.org/ns/anno.jsonld', | ||
type: 'Annotation', | ||
label: 'my custom name of local tribunal', | ||
body: | ||
{ | ||
value: '{"@context":{"Title":"http://dublincore.org/documents/dcmi-terms/#terms-title"},"schema:AdministrativeArea":"my custom name of local tribunal","Title":"Name of Local Tribunal"}', | ||
type: 'Dataset', | ||
purpose: 'oa:identifying', | ||
format: 'text/plain', | ||
}, | ||
body: { | ||
value: | ||
'{"@context":{"Title":"http://dublincore.org/documents/dcmi-terms/#terms-title"},"schema:AdministrativeArea":"my custom name of local tribunal","Title":"Name of Local Tribunal"}', | ||
type: 'Dataset', | ||
purpose: 'oa:identifying', | ||
format: 'text/plain', | ||
}, | ||
target: 'http://manifest#xywh=2320,444,840,230', | ||
}); | ||
}); | ||
}); |
@@ -25,3 +25,2 @@ 'use strict'; | ||
var Annotation = function () { | ||
// Serialized fields | ||
@@ -28,0 +27,0 @@ function Annotation(id, label, body, target, motivation, generator) { |
@@ -6,2 +6,6 @@ 'use strict'; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
@@ -26,3 +30,3 @@ | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) { | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) { | ||
(0, _classCallCheck3.default)(this, AnnotationSelector); | ||
@@ -40,9 +44,9 @@ | ||
this.textDirection = textDirection; | ||
this.selector = AnnotationSelector.parseTarget(id, scale, selector); | ||
this.selector = AnnotationSelector.parseTarget(id, scale, selector, partOf); | ||
} | ||
AnnotationSelector.fromTarget = function fromTarget(target, selector) { | ||
AnnotationSelector.fromTarget = function fromTarget(target, selector, partOf) { | ||
var annotationSelector = new AnnotationSelector(); | ||
annotationSelector.source = target; | ||
annotationSelector.selector = selector; | ||
annotationSelector.selector = AnnotationSelector.parseTarget(selector, 1, null, partOf); | ||
return annotationSelector; | ||
@@ -58,5 +62,9 @@ }; | ||
if (text['dcterms:isPartOf']) { | ||
text.partOf = text['dcterms:isPartOf']; | ||
} | ||
// https://www.w3.org/TR/annotation-model/#bodies-and-targets | ||
if (text.id) { | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection); | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text.partOf); | ||
} | ||
@@ -66,3 +74,3 @@ | ||
if (text.source) { | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector); | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text.partOf); | ||
} | ||
@@ -77,2 +85,3 @@ | ||
var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
@@ -106,9 +115,11 @@ var toParse = source; | ||
return source.split('#')[0]; | ||
} | ||
}, | ||
partOf: partOf | ||
}; | ||
} | ||
return source; | ||
return (0, _extends3.default)({}, source, { partOf: partOf }); | ||
}; | ||
AnnotationSelector.prototype.toJSON = function toJSON() { | ||
AnnotationSelector.prototype.getStringSelector = function getStringSelector() { | ||
if (!this.selector || this.selector.x === null || isNaN(Math.floor(this.selector.x)) || this.selector.y === null || isNaN(Math.floor(this.selector.y))) { | ||
@@ -125,2 +136,16 @@ return this.source; | ||
AnnotationSelector.prototype.toJSON = function toJSON() { | ||
// If we have a part of, we can't reduce to string. | ||
if (this.selector && this.selector.partOf) { | ||
// This is the target field. | ||
return { | ||
id: this.getStringSelector(), | ||
type: 'Canvas', | ||
'dcterms:isPartOf': this.selector.partOf | ||
}; | ||
} | ||
return this.getStringSelector(); | ||
}; | ||
AnnotationSelector.prototype.toString = function toString() { | ||
@@ -127,0 +152,0 @@ return this.id; |
@@ -48,5 +48,5 @@ 'use strict'; | ||
// Draft value is {id: 'http://..'} | ||
var FIELD_TYPES_THAT_ARE_ENTITIES = exports.FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
var FIELD_TYPES_THAT_ARE_ENTITIES = exports.FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
// Draft value is {label: 'human readable'} | ||
var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = exports.FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = exports.FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
@@ -168,3 +168,2 @@ function createCombinedAnnotationBody(captureModel, draft) { | ||
function createExternalResourceAnnotationBody(captureModel, draft) { | ||
var fieldIds = Object.keys(draft.input); | ||
@@ -197,5 +196,4 @@ var fields = getModelFields(fieldIds, captureModel.fields); | ||
}).reduce(function (state, field) { | ||
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && field.inputType === 'madoc:textarea') { | ||
var body = new _AnnotationBody2.default(null, draft.input[field.id], 'text/plain', 'TextualBody'); | ||
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && (field.inputType === 'madoc:textarea' || field.inputType === 'madoc:htmlfield')) { | ||
var body = new _AnnotationBody2.default(null, draft.input[field.id], field.inputType === 'madoc:textarea' ? 'text/plain' : 'text/html', 'TextualBody'); | ||
body.purpose = field.omekaMetaData.purpose ? field.omekaMetaData.purpose.label : null; | ||
@@ -243,3 +241,6 @@ state.push(body); | ||
var captureModelField = captureModel.fields[field.id]; | ||
var captureModelField = Object.values(captureModel.fields).find(function (_ref2) { | ||
var id = _ref2.id; | ||
return id === field.id; | ||
}); | ||
if (!(captureModelField && (captureModelField.metaData || captureModelField.omekaMeta))) { | ||
@@ -331,3 +332,9 @@ console.warn('createMultipleAnnotations', 'Looks like you have set derivedAnnoCombine to "False" without selectors on the fields, are you sure this is correct?', captureModelField); | ||
function createAnnotationFromCaptureModelAndDraft(target, captureModel, draft, customDraftSelector) { | ||
function createAnnotationFromCaptureModelAndDraft(_ref3) { | ||
var target = _ref3.target, | ||
captureModel = _ref3.captureModel, | ||
draft = _ref3.draft, | ||
customDraftSelector = _ref3.customDraftSelector, | ||
partOf = _ref3.partOf; | ||
var bodies = []; | ||
@@ -394,3 +401,3 @@ var label = 'unknown'; | ||
return new _Annotation2.default(null, label, _AnnotationBodyList2.default.fromJsonLD(bodies), _AnnotationSelector2.default.fromTarget(target, draftSelector), motivation, generator); | ||
return new _Annotation2.default(null, label, _AnnotationBodyList2.default.fromJsonLD(bodies), _AnnotationSelector2.default.fromTarget(target, draftSelector, partOf), motivation, generator); | ||
} |
@@ -6,2 +6,6 @@ 'use strict'; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
@@ -22,3 +26,3 @@ | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) { | ||
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) { | ||
(0, _classCallCheck3.default)(this, AnnotationSelector); | ||
@@ -38,3 +42,3 @@ | ||
this.textDirection = textDirection; | ||
this.target = AnnotationSelector.parseTarget(id, scale, selector); | ||
this.target = AnnotationSelector.parseTarget(id, scale, selector, partOf); | ||
} | ||
@@ -51,3 +55,3 @@ | ||
if (text.id) { | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection); | ||
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text['dcterms:isPartOf']); | ||
} | ||
@@ -57,3 +61,3 @@ | ||
if (text.source) { | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector); | ||
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text['dcterms:isPartOf']); | ||
} | ||
@@ -68,2 +72,3 @@ | ||
var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
@@ -85,2 +90,3 @@ var toParse = source; | ||
height: parseInt(match[5], 10) * scale, | ||
partOf: partOf, | ||
toString: function toString() { | ||
@@ -92,3 +98,3 @@ // @todo maybe something else? | ||
} | ||
return source; | ||
return (0, _extends3.default)({}, source, { partOf: partOf }); | ||
}; | ||
@@ -95,0 +101,0 @@ |
@@ -27,4 +27,4 @@ 'use strict'; | ||
var getAllAnnotationsFromCollection = exports.getAllAnnotationsFromCollection = function () { | ||
var _ref = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref2, item, collection, _item; | ||
var _ref2 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref3, item, collection, _item; | ||
@@ -61,3 +61,3 @@ return _regenerator2.default.wrap(function _callee$(_context) { | ||
case 7: | ||
_ref2 = _iterator[_i++]; | ||
_ref3 = _iterator[_i++]; | ||
_context.next = 14; | ||
@@ -77,6 +77,6 @@ break; | ||
case 13: | ||
_ref2 = _i.value; | ||
_ref3 = _i.value; | ||
case 14: | ||
item = _ref2; | ||
item = _ref3; | ||
_context.next = 17; | ||
@@ -129,4 +129,4 @@ return item; | ||
return function getAllAnnotationsFromCollection(_x4) { | ||
return _ref.apply(this, arguments); | ||
return function getAllAnnotationsFromCollection(_x5) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
@@ -136,4 +136,4 @@ }(); | ||
var fetchPageCollection = function () { | ||
var _ref3 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref4, item; | ||
var _ref4 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref5, item; | ||
@@ -171,3 +171,3 @@ return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
case 8: | ||
_ref4 = _iterator2[_i2++]; | ||
_ref5 = _iterator2[_i2++]; | ||
_context2.next = 15; | ||
@@ -187,6 +187,6 @@ break; | ||
case 14: | ||
_ref4 = _i2.value; | ||
_ref5 = _i2.value; | ||
case 15: | ||
item = _ref4; | ||
item = _ref5; | ||
_context2.next = 18; | ||
@@ -215,4 +215,4 @@ return item; | ||
return function fetchPageCollection(_x5) { | ||
return _ref3.apply(this, arguments); | ||
return function fetchPageCollection(_x6) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
@@ -252,2 +252,5 @@ }(); | ||
var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}, | ||
withoutCredentials = _ref.withoutCredentials; | ||
return fetch(uri, { | ||
@@ -257,4 +260,3 @@ method: method, | ||
body: JSON.stringify(body), | ||
credentials: process.env.NODE_ENV === 'production' ? 'include' : null, | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit', | ||
redirect: 'follow' | ||
@@ -273,3 +275,8 @@ }).then(function (response) { | ||
function get(uri, body) { | ||
return makeRequest('GET', uri, body); | ||
try { | ||
return makeRequest('GET', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('GET', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -280,3 +287,10 @@ | ||
return makeRequest('POST', uri, body, headers); | ||
try { | ||
return makeRequest('POST', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('POST', uri, body, headers, { | ||
withoutCredentials: true | ||
}); | ||
} | ||
} | ||
@@ -287,3 +301,8 @@ | ||
return makeRequest('PUT', uri, body, headers); | ||
try { | ||
return makeRequest('PUT', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('PUT', uri, body, headers, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -290,0 +309,0 @@ |
@@ -53,3 +53,6 @@ 'use strict'; | ||
if (showUntilQueue[action.type]) { | ||
store.dispatch({ type: 'SHOW_UNTIL_REMOVED', payload: { names: showUntilQueue[action.type] } }); | ||
store.dispatch({ | ||
type: 'SHOW_UNTIL_REMOVED', | ||
payload: { names: showUntilQueue[action.type] } | ||
}); | ||
showUntilQueue[action.type] = []; | ||
@@ -56,0 +59,0 @@ } |
@@ -45,4 +45,4 @@ "use strict"; | ||
var drafts = state.drafts.list; | ||
return Object.values(drafts).reduce(function (state, draft) { | ||
if (state) return state; | ||
return Object.values(drafts).reduce(function (found, draft) { | ||
if (found) return found; | ||
if (draft.id !== id && draft.fingerprint.identity === identity) { | ||
@@ -49,0 +49,0 @@ return draft; |
@@ -19,2 +19,4 @@ 'use strict'; | ||
var _utility = require('../utility'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -35,6 +37,18 @@ | ||
function getCanvasFromManifest(manifest, canvasId) { | ||
if (!(manifest || manifest.sequences || manifest.sequences[0] || manifest.sequences[0].canvases)) { | ||
if (!manifest) { | ||
return null; | ||
} | ||
var canvases = manifest.sequences[0].canvases; | ||
var canvases = null; | ||
var idProperty = null; | ||
try { | ||
if ((0, _utility.isV3Manifest)(manifest)) { | ||
canvases = manifest.items; | ||
idProperty = 'id'; | ||
} else { | ||
canvases = manifest.sequences[0].canvases; | ||
idProperty = '@id'; | ||
} | ||
} catch (ex) { | ||
return null; | ||
} | ||
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
@@ -54,3 +68,3 @@ var _ref; | ||
if (canvas['@id'] === canvasId) { | ||
if (canvas[idProperty] === canvasId) { | ||
return canvas; | ||
@@ -57,0 +71,0 @@ } |
@@ -11,3 +11,7 @@ "use strict"; | ||
return Object.keys(state.help[type]).map(function (key) { | ||
return { type: type, key: key, content: state.help[type][key] }; | ||
return { | ||
type: type, | ||
key: key, | ||
content: state.help[type][key] | ||
}; | ||
}); | ||
@@ -14,0 +18,0 @@ } |
@@ -10,2 +10,5 @@ 'use strict'; | ||
exports.allManifests = allManifests; | ||
var _utility = require('../utility'); | ||
function currentManifest(state) { | ||
@@ -16,13 +19,18 @@ return manifestById(state, state.manifest.current); | ||
function getImageServiceFromCanvas(canvas) { | ||
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) { | ||
return canvas.images[0].resource.service['@id'] + '/info.json'; | ||
} | ||
if (canvas.hasOwnProperty('type') && canvas.type === 'Canvas') { | ||
if (canvas.items && canvas.items[0] && canvas.items[0].items && canvas.items[0].items[0] && canvas.items[0].items[0].body && canvas.items[0].items[0].body.service && canvas.items[0].items[0].body.service[0] && canvas.items[0].items[0].body.service[0].id) { | ||
return canvas.items[0].items[0].body.service[0].id + '/info.json'; | ||
} | ||
} else { | ||
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) { | ||
return canvas.images[0].resource.service['@id'] + '/info.json'; | ||
} | ||
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) { | ||
return canvas.thumbnail.service['@id'] + '/info.json'; | ||
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) { | ||
return canvas.thumbnail.service['@id'] + '/info.json'; | ||
} | ||
if (canvas.thumbnail && canvas.thumbnail['@id']) { | ||
return canvas.thumbnail['@id']; | ||
} | ||
} | ||
if (canvas.thumbnail && canvas.thumbnail['@id']) { | ||
return canvas.thumbnail['@id']; | ||
} | ||
return null; | ||
@@ -43,6 +51,18 @@ } | ||
var canvasId = state.manifest.currentCanvas; | ||
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) { | ||
return null; | ||
var canvases = null; | ||
var idProperty = null; | ||
if ((0, _utility.isV3Manifest)(manifest)) { | ||
if (!manifest.hasOwnProperty('items')) { | ||
return null; | ||
} | ||
canvases = manifest.items; | ||
idProperty = 'id'; | ||
} else { | ||
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) { | ||
return null; | ||
} | ||
canvases = manifest.sequences[0].canvases; | ||
idProperty = '@id'; | ||
} | ||
var canvases = manifest.sequences[0].canvases; | ||
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
@@ -62,3 +82,3 @@ var _ref; | ||
if (canvas['@id'] === canvasId) { | ||
if (canvas[idProperty] === canvasId) { | ||
return canvas; | ||
@@ -65,0 +85,0 @@ } |
@@ -50,7 +50,7 @@ 'use strict'; | ||
var draftDefaultKeys = Object.keys(draftDefaults); | ||
var filledInputs = Object.keys(input).reduce(function (input, url) { | ||
var filledInputs = Object.keys(input).reduce(function (allInputs, url) { | ||
if (fields && fields[url] && fields[url].metaData && fields[url].metaData.conformsTo && fields[url].metaData.conformsTo.label && draftDefaultKeys.indexOf(fields[url].metaData.conformsTo.label) !== -1) { | ||
input[url] = draftDefaults[fields[url].metaData.conformsTo.label]; | ||
allInputs[url] = draftDefaults[fields[url].metaData.conformsTo.label]; | ||
} | ||
return input; | ||
return allInputs; | ||
}, input); | ||
@@ -57,0 +57,0 @@ |
@@ -85,3 +85,5 @@ 'use strict'; | ||
list: (_list5 = {}, _list5[action.payload.id] = { | ||
selector: { $set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector } | ||
selector: { | ||
$set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector | ||
} | ||
}, _list5) | ||
@@ -165,3 +167,2 @@ }); | ||
}); | ||
} | ||
@@ -168,0 +169,0 @@ return state; |
@@ -56,3 +56,5 @@ 'use strict'; | ||
collection: { | ||
$set: Object.assign({}, action.payload.collection, { loading: false }) | ||
$set: Object.assign({}, action.payload.collection, { | ||
loading: false | ||
}) | ||
} | ||
@@ -59,0 +61,0 @@ }); |
@@ -32,3 +32,2 @@ 'use strict'; | ||
switch (action.type) { | ||
@@ -35,0 +34,0 @@ case _help.HELP_INFO_ADD: |
@@ -32,5 +32,3 @@ 'use strict'; | ||
switch (action.type) { | ||
case _manifest.MANIFEST_ADD: | ||
@@ -37,0 +35,0 @@ return (0, _immutabilityHelper2.default)(state, { |
@@ -48,3 +48,2 @@ 'use strict'; | ||
switch (action.type) { | ||
case _resources.RESOURCE_NAV_FORWARD: | ||
@@ -65,5 +64,7 @@ if (!state.currentPaths[action.payload.tree]) { | ||
return (0, _immutabilityHelper2.default)(state, { | ||
currentPaths: (_currentPaths2 = {}, _currentPaths2[action.payload.tree] = { $apply: function $apply(path) { | ||
currentPaths: (_currentPaths2 = {}, _currentPaths2[action.payload.tree] = { | ||
$apply: function $apply(path) { | ||
return path.length > 0 ? path.slice(0, -1) : []; | ||
} }, _currentPaths2) | ||
} | ||
}, _currentPaths2) | ||
}); | ||
@@ -90,3 +91,5 @@ | ||
return (0, _immutabilityHelper2.default)(state, { | ||
list: (_list = {}, _list[action.payload.id] = { $set: (0, _extends3.default)({}, captureModelDefaults, action.payload.resource) }, _list) | ||
list: (_list = {}, _list[action.payload.id] = { | ||
$set: (0, _extends3.default)({}, captureModelDefaults, action.payload.resource) | ||
}, _list) | ||
}); | ||
@@ -93,0 +96,0 @@ |
@@ -28,3 +28,2 @@ 'use strict'; | ||
switch (action.type) { | ||
@@ -57,3 +56,2 @@ case _selectors.SELECTOR_SET_AVAILABLE: | ||
}); | ||
} | ||
@@ -60,0 +58,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
exports.selectorCompat = selectorCompat; | ||
exports.isV3Manifest = isV3Manifest; | ||
var SHOW_LOGS = false; | ||
@@ -57,2 +58,22 @@ var SHOW_WARNINGS = false; | ||
return item; | ||
} | ||
var CONTEXT_V3 = 'http://iiif.io/api/presentation/3/context.json'; | ||
function isV3Manifest(manifest) { | ||
if (!manifest) { | ||
return false; | ||
} | ||
var context = manifest['@context']; | ||
if (!context) { | ||
return false; | ||
} | ||
switch (context.constructor) { | ||
case Array: | ||
return context.includes(CONTEXT_V3); | ||
case String: | ||
return context === CONTEXT_V3; | ||
default: | ||
return false; | ||
} | ||
} |
{ | ||
"name": "@annotation-studio/redux", | ||
"version": "1.0.0-next.42ca5e47", | ||
"version": "1.0.0-next.51ce670e", | ||
"description": "Describe annotation-redux here", | ||
@@ -38,3 +38,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@fesk/test-environment": "^1.0.0-next.42ca5e47", | ||
"@fesk/test-environment": "1.0.0-next.51ce670e", | ||
"babel-jest": "^20.0.3", | ||
@@ -46,7 +46,9 @@ "babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"cross-spawn": "^6.0.5", | ||
"jest": "^20.0.0", | ||
"fetch-mock": "^6.5.1", | ||
"jest": "^23.6.0", | ||
"nwb": "^0.21.5", | ||
"nwb-watch": "^1.0.0-next.42ca5e47", | ||
"nwb-watch": "1.0.0-next.51ce670e", | ||
"react-intl": "^2.2.2", | ||
"react-intl-redux": "^0.7.0", | ||
"redux-mock-store": "^1.5.3", | ||
"webpack-cli": "^2.0.11" | ||
@@ -53,0 +55,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
342406
104
9117
9
15