@annotation-studio/redux
Advanced tools
Comparing version 1.0.0-pr.f0457139 to 1.0.0-pr.f4483907
@@ -11,2 +11,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
import { isSelecting, getCurrentSelector } from '../query/selectorQuery'; | ||
import { reset, moveForward } from './resources'; | ||
@@ -45,3 +46,3 @@ export var DRAFT_CREATE = 'DRAFT_CREATE'; | ||
return annotation.body.purpose === 'editing'; | ||
}; | ||
} | ||
@@ -93,3 +94,7 @@ export function createDraft(scope, _ref) { | ||
} else { | ||
dispatch(chooseSelector('WholeCanvasSelector', { template: currentTemplate.id, scope: scope, draft: draftId })); | ||
dispatch(chooseSelector('WholeCanvasSelector', { | ||
template: currentTemplate.id, | ||
scope: scope, | ||
draft: draftId | ||
})); | ||
} | ||
@@ -102,9 +107,6 @@ } | ||
// 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; | ||
} | ||
@@ -200,3 +202,9 @@ | ||
motivation: motivation, | ||
fingerprint: createFingerprint({ scope: scope, path: path, created: created, creator: 'you', partOf: partOf }) | ||
fingerprint: createFingerprint({ | ||
scope: scope, | ||
path: path, | ||
created: created, | ||
creator: 'you', | ||
partOf: partOf | ||
}) | ||
} | ||
@@ -273,3 +281,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) | ||
} | ||
}; | ||
} | ||
@@ -357,3 +371,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 }) } | ||
}); | ||
}; | ||
@@ -365,6 +382,40 @@ } | ||
markDraftAs(id, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ)(dispatch, getState); | ||
var state = getState(); | ||
var draft = getDraftById(state, id); | ||
// Cancel any previous selectors. | ||
dispatch(cancelSelector()); | ||
// Select draft. | ||
dispatch({ type: DRAFT_SELECT, payload: { id: id, scope: scope } }); | ||
// Update selector. | ||
if (draft.isPreviewing === false && draft.selector && draft.selector.type && draft.selector.type.toLowerCase() !== 'wholecanvasselector') { | ||
dispatch(editCurrentDraftSelector(scope)); | ||
} | ||
}; | ||
} | ||
export function selectDraftAndNavigate(id) { | ||
return function (dispatch, getState) { | ||
var state = getState(); | ||
var draft = getDraftById(state, id); | ||
// Error. | ||
if (!draft) { | ||
return null; | ||
} | ||
// Go to path. | ||
if (draft.fingerprint.path.length) { | ||
dispatch(reset(draft.fingerprint.scope)); | ||
draft.fingerprint.path.forEach(function (forward) { | ||
return dispatch(moveForward(draft.fingerprint.scope, forward)); | ||
}); | ||
} | ||
// select draft. | ||
dispatch(selectDraft(draft.fingerprint.scope, id)); | ||
}; | ||
} | ||
export function previewDraft(id) { | ||
@@ -371,0 +422,0 @@ return function (dispatch, getState) { |
@@ -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) { |
@@ -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 } }; |
@@ -0,2 +1,4 @@ | ||
import _regeneratorRuntime from 'babel-runtime/regenerator'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator'; | ||
import { addSelectorToDraft, addSelectorToDraftFieldFromViewer, addSelectorToDraftFromViewer, discardCurrentDraft, removeSelectorFromDraft, removeSelectorFromDraftField } from './drafts'; | ||
@@ -20,2 +22,4 @@ import { getCurrentDraft, getDraftById } from '../query/draftQuery'; | ||
export function chooseSelector(type, source, defaults, done) { | ||
var _this = this; | ||
var immediate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
@@ -38,20 +42,47 @@ | ||
} | ||
return withViewer(function (Canvas, dispatch) { | ||
var _Canvas$createViewpor = Canvas.createViewportPoint(defaults.x, defaults.y), | ||
x = _Canvas$createViewpor.x, | ||
y = _Canvas$createViewpor.y; | ||
return withViewer(function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(Canvas, dispatch) { | ||
var _Canvas$createViewpor, x, y, _Canvas$createViewpor2, maxX, maxY; | ||
var _Canvas$createViewpor2 = Canvas.createViewportPoint(defaults.x + defaults.width, defaults.y + defaults.height), | ||
maxX = _Canvas$createViewpor2.x, | ||
maxY = _Canvas$createViewpor2.y; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return Canvas.viewerReady; | ||
dispatch({ | ||
type: SELECTOR_CHOOSE, | ||
meta: { fromViewer: true }, | ||
payload: { type: type, source: source, defaults: selectorCompat(_extends({}, defaults, { x: x, y: y, width: maxX - x, height: maxY - y })) } | ||
}); | ||
if (done) { | ||
done(); | ||
} | ||
}); | ||
case 2: | ||
_Canvas$createViewpor = Canvas.createViewportPoint(defaults.x, defaults.y), x = _Canvas$createViewpor.x, y = _Canvas$createViewpor.y; | ||
_Canvas$createViewpor2 = Canvas.createViewportPoint(defaults.x + defaults.width, defaults.y + defaults.height), maxX = _Canvas$createViewpor2.x, maxY = _Canvas$createViewpor2.y; | ||
dispatch({ | ||
type: SELECTOR_CHOOSE, | ||
meta: { fromViewer: true }, | ||
payload: { | ||
type: type, | ||
source: source, | ||
defaults: selectorCompat(_extends({}, defaults, { | ||
x: x, | ||
y: y, | ||
width: maxX - x, | ||
height: maxY - y | ||
})) | ||
} | ||
}); | ||
if (done) { | ||
done(); | ||
} | ||
case 6: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, _this); | ||
})); | ||
return function (_x2, _x3) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()); | ||
} | ||
@@ -108,2 +139,3 @@ | ||
if (selector.type === 'WholeCanvasSelector') { | ||
console.warn('WARNING: `editCurrentDraftSelector` should never be called when whole canvas selector is chosen'); | ||
return dispatch(discardCurrentDraft(scope)); | ||
@@ -110,0 +142,0 @@ } |
@@ -14,3 +14,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
import { richAnnotationList } from './query/elucidateQuery'; | ||
import { currentManifest } from './query/manifestQuery'; | ||
import { currentManifest, currentCanvas } from './query/manifestQuery'; | ||
import { setViewer, withViewer } from './actions/viewer'; | ||
@@ -51,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 | ||
})); | ||
}); | ||
@@ -66,2 +70,4 @@ return selectors; | ||
currentSelector: currentSelector, | ||
elucidateServer: props.elucidateServer ? props.elucidateServer : state.elucidate ? state.elucidate.server : null, | ||
currentCanvas: currentCanvas(state), | ||
currentDraft: currentDraft, | ||
@@ -68,0 +74,0 @@ currentDrafts: state.drafts.currentDrafts, |
@@ -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({ target: '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', | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,2 @@ import AnnotationSelector from '../AnnotationSelector'; | ||
it('should retain partOf', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -26,2 +25,3 @@ id: 'http://canvas/#xywh=1,2,3,4', | ||
id: 'http://canvas/#xywh=1,2,3,4', | ||
type: 'Canvas', | ||
'dcterms:isPartOf': 'http://manifest', | ||
@@ -32,3 +32,2 @@ }); | ||
it('should ignore partOf if not found', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -35,0 +34,0 @@ id: 'http://canvas/#xywh=1,2,3,4', |
@@ -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({ target: '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({ target: 'http://manifest', captureModel, draft, partOf: 'http://some-manifest' }), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
partOf: 'http://some-manifest', | ||
}) | ||
); | ||
@@ -121,24 +125,26 @@ | ||
'@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': { | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
target: { | ||
'dcterms:isPartOf': 'http://some-manifest', | ||
'id': 'http://manifest', | ||
type: 'Canvas', | ||
id: 'http://manifest', | ||
}, | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
@@ -150,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', | ||
}); | ||
@@ -163,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({ target: '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({ target: '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) { |
@@ -123,2 +123,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
id: this.getStringSelector(), | ||
type: 'Canvas', | ||
'dcterms:isPartOf': this.selector.partOf | ||
@@ -125,0 +126,0 @@ }; |
@@ -129,3 +129,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
export function createExternalResourceAnnotationBody(captureModel, draft) { | ||
var fieldIds = Object.keys(draft.input); | ||
@@ -158,5 +157,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; | ||
@@ -163,0 +161,0 @@ state.push(body); |
@@ -110,3 +110,3 @@ import _asyncIterator from 'babel-runtime/helpers/asyncIterator'; | ||
body: JSON.stringify(body), | ||
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null, | ||
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit', | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
@@ -138,6 +138,8 @@ redirect: 'follow' | ||
try { | ||
return makeRequest('POST', uri, body); | ||
return makeRequest('POST', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('POST', uri, body, { withoutCredentials: true }); | ||
return makeRequest('POST', uri, body, headers, { | ||
withoutCredentials: true | ||
}); | ||
} | ||
@@ -150,6 +152,6 @@ } | ||
try { | ||
return makeRequest('PUT', uri, body); | ||
return makeRequest('PUT', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('PUT', uri, body, { withoutCredentials: true }); | ||
return makeRequest('PUT', uri, body, headers, { withoutCredentials: true }); | ||
} | ||
@@ -156,0 +158,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; | ||
} | ||
} |
@@ -41,2 +41,3 @@ 'use strict'; | ||
exports.selectDraft = selectDraft; | ||
exports.selectDraftAndNavigate = selectDraftAndNavigate; | ||
exports.previewDraft = previewDraft; | ||
@@ -65,2 +66,4 @@ exports.unpreviewDraft = unpreviewDraft; | ||
var _resources = require('./resources'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -100,3 +103,3 @@ | ||
return annotation.body.purpose === 'editing'; | ||
}; | ||
} | ||
@@ -148,3 +151,7 @@ function createDraft(scope, _ref) { | ||
} 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 | ||
})); | ||
} | ||
@@ -157,9 +164,6 @@ } | ||
// 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; | ||
} | ||
@@ -255,3 +259,9 @@ | ||
motivation: motivation, | ||
fingerprint: createFingerprint({ scope: scope, path: path, created: created, creator: 'you', partOf: partOf }) | ||
fingerprint: createFingerprint({ | ||
scope: scope, | ||
path: path, | ||
created: created, | ||
creator: 'you', | ||
partOf: partOf | ||
}) | ||
} | ||
@@ -328,3 +338,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) | ||
} | ||
}; | ||
} | ||
@@ -412,3 +428,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 }) } | ||
}); | ||
}; | ||
@@ -420,6 +439,40 @@ } | ||
markDraftAs(id, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ)(dispatch, getState); | ||
var state = getState(); | ||
var draft = (0, _draftQuery.getDraftById)(state, id); | ||
// Cancel any previous selectors. | ||
dispatch((0, _selectors2.cancelSelector)()); | ||
// Select draft. | ||
dispatch({ type: DRAFT_SELECT, payload: { id: id, scope: scope } }); | ||
// Update selector. | ||
if (draft.isPreviewing === false && draft.selector && draft.selector.type && draft.selector.type.toLowerCase() !== 'wholecanvasselector') { | ||
dispatch((0, _selectors2.editCurrentDraftSelector)(scope)); | ||
} | ||
}; | ||
} | ||
function selectDraftAndNavigate(id) { | ||
return function (dispatch, getState) { | ||
var state = getState(); | ||
var draft = (0, _draftQuery.getDraftById)(state, id); | ||
// Error. | ||
if (!draft) { | ||
return null; | ||
} | ||
// Go to path. | ||
if (draft.fingerprint.path.length) { | ||
dispatch((0, _resources.reset)(draft.fingerprint.scope)); | ||
draft.fingerprint.path.forEach(function (forward) { | ||
return dispatch((0, _resources.moveForward)(draft.fingerprint.scope, forward)); | ||
}); | ||
} | ||
// select draft. | ||
dispatch(selectDraft(draft.fingerprint.scope, id)); | ||
}; | ||
} | ||
function previewDraft(id) { | ||
@@ -426,0 +479,0 @@ return function (dispatch, getState) { |
@@ -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) { |
@@ -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 } }; |
@@ -6,2 +6,6 @@ 'use strict'; | ||
var _regenerator = require('babel-runtime/regenerator'); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
@@ -11,2 +15,6 @@ | ||
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator'); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
exports.setAvailableSelectors = setAvailableSelectors; | ||
@@ -46,2 +54,4 @@ exports.chooseSelector = chooseSelector; | ||
function chooseSelector(type, source, defaults, done) { | ||
var _this = this; | ||
var immediate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
@@ -64,20 +74,47 @@ | ||
} | ||
return (0, _viewer.withViewer)(function (Canvas, dispatch) { | ||
var _Canvas$createViewpor = Canvas.createViewportPoint(defaults.x, defaults.y), | ||
x = _Canvas$createViewpor.x, | ||
y = _Canvas$createViewpor.y; | ||
return (0, _viewer.withViewer)(function () { | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(Canvas, dispatch) { | ||
var _Canvas$createViewpor, x, y, _Canvas$createViewpor2, maxX, maxY; | ||
var _Canvas$createViewpor2 = Canvas.createViewportPoint(defaults.x + defaults.width, defaults.y + defaults.height), | ||
maxX = _Canvas$createViewpor2.x, | ||
maxY = _Canvas$createViewpor2.y; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return Canvas.viewerReady; | ||
dispatch({ | ||
type: SELECTOR_CHOOSE, | ||
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 })) } | ||
}); | ||
if (done) { | ||
done(); | ||
} | ||
}); | ||
case 2: | ||
_Canvas$createViewpor = Canvas.createViewportPoint(defaults.x, defaults.y), x = _Canvas$createViewpor.x, y = _Canvas$createViewpor.y; | ||
_Canvas$createViewpor2 = Canvas.createViewportPoint(defaults.x + defaults.width, defaults.y + defaults.height), maxX = _Canvas$createViewpor2.x, maxY = _Canvas$createViewpor2.y; | ||
dispatch({ | ||
type: SELECTOR_CHOOSE, | ||
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 | ||
})) | ||
} | ||
}); | ||
if (done) { | ||
done(); | ||
} | ||
case 6: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, _this); | ||
})); | ||
return function (_x2, _x3) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()); | ||
} | ||
@@ -134,2 +171,3 @@ | ||
if (selector.type === 'WholeCanvasSelector') { | ||
console.warn('WARNING: `editCurrentDraftSelector` should never be called when whole canvas selector is chosen'); | ||
return dispatch((0, _drafts.discardCurrentDraft)(scope)); | ||
@@ -136,0 +174,0 @@ } |
@@ -75,8 +75,12 @@ 'use strict'; | ||
} | ||
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 | ||
})); | ||
}); | ||
@@ -90,2 +94,4 @@ return selectors; | ||
currentSelector: currentSelector, | ||
elucidateServer: props.elucidateServer ? props.elucidateServer : state.elucidate ? state.elucidate.server : null, | ||
currentCanvas: (0, _manifestQuery.currentCanvas)(state), | ||
currentDraft: currentDraft, | ||
@@ -92,0 +98,0 @@ currentDrafts: state.drafts.currentDrafts, |
@@ -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({ target: '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', | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,2 @@ import AnnotationSelector from '../AnnotationSelector'; | ||
it('should retain partOf', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -26,2 +25,3 @@ id: 'http://canvas/#xywh=1,2,3,4', | ||
id: 'http://canvas/#xywh=1,2,3,4', | ||
type: 'Canvas', | ||
'dcterms:isPartOf': 'http://manifest', | ||
@@ -32,3 +32,2 @@ }); | ||
it('should ignore partOf if not found', () => { | ||
const annotation = AnnotationSelector.fromJsonLD({ | ||
@@ -35,0 +34,0 @@ id: 'http://canvas/#xywh=1,2,3,4', |
@@ -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({ target: '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({ target: 'http://manifest', captureModel, draft, partOf: 'http://some-manifest' }), | ||
createAnnotationFromCaptureModelAndDraft({ | ||
target: 'http://manifest', | ||
captureModel, | ||
draft, | ||
partOf: 'http://some-manifest', | ||
}) | ||
); | ||
@@ -121,24 +125,26 @@ | ||
'@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': { | ||
generator: 'http://omeka.dlcs-ida.org/api/item_sets/733', | ||
target: { | ||
'dcterms:isPartOf': 'http://some-manifest', | ||
'id': 'http://manifest', | ||
type: 'Canvas', | ||
id: 'http://manifest', | ||
}, | ||
'motivation': { | ||
'id': 'oa:tagging', | ||
'label': 'tagging', | ||
motivation: { | ||
id: 'oa:tagging', | ||
label: 'tagging', | ||
}, | ||
@@ -150,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', | ||
}); | ||
@@ -163,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({ target: '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({ target: '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) { |
@@ -135,2 +135,3 @@ 'use strict'; | ||
id: this.getStringSelector(), | ||
type: 'Canvas', | ||
'dcterms:isPartOf': this.selector.partOf | ||
@@ -137,0 +138,0 @@ }; |
@@ -167,3 +167,2 @@ 'use strict'; | ||
function createExternalResourceAnnotationBody(captureModel, draft) { | ||
var fieldIds = Object.keys(draft.input); | ||
@@ -196,5 +195,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; | ||
@@ -201,0 +199,0 @@ state.push(body); |
@@ -251,3 +251,3 @@ 'use strict'; | ||
body: JSON.stringify(body), | ||
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null, | ||
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit', | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
@@ -279,6 +279,8 @@ redirect: 'follow' | ||
try { | ||
return makeRequest('POST', uri, body); | ||
return makeRequest('POST', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('POST', uri, body, { withoutCredentials: true }); | ||
return makeRequest('POST', uri, body, headers, { | ||
withoutCredentials: true | ||
}); | ||
} | ||
@@ -291,6 +293,6 @@ } | ||
try { | ||
return makeRequest('PUT', uri, body); | ||
return makeRequest('PUT', uri, body, headers); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('PUT', uri, body, { withoutCredentials: true }); | ||
return makeRequest('PUT', uri, body, headers, { withoutCredentials: true }); | ||
} | ||
@@ -297,0 +299,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-pr.f0457139", | ||
"version": "1.0.0-pr.f4483907", | ||
"description": "Describe annotation-redux here", | ||
@@ -38,3 +38,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@fesk/test-environment": "^1.0.0-pr.f0457139", | ||
"@fesk/test-environment": "1.0.0-pr.f4483907", | ||
"babel-jest": "^20.0.3", | ||
@@ -46,7 +46,9 @@ "babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"cross-spawn": "^6.0.5", | ||
"fetch-mock": "^6.5.1", | ||
"jest": "^20.0.0", | ||
"nwb": "^0.21.5", | ||
"nwb-watch": "^1.0.0-pr.f0457139", | ||
"nwb-watch": "1.0.0-pr.f4483907", | ||
"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
347324
9220
15