Skip to content

Commit

Permalink
Adds Support for Video Transcripts in Generic Objects (#98)
Browse files Browse the repository at this point in the history
* Allow transcripts for Generic Objects
* Allow Generics to select a transcript in UI
* Allow VTT
* Upgrade tufts-curation to 1.3.1
* Pin chromedriver
  • Loading branch information
mkorcy authored Oct 5, 2023
1 parent 57c56c9 commit 2e2b3e8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
matrix:
ruby-version: ['2.7.5']
steps:
- name: Pin chrome
uses: abhi1693/[email protected]
with:
browser: chrome
version: 1036826
- name: Install OS packages
run: |
sudo apt-get update
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gem 'okcomputer'
gem 'pdf-reader'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2'
gem 'rmagick', '4.2.4'
gem 'rmagick', '4.2.6'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'
Expand All @@ -49,7 +49,7 @@ gem 'omniauth', '1.9.1'
gem 'omniauth-shibboleth'
gem 'whenever', require: false

gem 'tufts-curation', git: 'https://github.com/TuftsUniversity/tufts-curation', tag: 'v1.3.0'
gem 'tufts-curation', git: 'https://github.com/TuftsUniversity/tufts-curation', tag: 'v1.3.1'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ GIT

GIT
remote: https://github.com/TuftsUniversity/tufts-curation
revision: ff29ef21cb9fe97cf67e4de393e3f0104bf367c6
tag: v1.3.0
revision: 508861ddb02eed7dc72214a368949fe1021d6303
tag: v1.3.1
specs:
tufts-curation (0.1.0)
active-fedora (>= 11.5, <= 12.99)
Expand Down Expand Up @@ -785,7 +785,7 @@ GEM
railties (>= 5.0)
retriable (3.1.2)
rexml (3.2.5)
rmagick (4.2.4)
rmagick (4.2.6)
rsolr (2.5.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
Expand Down Expand Up @@ -1026,7 +1026,7 @@ DEPENDENCIES
rails (~> 5.2)
rails-controller-testing
react-rails
rmagick (= 4.2.4)
rmagick (= 4.2.6)
rsolr (>= 1.0)
rspec-rails
rubyzip (>= 1.2.2)
Expand Down
2 changes: 2 additions & 0 deletions app/forms/hyrax/generic_object_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# `rails generate hyrax:work GenericObject`
module Hyrax
class GenericObjectForm < Hyrax::Forms::WorkForm
include Tufts::HasTranscriptForm
self.model_class = ::GenericObject
self.terms += [:transcript_id]
self.terms += Tufts::Terms.shared_terms
Tufts::Terms.remove_terms.each { |term| terms.delete(term) }
self.required_fields = [:title, :displays_in]
Expand Down
8 changes: 4 additions & 4 deletions app/forms/tufts/has_transcript_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ def transcript_files(type)
Hash[transcript_files.map { |file| [file.to_s, file.id] }]
end

def transcript?(file, type)
if type == "Video"
file.mime_type.nil? || file.mime_type.include?('xml') || file.mime_type.include?('plain')
def transcript?(file, object_type)
if object_type == "Video" || object_type == "Generic Object"
['xml', 'plain', 'vtt'].any? { |mime_type| file.mime_type&.include?(mime_type) }
else
file.mime_type.nil? || file.mime_type.include?('xml')
file.mime_type&.include?('xml')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_form_metadata.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= render 'form_media', f: f %>
<% if @curation_concern.class.to_s == 'Audio' || @curation_concern.class.to_s == 'Video' %>
<% if @curation_concern.class.to_s == 'Audio' || @curation_concern.class.to_s == 'Video' || @curation_concern.class.to_s == 'GenericObject' %>
<div class="well transcript-selection">
<%= render_edit_field_partial(:transcript_id, f: f) %>
</div>
Expand Down
3 changes: 3 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@
ip = IPSocket.getaddress(Socket.gethostname)
Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"
else
Webdrivers::Chromedriver.required_version = '106.0.5249.21'
custom_chrome_path = '/opt/hostedtoolcache/chromium/1036826/x64/chrome'

# Adding chromedriver for js testing.
Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.headless!
browser_options.args << '--window-size=1920,1080'
browser_options.binary = custom_chrome_path
browser_options.add_preference(:download, prompt_for_download: false, default_directory: DownloadHelpers::PATH.to_s)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
Expand Down

0 comments on commit 2e2b3e8

Please sign in to comment.