From 9175a5ea0b055a7466cd50f6e413572f58dc0d80 Mon Sep 17 00:00:00 2001 From: dleadbetter <> Date: Fri, 19 Jan 2024 09:30:30 -0500 Subject: [PATCH] IIIF #39 - Updating the IIIF Presentation manifest creation to use a valid URL as the root level "id" attribute --- app/services/iiif/manifest.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/services/iiif/manifest.rb b/app/services/iiif/manifest.rb index 65227e1..0e268b8 100644 --- a/app/services/iiif/manifest.rb +++ b/app/services/iiif/manifest.rb @@ -2,7 +2,7 @@ module Iiif class Manifest def self.create(resource) manifest = to_json('manifest.json') - manifest['id'] = "https://#{resource.uuid}" + manifest['id'] = "#{base_url(resource)}/manifest" manifest['label'] = { en: [resource.name] } @@ -26,9 +26,13 @@ def self.create(resource) private + def self.base_url(resource) + "#{ENV['HOSTNAME']}/public/resources/#{resource.uuid}" + end + def self.create_annotation(resource, target, page_number) annotation = to_json('annotation.json') - annotation['id'] = "https://#{resource.uuid}/canvas/#{page_number}/annotation_page/1/annotation/1" + annotation['id'] = "#{base_url(resource)}/canvas/#{page_number}/annotation_page/1/annotation/1" annotation['target'] = target if resource.image? || resource.pdf? @@ -62,12 +66,12 @@ def self.create_annotation(resource, target, page_number) def self.create_canvas(resource, width, height, page_number) canvas = to_json('canvas.json') - canvas['id'] = "https://#{resource.uuid}/canvas/#{page_number}" + canvas['id'] = "#{base_url(resource)}/canvas/#{page_number}" canvas['width'] = width canvas['height'] = height canvas['items'] = [{ - id: "https://#{resource.uuid}/canvas/#{page_number}/annotation_page/1", + id: "#{base_url(resource)}/canvas/#{page_number}/annotation_page/1", type: 'AnnotationPage', items: [create_annotation(resource, canvas['id'], page_number)] }]