Skip to content

Commit

Permalink
Merge pull request #931 from scientist-softserv/i911-video-embed-OER
Browse files Browse the repository at this point in the history
🎁 Add video embed to OER Work Type
  • Loading branch information
Shana Moore authored Dec 7, 2023
2 parents ef0af1f + 628792a commit 572d29b
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/forms/hyrax/oer_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class OerForm < Hyrax::Forms::WorkForm
discipline rights_statement]

delegate :related_members_attributes=, :previous_version, :newer_version, :alternate_version, :related_item, to: :model
include VideoEmbedFormBehavior

def secondary_terms
super - [:rendering_ids]
Expand Down
2 changes: 1 addition & 1 deletion app/forms/video_embed_form_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module VideoEmbedFormBehavior
self.terms += %i[video_embed]
end

def secondary_terms
def primary_terms
super + %i[video_embed]
end
end
6 changes: 4 additions & 2 deletions app/models/concerns/video_embed_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module VideoEmbedBehavior
included do
validates :video_embed,
format: {
with: /(http:\/\/|https:\/\/)(www\.)?(player\.vimeo\.com|youtube\.com\/embed)/,
message: "Error: must be a valid YouTube or Vimeo Embed URL."
with: %r{(http://|https://)(www\.)?(player\.vimeo\.com|youtube\.com/embed)},
message: lambda do |_object, _data|
I18n.t('errors.messages.valid_embed_url', default: 'must be a valid YouTube or Vimeo Embed URL.')
end
},
if: :video_embed?

Expand Down
1 change: 1 addition & 0 deletions app/models/oer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Oer < ActiveFedora::Base
pdf_splitter_service: IiifPrint::TenantConfig::PdfSplitter
)
include PdfBehavior
include VideoEmbedBehavior

self.indexer = OerIndexer
# Change this to restrict which works can be added as a child.
Expand Down
2 changes: 1 addition & 1 deletion app/views/themes/cultural_show/hyrax/base/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="col-sm-12 centered-media">
<%= render 'representative_media', presenter: @presenter, viewer: true %>
</div>
<% elsif @presenter.pdf_viewer? %>
<% elsif @presenter.show_pdf_viewer? %>
<div class="col-sm-12">
<%= render 'pdf_js', file_set_presenter: pdf_file_set_presenter(@presenter) %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/themes/scholarly_show/hyrax/base/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<% render 'work_description', presenter: @presenter %>
</div>
</div>
<% elsif @presenter.pdf_viewer? %>
<% elsif @presenter.show_pdf_viewer? %>
<div class="col-sm-12">
<%= render 'pdf_js', file_set_presenter: pdf_file_set_presenter(@presenter) %>
</div>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
de:
errors:
messages:
valid_embed_url: "muss eine gültige YouTube- oder Vimeo-Einbettungs-URL sein."
activefedora:
models:
cdl: CDL
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
en:
errors:
messages:
valid_embed_url: "must be a valid YouTube or Vimeo Embed URL."
single_signon:
index:
sign_in_with_provider: Sign in with %{provider}
Expand Down
3 changes: 3 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
es:
errors:
messages:
valid_embed_url: "debe ser una URL de incrustación válida de YouTube o Vimeo."
activefedora:
models:
cdl: CDL
Expand Down
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
fr:
errors:
messages:
valid_embed_url: "doit être une URL d'incorporation valide de YouTube ou Vimeo."
activefedora:
models:
cdl: CDL
Expand Down
3 changes: 3 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
it:
errors:
messages:
valid_embed_url: "deve essere un URL di incorporamento valido di YouTube o Vimeo."
activefedora:
models:
cdl: CDL
Expand Down
3 changes: 3 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
pt-BR:
errors:
messages:
valid_embed_url: "deve ser uma URL de incorporação válida do YouTube ou Vimeo."
activefedora:
models:
cdl: CDL
Expand Down
3 changes: 3 additions & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
zh:
errors:
messages:
valid_embed_url: "必须是有效的YouTube或Vimeo嵌入URL。"
activefedora:
models:
cdl: CDL
Expand Down

0 comments on commit 572d29b

Please sign in to comment.