Skip to content

Commit

Permalink
Fix iiif validator errors for media object manifest generation (#5810)
Browse files Browse the repository at this point in the history
* Fix iiif validator errors for media object manifest generation

* Fix audio canvas height,width, and thumbnail url

* Fix failing test

* Use asset_host for thumbnail id serialization instead of thumbnail endpoint

Co-authored-by: Chris Colvard <[email protected]>

* Fix failing tests for assets

---------

Co-authored-by: Chris Colvard <[email protected]>
  • Loading branch information
Dananji and cjcolvar authored May 15, 2024
1 parent 231560f commit 164e5fe
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ def placeholder_content
elsif section_processing?(@master_file)
IIIFManifest::V3::DisplayContent.new(nil,
label: I18n.t('media_object.conversion_msg'),
width: 1280,
height: 720,
type: 'Text',
format: 'text/plain')
else
support_email = Settings.email.support
IIIFManifest::V3::DisplayContent.new(nil,
label: I18n.t('errors.missing_derivatives_error') % [support_email, support_email],
width: 1280,
height: 720,
type: 'Text',
format: 'text/plain')
end
Expand Down Expand Up @@ -213,8 +217,8 @@ def parse_hour_min_sec(s)
def manifest_attributes(quality, media_type)
media_hash = {
label: quality,
width: master_file.width.to_i,
height: master_file.height.to_i,
width: (master_file.width || '1280').to_i,
height: (master_file.height || MasterFile::AUDIO_HEIGHT).to_i,
duration: stream_info[:duration],
type: media_type,
format: 'application/x-mpegURL'
Expand Down
2 changes: 1 addition & 1 deletion app/models/iiif_manifest_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def thumbnail
def ranges
[
IiifManifestRange.new(
label: { '@none'.to_sym => media_object.title },
label: { 'none' => [media_object.title] },
items: file_set_presenters.collect(&:range)
)
]
Expand Down
1 change: 1 addition & 0 deletions config/initializers/default_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Rails.application.routes.default_url_options.merge!( server_options )
ActionMailer::Base.default_url_options.merge!( server_options )
ApplicationController.default_url_options = server_options
ActionController::Base.asset_host = URI("#{Settings.domain.protocol}://#{Settings.domain.host}:#{Settings.domain.port}").to_s
end

# Required for rails 6+
Expand Down
6 changes: 3 additions & 3 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@
end
it "should return audio icon" do
doc = {"avalon_resource_type_ssim" => ['Sound Recording', 'Sound Recording'] }
expect(helper.image_for(doc).start_with?('/assets/audio_icon')).to be_truthy
expect(helper.image_for(doc).start_with?("#{root_url}assets/audio_icon")).to be_truthy
end
it "should return video icon" do
doc = {"avalon_resource_type_ssim" => ['Moving Image'] }
expect(helper.image_for(doc).start_with?('/assets/video_icon')).to be_truthy
expect(helper.image_for(doc).start_with?("#{root_url}assets/video_icon")).to be_truthy
end
it "should return hybrid icon" do
doc = {"avalon_resource_type_ssim" => ['Moving Image', 'Sound Recording'] }
expect(helper.image_for(doc).start_with?('/assets/hybrid_icon')).to be_truthy
expect(helper.image_for(doc).start_with?("#{root_url}assets/hybrid_icon")).to be_truthy
end
it "should return nil when only unprocessed video" do
doc = {"section_id_ssim" => ['1'], "avalon_resource_type_ssim" => [] }
Expand Down
20 changes: 20 additions & 0 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@
it 'has format' do
expect(subject.format).to eq "application/x-mpegURL"
end

it 'has height and width' do
expect(subject.width).to eq 1280
expect(subject.height).to eq 40
end
end

context 'when video file' do
it 'has format' do
expect(subject.format).to eq "application/x-mpegURL"
end

it 'has height and width' do
expect(subject.width).to eq 1024
expect(subject.height).to eq 768
end
end
end

Expand Down Expand Up @@ -185,6 +195,11 @@
it 'has label' do
expect(subject.label).to eq I18n.t('errors.missing_derivatives_error') % [Settings.email.support, Settings.email.support]
end

it 'has height and width' do
expect(subject.width).to eq 1280
expect(subject.height).to eq 720
end
end

context 'when master file is processing' do
Expand All @@ -201,6 +216,11 @@
it 'has label' do
expect(subject.label).to eq I18n.t('media_object.conversion_msg')
end

it 'has height and width' do
expect(subject.width).to eq 1280
expect(subject.height).to eq 720
end
end
end

Expand Down

0 comments on commit 164e5fe

Please sign in to comment.