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 @@ +
+ +
\ No newline at end of file diff --git a/app/views/hyrax/base/show.html.erb b/app/views/hyrax/base/show.html.erb index 3c84d07ee..7866a0fe4 100644 --- a/app/views/hyrax/base/show.html.erb +++ b/app/views/hyrax/base/show.html.erb @@ -19,7 +19,9 @@
<%= render 'workflow_actions_widget', presenter: @presenter %> - <% if @presenter.iiif_viewer? %> + <% if @presenter.video_embed_viewer? %> + <%= render 'video_embed_viewer', presenter: @presenter %> + <% elsif @presenter.iiif_viewer? %>
<%= render 'representative_media', presenter: @presenter, viewer: true %>
diff --git a/app/views/layouts/hyrax/dashboard.html.erb b/app/views/layouts/hyrax/dashboard.html.erb new file mode 100644 index 000000000..5757dc589 --- /dev/null +++ b/app/views/layouts/hyrax/dashboard.html.erb @@ -0,0 +1,41 @@ +<%# OVERRIDE from Hyrax 3.6.0 to hide broken flash messages on the dashboard edit work pages %> + + + + + <%= render partial: 'layouts/head_tag_content' %> + <%= content_for(:head) %> + + + +
+ <%= link_to "Skip to Content", "#skip-to-content" %> +
+ <%= render '/masthead' %> + <%= content_for(:navbar) %> +
+ +
+ <%# OVERRIDE here to hide broken flash messages on the dashboard edit work pages. %> + <%# regex includes only the paths for works since this is the only known place flash messages are broken. %> + <%= render '/flash_msg' %> + <%= render_breadcrumbs builder: Hyrax::BootstrapBreadcrumbsBuilder %> + <% if content_for?(:page_header) %> +
+
+ <%= yield(:page_header) %> +
+
+ <% end %> + + + <%= content_for?(:content) ? yield(:content) : yield %> + +
+ +
+ <%= render 'shared/ajax_modal' %> + + \ No newline at end of file diff --git a/config/initializers/bulkrax.rb b/config/initializers/bulkrax.rb index 6a111c0e5..04050acb9 100644 --- a/config/initializers/bulkrax.rb +++ b/config/initializers/bulkrax.rb @@ -116,7 +116,9 @@ } config.field_mappings['Bulkrax::BagitParser'] = parser_mappings - config.field_mappings['Bulkrax::CsvParser'] = parser_mappings + config.field_mappings['Bulkrax::CsvParser'] = parser_mappings.merge( + {'video_embed' => { from: ['video_embed'] }} + ) # Add to, or change existing mappings as follows # e.g. to exclude date diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml index 0b9bd8870..a1bf0e3d7 100644 --- a/config/locales/hyrax.en.yml +++ b/config/locales/hyrax.en.yml @@ -1150,6 +1150,7 @@ en: resource_type: Pre-defined categories to describe the type of content being uploaded, such as "article" or "dataset." More than one type may be selected. subject: Headings or index terms describing what the work is about; these do need to conform to an existing vocabulary. title: A name to aid in identifying a work. + video_embed: "If you enter an embed link for a video, it must be a properly formatted url beginning with 'http://' or 'https://'. It also needs to contain a valid link to a hosted video that can appear in an iframe.

Examples:
https://player.vimeo.com/video/467264493?h=b089de0eab
https://www.youtube.com/embed/Znf73dsFdC8
" labels: collection: size: Size