From 32f2777e509d411b14f4fa40b73bcd761223be08 Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Mon, 9 Dec 2024 09:42:53 -0600 Subject: [PATCH] Refactor. --- docs/recipes/0033-choice.md | 3 +++ docs/recipes/scripts/0033-choice-method1.py | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/recipes/0033-choice.md b/docs/recipes/0033-choice.md index 3b325f1..6363f8a 100644 --- a/docs/recipes/0033-choice.md +++ b/docs/recipes/0033-choice.md @@ -5,3 +5,6 @@ | **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0033-choice/manifest.json](https://iiif.io/api/cookbook/recipe/0033-choice/manifest.json) | ### Method 1 - +```python +--8<-- "docs/recipes/scripts/0033-choice-method1.py" +``` \ No newline at end of file diff --git a/docs/recipes/scripts/0033-choice-method1.py b/docs/recipes/scripts/0033-choice-method1.py index 7439200..2f515d9 100644 --- a/docs/recipes/scripts/0033-choice-method1.py +++ b/docs/recipes/scripts/0033-choice-method1.py @@ -9,6 +9,8 @@ ) canvas = manifest.make_canvas( id=f"{base_url}/page/p1/1", + height=1271, + width=2000 ) natural_light = ResourceItem( @@ -40,14 +42,16 @@ choice = Choice( items=[natural_light, x_ray], ) -canvas.add_annotation( - anno_page_id=f"{base_url}/page/p1/1", - annotation=Annotation( - id=f"{base_url}/annotation/p0001-image", - motivation="painting", - body=choice, - target=f"{base_url}/canvas/p1" - ), +anno_page = AnnotationPage( + id=f"{base_url}/page/p1/1", +) +anno = Annotation( + id=f"{base_url}/annotation/p0001-image", + motivation="painting", + body=choice, + target=canvas.id ) +canvas.add_item(anno_page) +anno_page.add_item(anno) print(manifest.json(indent=2))