From 20d8154e82cc1585199442a3301869aeb9e86b48 Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Sat, 7 Sep 2024 10:05:11 -0500 Subject: [PATCH 1/3] Gen doc. --- docs/recipes/0047-homepage.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docs/recipes/0047-homepage.md diff --git a/docs/recipes/0047-homepage.md b/docs/recipes/0047-homepage.md new file mode 100644 index 0000000..2c2072b --- /dev/null +++ b/docs/recipes/0047-homepage.md @@ -0,0 +1,7 @@ +# Linking to Web Page of an Object +| | **Cookbook URLs** | +|--------------|-------------------| +| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0047-homepage/](https://iiif.io/api/cookbook/recipe/0047-homepage/) | +| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0047-homepage/manifest.json](https://iiif.io/api/cookbook/recipe/0047-homepage/manifest.json) | + +### Method 1 - From 809ef77df4cf8276659ccdd6a45a17f0784c3f6f Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Sat, 7 Sep 2024 14:28:27 -0500 Subject: [PATCH 2/3] Update with homepage solution. --- docs/recipes/0047-homepage.md | 5 ++- docs/recipes/scripts/0047-homepage-method1.py | 44 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 docs/recipes/scripts/0047-homepage-method1.py diff --git a/docs/recipes/0047-homepage.md b/docs/recipes/0047-homepage.md index 2c2072b..2348b81 100644 --- a/docs/recipes/0047-homepage.md +++ b/docs/recipes/0047-homepage.md @@ -4,4 +4,7 @@ | **Recipe:** | [https://iiif.io/api/cookbook/recipe/0047-homepage/](https://iiif.io/api/cookbook/recipe/0047-homepage/) | | **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0047-homepage/manifest.json](https://iiif.io/api/cookbook/recipe/0047-homepage/manifest.json) | -### Method 1 - +### Method 1 - Add Homepage as HomepageItem +```python +--8<-- "docs/recipes/scripts/0047-homepage-method1.py" +``` \ No newline at end of file diff --git a/docs/recipes/scripts/0047-homepage-method1.py b/docs/recipes/scripts/0047-homepage-method1.py new file mode 100644 index 0000000..bb8c895 --- /dev/null +++ b/docs/recipes/scripts/0047-homepage-method1.py @@ -0,0 +1,44 @@ +from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config, HomepageItem + +config.configs['helpers.auto_fields.AutoLang'].auto_lang = "none" +homepage = HomepageItem( + id="https://www.getty.edu/art/collection/object/103RQQ", + type="Text", + label={"en": ["Home page at the Getty Museum Collection"]}, + format="text/html", + language="en", +) +manifest = Manifest( + id="https://iiif.io/api/cookbook/recipe/0047-homepage/manifest.json", + label="Laocöon", + homepage=homepage, +) +canvas = manifest.make_canvas( + id="https://iiif.io/api/cookbook/recipe/0047-homepage/canvas/1", + label="Front" +) +anno_body = ResourceItem( + id="https://iiif.io/api/image/3.0/example/reference/28473c77da3deebe4375c3a50572d9d3-laocoon/full/!500,500/0/default.jpg", + type="Image", + format="image/jpeg" +) +anno_body.make_service( + id="https://iiif.io/api/image/3.0/example/reference/28473c77da3deebe4375c3a50572d9d3-laocoon", + type="ImageService3", + profile="level1" +) +anno_page = AnnotationPage( + id="https://iiif.io/api/cookbook/recipe/0047-homepage/canvas/1/page/1" +) +hw = {"height": 3000, "width": 2315} +anno_body.set_hwd(**hw) +canvas.set_hwd(**hw) +anno = Annotation( + id="https://iiif.io/api/cookbook/recipe/0047-homepage/canvas/1/page/1/annotation/1", + motivation="painting", + body=anno_body, + target=canvas.id +) +anno_page.add_item(anno) +canvas.add_item(anno_page) +print(manifest.json(indent=2)) From 1b61fc8b8f7716966b06c7d7af3f3aefbb458c59 Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Wed, 4 Dec 2024 22:14:27 -0600 Subject: [PATCH 3/3] Use base_url. --- docs/recipes/scripts/0047-homepage-method1.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/recipes/scripts/0047-homepage-method1.py b/docs/recipes/scripts/0047-homepage-method1.py index bb8c895..8a6590d 100644 --- a/docs/recipes/scripts/0047-homepage-method1.py +++ b/docs/recipes/scripts/0047-homepage-method1.py @@ -1,6 +1,8 @@ from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config, HomepageItem config.configs['helpers.auto_fields.AutoLang'].auto_lang = "none" +base_url = "https://iiif.io/api/cookbook/recipe/0047-homepage" + homepage = HomepageItem( id="https://www.getty.edu/art/collection/object/103RQQ", type="Text", @@ -9,12 +11,12 @@ language="en", ) manifest = Manifest( - id="https://iiif.io/api/cookbook/recipe/0047-homepage/manifest.json", + id=f"{base_url}/manifest.json", label="Laocöon", homepage=homepage, ) canvas = manifest.make_canvas( - id="https://iiif.io/api/cookbook/recipe/0047-homepage/canvas/1", + id=f"{base_url}/canvas/1", label="Front" ) anno_body = ResourceItem( @@ -28,13 +30,13 @@ profile="level1" ) anno_page = AnnotationPage( - id="https://iiif.io/api/cookbook/recipe/0047-homepage/canvas/1/page/1" + id=f"{base_url}/canvas/1/page/1" ) hw = {"height": 3000, "width": 2315} anno_body.set_hwd(**hw) canvas.set_hwd(**hw) anno = Annotation( - id="https://iiif.io/api/cookbook/recipe/0047-homepage/canvas/1/page/1/annotation/1", + id=f"{base_url}/canvas/1/page/1/annotation/1", motivation="painting", body=anno_body, target=canvas.id