-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.fix
106 lines (89 loc) · 4.79 KB
/
manifest.fix
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
###
### catmandu fix for converting a csv file to IIIF manifest file
### requires Perlmodule Catmandu-Store-REST
###
### Authors: Pieter De Praetere and Nastasia Vanderperren (PACKED vzw, 2017)
###
hash('fixed')
### set fixed values
add_field('url', 'http://free.iiifhosting.com/iiif/')
add_field('attribution', 'KMSKA')
add_field('logo', 'http://www.kmska.be/static/site_images/lgo_kmska.gif')
add_field('iiif-context', 'http://iiif.io/api/presentation/2/context.json')
add_field('manifest-type', 'sc:Manifest')
add_field('sequence-type', 'sc:Sequence')
add_field('canvas-type', 'sc:Canvas')
add_field('image-type', 'oa:Annotation')
add_field('image-motivation', 'sc:painting')
add_field('resource-type', 'dctypes:Image')
add_field('format', 'image/jpeg')
add_field('service-context', 'http://iiif.io/api/image/2/context.json')
add_field('service-profile', 'http://iiif.io/api/image/2/profiles/level1.json')
### structure manifest
copy_field('iiif-context', 'fixed.@context')
paste('fixed.@id', 'url', 'id') ## deze code werkt niet bij @id
replace_all('fixed.@id', ' ', '') ## in canvas, resource en service. waarom?
append('fixed.@id', '/manifest.json')
copy_field('manifest-type', 'fixed.@type')
copy_field('label', 'fixed.label')
copy_field('rechten', 'fixed.license')
copy_field('attribution', 'fixed.attribution')
copy_field('logo', 'fixed.logo')
copy_field('PID', 'fixed.seeAlso')
### structure sequences
set_array('fixed.sequences')
copy_field('sequence-type', 'fixed.sequences.$append.@type')
set_array('fixed.sequences.$last.canvases')
### building canvases by looping
split_field('afbeeldingen', ',')
hash('label_en_id')
add_field('t.id.first', 'http://free.iiifhosting.com/iiif/')
add_field('t.id.last', '/canvas.json')
### get label and id for each canvas
do list(path: afbeeldingen, var: a)
split_field('a', ':')
copy_field('a.0', 'label_en_id.$append.label')
copy_field('a.1', 'label_en_id.$last.id')
end
### connect to the IIIF Image API
do list(path: label_en_id, var: l)
copy_field(l.id, l.lookup_id)
lookup_in_store(
l.lookup_id,
REST,
base_url: 'http://free.iiifhosting.com/iiif',
query_string: '/info.json'
)
### structure canvas
copy_field('canvas-type', 'fixed.sequences.$last.canvases.$append.@type')
copy_field('l.id', 'fixed.sequences.$last.canvases.$last.@id')
prepend('fixed.sequences.$last.canvases.$last.@id', 'http://free.iiifhosting.com/iiif/')
append('fixed.sequences.$last.canvases.$last.@id', '/canvas.json')
copy_field('l.label', 'fixed.sequences.$last.canvases.$last.label')
copy_field(l.lookup_id.height, 'fixed.sequences.$last.canvases.$last.height')
copy_field(l.lookup_id.width, 'fixed.sequences.$last.canvases.$last.width')
### structure images
set_array('fixed.sequences.$last.canvases.$last.images')
copy_field('fixed.sequences.$last.canvases.$last.@id','fixed.sequences.$last.canvases.$last.images.$last.on')
#copy_field('image-type', 'fixed.sequences.$last.canvases.$last.images.$append.@type')
#copy_field('image-motivation', 'fixed.sequences.$last.canvases.$last.images.$last.motivation')
### structure resource
set_hash('fixed.sequences.$last.canvases.$last.images.$last.resource','@id': 'id','@type': 'dctypes:Image', 'format': 'image/jpeg','height': 'hoogte','width': 'breedte')
copy_field('l.id', 'fixed.sequences.$last.canvases.$last.images.$last.resource.@id')
copy_field(l.lookup_id.height, 'fixed.sequences.$last.canvases.$last.images.$last.resource.height')
copy_field(l.lookup_id.width, 'fixed.sequences.$last.canvases.$last.images.$last.resource.width')
prepend('fixed.sequences.$last.canvases.$last.images.$last.resource.@id', 'http://free.iiifhosting.com/iiif/')
append('fixed.sequences.$last.canvases.$last.images.$last.resource.@id', '/full/full/0/default.jpg')
set_hash('fixed.sequences.$last.canvases.$last.images.$last.resource.service', '@context': 'context', '@id': 'id', 'profile': 'profile')
copy_field('l.id', 'fixed.sequences.$last.canvases.$last.images.$last.resource.service.@id')
prepend('fixed.sequences.$last.canvases.$last.images.$last.resource.service.@id', 'http://free.iiifhosting.com/iiif/')
#copy_field('service-context', 'fixed.sequences.$last.canvases.$last.images.$last.resource.service.@context')
#copy_field('service-profile', 'fixed.sequences.$last.canvases.$last.images.$last.resource.service.profile')
end
### images
copy_field('image-type', 'fixed.sequences.$last.canvases.*.images.$last.@type')
copy_field('image-motivation', 'fixed.sequences.$last.canvases.*.images.$last.motivation')
copy_field('service-context', 'fixed.sequences.$last.canvases.*.images.$last.resource.service.@context')
copy_field('service-profile', 'fixed.sequences.$last.canvases.*.images.$last.resource.service.profile')
retain(fixed)
move_field(fixed, .)