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

Update recipes to use a base_url variable to improve readability #183

Merged
merged 2 commits into from
Dec 4, 2024
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
9 changes: 5 additions & 4 deletions docs/recipes/scripts/0001-mvm-image-method1.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from iiif_prezi3 import Manifest, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0001-mvm-image"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/manifest.json", label="Single Image Example")
canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/canvas/p1", height=1800, width=1200)
manifest = Manifest(id=f"{base_url}/manifest.json", label="Single Image Example")
canvas = manifest.make_canvas(id=f"{base_url}/canvas/p1", height=1800, width=1200)
anno_page = canvas.add_image(image_url="http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png",
anno_page_id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/page/p1/1",
anno_id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/annotation/p0001-image",
anno_page_id=f"{base_url}/page/p1/1",
anno_id=f"{base_url}/annotation/p0001-image",
format="image/png",
height=1800,
width=1200
Expand Down
9 changes: 5 additions & 4 deletions docs/recipes/scripts/0001-mvm-image-method2.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from iiif_prezi3 import Manifest, Canvas, AnnotationPage, Annotation, ResourceItem, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0001-mvm-image"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/manifest.json", label="Single Image Example")
canvas = Canvas(id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/canvas/p1", height=1800, width=1200)
manifest = Manifest(id=f"{base_url}/manifest.json", label="Single Image Example")
canvas = Canvas(id=f"{base_url}/canvas/p1", height=1800, width=1200)
anno_body = ResourceItem(id="http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png",
type="Image",
format="image/png",
height=1800,
width=1200)
anno_page = AnnotationPage(id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/page/p1/1")
anno = Annotation(id="https://iiif.io/api/cookbook/recipe/0001-mvm-image/annotation/p0001-image",
anno_page = AnnotationPage(id=f"{base_url}/page/p1/1")
anno = Annotation(id=f"{base_url}/annotation/p0001-image",
motivation="painting",
body=anno_body,
target=canvas.id)
Expand Down
10 changes: 6 additions & 4 deletions docs/recipes/scripts/0002-mvm-audio-method1.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from iiif_prezi3 import Manifest, AnnotationPage, Annotation, ResourceItem, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0002-mvm-audio"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0002-mvm-audio/manifest.json", label="Simplest Audio Example 1")
canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0002-mvm-audio/canvas", duration=1985.024)
manifest = Manifest(id=f"{base_url}/manifest.json", label="Simplest Audio Example 1")
canvas = manifest.make_canvas(id=f"{base_url}/canvas", duration=1985.024)
anno_body = ResourceItem(id="https://fixtures.iiif.io/audio/indiana/mahler-symphony-3/CD1/medium/128Kbps.mp4",
type="Sound",
format="audio/mp4",
duration=1985.024)
anno_page = AnnotationPage(id="https://iiif.io/api/cookbook/recipe/0002-mvm-audio/canvas/page")
anno = Annotation(id="https://iiif.io/api/cookbook/recipe/0002-mvm-audio/canvas/page/annotation",
anno_page = AnnotationPage(id=f"{base_url}/canvas/page")
anno = Annotation(id=f"{base_url}/canvas/page/annotation",
motivation="painting",
body=anno_body,
target=canvas.id)
anno_page.add_item(anno)
canvas.add_item(anno_page)

print(manifest.json(indent=2))

9 changes: 5 additions & 4 deletions docs/recipes/scripts/0003-mvm-video-method1.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from iiif_prezi3 import Manifest, AnnotationPage, Annotation, ResourceItem, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0003-mvm-video"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0003-mvm-video/manifest.json", label="Video Example 3")
canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas")
manifest = Manifest(id=f"{base_url}/manifest.json", label="Video Example 3")
canvas = manifest.make_canvas(id=f"{base_url}/canvas")
anno_body = ResourceItem(id="https://fixtures.iiif.io/video/indiana/lunchroom_manners/high/lunchroom_manners_1024kb.mp4",
type="Video",
format="video/mp4")
anno_page = AnnotationPage(id="https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas/page")
anno = Annotation(id="https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas/page/annotation",
anno_page = AnnotationPage(id=f"{base_url}/canvas/page")
anno = Annotation(id=f"{base_url}/canvas/page/annotation",
motivation="painting",
body=anno_body,
target=canvas.id)
Expand Down
9 changes: 5 additions & 4 deletions docs/recipes/scripts/0004-canvas-size-method1.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from iiif_prezi3 import Manifest, AnnotationPage, Annotation, ResourceItem, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0004-canvas-size"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0004-canvas-size/manifest.json", label="Still image from an opera performance at Indiana University")
canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0004-canvas-size/canvas/p1")
manifest = Manifest(id=f"{base_url}/manifest.json", label="Still image from an opera performance at Indiana University")
canvas = manifest.make_canvas(id=f"{base_url}/canvas/p1")
anno_body = ResourceItem(id="https://fixtures.iiif.io/video/indiana/donizetti-elixir/act1-thumbnail.png",
type="Image",
format="image/png")
anno_page = AnnotationPage(id="https://iiif.io/api/cookbook/recipe/0004-canvas-size/page/p1/1")
anno = Annotation(id="https://iiif.io/api/cookbook/recipe/0004-canvas-size/annotation/p0001-image",
anno_page = AnnotationPage(id=f"{base_url}/page/p1/1")
anno = Annotation(id=f"{base_url}/annotation/p0001-image",
motivation="painting",
body=anno_body,
target=canvas.id)
Expand Down
9 changes: 5 additions & 4 deletions docs/recipes/scripts/0005-image-service-method1.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from iiif_prezi3 import Manifest, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0005-image-service"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0005-image-service/manifest.json", label="Picture of Göttingen taken during the 2019 IIIF Conference")
manifest = Manifest(id=f"{base_url}/manifest.json", label="Picture of Göttingen taken during the 2019 IIIF Conference")
canvas = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen",
id="https://iiif.io/api/cookbook/recipe/0005-image-service/canvas/p1",
id=f"{base_url}/canvas/p1",
label="Canvas with a single IIIF image",
anno_id="https://iiif.io/api/cookbook/recipe/0005-image-service/annotation/p0001-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0005-image-service/page/p1/1")
anno_id=f"{base_url}/annotation/p0001-image",
anno_page_id=f"{base_url}/page/p1/1")

