sufia 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/Gemfile +1 -0
- data/Releasing_sufia.md +3 -0
- data/SUFIA_VERSION +1 -0
- data/app/assets/javascripts/sufia.js +22 -24
- data/app/assets/javascripts/sufia/batch_select_all.js +2 -0
- data/app/assets/javascripts/sufia/fileupload.js +6 -0
- data/app/assets/javascripts/sufia/uploader.js +165 -0
- data/app/assets/javascripts/terms_of_service.js +36 -30
- data/app/assets/stylesheets/{scholarsphere-bootstrap.css → application-bootstrap.css} +0 -0
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/controllers/batch_controller.rb +1 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +2 -1
- data/app/helpers/generic_file_helper.rb +17 -0
- data/{lib/sufia → app}/jobs/content_delete_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/content_deposit_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/content_new_version_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/content_restored_version_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/content_update_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/user_edit_profile_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/user_follow_event_job.rb +0 -0
- data/{lib/sufia → app}/jobs/user_unfollow_event_job.rb +0 -0
- data/app/models/contact_form.rb +2 -2
- data/app/views/_ga.html.erb +2 -2
- data/app/views/batch_edits/_batch_edits_actions.html.erb +1 -0
- data/app/views/batch_edits/_check_all.html.erb +1 -2
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/dashboard/_batch_edits_actions.html.erb +2 -0
- data/app/views/dashboard/_sort_and_per_page.html.erb +1 -1
- data/app/views/generic_files/_breadcrumbs.html.erb +5 -1
- data/app/views/generic_files/_descriptions.html.erb +6 -4
- data/app/views/generic_files/_dropbox_import.html.erb +3 -0
- data/app/views/generic_files/_field_display.html.erb +12 -0
- data/app/views/generic_files/_field_form.html.erb +1 -1
- data/app/views/generic_files/_multiple_upload.html.erb +4 -135
- data/app/views/generic_files/_permission_form.html.erb +5 -5
- data/app/views/generic_files/_show_descriptions.html.erb +6 -14
- data/app/views/generic_files/_show_details.html.erb +2 -2
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +9 -0
- data/app/views/generic_files/edit_fields/_rights.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_type.html.erb +4 -1
- data/app/views/generic_files/new.html.erb +18 -1
- data/app/views/generic_files/show_fields/_default.html.erb +12 -0
- data/app/views/generic_files/upload/_agreement.html.erb +5 -0
- data/app/views/generic_files/upload/_alerts.html.erb +19 -0
- data/app/views/generic_files/upload/_dropbox_chooser.html.erb +39 -0
- data/app/views/generic_files/upload/_form.html.erb +6 -0
- data/app/views/generic_files/upload/_form_fields.html.erb +47 -0
- data/app/views/generic_files/upload/_script_templates.html.erb +61 -0
- data/app/views/generic_files/upload/_tos_checkbox.html.erb +3 -0
- data/app/views/layouts/_head-tag-content.html.erb +22 -0
- data/app/views/layouts/{hydra-head.html.erb → homepage.html.erb} +3 -44
- data/app/views/layouts/sufia-one-column.html.erb +43 -0
- data/app/views/layouts/sufia-two-column.html.erb +45 -0
- data/app/views/static/agreement.html.erb +12 -11
- data/app/views/static/mendeley.html.erb +2 -2
- data/app/views/static/terms.html.erb +11 -11
- data/app/views/static/zotero.html.erb +2 -2
- data/config/initializers/sufia_events.rb +3 -0
- data/config/locales/sufia.en.yml +3 -6
- data/features/step_definitions/{scholarsphere.rb → sufia.rb} +0 -0
- data/lib/generators/sufia/sufia_generator.rb +1 -1
- data/lib/generators/sufia/templates/config/resque_config.rb +1 -1
- data/lib/generators/sufia/templates/config/sufia.rb +3 -0
- data/lib/sufia.rb +1 -50
- data/lib/sufia/batch_edits_controller_behavior.rb +4 -0
- data/lib/sufia/controller.rb +13 -0
- data/lib/sufia/dashboard_controller_behavior.rb +3 -2
- data/lib/sufia/files_controller_behavior.rb +35 -12
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/batch_edits_controller_spec.rb +2 -2
- data/spec/controllers/generic_files_controller_spec.rb +37 -1
- data/spec/models/generic_file_spec.rb +6 -6
- data/spec/models/properties_datastream_spec.rb +8 -7
- data/spec/models/transcode_audio_job_spec.rb +1 -1
- data/spec/models/transcode_video_job_spec.rb +1 -1
- data/spec/views/batch_edits/check_all_spec.rb +22 -0
- data/sufia-models/.gitignore +17 -0
- data/sufia-models/Gemfile +4 -0
- data/sufia-models/LICENSE.md +177 -0
- data/sufia-models/README.md +39 -0
- data/sufia-models/Rakefile +1 -0
- data/{app → sufia-models/app}/models/batch.rb +2 -4
- data/{app → sufia-models/app}/models/checksum_audit_log.rb +3 -4
- data/{app → sufia-models/app}/models/datastreams/batch_rdf_datastream.rb +0 -0
- data/{app → sufia-models/app}/models/datastreams/file_content_datastream.rb +0 -0
- data/{app → sufia-models/app}/models/datastreams/fits_datastream.rb +0 -0
- data/{app → sufia-models/app}/models/datastreams/generic_file_rdf_datastream.rb +12 -12
- data/{app → sufia-models/app}/models/datastreams/paranoid_rights_datastream.rb +0 -15
- data/{app → sufia-models/app}/models/datastreams/properties_datastream.rb +1 -2
- data/{app → sufia-models/app}/models/domain_term.rb +0 -0
- data/{app → sufia-models/app}/models/follow.rb +0 -0
- data/{app → sufia-models/app}/models/generic_file.rb +0 -0
- data/{app → sufia-models/app}/models/geo_names_resource.rb +0 -0
- data/{app → sufia-models/app}/models/group.rb +0 -0
- data/{app → sufia-models/app}/models/local_authority.rb +0 -0
- data/{app → sufia-models/app}/models/local_authority_entry.rb +0 -0
- data/{app → sufia-models/app}/models/single_use_link.rb +0 -0
- data/{app → sufia-models/app}/models/subject_local_authority_entry.rb +0 -0
- data/{app → sufia-models/app}/models/trophy.rb +0 -0
- data/{app → sufia-models/app}/models/version_committer.rb +0 -0
- data/sufia-models/config/locales/sufia.en.yml +6 -0
- data/sufia-models/lib/sufia/models.rb +34 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/active_fedora/redis.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/active_record/redis.rb +0 -0
- data/{lib → sufia-models/lib/sufia/models}/active_support/core_ext/marshal.rb +0 -0
- data/sufia-models/lib/sufia/models/engine.rb +61 -0
- data/sufia-models/lib/sufia/models/file_content.rb +9 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/file_content/extract_metadata.rb +2 -2
- data/{lib/sufia → sufia-models/lib/sufia/models}/file_content/versions.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file.rb +3 -34
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file/actions.rb +16 -1
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file/audit.rb +1 -1
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file/characterization.rb +1 -2
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file/export.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file/permissions.rb +0 -1
- data/{lib/sufia → sufia-models/lib/sufia/models}/generic_file/thumbnail.rb +3 -3
- data/sufia-models/lib/sufia/models/generic_file/web_form.rb +45 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/id_service.rb +11 -7
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/audit_job.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/batch_update_job.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/characterize_job.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/ffmpeg_transcode_job.rb +3 -3
- data/sufia-models/lib/sufia/models/jobs/import_url_job.rb +55 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/resolrize_job.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/transcode_audio_job.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/transcode_video_job.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/jobs/unzip_job.rb +16 -4
- data/{lib/sufia → sufia-models/lib/sufia/models}/model_methods.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/noid.rb +1 -1
- data/{lib/sufia/queue → sufia-models/lib/sufia/models}/resque.rb +0 -2
- data/{lib/sufia → sufia-models/lib/sufia/models}/solr_document_behavior.rb +0 -0
- data/{lib/sufia → sufia-models/lib/sufia/models}/user.rb +1 -1
- data/{lib/sufia → sufia-models/lib/sufia/models}/utils.rb +0 -0
- data/sufia-models/lib/sufia/models/version.rb +5 -0
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +7 -0
- data/sufia-models/sufia-models.gemspec +44 -0
- data/sufia.gemspec +2 -12
- data/tasks/release.rake +90 -0
- data/tasks/sufia-dev.rake +1 -1
- data/tasks/sufia.rake +1 -3
- metadata +118 -238
- data/app/views/generic_files/show_fields/_based_near.html.erb +0 -12
- data/app/views/generic_files/show_fields/_contributor.html.erb +0 -12
- data/app/views/generic_files/show_fields/_creator.html.erb +0 -12
- data/app/views/generic_files/show_fields/_date_created.html.erb +0 -12
- data/app/views/generic_files/show_fields/_description.html.erb +0 -12
- data/app/views/generic_files/show_fields/_identifier.html.erb +0 -9
- data/app/views/generic_files/show_fields/_language.html.erb +0 -9
- data/app/views/generic_files/show_fields/_publisher.html.erb +0 -12
- data/app/views/generic_files/show_fields/_related_url.html.erb +0 -11
- data/app/views/generic_files/show_fields/_resource_type.html.erb +0 -9
- data/app/views/generic_files/show_fields/_rights.html.erb +0 -9
- data/app/views/generic_files/show_fields/_subject.html.erb +0 -12
- data/app/views/generic_files/show_fields/_tag.html.erb +0 -9
- data/app/views/generic_files/show_fields/_title.html.erb +0 -12
- data/lib/sufia/file_content.rb +0 -8
- data/lib/sufia/generic_file/web_form.rb +0 -15
- data/vendor/assets/javascripts/fileupload.js +0 -6
- data/vendor/assets/javascripts/fileupload/application.js +0 -185
- data/vendor/assets/javascripts/fileupload/jquery-ui-1.8.14.custom.min.js +0 -76
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "sufia/models/version"
|
2
|
+
require "sufia/models/engine"
|
3
|
+
require 'hydra/head'
|
4
|
+
require 'devise'
|
5
|
+
require 'nest'
|
6
|
+
require 'mailboxer'
|
7
|
+
require 'acts_as_follower'
|
8
|
+
require 'paperclip'
|
9
|
+
require 'RMagick'
|
10
|
+
require 'activerecord-import'
|
11
|
+
require 'resque/server'
|
12
|
+
|
13
|
+
module Sufia
|
14
|
+
extend ActiveSupport::Autoload
|
15
|
+
|
16
|
+
module Models
|
17
|
+
end
|
18
|
+
|
19
|
+
autoload :Utils, 'sufia/models/utils'
|
20
|
+
|
21
|
+
attr_writer :queue
|
22
|
+
|
23
|
+
def self.queue
|
24
|
+
@queue ||= config.queue.new('sufia')
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.config(&block)
|
28
|
+
@@config ||= Sufia::Models::Engine::Configuration.new
|
29
|
+
|
30
|
+
yield @@config if block
|
31
|
+
|
32
|
+
return @@config
|
33
|
+
end
|
34
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'sufia/models/resque'
|
2
|
+
module Sufia
|
3
|
+
module Models
|
4
|
+
def self.config(&block)
|
5
|
+
@@config ||= Engine::Configuration.new
|
6
|
+
|
7
|
+
yield @@config if block
|
8
|
+
|
9
|
+
return @@config
|
10
|
+
end
|
11
|
+
|
12
|
+
class Engine < ::Rails::Engine
|
13
|
+
|
14
|
+
# Set some configuration defaults
|
15
|
+
config.enable_ffmpeg = false
|
16
|
+
config.noid_template = '.reeddeeddk'
|
17
|
+
config.ffmpeg_path = 'ffmpeg'
|
18
|
+
config.fits_message_length = 5
|
19
|
+
config.temp_file_base = nil
|
20
|
+
config.minter_statefile = '/tmp/minter-state'
|
21
|
+
config.id_namespace = "sufia"
|
22
|
+
config.fits_path = "fits.sh"
|
23
|
+
config.enable_contact_form_delivery = false
|
24
|
+
config.dropbox_api_key = nil
|
25
|
+
config.queue = Sufia::Resque::Queue
|
26
|
+
|
27
|
+
config.autoload_paths += %W(
|
28
|
+
#{config.root}/lib/sufia/models/jobs
|
29
|
+
#{config.root}/app/models/datastreams
|
30
|
+
)
|
31
|
+
|
32
|
+
rake_tasks do
|
33
|
+
load File.expand_path('../../../tasks/sufia-models_tasks.rake', __FILE__)
|
34
|
+
end
|
35
|
+
|
36
|
+
initializer "patches" do
|
37
|
+
require 'sufia/models/active_fedora/redis'
|
38
|
+
require 'sufia/models/active_record/redis'
|
39
|
+
require 'sufia/models/active_support/core_ext/marshal'
|
40
|
+
end
|
41
|
+
|
42
|
+
initializer 'requires' do
|
43
|
+
require 'sufia/models/model_methods'
|
44
|
+
require 'sufia/models/noid'
|
45
|
+
require 'sufia/models/file_content'
|
46
|
+
require 'sufia/models/file_content/extract_metadata'
|
47
|
+
require 'sufia/models/file_content/versions'
|
48
|
+
require 'sufia/models/generic_file/actions'
|
49
|
+
require 'sufia/models/generic_file/audit'
|
50
|
+
require 'sufia/models/generic_file/characterization'
|
51
|
+
require 'sufia/models/generic_file/export'
|
52
|
+
require 'sufia/models/generic_file/permissions'
|
53
|
+
require 'sufia/models/generic_file/thumbnail'
|
54
|
+
require 'sufia/models/generic_file'
|
55
|
+
require 'sufia/models/user'
|
56
|
+
require 'sufia/models/id_service'
|
57
|
+
require 'sufia/models/solr_document_behavior'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -14,7 +14,7 @@ module Sufia
|
|
14
14
|
|
15
15
|
def to_tempfile &block
|
16
16
|
return unless has_content?
|
17
|
-
tmp_base = Sufia
|
17
|
+
tmp_base = Sufia.config.temp_file_base
|
18
18
|
f = Tempfile.new("#{pid}-#{dsVersionID}")
|
19
19
|
f.binmode
|
20
20
|
if content.respond_to? :read
|
@@ -52,7 +52,7 @@ module Sufia
|
|
52
52
|
|
53
53
|
|
54
54
|
def fits_path
|
55
|
-
Sufia
|
55
|
+
Sufia.config.fits_path
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
File without changes
|
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'datastreams/generic_file_rdf_datastream'
|
2
|
-
require 'datastreams/properties_datastream'
|
3
|
-
require 'datastreams/file_content_datastream'
|
4
|
-
|
5
1
|
module Sufia
|
6
2
|
module GenericFile
|
7
3
|
extend ActiveSupport::Concern
|
@@ -12,7 +8,7 @@ module Sufia
|
|
12
8
|
autoload :Audit
|
13
9
|
autoload :Actions
|
14
10
|
autoload :Permissions
|
15
|
-
autoload :WebForm
|
11
|
+
autoload :WebForm, 'sufia/models/generic_file/web_form'
|
16
12
|
include Sufia::ModelMethods
|
17
13
|
include Sufia::Noid
|
18
14
|
include Sufia::GenericFile::Thumbnail
|
@@ -30,7 +26,7 @@ module Sufia
|
|
30
26
|
|
31
27
|
belongs_to :batch, :property => :is_part_of
|
32
28
|
|
33
|
-
delegate_to :properties, [:relative_path, :depositor], :unique => true
|
29
|
+
delegate_to :properties, [:relative_path, :depositor, :import_url], :unique => true
|
34
30
|
delegate_to :descMetadata, [:date_uploaded, :date_modified], :unique => true
|
35
31
|
delegate_to :descMetadata, [:related_url, :based_near, :part_of, :creator,
|
36
32
|
:contributor, :title, :tag, :description, :rights,
|
@@ -38,16 +34,9 @@ module Sufia
|
|
38
34
|
:resource_type, :identifier, :language]
|
39
35
|
|
40
36
|
around_save :characterize_if_changed, :retry_warming
|
41
|
-
before_save :remove_blank_assertions
|
42
37
|
before_destroy :cleanup_trophies
|
43
38
|
end
|
44
39
|
|
45
|
-
def remove_blank_assertions
|
46
|
-
terms_for_editing.each do |key|
|
47
|
-
self[key] = nil if self[key] == ['']
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
40
|
|
52
41
|
def record_version_committer(user)
|
53
42
|
version = content.latest_version
|
@@ -78,7 +67,7 @@ module Sufia
|
|
78
67
|
end
|
79
68
|
|
80
69
|
def persistent_url
|
81
|
-
"#{Sufia
|
70
|
+
"#{Sufia.config.persistent_hostpath}#{noid}"
|
82
71
|
end
|
83
72
|
|
84
73
|
def retry_warming
|
@@ -161,26 +150,6 @@ module Sufia
|
|
161
150
|
end
|
162
151
|
end
|
163
152
|
|
164
|
-
def to_jq_upload
|
165
|
-
return {
|
166
|
-
"name" => self.title,
|
167
|
-
"size" => self.file_size,
|
168
|
-
"url" => "/files/#{noid}",
|
169
|
-
"thumbnail_url" => self.pid,
|
170
|
-
"delete_url" => "deleteme", # generic_file_path(:id => id),
|
171
|
-
"delete_type" => "DELETE"
|
172
|
-
}
|
173
|
-
end
|
174
|
-
|
175
|
-
def terms_for_editing
|
176
|
-
terms_for_display -
|
177
|
-
[:part_of, :date_modified, :date_uploaded, :format] #, :resource_type]
|
178
|
-
end
|
179
|
-
|
180
|
-
def terms_for_display
|
181
|
-
self.descMetadata.class.config.keys
|
182
|
-
end
|
183
|
-
|
184
153
|
# Is this file in the middle of being processed by a batch?
|
185
154
|
def processing?
|
186
155
|
return false if self.batch.blank?
|
@@ -13,6 +13,7 @@ module Sufia::GenericFile
|
|
13
13
|
else
|
14
14
|
logger.warn "unable to find batch to attach to"
|
15
15
|
end
|
16
|
+
yield(generic_file) if block_given?
|
16
17
|
generic_file.save!
|
17
18
|
end
|
18
19
|
|
@@ -33,7 +34,21 @@ module Sufia::GenericFile
|
|
33
34
|
|
34
35
|
generic_file.record_version_committer(user)
|
35
36
|
Sufia.queue.push(UnzipJob.new(generic_file.pid)) if generic_file.content.mimeType == 'application/zip'
|
36
|
-
Sufia.
|
37
|
+
if Sufia.config.respond_to?(:after_create_content)
|
38
|
+
Sufia.config.after_create_content.call(generic_file, user)
|
39
|
+
end
|
37
40
|
end
|
41
|
+
|
42
|
+
def self.virus_check(file)
|
43
|
+
if defined? ClamAV
|
44
|
+
stat = ClamAV.instance.scanfile(file.path)
|
45
|
+
logger.warn "Virus checking did not pass for #{file.inspect} status = #{stat}" unless stat == 0
|
46
|
+
stat
|
47
|
+
else
|
48
|
+
logger.warn "Virus checking disabled for #{file.inspect}"
|
49
|
+
0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
end
|
39
54
|
end
|
@@ -77,7 +77,7 @@ module Sufia
|
|
77
77
|
#logger.debug "***AUDIT*** last audit = #{latest_audit.updated_at.to_date}"
|
78
78
|
days_since_last_audit = (DateTime.now - latest_audit.updated_at.to_date).to_i
|
79
79
|
#logger.debug "***AUDIT*** days since last audit: #{days_since_last_audit}"
|
80
|
-
if days_since_last_audit < Sufia
|
80
|
+
if days_since_last_audit < Sufia.config.max_days_between_audits
|
81
81
|
#logger.debug "***AUDIT*** No audit needed for #{version.pid} #{version.versionID} (#{latest_audit.updated_at})"
|
82
82
|
return false
|
83
83
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'datastreams/fits_datastream'
|
2
1
|
module Sufia
|
3
2
|
module GenericFile
|
4
3
|
module Characterization
|
@@ -43,7 +42,7 @@ module Sufia
|
|
43
42
|
# Populate descMetadata with fields from FITS (e.g. Author from pdfs)
|
44
43
|
def append_metadata
|
45
44
|
terms = self.characterization_terms
|
46
|
-
Sufia
|
45
|
+
Sufia.config.fits_to_desc_mapping.each_pair do |k, v|
|
47
46
|
if terms.has_key?(k)
|
48
47
|
# coerce to array to remove a conditional
|
49
48
|
terms[k] = [terms[k]] unless terms[k].is_a? Array
|
File without changes
|
@@ -16,13 +16,13 @@ module Sufia
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
def create_video_thumbnail
|
19
|
-
return unless Sufia
|
19
|
+
return unless Sufia.config.enable_ffmpeg
|
20
20
|
|
21
|
-
output_file = Dir::Tmpname.create(['sufia', ".png"], Sufia
|
21
|
+
output_file = Dir::Tmpname.create(['sufia', ".png"], Sufia.config.temp_file_base){}
|
22
22
|
content.to_tempfile do |f|
|
23
23
|
# we could use something like this in order to find a frame in the middle.
|
24
24
|
#ffprobe -show_files video.avi 2> /dev/null | grep duration | cut -d= -f2 53.399999
|
25
|
-
command = "#{Sufia
|
25
|
+
command = "#{Sufia.config.ffmpeg_path} -i \"#{f.path}\" -loglevel quiet -vf \"scale=338:-1\" -r 1 -t 1 #{output_file}"
|
26
26
|
system(command)
|
27
27
|
raise "Unable to execute command \"#{command}\"" unless $?.success?
|
28
28
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Sufia
|
2
|
+
module GenericFile
|
3
|
+
module WebForm
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
before_save :remove_blank_assertions
|
7
|
+
end
|
8
|
+
|
9
|
+
def remove_blank_assertions
|
10
|
+
terms_for_editing.each do |key|
|
11
|
+
self[key] = nil if self[key] == ['']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
16
|
+
def initialize_fields
|
17
|
+
terms_for_editing.each do |key|
|
18
|
+
# if value is empty, we create an one element array to loop over for output
|
19
|
+
self[key] = [''] if self[key].empty?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def terms_for_editing
|
24
|
+
terms_for_display -
|
25
|
+
[:part_of, :date_modified, :date_uploaded, :format] #, :resource_type]
|
26
|
+
end
|
27
|
+
|
28
|
+
def terms_for_display
|
29
|
+
self.descMetadata.class.config.keys
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_jq_upload
|
33
|
+
return {
|
34
|
+
"name" => self.title,
|
35
|
+
"size" => self.file_size,
|
36
|
+
"url" => "/files/#{noid}",
|
37
|
+
"thumbnail_url" => self.pid,
|
38
|
+
"delete_url" => "deleteme", # generic_file_path(:id => id),
|
39
|
+
"delete_type" => "DELETE"
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -16,9 +16,14 @@ require 'noid'
|
|
16
16
|
|
17
17
|
module Sufia
|
18
18
|
module IdService
|
19
|
-
|
19
|
+
|
20
|
+
def self.noid_template
|
21
|
+
Sufia.config.noid_template
|
22
|
+
end
|
23
|
+
|
24
|
+
@minter = ::Noid::Minter.new(:template => noid_template)
|
20
25
|
@pid = $$
|
21
|
-
@namespace = Sufia
|
26
|
+
@namespace = Sufia.config.id_namespace
|
22
27
|
@semaphore = Mutex.new
|
23
28
|
def self.valid?(identifier)
|
24
29
|
# remove the fedora namespace since it's not part of the noid
|
@@ -38,20 +43,19 @@ module Sufia
|
|
38
43
|
|
39
44
|
def self.next_id
|
40
45
|
pid = ''
|
41
|
-
File.open(
|
46
|
+
File.open(Sufia.config.minter_statefile, File::RDWR|File::CREAT, 0644) do |f|
|
42
47
|
f.flock(File::LOCK_EX)
|
43
48
|
yaml = YAML::load(f.read)
|
44
|
-
yaml = {:template =>
|
49
|
+
yaml = {:template => noid_template} unless yaml
|
45
50
|
minter = ::Noid::Minter.new(yaml)
|
46
|
-
pid =
|
51
|
+
pid = "#{@namespace}:#{minter.mint}"
|
47
52
|
f.rewind
|
48
53
|
yaml = YAML::dump(minter.dump)
|
49
54
|
f.write yaml
|
50
55
|
f.flush
|
51
56
|
f.truncate(f.pos)
|
52
|
-
|
57
|
+
end
|
53
58
|
return pid
|
54
59
|
end
|
55
|
-
|
56
60
|
end
|
57
61
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -19,7 +19,7 @@ class FfmpegTranscodeJob
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def run
|
22
|
-
return unless Sufia
|
22
|
+
return unless Sufia.config.enable_ffmpeg
|
23
23
|
self.generic_file = GenericFile.find(generic_file_id)
|
24
24
|
self.datastream = generic_file.datastreams[datastream_in]
|
25
25
|
if datastream
|
@@ -33,7 +33,7 @@ class FfmpegTranscodeJob
|
|
33
33
|
def encode_datastream(dest_dsid, mime_type, options)
|
34
34
|
file_suffix = dest_dsid
|
35
35
|
out_file = nil
|
36
|
-
output_file = Dir::Tmpname.create(['sufia', ".#{file_suffix}"], Sufia
|
36
|
+
output_file = Dir::Tmpname.create(['sufia', ".#{file_suffix}"], Sufia.config.temp_file_base){}
|
37
37
|
datastream.to_tempfile do |f|
|
38
38
|
self.class.encode(f.path, options, output_file)
|
39
39
|
end
|
@@ -54,7 +54,7 @@ class FfmpegTranscodeJob
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def self.ffmpeg_path
|
57
|
-
Sufia
|
57
|
+
Sufia.config.ffmpeg_path
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|