diff --git a/app/models/concerns/master_file_behavior.rb b/app/models/concerns/master_file_behavior.rb index 8b546dac9d..415842a87f 100644 --- a/app/models/concerns/master_file_behavior.rb +++ b/app/models/concerns/master_file_behavior.rb @@ -68,7 +68,7 @@ def stream_details # Returns the hash return({ id: self.id, - label: title, + label: structure_title, is_video: is_video?, poster_image: poster_path, embed_code: embed_code(EMBED_SIZE[:medium], {urlappend: '/embed'}), @@ -119,6 +119,10 @@ def embed_title [media_object.title, display_title].compact.join(" - ") end + def structure_title + display_title.present? ? display_title : media_object.title + end + def embed_code(width, permalink_opts = {}) begin url = if self.permalink.present? diff --git a/app/models/iiif_canvas_presenter.rb b/app/models/iiif_canvas_presenter.rb index 2d12db3862..c43ac2a1b6 100644 --- a/app/models/iiif_canvas_presenter.rb +++ b/app/models/iiif_canvas_presenter.rb @@ -131,8 +131,7 @@ def supplemental_captions_transcripts files end - def simple_iiif_range(label = stream_info[:embed_title]) - # TODO: embed_title? + def simple_iiif_range(label = stream_info[:label]) IiifManifestRange.new( label: { "none" => [label] }, items: [ diff --git a/app/presenters/speedy_af/proxy/master_file.rb b/app/presenters/speedy_af/proxy/master_file.rb index 6881a2e03a..867c7fa660 100644 --- a/app/presenters/speedy_af/proxy/master_file.rb +++ b/app/presenters/speedy_af/proxy/master_file.rb @@ -1,11 +1,11 @@ # Copyright 2011-2023, The Trustees of Indiana University and Northwestern # University. Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -# +# # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the diff --git a/spec/models/iiif_canvas_presenter_spec.rb b/spec/models/iiif_canvas_presenter_spec.rb index 46a7b8e665..a31f965dbb 100644 --- a/spec/models/iiif_canvas_presenter_spec.rb +++ b/spec/models/iiif_canvas_presenter_spec.rb @@ -88,13 +88,27 @@ end context 'with no structural metadata' do - let(:structure_xml) { "" } + context 'master file with title' do + let(:structure_xml) { "" } + let(:master_file) { FactoryBot.create(:master_file, title: "video.mp4", media_object: media_object, derivatives: [derivative]) } + + it 'autogenerates a basic range with structure_title as label' do + expect(subject.label.to_s).to eq "{\"none\"=>[\"#{master_file.structure_title}\"]}" + expect(subject.items.size).to eq 1 + expect(subject.items.first).to be_a IiifCanvasPresenter + expect(subject.items.first.media_fragment).to eq "t=0,#{master_file.duration.to_f/1000}" + end + end - it 'autogenerates a basic range' do - expect(subject.label.to_s).to eq "{\"none\"=>[\"#{master_file.embed_title}\"]}" - expect(subject.items.size).to eq 1 - expect(subject.items.first).to be_a IiifCanvasPresenter - expect(subject.items.first.media_fragment).to eq "t=0,#{master_file.duration.to_f/1000}" + context 'master file without title' do + let(:structure_xml) { "" } + + it 'autogenerates a basic range with media_object.title as label' do + expect(subject.label.to_s).to eq "{\"none\"=>[\"#{media_object.title}\"]}" + expect(subject.items.size).to eq 1 + expect(subject.items.first).to be_a IiifCanvasPresenter + expect(subject.items.first.media_fragment).to eq "t=0,#{master_file.duration.to_f/1000}" + end end end