Skip to content

Commit

Permalink
Add ID property to Annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
masaball committed May 3, 2022
1 parent 3558acf commit 1d70a58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/iiif_manifest/v3/manifest_builder/content_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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}")
annotation['target'] = canvas['id']
canvas['width'] = annotation.body['width'] if annotation.body['width'].present?
canvas['height'] = annotation.body['height'] if annotation.body['height'].present?
Expand Down
4 changes: 4 additions & 0 deletions lib/iiif_manifest/v3/manifest_builder/iiif_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def body
inner_hash['body']
end

def index
@index ||= SecureRandom.uuid
end

def initial_attributes
{
'type' => 'Annotation',
Expand Down

0 comments on commit 1d70a58

Please sign in to comment.