Skip to content

Commit

Permalink
Merge pull request #5769 from avalonmediasystem/srt_download
Browse files Browse the repository at this point in the history
Serialize captions as both supplementing annotation and rendering
  • Loading branch information
masaball authored Apr 5, 2024
2 parents 5f87075 + 8681a8d commit 9680532
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 13 additions & 7 deletions app/models/concerns/iiif_supplemental_file_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ module IiifSupplementalFileBehavior
private

def supplemental_files_rendering(object)
object.supplemental_files(tag: nil).collect do |sf|
{
"@id" => object_supplemental_file_url(object, sf),
"type" => determine_rendering_type(sf.file.content_type),
"label" => { "en" => [sf.label] },
"format" => sf.file.content_type
}
tags = ['caption', nil]
supplemental_files = []
tags.each do |tag|
supplemental_files += object.supplemental_files(tag: tag).collect do |sf|
{
"@id" => object_supplemental_file_url(object, sf),
"type" => determine_rendering_type(sf.file.content_type),
"label" => { "en" => [sf.label] },
"format" => sf.file.content_type
}
end
end

supplemental_files
end

def object_supplemental_file_url(object, supplemental_file)
Expand Down
6 changes: 3 additions & 3 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@
describe '#sequence_rendering' do
subject { presenter.sequence_rendering }

it 'includes supplemental files' do
it 'includes supplemental files and captions' do
expect(subject.any? { |rendering| rendering["@id"] =~ /supplemental_files\/#{supplemental_file.id}/ }).to eq true
expect(subject.any? { |rendering| rendering["@id"] =~ /supplemental_files\/#{caption_file.id}/ }).to eq true
end

it 'does not include waveform, transcripts, or captions' do
it 'does not include waveform or transcripts' do
expect(subject.any? { |rendering| rendering["label"]["en"] == ["waveform.json"] }).to eq false
expect(subject.any? { |rendering| rendering["@id"] =~ /supplemental_files\/#{transcript_file.id}/ }).to eq false
expect(subject.any? { |rendering| rendering["@id"] =~ /supplemental_files\/#{caption_file.id}/ }).to eq false
end
end

Expand Down

0 comments on commit 9680532

Please sign in to comment.