print(manifest.json(indent=2))
10 changes: 6 additions & 4 deletions docs/recipes/scripts/0006-text-language-method1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from iiif_prezi3 import Manifest, KeyValueString

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json",
base_url = "https://iiif.io/api/cookbook/recipe/0006-text-language"

manifest = Manifest(id=f"{base_url}/manifest.json",
label={"en": ["Whistler's Mother"], "fr": ["La Mère de Whistler"]})
manifest.metadata = [
KeyValueString(label={"en": ["Creator"], "fr": ["Auteur"]}, value="Whistler, James Abbott McNeill"),
Expand All @@ -13,8 +15,8 @@
manifest.requiredStatement = KeyValueString(label={"en": ["Held By"], "fr": ["Détenu par"]}, value="Musée d'Orsay, Paris, France")

canvas = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/329817fc8a251a01c393f517d8a17d87-Whistlers_Mother",
id="https://iiif.io/api/cookbook/recipe/0006-text-language/canvas/p1",
anno_id="https://iiif.io/api/cookbook/recipe/0006-text-language/annotation/p0001-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0006-text-language/page/p1/1")
id=f"{base_url}/canvas/p1",
anno_id=f"{base_url}/annotation/p0001-image",
anno_page_id=f"{base_url}/page/p1/1")

print(manifest.json(indent=2))
9 changes: 5 additions & 4 deletions docs/recipes/scripts/0007-string-formats-method1.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from iiif_prezi3 import Manifest, KeyValueString, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0007-string-formats"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0007-string-formats/manifest.json",
manifest = Manifest(id=f"{base_url}/manifest.json",
label="Picture of Göttingen taken during the 2019 IIIF Conference",
summary="<p>Picture taken by the <a href=\"https://github.com/glenrobson\">IIIF Technical Coordinator</a></p>",
rights="http://creativecommons.org/licenses/by-sa/3.0/",
requiredStatement=KeyValueString(label="Attribution",
value="<span>Glen Robson, IIIF Technical Coordinator. <a href=\"https://creativecommons.org/licenses/by-sa/3.0\">CC BY-SA 3.0</a> <img src=\"https://licensebuttons.net/l/by-sa/3.0/88x31.png\"/></span>"),
metadata=[KeyValueString(label="Author", value={"none": ["<span><a href='https://github.com/glenrobson'>Glen Robson</a></span>"]})])
canvas = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen",
id="https://iiif.io/api/cookbook/recipe/0007-string-formats/canvas/p1",
anno_id="https://iiif.io/api/cookbook/recipe/0007-string-formats/annotation/p0001-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0007-string-formats/page/p1/1")
id=f"{base_url}/canvas/p1",
anno_id=f"{base_url}/annotation/p0001-image",
anno_page_id=f"{base_url}/page/p1/1")

