Skip to content

Commit dc62764

Browse files
authored
Merge pull request #6572 from avalonmediasystem/staging
Release Avalon 8.1.1
2 parents ddba3e3 + 7153fe5 commit dc62764

File tree

8 files changed

+57
-24
lines changed

8 files changed

+57
-24
lines changed

app/assets/stylesheets/avalon.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ h5.card-title {
909909
div.file_view {
910910
margin: 10px 0 5px 20px;
911911

912-
ul {
912+
ul:not(.autocomplete_popup) {
913913
padding-left: 20px;
914914

915915
li {

app/views/media_objects/_supplemental_files_list.html.erb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ Unless required by applicable law or agreed to in writing, software distributed
4040
<%= form.text_field :label, id: "supplemental_file_input_#{section.id}_#{file.id}", value: file.label %>
4141
</div>
4242
<% if tag == 'transcript' %>
43-
<div class="mb-3 col-md-6 col p-0">
44-
<%= render partial: 'modules/autocomplete_input', locals: { field_name: :language,
43+
<div class="mb-3 col-md-6 col p-0" style='display: flex;'>
44+
<%= render partial: 'modules/autocomplete_input', locals: { field_name: "supplemental_file[language]",
45+
for_field: "language_#{file.id}",
4546
field_id: "supplemental_file_language_#{section.id}_#{file.id}",
4647
value: display_supplemental_file_language(file.language),
4748
model: 'languageTerm'} %>
48-
<%= form.text_field :language,
49-
id: "supplemental_file_language_#{section.id}_#{file.id}",
50-
value: display_supplemental_file_language(file.language),
51-
class: "typeahead from-model form-control",
52-
data: { model: 'languageTerm', validate: false } %>
5349
</div>
5450
<div class="row-col-sm-9 row-col-md-8 row-col-9 p-0">
5551
<span class="form-check-inline col-md-6 col-sm-6 col-6 p-0">
@@ -61,12 +57,12 @@ Unless required by applicable law or agreed to in writing, software distributed
6157
</div>
6258
<% end %>
6359
<% if tag == 'caption' %>
64-
<div class="mb-3 col-md-6 col p-0">
65-
<%= form.text_field :language,
66-
id: "supplemental_file_language_#{section.id}_#{file.id}",
67-
value: display_supplemental_file_language(file.language),
68-
class: "typeahead from-model form-control",
69-
data: { model: 'languageTerm', validate: false } %>
60+
<div class="mb-3 col-md-6 col p-0" style='display: flex;'>
61+
<%= render partial: 'modules/autocomplete_input', locals: { field_name: "supplemental_file[language]",
62+
for_field: "language_#{file.id}",
63+
field_id: "supplemental_file_language_#{section.id}_#{file.id}",
64+
value: display_supplemental_file_language(file.language),
65+
model: 'languageTerm'} %>
7066
</div>
7167
<div class="row-col-sm-9 row-col-md-8 row-col-9 p-0">
7268
<div class="form-check-inline col-md-6 col-sm-6 col-6 p-0">

config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Bundler.require(*Rails.groups)
1010

1111
module Avalon
12-
VERSION = '8.1.0'
12+
VERSION = '8.1.1'
1313

1414
class Application < Rails::Application
1515
require 'avalon/configuration'

lib/avalon/transcript_search.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def initialize(query:, master_file:, request_url: nil)
2525
end
2626

2727
def perform_search(phrase_searching: true)
28+
return {} if query.blank?
29+
2830
subquery = if phrase_searching
2931
"transcript_tsim:\"#{RSolr.solr_escape(query)}\""
3032
else
@@ -56,13 +58,13 @@ def iiif_content_search(phrase_searching: true)
5658

5759
def items_builder search_results
5860
formatted_response = []
59-
search_results["highlighting"].each do |result|
60-
transcript_id = result.first.split('/').last.to_i
61-
mime_type = search_results["response"]["docs"].filter { |doc| doc["id"] == result.first }.first["mime_type_ssi"]
61+
search_results["highlighting"]&.each do |id, matches|
62+
transcript_id = id.split('/').last.to_i
63+
mime_type = search_results["response"]["docs"].filter { |doc| doc["id"] == id }.first["mime_type_ssi"]
6264
canvas = "#{Rails.application.routes.url_helpers.media_object_url(master_file.media_object_id).to_s}/manifest/canvas/#{master_file.id}"
6365
target = Rails.application.routes.url_helpers.transcripts_master_file_supplemental_file_url(master_file.id, transcript_id)
6466

65-
text_matches = result[1]["transcript_tsim"]
67+
text_matches = matches["transcript_tsim"]
6668

6769
formatted_response += process_items(text_matches, mime_type, canvas, target)
6870
end

spec/controllers/master_files_controller_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,5 +901,16 @@ class << file
901901
expect(items[0]["body"]["value"]).to eq "Just <em>before</em> <em>lunch</em> one day, a puppet show was put on at school."
902902
expect(items[0]["target"]).to eq "#{Rails.application.routes.url_helpers.transcripts_master_file_supplemental_file_url(parent_master_file.id, transcript_1.id)}#t=00:00:22.200,00:00:26.600"
903903
end
904+
905+
context 'with empty search' do
906+
it 'returns an empty valid IIIF content search response' do
907+
get('search', params: { id: parent_master_file.id })
908+
result = JSON.parse(response.body)
909+
expect(result["@context"]).to eq "http://iiif.io/api/search/2/context.json"
910+
expect(result["id"]).to eq "#{Rails.application.routes.url_helpers.search_master_file_url(parent_master_file.id)}"
911+
expect(result["type"]).to eq "AnnotationPage"
912+
expect(result["items"]).to be_blank
913+
end
914+
end
904915
end
905916
end

spec/controllers/playlist_items_controller_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,20 @@
142142
end
143143
describe 'PATCH #update' do
144144
let!(:video_master_file) { FactoryBot.create(:master_file, duration: "200000") }
145-
let!(:clip) { AvalonClip.create(master_file: video_master_file, title: Faker::Lorem.word, comment: Faker::Lorem.sentence, start_time: 1000, end_time: 2000) }
145+
let!(:clip) { AvalonClip.create(master_file: video_master_file, title: Faker::Lorem.unique.word, comment: Faker::Lorem.sentence, start_time: 1000, end_time: 2000) }
146146
let!(:playlist_item) { PlaylistItem.create!(playlist: playlist, clip: clip) }
147147

148148
context 'with valid params' do
149149
it 'updates Playlist Item' do
150150
expect do
151-
patch :update, params: { playlist_id: playlist.id, id: playlist_item.id, playlist_item: { title: Faker::Lorem.word, start_time:'00:20', end_time:'1:20' } }, session: valid_session
151+
patch :update, params: { playlist_id: playlist.id, id: playlist_item.id, playlist_item: { title: Faker::Lorem.unique.word, start_time:'00:20', end_time:'1:20' } }, session: valid_session
152152
end.to change{ playlist_item.reload.title }
153153
end
154154
end
155155
context 'with invalid params' do
156156
it 'fails to update Playlist Item' do
157157
expect do
158-
patch :update, params: { playlist_id: playlist.id, id: playlist_item.id, playlist_item: { title: Faker::Lorem.word, start_time:'00:20', end_time:'not-a-time' } }, session: valid_session
158+
patch :update, params: { playlist_id: playlist.id, id: playlist_item.id, playlist_item: { title: Faker::Lorem.unique.word, start_time:'00:20', end_time:'not-a-time' } }, session: valid_session
159159
end.not_to change{ playlist_item.reload.title }
160160
end
161161
end

spec/lib/avalon/transcript_search.rb renamed to spec/lib/avalon/transcript_search_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464
end
6565
end
6666
end
67+
68+
context 'with empty search' do
69+
subject { described_class.new(query: '', master_file: parent_master_file) }
70+
71+
it 'returns an empty hash' do
72+
search = subject.perform_search
73+
expect(search).to be_a Hash
74+
expect(search).to be_blank
75+
end
76+
end
6777
end
6878

6979
describe '#iiif_content_search' do
@@ -117,5 +127,18 @@
117127
end
118128
end
119129
end
130+
131+
context 'with empty search' do
132+
subject { described_class.new(query: '', master_file: parent_master_file) }
133+
134+
it 'returns valid empty IIIF content search response' do
135+
allow(SecureRandom).to receive(:uuid).and_return('abc1234')
136+
search = subject.iiif_content_search
137+
expect(search["@context".to_sym]).to eq "http://iiif.io/api/search/2/context.json"
138+
expect(search[:id]).to eq "#{Rails.application.routes.url_helpers.search_master_file_url(parent_master_file.id)}?q="
139+
expect(search[:type]).to eq "AnnotationPage"
140+
expect(search[:items]).to be_blank
141+
end
142+
end
120143
end
121144
end

spec/support/supplemental_files_controller_examples.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,13 @@
390390
request.headers['Content-Type'] = 'application/json'
391391
end
392392
context "with valid metadata params" do
393-
let(:valid_update_attributes) { { label: 'new label', type: 'transcript', machine_generated: true }.to_json }
393+
let(:valid_update_attributes) { { label: 'new label', type: 'transcript', machine_generated: true, language: 'French' }.to_json }
394394
it "updates the SupplementalFile metadata for #{object_class}" do
395395
expect {
396396
put :update, params: { class_id => object.id, id: supplemental_file.id, metadata: valid_update_attributes, format: :json }, session: valid_session
397397
}.to change { object.reload.supplemental_files.first.label }.from('label').to('new label')
398398
.and change { object.reload.supplemental_files.first.tags }.from([]).to(['transcript', 'machine_generated'])
399+
.and change { object.reload.supplemental_files.first.language }.from('eng').to('fre')
399400

400401
expect(response).to have_http_status(:ok)
401402
expect(response.body).to eq({ "id": supplemental_file.id }.to_json)
@@ -507,7 +508,7 @@
507508
# so we only test against the MasterFile case.
508509
if object.is_a?(MasterFile)
509510
expect{
510-
put :update, params: { class_id => object.id, id: supplemental_file.id, supplemental_file:valid_update_attributes, format: :html}, session: valid_session
511+
put :update, params: { class_id => object.id, id: supplemental_file.id, supplemental_file: valid_update_attributes, format: :html}, session: valid_session
511512
}.to change { object.reload.media_object.to_solr(include_child_fields: true)['has_transcripts_bsi'] }.from(true).to(false)
512513
end
513514
end

0 commit comments

Comments
 (0)