Skip to content

Commit

Permalink
IIIF #39 - Updating the IIIF Presentation manifest creation to use a …
Browse files Browse the repository at this point in the history
…valid URL as the root level "id" attribute
  • Loading branch information
dleadbetter committed Jan 19, 2024
1 parent c95eaf1 commit 9175a5e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/services/iiif/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand All @@ -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?
Expand Down Expand Up @@ -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)]
}]
Expand Down

0 comments on commit 9175a5e

Please sign in to comment.