Skip to content

Commit

Permalink
🎁 Video Embed: CDL
Browse files Browse the repository at this point in the history
Adds video embed to CDL work type.

Issue:
- #911
  • Loading branch information
ShanaLMoore committed Dec 6, 2023
1 parent 4ce94a5 commit bf07487
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/forms/hyrax/cdl_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ class CdlForm < Hyrax::Forms::WorkForm
include HydraEditor::Form::Permissions
include PdfFormBehavior
# List these terms first after the "Additional fields" divider
self.terms = %i[contributing_library library_catalog_identifier admin_note] + self.terms # rubocop:disable Style/RedundantSelf
self.terms = %i[contributing_library library_catalog_identifier admin_note video_embed] + self.terms # rubocop:disable Style/RedundantSelf
self.terms += %i[resource_type additional_information bibliographic_citation chronology_note]
self.terms -= %i[based_near]
self.required_fields = %i[title creator keyword rights_statement resource_type]

def secondary_terms
super + %i[video_embed]
end
end
end
18 changes: 18 additions & 0 deletions app/models/cdl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class Cdl < ActiveFedora::Base
self.indexer = CdlIndexer
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
Expand Down Expand Up @@ -44,6 +54,14 @@ class Cdl < 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
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/hyku/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def show_pdf_download_button?
show_pdf_download_button.first.to_i.positive?
end

def viewer?
iiif_viewer? || video_embed_viewer? || pdf_viewer?
end

def parent_works(current_user = nil)
@parent_works ||= begin
docs = solr_document.load_parent_docs
Expand Down
21 changes: 14 additions & 7 deletions app/views/hyrax/base/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,21 @@
<div class="col-sm-12">
<%= render 'pdf_js', file_set_presenter: pdf_file_set_presenter(@presenter) %>
</div>
<% else %>
<div class="col-sm-3 text-center">
<%= render 'representative_media', presenter: @presenter, viewer: false %>
<%= render('download_pdf', presenter: @presenter, file_set_id: @presenter.file_set_presenters.first.id) if @presenter.show_pdf_download_button? %>
<%= render 'citations', presenter: @presenter %>
</div>
<% end %>
<% if @presenter.viewer? %>
<div class="col-sm-3 text-center">
<%= render('download_pdf', presenter: @presenter, file_set_id: @presenter.file_set_presenters.first.id) if @presenter.show_pdf_download_button? %>
<%= render 'citations', presenter: @presenter %>
<!-- analytics_button is disabled until future fix -->
<%#= render 'analytics_button', presenter: @presenter %>
</div>
<% end %>
<div class="col-sm-3 text-center">
<%= render 'representative_media', presenter: @presenter, viewer: false unless @presenter.iiif_viewer? || @presenter.show_pdf_viewer? %>
<%= render('download_pdf', presenter: @presenter, file_set_id: @presenter.file_set_presenters.first.id) if @presenter.show_pdf_download_button? %>
<%= render 'citations', presenter: @presenter %>
<!-- analytics_button is disabled until future fix -->
<%#= render 'analytics_button', presenter: @presenter %>
</div>
<div class="col-sm-9">
<%= render 'work_description', presenter: @presenter %>
<%= render 'metadata', presenter: @presenter %>
Expand Down

0 comments on commit bf07487

Please sign in to comment.