Skip to content

Commit

Permalink
Merge pull request #5556 from avalonmediasystem/manifest_item_label
Browse files Browse the repository at this point in the history
Serialize master file display title to iiif ranges
  • Loading branch information
masaball authored Jan 10, 2024
2 parents d10ed59 + b2d5c7f commit 8242230
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
6 changes: 5 additions & 1 deletion app/models/concerns/master_file_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'}),
Expand Down Expand Up @@ -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?
Expand Down
3 changes: 1 addition & 2 deletions app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/speedy_af/proxy/master_file.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 20 additions & 6 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8242230

Please sign in to comment.