Last active
March 20, 2018 05:13
-
-
Save jpstroop/b0b18e18fb8b96bb114c to your computer and use it in GitHub Desktop.
Example: How to create a bare-bones IIIF Presentation Manifest w/ O'Sullivan
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
require 'iiif/presentation' | |
MY_IIIF_IMAGE_SERVER = 'http://libimages1.princeton.edu/loris/' | |
SOME_IIIF_IMAGES = [ | |
{ id: 'pudl0001%2F4609321%2Fs42%2F00000006.jp2', label: "Page 1" }, | |
{ id: 'pudl0001%2F4609321%2Fs42%2F00000007.jp2', label: "Page 2" }, | |
{ id: 'pudl0001%2F4609321%2Fs42%2F00000008.jp2', label: "Page 3" }, | |
{ id: 'pudl0001%2F4609321%2Fs42%2F00000009.jp2', label: "Page 4" }, | |
{ id: 'pudl0001%2F4609321%2Fs42%2F00000010.jp2', label: "Page 5" } | |
] | |
def image_annotation_from_id(image_id, label) | |
annotation = IIIF::Presentation::Annotation.new | |
annotation.resource = image_resource_from_page_hash(image_id) | |
canvas = IIIF::Presentation::Canvas.new | |
canvas_uri = "http://example.org/my_book/pages/#{image_id}" | |
canvas['@id'] = canvas_uri | |
canvas.label = label | |
canvas.width = annotation.resource['width'] | |
canvas.height = annotation.resource['height'] | |
canvas.images << annotation | |
canvas | |
end | |
def image_resource_from_page_hash(page_id) | |
base_uri = "#{MY_IIIF_IMAGE_SERVER}#{page_id}" | |
params = {service_id: base_uri} | |
image_resource = IIIF::Presentation::ImageResource.create_image_api_image_resource(params) | |
image_resource | |
end | |
## Main | |
manifest = IIIF::Presentation::Manifest.new('@id' => 'http://example.org/my_book') | |
manifest.label = "My Book" | |
manifest.viewing_hint = 'paged' | |
manifest.metadata = [ | |
{ 'Foo' => 'Bar' }, | |
{ 'Bazzers' => [ 'Quux', 'Corge' ]} | |
] | |
sequence = IIIF::Presentation::Sequence.new | |
SOME_IIIF_IMAGES.each do |image| | |
sequence.canvases << image_annotation_from_id(image[:id], image[:label]) | |
end | |
manifest.sequences << sequence | |
thumb = manifest.sequences.first.canvases.first.images.first.resource['@id'] | |
manifest.insert_after(existing_key: 'label', new_key: 'thumbnail', value: thumb) | |
puts manifest.to_json(pretty: true) |
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
{ | |
"@context": "http://iiif.io/api/presentation/2/context.json", | |
"@id": "http://example.org/my_book", | |
"@type": "sc:Manifest", | |
"label": "My Book", | |
"thumbnail": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg", | |
"viewingHint": "paged", | |
"metadata": [ | |
{ | |
"Foo": "Bar" | |
}, | |
{ | |
"Bazzers": [ | |
"Quux", | |
"Corge" | |
] | |
} | |
], | |
"sequences": [ | |
{ | |
"@type": "sc:Sequence", | |
"canvases": [ | |
{ | |
"@id": "http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000006.jp2", | |
"@type": "sc:Canvas", | |
"label": "Page 1", | |
"width": 5434, | |
"height": 7200, | |
"images": [ | |
{ | |
"@type": "oa:Annotation", | |
"motivation": "sc:painting", | |
"resource": { | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg", | |
"@type": "dcterms:Image", | |
"format": "image/jpeg", | |
"width": 5434, | |
"height": 7200, | |
"service": { | |
"@context": "http://iiif.io/api/image/2/context.json", | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2", | |
"profile": "http://iiif.io/api/image/2/level2.json" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"@id": "http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000007.jp2", | |
"@type": "sc:Canvas", | |
"label": "Page 2", | |
"width": 5387, | |
"height": 7200, | |
"images": [ | |
{ | |
"@type": "oa:Annotation", | |
"motivation": "sc:painting", | |
"resource": { | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2/full/!200,200/0/default.jpg", | |
"@type": "dcterms:Image", | |
"format": "image/jpeg", | |
"width": 5387, | |
"height": 7200, | |
"service": { | |
"@context": "http://iiif.io/api/image/2/context.json", | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2", | |
"profile": "http://iiif.io/api/image/2/level2.json" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"@id": "http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000008.jp2", | |
"@type": "sc:Canvas", | |
"label": "Page 3", | |
"width": 5434, | |
"height": 7200, | |
"images": [ | |
{ | |
"@type": "oa:Annotation", | |
"motivation": "sc:painting", | |
"resource": { | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2/full/!200,200/0/default.jpg", | |
"@type": "dcterms:Image", | |
"format": "image/jpeg", | |
"width": 5434, | |
"height": 7200, | |
"service": { | |
"@context": "http://iiif.io/api/image/2/context.json", | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2", | |
"profile": "http://iiif.io/api/image/2/level2.json" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"@id": "http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000009.jp2", | |
"@type": "sc:Canvas", | |
"label": "Page 4", | |
"width": 5387, | |
"height": 7200, | |
"images": [ | |
{ | |
"@type": "oa:Annotation", | |
"motivation": "sc:painting", | |
"resource": { | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2/full/!200,200/0/default.jpg", | |
"@type": "dcterms:Image", | |
"format": "image/jpeg", | |
"width": 5387, | |
"height": 7200, | |
"service": { | |
"@context": "http://iiif.io/api/image/2/context.json", | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2", | |
"profile": "http://iiif.io/api/image/2/level2.json" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"@id": "http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000010.jp2", | |
"@type": "sc:Canvas", | |
"label": "Page 5", | |
"width": 5434, | |
"height": 7200, | |
"images": [ | |
{ | |
"@type": "oa:Annotation", | |
"motivation": "sc:painting", | |
"resource": { | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2/full/!200,200/0/default.jpg", | |
"@type": "dcterms:Image", | |
"format": "image/jpeg", | |
"width": 5434, | |
"height": 7200, | |
"service": { | |
"@context": "http://iiif.io/api/image/2/context.json", | |
"@id": "http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2", | |
"profile": "http://iiif.io/api/image/2/level2.json" | |
} | |
} | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
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
2.2.2 :001 > require 'iiif/presentation' | |
=> true | |
2.2.2 :002 > my_manifest = '{"@context":"http://iiif.io/api/presentation/2/context.json","@id":"http://example.org/my_book","@type":"sc:Manifest","label":"My Book","thumbnail":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg","viewingHint":"paged","metadata":[{"Foo":"Bar"},{"Bazzers":["Quux","Corge"]}],"sequences":[{"@type":"sc:Sequence","canvases":[{"@id":"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000006.jp2","@type":"sc:Canvas","label":"Page 1","width":5434,"height":7200,"images":[{"@type":"oa:Annotation","motivation":"sc:painting","resource":{"@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg","@type":"dcterms:Image","format":"image/jpeg","width":5434,"height":7200,"service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2","profile":"http://iiif.io/api/image/2/level2.json"}}}]},{"@id":"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000007.jp2","@type":"sc:Canvas","label":"Page 2","width":5387,"height":7200,"images":[{"@type":"oa:Annotation","motivation":"sc:painting","resource":{"@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2/full/!200,200/0/default.jpg","@type":"dcterms:Image","format":"image/jpeg","width":5387,"height":7200,"service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2","profile":"http://iiif.io/api/image/2/level2.json"}}}]},{"@id":"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000008.jp2","@type":"sc:Canvas","label":"Page 3","width":5434,"height":7200,"images":[{"@type":"oa:Annotation","motivation":"sc:painting","resource":{"@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2/full/!200,200/0/default.jpg","@type":"dcterms:Image","format":"image/jpeg","width":5434,"height":7200,"service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2","profile":"http://iiif.io/api/image/2/level2.json"}}}]},{"@id":"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000009.jp2","@type":"sc:Canvas","label":"Page 4","width":5387,"height":7200,"images":[{"@type":"oa:Annotation","motivation":"sc:painting","resource":{"@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2/full/!200,200/0/default.jpg","@type":"dcterms:Image","format":"image/jpeg","width":5387,"height":7200,"service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2","profile":"http://iiif.io/api/image/2/level2.json"}}}]},{"@id":"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000010.jp2","@type":"sc:Canvas","label":"Page 5","width":5434,"height":7200,"images":[{"@type":"oa:Annotation","motivation":"sc:painting","resource":{"@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2/full/!200,200/0/default.jpg","@type":"dcterms:Image","format":"image/jpeg","width":5434,"height":7200,"service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2","profile":"http://iiif.io/api/image/2/level2.json"}}}]}]}]}' | |
=> "{\"@context\":\"http://iiif.io/api/presentation/2/context.json\",\"@id\":\"http://example.org/my_book\",\"@type\":\"sc:Manifest\",\"label\":\"My Book\",\"thumbnail\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg\",\"viewingHint\":\"paged\",\"metadata\":[{\"Foo\":\"Bar\"},{\"Bazzers\":[\"Quux\",\"Corge\"]}],\"sequences\":[{\"@type\":\"sc:Sequence\",\"canvases\":[{\"@id\":\"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000006.jp2\",\"@type\":\"sc:Canvas\",\"label\":\"Page 1\",\"width\":5434,\"height\":7200,\"images\":[{\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg\",\"@type\":\"dcterms:Image\",\"format\":\"image/jpeg\",\"width\":5434,\"height\":7200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}}}]},{\"@id\":\"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000007.jp2\",\"@type\":\"sc:Canvas\",\"label\":\"Page 2\",\"width\":5387,\"height\":7200,\"images\":[{\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2/full/!200,200/0/default.jpg\",\"@type\":\"dcterms:Image\",\"format\":\"image/jpeg\",\"width\":5387,\"height\":7200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}}}]},{\"@id\":\"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000008.jp2\",\"@type\":\"sc:Canvas\",\"label\":\"Page 3\",\"width\":5434,\"height\":7200,\"images\":[{\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2/full/!200,200/0/default.jpg\",\"@type\":\"dcterms:Image\",\"format\":\"image/jpeg\",\"width\":5434,\"height\":7200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}}}]},{\"@id\":\"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000009.jp2\",\"@type\":\"sc:Canvas\",\"label\":\"Page 4\",\"width\":5387,\"height\":7200,\"images\":[{\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2/full/!200,200/0/default.jpg\",\"@type\":\"dcterms:Image\",\"format\":\"image/jpeg\",\"width\":5387,\"height\":7200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}}}]},{\"@id\":\"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000010.jp2\",\"@type\":\"sc:Canvas\",\"label\":\"Page 5\",\"width\":5434,\"height\":7200,\"images\":[{\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2/full/!200,200/0/default.jpg\",\"@type\":\"dcterms:Image\",\"format\":\"image/jpeg\",\"width\":5434,\"height\":7200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}}}]}]}]}" | |
2.2.2 :003 > my_resource = IIIF::Service.parse(my_manifest) | |
=> #<IIIF::Presentation::Manifest:0x00000001c4aff8 @data={"@type"=>"sc:Manifest", "@context"=>"http://iiif.io/api/presentation/2/context.json", "@id"=>"http://example.org/my_book", "label"=>"My Book", "thumbnail"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg", "viewing_hint"=>"paged", "metadata"=>[{"foo"=>"Bar"}, {"bazzers"=>["Quux", "Corge"]}], "sequences"=>[#<IIIF::Presentation::Sequence:0x000000012d8718 @data={"@type"=>"sc:Sequence", "canvases"=>[#<IIIF::Presentation::Canvas:0x0000000150b0f8 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000006.jp2", "label"=>"Page 1", "width"=>5434, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x000000015eca08 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x000000014bb328 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5434, "height"=>7200, "service"=>#<IIIF::Service:0x000000016c4ae8 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x00000001663748 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000007.jp2", "label"=>"Page 2", "width"=>5387, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x000000018d6778 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x00000001904d08 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5387, "height"=>7200, "service"=>#<IIIF::Service:0x00000001926160 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x000000019249a0 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000008.jp2", "label"=>"Page 3", "width"=>5434, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x00000001953408 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x000000019ba9f0 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5434, "height"=>7200, "service"=>#<IIIF::Service:0x000000019f1c20 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x000000019f0b40 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000009.jp2", "label"=>"Page 4", "width"=>5387, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x00000001a2a228 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x00000001a43d90 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5387, "height"=>7200, "service"=>#<IIIF::Service:0x00000001a51418 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x00000001a506d0 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000010.jp2", "label"=>"Page 5", "width"=>5434, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x00000001a80358 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x00000001a9c080 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5434, "height"=>7200, "service"=>#<IIIF::Service:0x00000001adffb0 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>]}>]}> | |
2.2.2 :004 > my_resource['@type'] | |
=> "sc:Manifest" | |
2.2.2 :005 > my_resource.sequences | |
=> [#<IIIF::Presentation::Sequence:0x000000012d8718 @data={"@type"=>"sc:Sequence", "canvases"=>[#<IIIF::Presentation::Canvas:0x0000000150b0f8 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000006.jp2", "label"=>"Page 1", "width"=>5434, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x000000015eca08 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x000000014bb328 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5434, "height"=>7200, "service"=>#<IIIF::Service:0x000000016c4ae8 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000006.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x00000001663748 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000007.jp2", "label"=>"Page 2", "width"=>5387, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x000000018d6778 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x00000001904d08 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5387, "height"=>7200, "service"=>#<IIIF::Service:0x00000001926160 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000007.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x000000019249a0 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000008.jp2", "label"=>"Page 3", "width"=>5434, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x00000001953408 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x000000019ba9f0 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5434, "height"=>7200, "service"=>#<IIIF::Service:0x000000019f1c20 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000008.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x000000019f0b40 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000009.jp2", "label"=>"Page 4", "width"=>5387, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x00000001a2a228 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x00000001a43d90 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5387, "height"=>7200, "service"=>#<IIIF::Service:0x00000001a51418 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000009.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>, #<IIIF::Presentation::Canvas:0x00000001a506d0 @data={"@type"=>"sc:Canvas", "@id"=>"http://example.org/my_book/pages/pudl0001%2F4609321%2Fs42%2F00000010.jp2", "label"=>"Page 5", "width"=>5434, "height"=>7200, "images"=>[#<IIIF::Presentation::Annotation:0x00000001a80358 @data={"@type"=>"oa:Annotation", "motivation"=>"sc:painting", "resource"=>#<IIIF::Presentation::Resource:0x00000001a9c080 @data={"@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2/full/!200,200/0/default.jpg", "@type"=>"dcterms:Image", "format"=>"image/jpeg", "width"=>5434, "height"=>7200, "service"=>#<IIIF::Service:0x00000001adffb0 @data={"@context"=>"http://iiif.io/api/image/2/context.json", "@id"=>"http://libimages1.princeton.edu/loris/pudl0001%2F4609321%2Fs42%2F00000010.jp2", "profile"=>"http://iiif.io/api/image/2/level2.json"}>}>}>]}>]}>] |
I think maybe something like this:
manifest.metadata = [
{ 'label' => 'Foo', 'value' => 'Bar' },
{ 'label' => 'Bazzers', 'value' => [ {'@value' => 'Quux'}, {'@value' => 'Corge'} ] }
]
Going to run that through the validator from https://github.com/IIIF/presentation-validato and see what happens...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this gist is a few years old but I wanted to point out that the metadata section is a bit misleading. It seems to me that it should be more like...
manifest.metadata = [
{ 'label' => 'Foo', 'value' => 'Bar' },
]
I don't know about the multiple values... I'll try that now...