From f7dcb9073d52e34b00a3d169889e40eb414a2f21 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Wed, 4 May 2022 14:15:59 -0400 Subject: [PATCH] Change annotation id URI to match JSON nesting --- lib/iiif_manifest/v3/manifest_builder/content_builder.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/iiif_manifest/v3/manifest_builder/content_builder.rb b/lib/iiif_manifest/v3/manifest_builder/content_builder.rb index 54ee64d..75d5357 100644 --- a/lib/iiif_manifest/v3/manifest_builder/content_builder.rb +++ b/lib/iiif_manifest/v3/manifest_builder/content_builder.rb @@ -11,12 +11,12 @@ def initialize(display_content, iiif_annotation_factory:, body_builder_factory:) end def apply(canvas) - annotation['id'] = canvas['id'].to_s.gsub(/manifest.*/, "annotation/#{annotation.index}") + # 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