Skip to content

Commit

Permalink
Merge pull request #198 from markpbaggett/recipe_0047
Browse files Browse the repository at this point in the history
Add recipe for 0047 Homepage.
  • Loading branch information
glenrobson authored Dec 5, 2024
2 parents 32fd78b + 1b61fc8 commit 73fe84b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/recipes/0047-homepage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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 - Add Homepage as HomepageItem
```python
--8<-- "docs/recipes/scripts/0047-homepage-method1.py"
```
46 changes: 46 additions & 0 deletions docs/recipes/scripts/0047-homepage-method1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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",
label={"en": ["Home page at the Getty Museum Collection"]},
format="text/html",
language="en",
)
manifest = Manifest(
id=f"{base_url}/manifest.json",
label="Laocöon",
homepage=homepage,
)
canvas = manifest.make_canvas(
id=f"{base_url}/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=f"{base_url}/canvas/1/page/1"
)
hw = {"height": 3000, "width": 2315}
anno_body.set_hwd(**hw)
canvas.set_hwd(**hw)
anno = Annotation(
id=f"{base_url}/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))

0 comments on commit 73fe84b

Please sign in to comment.