Skip to content

Commit

Permalink
Merge pull request #5599 from avalonmediasystem/original_transcript_name
Browse files Browse the repository at this point in the history
Include original supplemental filenames in iiif manifest
  • Loading branch information
masaball authored Jan 31, 2024
2 parents e49b20d + dcc4b87 commit b3deca1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,16 @@ def supplemental_attributes(file)
label = file.tags.include?('machine_generated') ? file.label + ' (machine generated)' : file.label
format = file.file.content_type
language = file.language || 'en'
filename = file.file.filename.to_s
else
label = 'English'
format = file.mime_type
language = 'en'
filename = file.original_name.to_s
end
{
motivation: 'supplementing',
label: label,
label: { language => [label], 'none' => [filename] },
type: 'Text',
format: format,
language: language
Expand Down
1 change: 1 addition & 0 deletions spec/factories/master_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
trait :with_captions do
after(:create) do |mf|
mf.captions.content = File.read('spec/fixtures/captions.vtt')
mf.captions.original_name = 'captions.vtt'
mf.save
end
end
Expand Down
18 changes: 15 additions & 3 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,22 @@
expect(subject.any? { |content| content.body_id =~ /supplemental_files\/#{caption_file.id}/ }).to eq true
end

it 'includes original filenames' do
expect(subject.any? { |content| content.label['none'] == [caption_file.file.filename.to_s] }).to eq true
end

it 'includes label' do
expect(subject.any? { |content| content.label['eng'] == [caption_file.label] }).to eq true
end

it 'differentiates between transcript and caption files' do
expect(subject.any? { |content| content.body_id =~ /supplemental_files\/#{transcript_file.id}\/transcripts/ }).to eq true
expect(subject.any? { |content| content.body_id =~ /supplemental_files\/#{caption_file.id}\/captions/ }).to eq true
end

it 'does not add " (machine generated)" to label of non-generated files' do
expect(subject.any? { |content| content.label =~ /#{transcript_file.label} \(machine generated\)/ }).to eq false
expect(subject.any? { |content| content.label =~ /#{caption_file.label} \(machine generated\)/ }).to eq false
expect(subject.any? { |content| content.label['eng'][0] =~ /#{transcript_file.label} \(machine generated\)/ }).to eq false
expect(subject.any? { |content| content.label['eng'][0] =~ /#{caption_file.label} \(machine generated\)/ }).to eq false
end

it 'does not include generic supplemental files or waveform' do
Expand All @@ -267,13 +275,17 @@
it 'includes the master file captions' do
expect(subject.any? { |content| content.body_id =~ /master_files\/#{master_file.id}\/captions/ }).to eq true
end

it 'includes the original filename' do
expect(subject.any? { |content| content.label['none'] == [master_file.captions.original_name] }).to eq true
end
end

context 'machine generated transcript' do
let(:transcript_file) { FactoryBot.create(:supplemental_file, tags: ['transcript', 'machine_generated']) }

it "adds '(machine generated)' to the label" do
expect(subject.any? { |content| content.label =~ /#{transcript_file.label} \(machine generated\)/ }).to eq true
expect(subject.any? { |content| content.label['eng'][0] =~ /#{transcript_file.label} \(machine generated\)/ }).to eq true
end
end
end
Expand Down

0 comments on commit b3deca1

Please sign in to comment.