print(manifest.json(indent=2))
9 changes: 5 additions & 4 deletions docs/recipes/scripts/0008-rights-method1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from iiif_prezi3 import Manifest, KeyValueString, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0008-rights"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0008-rights/manifest.json",
manifest = Manifest(id=f"{base_url}/manifest.json",
label="Picture of Göttingen taken during the 2019 IIIF Conference",
summary="<p>Picture taken by the <a href=\"https://github.com/glenrobson\">IIIF Technical Coordinator</a></p>",
rights="http://creativecommons.org/licenses/by-sa/3.0/",
Expand All @@ -11,8 +12,8 @@
)

canvas = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen",
id="https://iiif.io/api/cookbook/recipe/0008-rights/canvas/p1",
anno_id="https://iiif.io/api/cookbook/recipe/0008-rights/annotation/p0001-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0008-rights/page/p1/1")
id=f"{base_url}/canvas/p1",
anno_id=f"{base_url}/annotation/p0001-image",
anno_page_id=f"{base_url}/page/p1/1")

print(manifest.json(indent=2))
33 changes: 17 additions & 16 deletions docs/recipes/scripts/0009-book-1-method1.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
from iiif_prezi3 import Manifest, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0009-book-1"

manifest = Manifest(id="https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json",
manifest = Manifest(id=f"{base_url}/manifest.json",
label="Simple Manifest - Book",
behavior=["paged"])
canvas1 = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f18",
id="https://iiif.io/api/cookbook/recipe/0009-book-1/canvas/p1",
id=f"{base_url}/canvas/p1",
label="Blank page",
anno_id="https://iiif.io/api/cookbook/recipe/0009-book-1/annotation/p0001-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0009-book-1/page/p1/1")
anno_id=f"{base_url}/annotation/p0001-image",
anno_page_id=f"{base_url}/page/p1/1")

canvas2 = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f19",
id="https://iiif.io/api/cookbook/recipe/0009-book-1/canvas/p2",
id=f"{base_url}/canvas/p2",
label="Frontispiece",
anno_id="https://iiif.io/api/cookbook/recipe/0009-book-1/annotation/p0002-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0009-book-1/page/p2/1")
anno_id=f"{base_url}/annotation/p0002-image",
anno_page_id=f"{base_url}/page/p2/1")

canvas3 = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f20",
id="https://iiif.io/api/cookbook/recipe/0009-book-1/canvas/p3",
id=f"{base_url}/canvas/p3",
label="Title page",
anno_id="https://iiif.io/api/cookbook/recipe/0009-book-1/annotation/p0003-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0009-book-1/page/p3/1")
anno_id=f"{base_url}/annotation/p0003-image",
anno_page_id=f"{base_url}/page/p3/1")

canvas4 = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f21",
id="https://iiif.io/api/cookbook/recipe/0009-book-1/canvas/p4",
id=f"{base_url}/canvas/p4",
label="Blank page",
anno_id="https://iiif.io/api/cookbook/recipe/0009-book-1/annotation/p0004-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0009-book-1/page/p4/1")
anno_id=f"{base_url}/annotation/p0004-image",
anno_page_id=f"{base_url}/page/p4/1")

canvas5 = manifest.make_canvas_from_iiif(url="https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f22",
id="https://iiif.io/api/cookbook/recipe/0009-book-1/canvas/p5",
id=f"{base_url}/canvas/p5",
label="Bookplate",
anno_id="https://iiif.io/api/cookbook/recipe/0009-book-1/annotation/p0005-image",
anno_page_id="https://iiif.io/api/cookbook/recipe/0009-book-1/page/p5/1")
anno_id=f"{base_url}/annotation/p0005-image",
anno_page_id=f"{base_url}/page/p5/1")

print(manifest.json(indent=2))
Loading
Loading