diff --git a/lib/iiif_manifest/v3/manifest_builder/content_builder.rb b/lib/iiif_manifest/v3/manifest_builder/content_builder.rb index 2be7db9..75d5357 100644 --- a/lib/iiif_manifest/v3/manifest_builder/content_builder.rb +++ b/lib/iiif_manifest/v3/manifest_builder/content_builder.rb @@ -11,11 +11,12 @@ def initialize(display_content, iiif_annotation_factory:, body_builder_factory:) end def apply(canvas) + # Assume first item in canvas is an annotation page + annotation['id'] = "#{canvas.items.first['id']}/annotation/#{annotation.index}" annotation['target'] = canvas['id'] canvas['width'] = annotation.body['width'] if annotation.body['width'].present? canvas['height'] = annotation.body['height'] if annotation.body['height'].present? canvas['duration'] = annotation.body['duration'] if annotation.body['duration'].present? - # Assume first item in canvas is an annotation page canvas.items.first.items += [annotation] end diff --git a/lib/iiif_manifest/v3/manifest_builder/iiif_service.rb b/lib/iiif_manifest/v3/manifest_builder/iiif_service.rb index 61ecb79..d4885f5 100644 --- a/lib/iiif_manifest/v3/manifest_builder/iiif_service.rb +++ b/lib/iiif_manifest/v3/manifest_builder/iiif_service.rb @@ -191,6 +191,10 @@ def body inner_hash['body'] end + def index + @index ||= SecureRandom.uuid + end + def initial_attributes { 'type' => 'Annotation', diff --git a/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb b/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb index 8bb1fd1..5ae6a0f 100644 --- a/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb +++ b/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb @@ -142,6 +142,7 @@ def display_content expect(result['items'].first['items'].first['id']).not_to be_empty expect(result['items'].first['items'].first['items'].length).to eq 1 expect(result['items'].first['items'].first['items'].first['type']).to eq 'Annotation' + expect(result['items'].first['items'].first['items'].first['id']).not_to be_empty expect(result['items'].first['items'].first['items'].first['motivation']).to eq 'painting' expect(result['items'].first['items'].first['items'].first['target']).to eq result['items'].first['id'] expect(result['items'].first['items'].first['items'].first['body']['type']).to eq 'Image' @@ -185,6 +186,7 @@ def display_content expect(result['items'].first['items'].first['id']).not_to be_empty expect(result['items'].first['items'].first['items'].length).to eq 1 expect(result['items'].first['items'].first['items'].first['type']).to eq 'Annotation' + expect(result['items'].first['items'].first['items'].first['id']).not_to be_empty expect(result['items'].first['items'].first['items'].first['motivation']).to eq 'painting' expect(result['items'].first['items'].first['items'].first['target']).to eq result['items'].first['id'] expect(result['items'].first['items'].first['items'].first['body']['type']).to eq 'Sound'