Skip to content

Commit

Permalink
🎁 Add video embed to OER Work Type
Browse files Browse the repository at this point in the history
This commit manually adds video embed to oer model and form files. TODO: figure out why including the VideoEmbedBehavior and the VideoEmbedForm modules don't work for OER.

Issue:
- #911
  • Loading branch information
Shana Moore committed Dec 6, 2023
1 parent 755e4f5 commit 65d2304
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/forms/hyrax/oer_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class OerForm < Hyrax::Forms::WorkForm
newer_version_id previous_version_id alternate_version_id related_item_id keyword
date_created files visibility_during_embargo embargo_release_date visibility_after_embargo
visibility_during_lease lease_expiration_date visibility_after_lease visibility
ordered_member_ids in_works_ids member_of_collection_ids admin_set_id abstract]
ordered_member_ids in_works_ids member_of_collection_ids admin_set_id abstract video_embed]
self.terms -=%i[previous_version_id newer_version_id alternate_version_id related_item_id]
self.required_fields = %i[title creator resource_type date_created audience education_level learning_resource_type
discipline rights_statement]

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

def secondary_terms
super - [:rendering_ids]
super - [:rendering_ids] + [:video_embed]
end

def self.build_permitted_params
Expand Down
17 changes: 17 additions & 0 deletions app/models/oer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class Oer < ActiveFedora::Base
validates :learning_resource_type, presence: { message: 'You must select a learning resource type.' }
validates :resource_type, presence: { message: 'You must select a resource type.' }
validates :discipline, presence: { message: 'You must select a discipline.' }
# 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 :audience, predicate: ::RDF::Vocab::SCHEMA.EducationalAudience do |index|
index.as :stored_searchable, :facetable
Expand Down Expand Up @@ -107,6 +116,14 @@ class Oer < 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

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
Expand Down

0 comments on commit 65d2304

Please sign in to comment.