From 8833ab8646072aefc03f3d2dbbef95c97cc6eed8 Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Thu, 2 Jan 2025 16:27:01 -0600 Subject: [PATCH 1/3] Init solution for 0266. --- docs/recipes/0266-full-canvas-annotation.md | 10 ++++ .../0266-full-canvas-annotation-method1.py | 51 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 docs/recipes/0266-full-canvas-annotation.md create mode 100644 docs/recipes/scripts/0266-full-canvas-annotation-method1.py diff --git a/docs/recipes/0266-full-canvas-annotation.md b/docs/recipes/0266-full-canvas-annotation.md new file mode 100644 index 0000000..a7706cc --- /dev/null +++ b/docs/recipes/0266-full-canvas-annotation.md @@ -0,0 +1,10 @@ +# Simplest Annotation +| | **Cookbook URLs** | +|--------------|-------------------| +| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/](https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/) | +| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json](https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json) | + +### Method 1 - +```python +--8<-- "docs/recipes/scripts/0266-full-canvas-annotation-method1.py" +``` \ No newline at end of file diff --git a/docs/recipes/scripts/0266-full-canvas-annotation-method1.py b/docs/recipes/scripts/0266-full-canvas-annotation-method1.py new file mode 100644 index 0000000..2dc794b --- /dev/null +++ b/docs/recipes/scripts/0266-full-canvas-annotation-method1.py @@ -0,0 +1,51 @@ +from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config + +config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" +base_url = "https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation" + +manifest = Manifest( + id=f"{base_url}/manifest.json", + label="Picture of Göttingen taken during the 2019 IIIF Conference", +) + +anno_page = AnnotationPage( + id=f"{base_url}/canvas-1/annopage-1" +) +painting_body = ResourceItem( + id="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen/full/max/0/default.jpg", + type="Image", + format="image/jpeg", +) +painting_body.make_service( + id="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen", + type="ImageService3", + profile="level1" +) +painting_anno = Annotation( + id=f"{base_url}/canvas-1/annopage-1/anno-1", + motivation="painting", + body=painting_body, + target=f"{base_url}/canvas-1" +) +anno_page.add_item(painting_anno) +hw = {"height": 3024, "width": 4032} +canvas = manifest.make_canvas( + id=f"{base_url}/canvas-1", +) +painting_body.set_hwd(**hw) +canvas.set_hwd(**hw) +canvas.add_item(anno_page) +anno_body = ResourceItem( + type="TextualBody", + language="de", + format="text/plain", + value="Göttinger Marktplatz mit Gänseliesel Brunnen" +) +anno = canvas.make_annotation( + id=f"{base_url}/canvas-1/annopage-2/anno-1", + motivation="commenting", + body=anno_body, + target=canvas.id +) + +print(manifest.json(indent=2)) \ No newline at end of file From 2a769d1adce3382aee7a03efd9e9a01c8a032bdf Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Thu, 2 Jan 2025 16:40:13 -0600 Subject: [PATCH 2/3] Fix anno page id. --- docs/recipes/0266-full-canvas-annotation.md | 2 +- docs/recipes/scripts/0266-full-canvas-annotation-method1.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/recipes/0266-full-canvas-annotation.md b/docs/recipes/0266-full-canvas-annotation.md index a7706cc..ca1c7ab 100644 --- a/docs/recipes/0266-full-canvas-annotation.md +++ b/docs/recipes/0266-full-canvas-annotation.md @@ -4,7 +4,7 @@ | **Recipe:** | [https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/](https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/) | | **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json](https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json) | -### Method 1 - +### Method 1 - Use make_annotation() helper ```python --8<-- "docs/recipes/scripts/0266-full-canvas-annotation-method1.py" ``` \ No newline at end of file diff --git a/docs/recipes/scripts/0266-full-canvas-annotation-method1.py b/docs/recipes/scripts/0266-full-canvas-annotation-method1.py index 2dc794b..9c0a197 100644 --- a/docs/recipes/scripts/0266-full-canvas-annotation-method1.py +++ b/docs/recipes/scripts/0266-full-canvas-annotation-method1.py @@ -45,7 +45,8 @@ id=f"{base_url}/canvas-1/annopage-2/anno-1", motivation="commenting", body=anno_body, - target=canvas.id + target=canvas.id, + anno_page_id=f"{base_url}/canvas-1/annopage-2" ) -print(manifest.json(indent=2)) \ No newline at end of file +print(manifest.json(indent=2)) From fc308ebe55d5db4090a76a59db607bc9a1c12fee Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Thu, 2 Jan 2025 16:43:50 -0600 Subject: [PATCH 3/3] Use correct class for Annotation body. --- docs/recipes/scripts/0266-full-canvas-annotation-method1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/recipes/scripts/0266-full-canvas-annotation-method1.py b/docs/recipes/scripts/0266-full-canvas-annotation-method1.py index 9c0a197..ae23493 100644 --- a/docs/recipes/scripts/0266-full-canvas-annotation-method1.py +++ b/docs/recipes/scripts/0266-full-canvas-annotation-method1.py @@ -1,4 +1,4 @@ -from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config +from iiif_prezi3 import Manifest, ResourceItem, ResourceItem1, AnnotationPage, Annotation, config config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" base_url = "https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation" @@ -35,7 +35,7 @@ painting_body.set_hwd(**hw) canvas.set_hwd(**hw) canvas.add_item(anno_page) -anno_body = ResourceItem( +anno_body = ResourceItem1( type="TextualBody", language="de", format="text/plain",