-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from markpbaggett/recipe_0013
Add solution for Recipe 0013.
- Loading branch information
Showing
4 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Load a Preview Image Before the Main Content | ||
| | **Cookbook URLs** | | ||
|--------------|-------------------| | ||
| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0013-placeholderCanvas/](https://iiif.io/api/cookbook/recipe/0013-placeholderCanvas/) | | ||
| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0013-placeholderCanvas/manifest.json](https://iiif.io/api/cookbook/recipe/0013-placeholderCanvas/manifest.json) | | ||
|
||
### Method 1 - Use PlaceholderCanvas and add_item() helper | ||
```python | ||
--8<-- "docs/recipes/scripts/0013-placeholderCanvas-method1.py" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config, PlaceholderCanvas | ||
|
||
config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" | ||
base_url = "https://iiif.io/api/cookbook/recipe/0013-placeholderCanvas" | ||
|
||
manifest = Manifest( | ||
id=f"{base_url}/manifest.json", | ||
label="Video recording of Donizetti's _The Elixer of Love_", | ||
) | ||
placeholder_canvas = PlaceholderCanvas( | ||
id=f"{base_url}/canvas/donizetti/placeholder", | ||
width=640, | ||
height=360, | ||
) | ||
pc_anno_page = AnnotationPage( | ||
id=f"{base_url}/canvas/donizetti/placeholder/1" | ||
) | ||
pc_anno_body = ResourceItem( | ||
id="https://fixtures.iiif.io/video/indiana/donizetti-elixir/act1-thumbnail.png", | ||
type="Image", | ||
format="image/png", | ||
width=640, | ||
height=360, | ||
) | ||
pc_anno = Annotation( | ||
id=f"{base_url}/canvas/donizetti/placeholder/1-image", | ||
motivation="painting", | ||
body=pc_anno_body, | ||
target=f"{base_url}/canvas/donizetti/placeholder" | ||
) | ||
pc_anno_page.add_item(pc_anno) | ||
placeholder_canvas.add_item(pc_anno_page) | ||
|
||
canvas = manifest.make_canvas( | ||
id=f"{base_url}/canvas/donizetti", | ||
duration=7278.466, | ||
height=360, | ||
width=640, | ||
placeholderCanvas=placeholder_canvas, | ||
) | ||
|
||
anno_body = ResourceItem( | ||
id="https://fixtures.iiif.io/video/indiana/donizetti-elixir/vae0637_accessH264_low.mp4", | ||
type="Video", | ||
duration=7278.466, | ||
width=640, | ||
height=360, | ||
format="video/mp4" | ||
) | ||
anno = Annotation( | ||
id=f"{base_url}/donizetti/1-video", | ||
motivation="painting", | ||
body=anno_body, | ||
target=canvas.id | ||
) | ||
anno_page = AnnotationPage( | ||
id=f"{base_url}/donizetti/1", | ||
) | ||
anno_page.add_item(anno) | ||
canvas.add_item(anno_page) | ||
|
||
print(manifest.json(indent=2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters