Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 0118-multivalue recipe #165

Merged
merged 5 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/recipes/0118-multivalue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Displaying Multiple Values with Language Maps
| | **Cookbook URLs** |
|--------------|----------------------------------------------------------------------------------------------------------------------------------|
| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0118_multivalue/](https://iiif.io/api/cookbook/recipe/0118_multivalue/) |
| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0118_multivalue/manifest.json](https://iiif.io/api/cookbook/recipe/0118_multivalue/manifest.json) |

### Method 1 - Use a `KeyValueString` object and a dictionary to create language maps.
```python
--8<-- "docs/recipes/scripts/0118-multivalue-method1.py"
```
21 changes: 21 additions & 0 deletions docs/recipes/scripts/0118-multivalue-method1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from iiif_prezi3 import Manifest, KeyValueString

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0118_multivalue/manifest.json",
label={"fr": ["Arrangement en gris et noir no 1"]})
manifest.metadata = [
KeyValueString(label={"en": ["Alternative titles"]},
value={"en": ["Whistler's Mother", "Arrangement in Grey and Black No. 1"],
"fr": ["Portrait de la mère de l'artiste", "La Mère de Whistler"]})
]
manifest.summary = {"en": ["A painting in oil on canvas created by the American-born painter James McNeill Whistler, in 1871."]}

canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0118_multivalue/canvas/1", height=991, width=1114)
anno_page = canvas.add_image(image_url="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Whistlers_Mother_high_res.jpg/1114px-Whistlers_Mother_high_res.jpg",
anno_page_id="https://iiif.io/api/cookbook/recipe/0118_multivalue/canvas/1/page/1",
anno_id="https://iiif.io/api/cookbook/recipe/0118_multivalue/canvas/1/page/1/annotation/1",
format="image/jpeg",
)

canvas.items[0].items[0].id = "https://iiif.io/api/cookbook/recipe/0118_multivalue/canvas/1/page/1/annotation/1"

print(manifest.json(indent=2, ensure_ascii=False))