diff --git a/RepoREADME.md b/RepoREADME.md index 197ce30e1..1b095943b 100644 --- a/RepoREADME.md +++ b/RepoREADME.md @@ -242,3 +242,13 @@ Multi-tenant mode: ```bash rake tenantize:task[workflow:setup] ``` +### Youtube/Vimeo Video Player For Works +- Works will have the option to add a youtube or vimeo player via an embed link +- This link must be a correctly formatted embed link from either youtube or vimeo. +- To find this link: + - Navigate to the url of the video you would like to include. + - Click the "share" button + - You will see a link or a section called "Embed". View the embed code for the video + - Copy JUST the link. The link will be formatted as so for Youtube and Vimeo respectively: + - https://www.youtube.com/embed/Znf73dsFdC8 + - https://player.vimeo.com/video/467264493?h=b089de0eab \ No newline at end of file diff --git a/app/assets/stylesheets/viewer.scss b/app/assets/stylesheets/viewer.scss index f5a1ff277..2a7acc009 100644 --- a/app/assets/stylesheets/viewer.scss +++ b/app/assets/stylesheets/viewer.scss @@ -5,9 +5,6 @@ .viewer { height: 100%; padding: 10px; - iframe { - // position: absolute; - } } #viewer-modal { @@ -21,3 +18,8 @@ margin-bottom: 10px; } } + +.video-embed-viewer { + aspect-ratio: 16 / 9; + width: 100%; +} \ No newline at end of file diff --git a/app/forms/hyrax/generic_work_form.rb b/app/forms/hyrax/generic_work_form.rb index 2a89b75de..60cafca3b 100644 --- a/app/forms/hyrax/generic_work_form.rb +++ b/app/forms/hyrax/generic_work_form.rb @@ -9,8 +9,12 @@ class GenericWorkForm < Hyrax::Forms::WorkForm include HydraEditor::Form::Permissions include PdfFormBehavior - self.terms = [:admin_note] + self.terms # rubocop:disable Style/RedundantSelf + self.terms = [:admin_note, :resource_type, :video_embed] + terms self.terms += %i[resource_type additional_information bibliographic_citation] self.required_fields = %i[title creator keyword rights_statement resource_type] + + def secondary_terms + super + %i[video_embed] + end end end diff --git a/app/models/generic_work.rb b/app/models/generic_work.rb index 49dfed9e1..f69ba5b85 100644 --- a/app/models/generic_work.rb +++ b/app/models/generic_work.rb @@ -12,6 +12,16 @@ class GenericWork < ActiveFedora::Base validates :title, presence: { message: 'Your work must have a title.' } + # rubocop:disable Style/RegexpLiteral + validates :video_embed, + format: { + # regex matches only youtube & vimeo urls that are formatted as embed links. + with: /(http:\/\/|https:\/\/)(www\.)?(player\.vimeo\.com|youtube\.com\/embed)/, + message: "Error: must be a valid YouTube or Vimeo Embed URL." + }, + if: :video_embed? + # rubocop:enable Style/RegexpLiteral + property :additional_information, predicate: ::RDF::Vocab::DC.accessRights do |index| index.as :stored_searchable end @@ -32,6 +42,14 @@ class GenericWork < ActiveFedora::Base index.as :stored_searchable, :facetable end + property :video_embed, predicate: ::RDF::URI("https://atla.com/terms/video_embed"), multiple: false do |index| + index.as :stored_searchable + end + + def video_embed? + video_embed.present? + end + include ::Hyrax::BasicMetadata # This line must be kept below all others that set up properties, # including `include ::Hyrax::BasicMetadata`. All properties must diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 1665e3f89..ac4ba2b95 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -62,6 +62,7 @@ class SolrDocument attribute :library_catalog_identifier, Solr::String, 'library_catalog_identifier_tesim' attribute :chronology_note, Solr::String, 'chronology_note_tesim' attribute :based_near, Solr::Array, 'based_near_tesim' + attribute :video_embed, Solr::String, 'video_embed_tesim' field_semantics.merge!( contributor: 'contributor_tesim', diff --git a/app/presenters/hyku/work_show_presenter.rb b/app/presenters/hyku/work_show_presenter.rb index 2e1ba75d9..f020db677 100644 --- a/app/presenters/hyku/work_show_presenter.rb +++ b/app/presenters/hyku/work_show_presenter.rb @@ -104,9 +104,16 @@ def parent_works(current_user = nil) end end + def video_embed_viewer? + extract_video_embed_presence + end private + def extract_video_embed_presence + solr_document[:video_embed_tesim].present? + end + def extract_from_identifier(rgx) if solr_document['identifier_tesim'].present? ref = solr_document['identifier_tesim'].map do |str| diff --git a/app/views/hyrax/base/_form.html.erb b/app/views/hyrax/base/_form.html.erb new file mode 100644 index 000000000..38a9862c2 --- /dev/null +++ b/app/views/hyrax/base/_form.html.erb @@ -0,0 +1,24 @@ +<%# OVERRIDE Hyrax 3.6.0 to remove the broken error alerts from form validations %> + +<%= simple_form_for [main_app, @form], + html: { + data: { behavior: 'work-form', + 'param-key' => @form.model_name.param_key }, + multipart: true + } do |f| %> + <%# OVERRIDE Here to remove broken error alert from form validation %> + <% if Flipflop.batch_upload? && !f.object.persisted? %> + <% provide :metadata_tab do %> +
<%= t('.batch_upload_hint') %> <%= link_to t('.batch_link'), hyrax.new_batch_upload_path(payload_concern: @form.model.class) %>
+ <% end %> + <% end %> + <%= render 'hyrax/base/guts4form', f: f, tabs: form_tabs_for(form: f.object) %> +<% end %> + + \ No newline at end of file diff --git a/app/views/hyrax/base/_video_embed_viewer.html.erb b/app/views/hyrax/base/_video_embed_viewer.html.erb new file mode 100644 index 000000000..05ca0a939 --- /dev/null +++ b/app/views/hyrax/base/_video_embed_viewer.html.erb @@ -0,0 +1,3 @@ +