-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathiiif_presentation_api_3.0_manifest.twig.html
664 lines (664 loc) · 26.4 KB
/
iiif_presentation_api_3.0_manifest.twig.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
{# This Template generates IIIF 3.0 Presentation API Manifest from a Strawberry Field
JSON.
Updated 17/06/2024 for 1.4.0
Changes:
- Plain Text added as supplementing for Images if present. Processed in the same block as direct Annotations
- VTTs added as supplementing for Videos if present.
- Better Labeling for Items
- Adds Rights
- Fixes on Canvas IDs
- Deals with PDFs too, joining them all together
- Adds MarkDown support for Description
- Fixes Structures/Canvas IDs
- Adds Annotations for Images
- Adds PDF/Document/pages
- Adds Thumbnail for Video
- Fixes mirador_path to handle both standard and self-closing polygon tags.
Structures passed from Archipelago are
- node
The full Node entity
- data
The Full JSON Structure converted in an Array
- iiif_server
The publicly available IIIF Server (Global Setting)
Since JSON was decoded into the 'data' values are valid PHP but could not
be valid JSON when outputting. So We use data.description|json_encode|raw
Without Double quotes.
#}
{%- set structureCanvasIds = [] %}
{# with 150 being Cantaloupe's setup PDF rastering resolution and 72 what PDFINFO produces by default #}
{%- set pdf_resolution = (150/72) %}
{%- set baseurl = url('<front>')|render -%}
{%- set Webserverurl = baseurl -%}
{%- set IIIFserverurl = iiif_server ? iiif_server ~ '/': Webserverurl -%}
{%- set currenturl = url('<current>')|render -%}
{%- set parentcollectionurl = '' -%}
{%- set itemCount = 0 -%}
{%- if node.id %}
{%- set nodeurl = url('entity.node.canonical', {'node': node.id}, {'absolute': true}) -%}
{%- else -%}
{%- set nodeurl = currenturl -%}
{%- endif -%}
{%- if attribute(data, 'ismemberof') %}
{%- if attribute(data, 'ismemberof') is iterable -%}
{%- for collection in attribute(data, 'ismemberof') -%}
{%- set parentcollectionurl = url('entity.node.canonical', {'node': collection}, {'absolute': true}) -%}
{%- endfor -%}
{%- else -%}
{%- set parentcollectionurl = url('entity.node.canonical', {'node': attribute(data, 'ismemberof')}, {'absolute': true}) -%}
{%- endif -%}
{%- endif -%}
{%- if attribute(data, 'ispartof') -%}
{%- if attribute(data, 'ispartof') is iterable -%}
{%- for child in attribute(data, 'ispartof') -%}
{%- set parentnodeurl = url('entity.node.canonical', {'node': child}, {'absolute': true}) -%}
{%- endfor -%}
{%- else -%}
{%- set parentnodeurl = url('entity.node.canonical', {'node': attribute(data, 'ispartof')}, {'absolute': true}) -%}
{%- endif -%}
{%- endif -%}
{%- set len = language.getId() ? language.getId() : "en" -%}
{% set computed_rights = "http://rightsstatements.org/vocab/InC-EDU/1.0/" %}
{% if data.rights|length > 0 or data.rights_statements|length > 0 %}
{% if data.rights|length > 0 %}
{% set computed_rights = data.rights %}
{% endif %}
{% elseif data.rights_statements|length > 0 %}
{% if data.rights_statements in ['In Copyright'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/InC/1.0/" %}
{% endif %}
{% if data.rights_statements in ['In Copyright - EU Orphan Work'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/InC-OW-EU/1.0/" %}
{% endif %}
{% if data.rights_statements in ['In Copyright - Educational Use Permitted'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/InC-EDU/1.0/" %}
{% endif %}
{% if data.rights_statements in ['In Copyright - Non-Commercial Use Permitted'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/InC-NC/1.0/" %}
{% endif %}
{% if data.rights_statements in ['In Copyright - Rights-holder(s) Unlocatable or Unidentifiable'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/InC-RUU/1.0/" %}
{% endif %}
{% if data.rights_statements in ['No Copyright - Contractual Restrictions'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/NoC-CR/1.0/" %}
{% endif %}
{% if data.rights_statements in ['No Copyright - Non-Commercial Use Only'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/NoC-NC/1.0/" %}
{% endif %}
{% if data.rights_statements in ['No Copyright - Other Known Legal Restrictions'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/NoC-OKLR/1.0/" %}
{% endif %}
{% if data.rights_statements in ['No Copyright - United States'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/NoC-US/1.0/" %}
{% endif %}
{% if data.rights_statements in ['Copyright Not Evaluated'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/CNE/1.0/" %}
{% endif %}
{% if data.rights_statements in ['Copyright Undetermined'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/UND/1.0/" %}
{% endif %}
{% if data.rights_statements in ['No Known Copyright'] %}
{% set computed_rights = "http://rightsstatements.org/vocab/NKC/1.0/" %}
{% endif %}
{% endif %}
{%- set max_thumb_width = 240 -%}{
"@context": [
"http://www.w3.org/ns/anno.jsonld",
"http://iiif.io/api/presentation/3/context.json"
],
"type": "Manifest",
"id": "{{ currenturl }}",
"label": {
"{{ len }}": [
{{ node.label|json_encode|raw }}
]
},
"rights": {{ computed_rights|json_encode|raw }},
"behavior": ["paged"],
"requiredStatement": {
"label": { "en": [ "Attribution" ] },
"value": { "en": [ "Provided by Archipelago Deployment" ] }
},
"metadata": [
{% for agent in attribute(data, 'edm_agent') %}
{
"label": {
"{{ len }}": [
{{ agent.role_label|json_encode|raw }}
]
},
"value": {
"{{ len }}": [
{{ agent.name_label|json_encode|raw }}
]
}
},
{% endfor %}
{
"label": {
"{{ len }}": [
"description"
]
},
"value": {
"{{ len }}": [
{{ data.description|markdown_2_html|json_encode|raw }}
]
}
},
{
"label": {
"{{ len }}": [
"navDate"
]
},
"value": {
"{{ len }}": [
{{ "now"|date("F jS \\a\\t g:ia")|json_encode|raw }}
{# node.getChangedTime|date("F jS \\a\\t g:ia")|json_encode|raw #}
]
}
},
{
"label": {
"{{ len }}": [
"license"
]
},
"value": {
"{{ len }}": [
{{ computed_rights|json_encode|raw }}
]
}
}
],
{% if attribute(data, 'ismemberof') -%}
"within": "{{ parentcollectionurl }}",
"partOf": [ { "id": "{{ parentcollectionurl }}/metadata/iiifmanifest3collection/default.jsonld", "type": "Manifest" } ],
{%- endif -%}
{%- if attribute(data, 'ispartof') %}
"within": "{{ parentnodeurl }}",
"partOf": [ { "id": "{{ parentnodeurl }}/metadata/iiifmanifest3cws/default.jsonld", "type": "Manifest" } ],
{%- endif -%}
{# Allison: add note why we have 3 services. SearchService2 is the current one, no viewer supports it, SearchService1 is for Mirador, http://iiif.io/api/search/0/search is for UV #}
{%- if node.uuid.value -%}
"service": [
{
"id": "{{ baseurl }}iiifcontentsearch/v2/do/{{ node.uuid.value }}/metadatadisplayexposed/iiifmanifest/mode/advanced/page/0",
"type": "SearchService2"
},
{
"id": "{{ baseurl }}iiifcontentsearch/v1/do/{{ node.uuid.value }}/metadatadisplayexposed/iiifmanifest/mode/advanced/page/0",
"type": "SearchService1",
"@context": "http://iiif.io/api/search/1/context.json",
"profile": "http://iiif.io/api/search/1/search"
},
{
"@id": "{{ baseurl }}iiifcontentsearch/v1/do/{{ node.uuid.value }}/metadatadisplayexposed/iiifmanifest/mode/advanced/page/0",
"@context": "http://iiif.io/api/search/0/context.json",
"profile": "http://iiif.io/api/search/0/search"
}
],
{%- endif -%}
"items": [
{%- set document_count = attribute(data, 'as:document')|length -%}
{%- set TotalpageCount = 0 -%}
{%- for document in attribute(data, 'as:document')%}
{#- WIZARDLY UPDATED BY ARCHIPELAGO -#}
{% if document['flv:exif'].PageCount -%}
{%- set TotalpageCount = (TotalpageCount + document['flv:exif'].PageCount) -%}
{#- WIZARDLY UPDATED BY ARCHIPELAGO -#}
{% endif %}
{%- endfor -%}
{% for document in attribute(data, 'as:document')%}
{#- WIZARDLY UPDATED BY ARCHIPELAGO -#}
{% if document['flv:exif'].PageCount %}
{%- set pageCount = document['flv:exif'].PageCount -%}
{%- set cantaloupeid = IIIFserverurl ~ document['url']|replace({'s3://':''})|replace({'private://':''})|url_encode -%}
{% for pagenumber in 1..pageCount %}{
{%- set itemCount = itemCount + 1 -%}
{% if attribute(document["flv:pdfinfo"], pagenumber) %}
{% set width = attribute(document["flv:pdfinfo"], pagenumber).width ? (attribute(document["flv:pdfinfo"], pagenumber).width * pdf_resolution)|round : 600 %}
{% set height = attribute(document["flv:pdfinfo"], pagenumber).height ? (attribute(document["flv:pdfinfo"], pagenumber).height * pdf_resolution)|round : 450 %}
{% else %}
{% if attribute(document["flv:identify"], pagenumber) %}
{% set width = attribute(document["flv:identify"], pagenumber).width ? (attribute(document["flv:identify"], pagenumber).width * pdf_resolution)|round : 600 %}
{% set height = attribute(document["flv:identify"], pagenumber).height ? (attribute(document["flv:identify"], pagenumber).height * pdf_resolution)|round : 450 %}
{% else %}
{% set width = 600 %}
{% set height = 450 %}
{% endif %}
{% endif %}
{% set thumb_width = width < max_thumb_width ? width: max_thumb_width %}
{% set thumb_height = (thumb_width/width * height)|round() %}
{% set canvasId = nodeurl|render ~ '/iiif/' ~ document['dr:uuid'] ~ '/canvas/p' ~ pagenumber %}
{% set structureCanvasIds = structureCanvasIds|merge([canvasId]) %}
{% set thumbnail %}
"thumbnail": [{
"id": "{{ cantaloupeid }}/full/{{thumb_width}},/0/default.jpg?page={{ pagenumber }}",
"type": "Image",
"format": "image/jpeg",
"width": {{ thumb_width }},
"height": {{ thumb_height }}
}],
{% endset %}
"id": "{{ canvasId }}",
"type": "Canvas",
"label": { "{{ len }}": [
{%- if (pageCount > 1) -%}
{{ (loop.index ~ ' of ' ~ pageCount ~ ' pages: ' ~ data.label)|json_encode|raw }}
{% else %}
{{ data.label|json_encode|raw }}
{%- endif -%}
]},
{{ thumbnail }}
"height": {{ height }},
"width": {{ width }},
"items": [
{
"id": "{{ nodeurl }}/iiif/{{ document['dr:uuid'] }}/page/p{{ pagenumber}}",
"type": "AnnotationPage",
"items": [
{
"id": "{{ nodeurl }}/iiif/{{ document['dr:uuid'] }}/annotation/p{{ pagenumber }}",
"type": "Annotation",
"motivation": "painting",
{{ thumbnail }}
"body": {
"id": "{{ cantaloupeid ~ ';' ~ pagenumber }}/full/full/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"service": [
{
"id": "{{ cantaloupeid ~ ';' ~ pagenumber }}",
"type": "ImageService2",
"profile": "level2"
}
]
{% if data.type in ['Book','Document','ArchivalDescription','Page','Letter'] %}
,
"seeAlso": {
"@id": "{{ nodeurl }}/flavorsearch/{{ document['dr:uuid'] }}/ocr/originalocr/{{ pagenumber}}",
{# "profile": "http://www.loc.gov/standards/alto/v3/alto.xsd", NOTE THIS CAN BE ANY URL YOU ARE GOING TO USE TO IDENTIFY/DISCERN between XML formats. Up to you#}
"format": "text/xml",
"label": "MINIOCR XML"
}
{% endif %}
},
"target": "{{ nodeurl }}/iiif/{{ document['dr:uuid'] }}/canvas/p{{ pagenumber }}"
}
]
}
]
}{{ itemCount < TotalpageCount ? ',' : '' }}
{% endfor %}
{#- WIZARDLY UPDATED BY ARCHIPELAGO -#}
{% endif %}
{% endfor %}
{#- ImagesManifest -#}
{#- Count Images upfront -#}
{%- if (attribute(data, 'as:image')|length > 0) -%}
{%- if itemCount > 0 -%}
,
{%- endif -%}
{%- endif -%}
{% for page in attribute(data, 'as:image') %}
{
{%- set itemCount = itemCount + 1 %}
{%- set cantaloupeid = IIIFserverurl ~ page['url']|replace({'s3://':''})|replace({'private://':''})|url_encode -%}
{%- if page["flv:exif"] -%}
{%- set width = page["flv:exif"].ImageWidth -%}
{%- else -%}
{%- set width = 1200 -%}
{%- endif -%}
{%- if page["flv:exif"] -%}
{%- set height = page["flv:exif"].ImageHeight -%}
{%- else -%}
{%- set height = 1600 -%}
{%- endif -%}
{%- set thumb_width = width < max_thumb_width ? width: max_thumb_width -%}
{%- set thumb_height = (thumb_width/width * height)|round() -%}
{% set canvasId = nodeurl|render ~ '/iiif/canvas/p' ~ itemCount %}
{% set structureCanvasIds = structureCanvasIds|merge([canvasId]) %}
{% set thumbnail -%}
"thumbnail": [
{
"id": "{{ cantaloupeid }}/full/{{thumb_width}},/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"width": {{ thumb_width }},
"height": {{ thumb_height }}
}
],
{%- endset %}
"id": "{{ canvasId }}",
"type": "Canvas",
"label": { "{{ len }}": [
{%- if (image_count > 1) -%}
{{ (loop.index ~ ' of ' ~ image_count ~ ' images: ' ~ data.label)|json_encode|raw }}
{% else %}
{{ data.label|json_encode|raw }}
{%- endif -%}
]},
{{ thumbnail }}
"height": {{ height }},
"width": {{ width }},
"items": [
{
"id": "{{ nodeurl }}/iiif/page/p{{ itemCount}}",
"type": "AnnotationPage",
"items": [
{
"id": "{{ nodeurl }}/iiif/annotation/p{{ itemCount }}",
"type": "Annotation",
"motivation": "painting",
{{ thumbnail }}
"body": {
"id": "{{ cantaloupeid }}/full/full/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"service": [
{
"id": "{{ cantaloupeid }}",
"type": "ImageService2",
"profile": "level2"
}
],
"height": {{ height }},
"width": {{ width }}
},
"target": "{{ nodeurl }}/iiif/canvas/p{{ itemCount }}"
}
]
}
]
{# Annotations for this canvas
"annotations": [
{
"id": "https://iiif.io/api/cookbook/recipe/0021-tagging/page/p2/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0021-tagging/annotation/p0002-tag",
"type": "Annotation",
"motivation": "tagging",
"body": {
"type": "TextualBody",
"value": "Gänseliesel-Brunnen",
"language": "de",
"format": "text/plain"
},
"target": "https://iiif.io/api/cookbook/recipe/0021-tagging/canvas/p1#xywh=265,661,1260,1239"
}
]
}
]
#}
{#- starts Pure Text annotation and direct Image annotations-#}
{% set texts = [] %}
{%- for text_uuid, text_file in data["as:text"] %}
{# only generate an annotation if text and image where uploaded to the same key OR
there is exactly a single Image #}
{% if (text_file["dr:for"] == page["dr:for"] or data["as:image"]|length == 1) and text_file["dr:mimetype"] == "text\/plain" %}
{% set texts = texts|merge([{'dr:uuid': text_file['dr:uuid'], 'name': text_file['name']}]) %}
{% endif %}
{%- endfor %}
{% if texts|length > 0 or data["ap:annotationCollection"][cantaloupeid ~ '/info.json'] is defined %}
,
"annotations": [
{%- if texts|length > 0 -%}
{
"id": "{{ nodeurl }}/iiif/subtitles/s{{ itemCount }}",
"type": "AnnotationPage",
"items": [
{%- for text_file in texts %}
{
"id": "{{ nodeurl }}/iiif/text/p{{ itemCount }}/{{ text_file['dr:uuid'] }}",
"type": "Annotation",
"motivation": "supplementing",
"body": {
"id": "{{ Webserverurl }}do/{{ node.uuid.value }}/file/{{ text_file['dr:uuid'] }}/download/{{ text_file["name"] }}",
"type": "Text",
"format": "text/plain",
"label": {
"en": [
"{{ text_file.name }}"
]
},
"language": "en"
},
"target": "{{ nodeurl }}/iiif/canvas/p{{ itemCount }}"
}{{ not loop.last ? ',' : '' }}
{% endfor -%}
{%- endif -%}
{% if data["ap:annotationCollection"][cantaloupeid ~ '/info.json'] is defined %}
{%- if texts|length > 0 -%},{% endif %}
{
"id": "{{ nodeurl }}/iiif/comments/p{{ itemCount }}",
"type": "AnnotationPage",
"items": [
{% for annotation in data["ap:annotationCollection"][cantaloupeid ~ '/info.json'] %}
{
"id": "{{ nodeurl }}/iiif/comments/p{{ itemCount }}/{{ annotation.id }}",
{# @TODO a single annotation might have multiple Bodies and multiple motivations #}
"motivation": "tagging",
{% set temp_annotation_body = [] %}
{# We need to enrich here, missing language and format #}
{% if annotation.body is iterable %}
{% for body in annotation.body %}
{% set annotation_body = body|merge({'language': len, 'format': 'text/plain'}) %}
{% set temp_annotation_body = temp_annotation_body|merge([annotation_body]) %}
{% endfor %}
{% else %}
{% endif %}
"body": {{ temp_annotation_body|json_encode|raw }},
"type": {{ annotation.type|json_encode(constant('JSON_FORCE_OBJECT'))|raw }}
{# check target type: If polygon we need the selector, if a square, we need the xywh #}
{% if annotation.target.selector.type == "FragmentSelector" %}
{# MIRADOR does not know how to hande "pixel:" in the fragment coordinates selector #}
{% set target = nodeurl|render ~ "/iiif/canvas/p" ~ itemCount ~ '#' ~ annotation.target.selector.value|replace({"pixel:" : ""}) %}
,"target": {{ target|json_encode|raw }}
{% else %}
{# Parse our polygon point values into path for Mirador #}
{% if 'points="' in annotation.target.selector.value %}
{% set mirador_path = annotation.target.selector.value | preg_replace('/.+?points="/','') | preg_replace('/".*/','') %}
{% set mirador_path = "M" ~ (mirador_path|split(" ")|join("L")) ~ " z" %}
{% set target = {
"source" : nodeurl|render ~ "/iiif/canvas/p" ~ itemCount,
"selector": {
"type": annotation.target.selector.type,
"value": '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><path d="' ~ mirador_path ~ '"/></g></svg>'
},
"type": "SpecificResource"
}
%}
,"target": {{ target|json_encode|raw }}
{% endif %}
{% endif %}
}{{ not loop.last ? ',' : '' }}
{% endfor -%}
{% endif %}
]
}]
{% endif %}
{#- ends Pure text and Direct Image annotation -#}
}{{ not loop.last ? ',' : '' }}
{% endfor %}
{#- Video Manifest -#}
{%- if (attribute(data, 'as:video')|length > 0) -%}
{%- if itemCount > 0 -%}
,
{%- endif -%}
{#- Count Videos upfront -#}
{%- set video_count = attribute(data, 'as:video')|length -%}
{% for video in attribute(data, 'as:video') %}
{%- set itemCount = itemCount + 1 -%}
{%- set cantaloupeid = IIIFserverurl ~ video['url']|replace({'s3://':''})|replace({'private://':''})|url_encode -%}
{%- if video["flv:exif"] -%}
{%- set width = video["flv:mediainfo"].videos[0].width.absoluteValue|default(720) -%}
{% else %}
{%- set width = 720 -%}
{% endif %}
{%- if video["flv:mediainfo"] -%}
{%- set height = video["flv:mediainfo"].videos[0].height.absoluteValue -%}
{%- else -%}
{%- set height = 480 -%}
{%- endif -%}
{%- set thumb_width = width < max_thumb_width ? width: max_thumb_width -%}
{%- set thumb_height = (thumb_width/width * height)|round() -%}
{% set thumbnail -%}
"thumbnail": [
{
"id": "{{ cantaloupeid }};1/full/{{thumb_width}},/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"width": {{ thumb_width }},
"height": {{ thumb_height }}
}
],
{%- endset %}
{% set canvasId = nodeurl|render ~ '/iiif/canvas/p' ~ itemCount %}
{% set structureCanvasIds = structureCanvasIds|merge([canvasId]) %}
{
"id": "{{ canvasId }}",
"type": "Canvas",
"label": { "{{ len }}": [
{%- if (video_count > 1) -%}
{{ (loop.index ~ ' of ' ~ video_count ~ ' videos: ' ~ data.label)|json_encode|raw }}
{% else %}
{{ ("Video:" ~ data.label)|json_encode|raw }}
{%- endif -%}
]},
{{ thumbnail }}
"width": {{ width }},
"height": {{ height }},
"duration": {{ video["flv:mediainfo"].videos[0].duration.milliseconds|default(1000) }},
"items": [
{
"id": "{{ nodeurl }}/iiif/page/p{{ itemCount }}",
"type": "AnnotationPage",
"items": [
{
"id": "{{ nodeurl }}/iiif/annotation/p{{ itemCount }}",
"type": "Annotation",
"motivation": "painting",
{{ thumbnail }}
"body": [{
"id": "{{ Webserverurl }}do/{{ node.id }}/iiif/{{ video['dr:uuid'] }}/full/full/0/{{ video.name }}",
"type": "Video",
"format": "{{ video["flv:mediainfo"].general.internet_media_type }}",
"duration": {{ video["flv:mediainfo"].videos[0].duration.milliseconds|default(1000) }},
"height": {{ height }},
"width": {{ width }}
}],
"target": "{{ nodeurl }}/iiif/canvas/p{{ itemCount }}"
}
]
}
]
{#- starts subtitle annotation -#}
{% set vtts = [] %}
{%- for text_uuid, subtitle_track in data["as:text"] %}
{% if subtitle_track["dr:for"] == video["dr:for"] and subtitle_track["dr:mimetype"] == "text\/vtt" %}
{% set vtts = vtts|merge([{'dr:uuid': subtitle_track['dr:uuid'], 'name': subtitle_track['name']}]) %}
{% endif %}
{%- endfor %}
{% if vtts|length > 0 %}
,
"annotations": [{
"id": "{{ nodeurl }}/iiif/subtitles/s{{ itemCount }}",
"type": "AnnotationPage",
"items": [
{%- for subtitle_track in vtts %}
{
"id": "{{ nodeurl }}/iiif/subtitles/p{{ itemCount }}/{{ subtitle_track['dr:uuid'] }}",
"type": "Annotation",
"motivation": "supplementing",
"body": {
"id": "{{ Webserverurl }}do/{{ node.uuid.value }}/file/{{ subtitle_track['dr:uuid'] }}/download/{{ subtitle_track["name"] }}",
"type": "Text",
"format": "text/vtt",
"label": {
"en": [
"{{ subtitle_track.name }}"
]
},
"language": "en"
},
"target": "{{ nodeurl }}/iiif/canvas/p{{ itemCount }}"
}{{ not loop.last ? ',' : '' }}
{% endfor -%}
]
}]
{% endif %}
{#- ends subtitle annotation -#}
}{{ not loop.last ? ',' : '' }}
{% endfor %}
{% endif %}
{# Audio Manifest #}
{%- if (attribute(data, 'as:audio')|length > 0) -%}
{%- if itemCount > 0 -%}
,
{%- endif -%}
{#- Count Audios upfront -#}
{%- set audio_count = attribute(data, 'as:audio')|length -%}
{% for audio in attribute(data, 'as:audio') %}
{%- set itemCount = itemCount + 1 -%}
{% set canvasId = nodeurl|render ~ '/iiif/canvas/p' ~ itemCount %}
{% set structureCanvasIds = structureCanvasIds|merge([canvasId]) %}
{
"id": "{{ canvasId }}",
"type": "Canvas",
"label": { "{{ len }}": [
{%- if (audio_count > 1) -%}
{{ (loop.index ~ ' of ' ~ audio_count ~ ' audios: ' ~ data.label)|json_encode|raw }}
{% else %}
{{ ("Audio:" ~ data.label )|json_encode|raw }}
{%- endif -%}
]},
"duration": {{ audio["flv:mediainfo"].audios[0].duration.milliseconds|default(1000) }},
"items": [
{
"id": "{{ nodeurl }}/iiif/page/p{{ itemCount }}",
"type": "AnnotationPage",
"items": [
{
"id": "{{ nodeurl }}/iiif/annotation/p{{ itemCount }}",
"type": "Annotation",
"motivation": "painting",
{{ thumbnail }}
"body": {
"id": "{{ Webserverurl }}do/{{ node.id }}/iiif/{{ audio['dr:uuid'] }}/full/full/0/{{ audio.name }}",
"type": "Sound",
"format": "{{ audio["flv:mediainfo"].general.internet_media_type }}",
"duration": {{ audio["flv:mediainfo"].audios[0].duration.milliseconds|default(1000) }}
},
"target": "{{ nodeurl }}/iiif/canvas/p{{ itemCount }}"
}
]
}
]
}{{ not loop.last ? ',' : '' }}
{% endfor %}
{% endif %}
],
"structures": [
{
"id": "{{ nodeurl }}/iiif/range/r1",
"type": "Range",
"label": {
"{{ len }}": [
{{ node.label|json_encode|raw }}
]
},
"items": [
{% for rangeItem in structureCanvasIds %}
{
"id": "{{ rangeItem }}",
"type": "Canvas"
}{{ not loop.last ? ',' : '' }}
{% endfor %}
]
}
]
}