Skip to content

Commit

Permalink
Merge pull request #148 from IIIF/issue-147
Browse files Browse the repository at this point in the history
Adding support for scope in Web annotation. Closes #147
  • Loading branch information
glenrobson committed Aug 30, 2022
2 parents f21e049 + 5e36a77 commit 063d493
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 3 deletions.
1 change: 1 addition & 0 deletions fixtures/3/anno_pointselector.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"format": "text/plain"
},
"target": {
"type": "SpecificResource",
"source": "https://preview.iiif.io/cookbook/0103-poetry/recipe/0103-poetry-reading-annotations/canvas/1",
"selector": {
"type": "PointSelector",
Expand Down
98 changes: 98 additions & 0 deletions fixtures/3/anno_source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/manifest.json",
"type": "Manifest",
"label": {
"en": [
"Choice Example with layer specific annotation"
]
},
"items": [
{
"id": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/canvas/p1",
"type": "Canvas",
"height": 1271,
"width": 2000,
"items": [
{
"id": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/page/p1/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/annotation/p0001-image",
"type": "Annotation",
"motivation": "painting",
"body": {
"type": "Choice",
"items": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/421e65be2ce95439b3ad6ef1f2ab87a9-dee-natural/full/max/0/default.jpg",
"type": "Image",
"label": {
"en": [
"Natural Light"
]
},
"format": "image/jpeg",
"height": 1271,
"width": 2000,
"service": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/421e65be2ce95439b3ad6ef1f2ab87a9-dee-natural",
"type": "ImageService3",
"profile": "level1"
}
]
},
{
"id": "https://iiif.io/api/image/3.0/example/reference/421e65be2ce95439b3ad6ef1f2ab87a9-dee-xray/full/max/0/default.jpg",
"type": "Image",
"label": {
"en": [
"X-Ray"
]
},
"format": "image/jpeg",
"height": 1271,
"width": 2000,
"service": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/421e65be2ce95439b3ad6ef1f2ab87a9-dee-xray",
"type": "ImageService3",
"profile": "level1"
}
],
"annotations": [
{
"id": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/page/p2/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/annotation/p0002-tag",
"type": "Annotation",
"motivation": "tagging",
"body": {
"type": "TextualBody",
"value": "A group of skulls.",
"language": "en",
"format": "text/plain"
},
"target": {
"source": "https://iiif.io/api/image/3.0/example/reference/421e65be2ce95439b3ad6ef1f2ab87a9-dee-xray/full/max/0/default.jpg#xywh=810,900,260,370",
"scope": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/canvas/p1"
}
}
]
}
]
}
]
},
"target": "https://preview.iiif.io/cookbook/0326-annotating-image-layer/recipe/0326-annotating-image-layer/canvas/p1"
}
]
}
]
}
]
}
9 changes: 9 additions & 0 deletions schema/iiif_3_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,15 @@
},
{
"$ref": "#/classes/specificResource"
},
{
"title": "Annotation target can also contain just scope and source",
"type": "object",
"properties": {
"source": { "$ref": "#/types/id" },
"scope": { "$ref": "#/types/id" }
},
"required": ["source", "scope"]
}
]
},
Expand Down
12 changes: 9 additions & 3 deletions tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,21 @@ def test07_check_manifest3(self):
'fixtures/3/extension_anno.json',
'fixtures/3/multi_bodies.json',
'fixtures/3/publicdomain.json',
'fixtures/3/navPlace.json'
'fixtures/3/navPlace.json',
'fixtures/3/anno_source.json'
]:
with open(good, 'r') as fh:
print ('Testing: {}'.format(good))
data = fh.read()
j = json.loads(v.check_manifest(data, '3.0'))
if j['okay'] != 1:
self.printValidationerror(good, j['errorList'])
if 'errorList' in j:
self.printValidationerror(good, j['errorList'])
else:
print ('Failed to find errors but manifest {} failed validation'.format(good))
print (j)

self.assertEqual(j['okay'], 1)
self.assertEqual(j['okay'], 1, 'Expected manifest {} to pass validation but it failed'.format(good))

for bad_data in ['fixtures/3/broken_simple_image.json',
'fixtures/3/broken_choice.json',
Expand Down

0 comments on commit 063d493

Please sign in to comment.