-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
34 additions
and
32 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
curation_concerns-models/app/models/concerns/curation_concerns/generic_file/derivatives.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module CurationConcerns | ||
module GenericFile | ||
module Derivatives | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# Using File and ServiceFile so that we can have two alternative | ||
# sound encoding formats and two alternative video formats | ||
# with unique RDF URIs. | ||
# TODO: Is there a mime type ontology we should be using instead? | ||
directly_contains_one :ogg, through: :files, type: ::RDF::URI("http://pcdm.org/use#ServiceFile"), class_name: "Hydra::PCDM::File" | ||
directly_contains_one :mp3, through: :files, type: ::RDF::URI("http://pcdm.org/use#File"), class_name: "Hydra::PCDM::File" | ||
directly_contains_one :mp4, through: :files, type: ::RDF::URI("http://pcdm.org/use#ServiceFile"), class_name: "Hydra::PCDM::File" | ||
directly_contains_one :webm, through: :files, type: ::RDF::URI("http://pcdm.org/use#File"), class_name: "Hydra::PCDM::File" | ||
|
||
makes_derivatives do |obj| | ||
case obj.original_file.mime_type | ||
when *pdf_mime_types | ||
obj.transform_file :original_file, thumbnail: { format: 'jpg', size: '338x493' } | ||
when *office_document_mime_types | ||
obj.transform_file :original_file, { thumbnail: { format: 'jpg', size: '200x150>' } }, processor: :document | ||
when *audio_mime_types | ||
obj.transform_file :original_file, { mp3: { format: 'mp3' }, ogg: { format: 'ogg' } }, processor: :audio | ||
when *video_mime_types | ||
obj.transform_file :original_file, { webm: { format: 'webm' }, mp4: { format: 'mp4' }, thumbnail: { format: 'jpg' } }, processor: :video | ||
when *image_mime_types | ||
obj.transform_file :original_file, thumbnail: { format: 'jpg', size: '200x150>' } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters