sufia-models 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/sufia.en.yml +4 -0
- data/lib/sufia/models.rb +30 -2
- data/lib/sufia/models/active_support/core_ext/marshal.rb +22 -0
- data/lib/sufia/models/engine.rb +11 -5
- data/lib/sufia/models/file_content/extract_metadata.rb +2 -2
- data/lib/sufia/models/generic_file.rb +1 -1
- data/lib/sufia/models/generic_file/actions.rb +4 -1
- data/lib/sufia/models/generic_file/audit.rb +1 -1
- data/lib/sufia/models/generic_file/characterization.rb +1 -1
- data/lib/sufia/models/generic_file/thumbnail.rb +3 -3
- data/lib/sufia/models/id_service.rb +4 -3
- data/lib/sufia/models/jobs/ffmpeg_transcode_job.rb +3 -3
- data/lib/sufia/models/noid.rb +1 -1
- data/lib/sufia/models/resque.rb +28 -0
- data/lib/sufia/models/user.rb +1 -1
- data/lib/sufia/models/version.rb +1 -1
- data/sufia-models.gemspec +13 -0
- metadata +173 -12
- data/app/models/contact_form.rb +0 -42
- data/lib/sufia/models/jobs/content_delete_event_job.rb +0 -31
- data/lib/sufia/models/jobs/content_deposit_event_job.rb +0 -32
- data/lib/sufia/models/jobs/content_new_version_event_job.rb +0 -32
- data/lib/sufia/models/jobs/content_restored_version_event_job.rb +0 -40
- data/lib/sufia/models/jobs/content_update_event_job.rb +0 -32
- data/lib/sufia/models/jobs/event_job.rb +0 -33
- data/lib/sufia/models/jobs/user_edit_profile_event_job.rb +0 -35
- data/lib/sufia/models/jobs/user_follow_event_job.rb +0 -37
- data/lib/sufia/models/jobs/user_unfollow_event_job.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3f270df659dfb48b395c515f70e0447c94504f7
|
4
|
+
data.tar.gz: d7db33a427da9b43b84e51e25ffc6fa2c3dbdd4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b76383a5af4b49c6bfd22e158233d0d51088cb3b1545b5dfafbde77827dcf6c662889fdf34bf01bfe46fc1406ef147009b2791d64c523fcee507cd8a5f910b67
|
7
|
+
data.tar.gz: d800eba8c79b73b29da94a8ab1928dee3bf883e1c07115ddec34b85186cc41dc77a22075e51fac85f4141daffa03013ccf1f1e6c716a5ebaa0fa59ddd22172ff
|
data/lib/sufia/models.rb
CHANGED
@@ -1,11 +1,39 @@
|
|
1
1
|
require "sufia/models/version"
|
2
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'
|
3
12
|
|
4
13
|
module Sufia
|
14
|
+
extend ActiveSupport::Autoload
|
15
|
+
|
5
16
|
module Models
|
17
|
+
|
6
18
|
extend ActiveSupport::Autoload
|
7
19
|
|
8
|
-
autoload :Resque, 'models/queue/resque'
|
9
|
-
autoload :User, 'models/user'
|
20
|
+
autoload :Resque, 'sufia/models/queue/resque'
|
21
|
+
autoload :User, 'sufia/models/user'
|
22
|
+
end
|
23
|
+
|
24
|
+
autoload :Resque, 'sufia/models/resque'
|
25
|
+
|
26
|
+
attr_writer :queue
|
27
|
+
|
28
|
+
def self.queue
|
29
|
+
@queue ||= config.queue.new('sufia')
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.config(&block)
|
33
|
+
@@config ||= Sufia::Models::Engine::Configuration.new
|
34
|
+
|
35
|
+
yield @@config if block
|
36
|
+
|
37
|
+
return @@config
|
10
38
|
end
|
11
39
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
### This patch is going into active-support (rails 4). https://github.com/rails/rails/pull/8246
|
2
|
+
module Marshal
|
3
|
+
class << self
|
4
|
+
def load_with_autoloading(source)
|
5
|
+
begin
|
6
|
+
load_without_autoloading(source)
|
7
|
+
rescue ArgumentError, NameError => exc
|
8
|
+
if exc.message.match(%r|undefined class/module (.+)|)
|
9
|
+
# try loading the class/module
|
10
|
+
$1.constantize
|
11
|
+
# if it is a IO we need to go back to read the object
|
12
|
+
source.rewind if source.respond_to?(:rewind)
|
13
|
+
retry
|
14
|
+
else
|
15
|
+
raise exc
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method_chain :load, :autoloading
|
21
|
+
end
|
22
|
+
end
|
data/lib/sufia/models/engine.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
module
|
1
|
+
module Sufia
|
2
2
|
module Models
|
3
|
+
def self.config(&block)
|
4
|
+
@@config ||= Engine::Configuration.new
|
5
|
+
|
6
|
+
yield @@config if block
|
7
|
+
|
8
|
+
return @@config
|
9
|
+
end
|
10
|
+
|
3
11
|
class Engine < ::Rails::Engine
|
4
12
|
config.autoload_paths += %W(
|
5
13
|
#{config.root}/lib/sufia/models/jobs
|
6
14
|
)
|
7
|
-
initializer "
|
15
|
+
initializer "patches" do
|
8
16
|
require 'sufia/models/active_fedora/redis'
|
9
|
-
end
|
10
|
-
|
11
|
-
initializer "Patch active_record" do
|
12
17
|
require 'sufia/models/active_record/redis'
|
18
|
+
require 'sufia/models/active_support/core_ext/marshal'
|
13
19
|
end
|
14
20
|
|
15
21
|
initializer 'requires' do
|
@@ -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
|
@@ -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,9 @@ 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
|
38
41
|
end
|
39
42
|
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
|
@@ -43,7 +43,7 @@ module Sufia
|
|
43
43
|
# Populate descMetadata with fields from FITS (e.g. Author from pdfs)
|
44
44
|
def append_metadata
|
45
45
|
terms = self.characterization_terms
|
46
|
-
Sufia
|
46
|
+
Sufia.config.fits_to_desc_mapping.each_pair do |k, v|
|
47
47
|
if terms.has_key?(k)
|
48
48
|
# coerce to array to remove a conditional
|
49
49
|
terms[k] = [terms[k]] unless terms[k].is_a? Array
|
@@ -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
|
@@ -16,9 +16,10 @@ require 'noid'
|
|
16
16
|
|
17
17
|
module Sufia
|
18
18
|
module IdService
|
19
|
-
@
|
19
|
+
@template = Sufia.config.noid_template rescue '.reeddeeddk'
|
20
|
+
@minter = ::Noid::Minter.new(:template => @template)
|
20
21
|
@pid = $$
|
21
|
-
@namespace = Sufia
|
22
|
+
@namespace = Sufia.config.id_namespace
|
22
23
|
@semaphore = Mutex.new
|
23
24
|
def self.valid?(identifier)
|
24
25
|
# remove the fedora namespace since it's not part of the noid
|
@@ -41,7 +42,7 @@ module Sufia
|
|
41
42
|
File.open("tmp/minter-state", File::RDWR|File::CREAT, 0644) {|f|
|
42
43
|
f.flock(File::LOCK_EX)
|
43
44
|
yaml = YAML::load(f.read)
|
44
|
-
yaml = {:template =>
|
45
|
+
yaml = {:template => @template} unless yaml
|
45
46
|
minter = ::Noid::Minter.new(yaml)
|
46
47
|
pid = "#{@namespace}:#{minter.mint}"
|
47
48
|
f.rewind
|
@@ -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
|
|
data/lib/sufia/models/noid.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Borrowed from:
|
2
|
+
# https://github.com/jeremy/resque-rails/blob/master/lib/resque/rails/queue.rb
|
3
|
+
module Sufia
|
4
|
+
module Resque
|
5
|
+
class Queue
|
6
|
+
attr_reader :default_queue_name
|
7
|
+
|
8
|
+
def initialize(default_queue_name)
|
9
|
+
@default_queue_name = default_queue_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def push(job)
|
13
|
+
queue = job.respond_to?(:queue_name) ? job.queue_name : default_queue_name
|
14
|
+
begin
|
15
|
+
::Resque.enqueue_to queue, MarshaledJob, Base64.encode64(Marshal.dump(job))
|
16
|
+
rescue Redis::CannotConnectError
|
17
|
+
logger.error "Redis is down!"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class MarshaledJob
|
23
|
+
def self.perform(marshaled_job)
|
24
|
+
Marshal.load(Base64.decode64(marshaled_job)).run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/sufia/models/user.rb
CHANGED
@@ -71,7 +71,7 @@ module Sufia::User
|
|
71
71
|
|
72
72
|
#method to get the trophy ids without the namespace included
|
73
73
|
def trophy_ids
|
74
|
-
trophies.map { |t| "#{Sufia
|
74
|
+
trophies.map { |t| "#{Sufia.config.id_namespace}:#{t.generic_file_id}" }
|
75
75
|
end
|
76
76
|
|
77
77
|
# method needed for messaging
|
data/lib/sufia/models/version.rb
CHANGED
data/sufia-models.gemspec
CHANGED
@@ -28,4 +28,17 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
29
29
|
spec.add_development_dependency "rake"
|
30
30
|
spec.add_dependency "rails", "~> 3.2.13"
|
31
|
+
spec.add_dependency 'hydra-head', '~> 6.0'
|
32
|
+
spec.add_dependency 'nest', '~> 1.1.1'
|
33
|
+
spec.add_dependency 'resque', '~> 1.23.0'#, :require => 'resque/server'
|
34
|
+
spec.add_dependency 'resque-pool', '0.3.0'
|
35
|
+
spec.add_dependency 'noid', '~> 0.6.6'
|
36
|
+
spec.add_dependency 'mailboxer', '0.8.0'
|
37
|
+
spec.add_dependency 'acts_as_follower', '0.1.1'
|
38
|
+
spec.add_dependency 'rmagick'
|
39
|
+
spec.add_dependency 'paperclip', '3.3.0'
|
40
|
+
spec.add_dependency 'zipruby', '0.3.6'
|
41
|
+
spec.add_dependency 'activerecord-import', '0.3.0' # 0.3.1 caused a bug in testing: "SQLite3::SQLException: near ",": syntax error: INSERT INTO..."
|
42
|
+
spec.add_dependency 'devise'
|
43
|
+
|
31
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,174 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.2.13
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hydra-head
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '6.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: resque
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.23.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.23.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: resque-pool
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.3.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.3.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: noid
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.6.6
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.6.6
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mailboxer
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.8.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.8.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: acts_as_follower
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.1.1
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.1.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rmagick
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: paperclip
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 3.3.0
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 3.3.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: zipruby
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.3.6
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.3.6
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: activerecord-import
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 0.3.0
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 0.3.0
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: devise
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '>='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - '>='
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
55
223
|
description: Models and services for sufia
|
56
224
|
email:
|
57
225
|
- jeremy.n.friesen@gmail.com
|
@@ -66,7 +234,6 @@ files:
|
|
66
234
|
- Rakefile
|
67
235
|
- app/models/batch.rb
|
68
236
|
- app/models/checksum_audit_log.rb
|
69
|
-
- app/models/contact_form.rb
|
70
237
|
- app/models/datastreams/batch_rdf_datastream.rb
|
71
238
|
- app/models/datastreams/file_content_datastream.rb
|
72
239
|
- app/models/datastreams/fits_datastream.rb
|
@@ -84,9 +251,11 @@ files:
|
|
84
251
|
- app/models/subject_local_authority_entry.rb
|
85
252
|
- app/models/trophy.rb
|
86
253
|
- app/models/version_committer.rb
|
254
|
+
- config/locales/sufia.en.yml
|
87
255
|
- lib/sufia/models.rb
|
88
256
|
- lib/sufia/models/active_fedora/redis.rb
|
89
257
|
- lib/sufia/models/active_record/redis.rb
|
258
|
+
- lib/sufia/models/active_support/core_ext/marshal.rb
|
90
259
|
- lib/sufia/models/engine.rb
|
91
260
|
- lib/sufia/models/file_content.rb
|
92
261
|
- lib/sufia/models/file_content/extract_metadata.rb
|
@@ -102,22 +271,14 @@ files:
|
|
102
271
|
- lib/sufia/models/jobs/audit_job.rb
|
103
272
|
- lib/sufia/models/jobs/batch_update_job.rb
|
104
273
|
- lib/sufia/models/jobs/characterize_job.rb
|
105
|
-
- lib/sufia/models/jobs/content_delete_event_job.rb
|
106
|
-
- lib/sufia/models/jobs/content_deposit_event_job.rb
|
107
|
-
- lib/sufia/models/jobs/content_new_version_event_job.rb
|
108
|
-
- lib/sufia/models/jobs/content_restored_version_event_job.rb
|
109
|
-
- lib/sufia/models/jobs/content_update_event_job.rb
|
110
|
-
- lib/sufia/models/jobs/event_job.rb
|
111
274
|
- lib/sufia/models/jobs/ffmpeg_transcode_job.rb
|
112
275
|
- lib/sufia/models/jobs/resolrize_job.rb
|
113
276
|
- lib/sufia/models/jobs/transcode_audio_job.rb
|
114
277
|
- lib/sufia/models/jobs/transcode_video_job.rb
|
115
278
|
- lib/sufia/models/jobs/unzip_job.rb
|
116
|
-
- lib/sufia/models/jobs/user_edit_profile_event_job.rb
|
117
|
-
- lib/sufia/models/jobs/user_follow_event_job.rb
|
118
|
-
- lib/sufia/models/jobs/user_unfollow_event_job.rb
|
119
279
|
- lib/sufia/models/model_methods.rb
|
120
280
|
- lib/sufia/models/noid.rb
|
281
|
+
- lib/sufia/models/resque.rb
|
121
282
|
- lib/sufia/models/solr_document_behavior.rb
|
122
283
|
- lib/sufia/models/user.rb
|
123
284
|
- lib/sufia/models/utils.rb
|
data/app/models/contact_form.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'mail_form'
|
16
|
-
|
17
|
-
class ContactForm < MailForm::Base
|
18
|
-
ISSUE_TYPES = [
|
19
|
-
["Depositing content", "Depositing content"],
|
20
|
-
["Making changes to my content", "Making changes to my content"],
|
21
|
-
["Browsing and searching", "Browsing and searching"],
|
22
|
-
["Reporting a problem", "Reporting a problem"],
|
23
|
-
["General inquiry or request", "General inquiry or request"]
|
24
|
-
]
|
25
|
-
attribute :contact_method, :captcha => true
|
26
|
-
attribute :category, :validate => true
|
27
|
-
attribute :name, :validate => true
|
28
|
-
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
|
29
|
-
attribute :subject, :validate => true
|
30
|
-
attribute :message, :validate => true
|
31
|
-
# - can't use this without ActiveRecord::Base validates_inclusion_of :issue_type, :in => ISSUE_TYPES
|
32
|
-
|
33
|
-
# Declare the e-mail headers. It accepts anything the mail method
|
34
|
-
# in ActionMailer accepts.
|
35
|
-
def headers
|
36
|
-
{
|
37
|
-
:subject => "Contact Form:#{subject}",
|
38
|
-
:to => Sufia::Engine.config.contact_email,
|
39
|
-
:from => Sufia::Engine.config.from_email
|
40
|
-
}
|
41
|
-
end
|
42
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class ContentDeleteEventJob < EventJob
|
16
|
-
|
17
|
-
|
18
|
-
def run
|
19
|
-
action = "User #{link_to_profile depositor_id} has deleted file '#{generic_file_id}'"
|
20
|
-
timestamp = Time.now.to_i
|
21
|
-
depositor = User.find_by_user_key(depositor_id)
|
22
|
-
# Create the event
|
23
|
-
event = depositor.create_event(action, timestamp)
|
24
|
-
# Log the event to the depositor's profile stream
|
25
|
-
depositor.log_profile_event(event)
|
26
|
-
# Fan out the event to all followers
|
27
|
-
depositor.followers.each do |follower|
|
28
|
-
follower.log_event(event)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class ContentDepositEventJob < EventJob
|
16
|
-
def run
|
17
|
-
gf = GenericFile.find(generic_file_id)
|
18
|
-
action = "User #{link_to_profile depositor_id} has deposited #{link_to gf.title.first, Sufia::Engine.routes.url_helpers.generic_file_path(gf.noid)}"
|
19
|
-
timestamp = Time.now.to_i
|
20
|
-
depositor = User.find_by_user_key(depositor_id)
|
21
|
-
# Create the event
|
22
|
-
event = depositor.create_event(action, timestamp)
|
23
|
-
# Log the event to the depositor's profile stream
|
24
|
-
depositor.log_profile_event(event)
|
25
|
-
# Log the event to the GF's stream
|
26
|
-
gf.log_event(event)
|
27
|
-
# Fan out the event to all followers who have access
|
28
|
-
depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
|
29
|
-
follower.log_event(event)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class ContentNewVersionEventJob < EventJob
|
16
|
-
def run
|
17
|
-
gf = GenericFile.find(generic_file_id)
|
18
|
-
action = "User #{link_to_profile depositor_id} has added a new version of #{link_to gf.title.first, Sufia::Engine.routes.url_helpers.generic_file_path(gf.noid)}"
|
19
|
-
timestamp = Time.now.to_i
|
20
|
-
depositor = User.find_by_user_key(depositor_id)
|
21
|
-
# Create the event
|
22
|
-
event = depositor.create_event(action, timestamp)
|
23
|
-
# Log the event to the depositor's profile stream
|
24
|
-
depositor.log_profile_event(event)
|
25
|
-
# Log the event to the GF's stream
|
26
|
-
gf.log_event(event)
|
27
|
-
# Fan out the event to all followers who have access
|
28
|
-
depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
|
29
|
-
follower.log_event(event)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class ContentRestoredVersionEventJob < EventJob
|
16
|
-
attr_accessor :revision_id
|
17
|
-
|
18
|
-
def initialize(generic_file_id, depositor_id, revision_id)
|
19
|
-
self.generic_file_id = generic_file_id
|
20
|
-
self.depositor_id = depositor_id
|
21
|
-
self.revision_id = revision_id
|
22
|
-
end
|
23
|
-
|
24
|
-
def run
|
25
|
-
gf = GenericFile.find(generic_file_id)
|
26
|
-
action = "User #{link_to_profile depositor_id} has restored a version '#{revision_id}' of #{link_to gf.title.first, Sufia::Engine.routes.url_helpers.generic_file_path(gf.noid)}"
|
27
|
-
timestamp = Time.now.to_i
|
28
|
-
depositor = User.find_by_user_key(depositor_id)
|
29
|
-
# Create the event
|
30
|
-
event = depositor.create_event(action, timestamp)
|
31
|
-
# Log the event to the depositor's profile stream
|
32
|
-
depositor.log_profile_event(event)
|
33
|
-
# Log the event to the GF's stream
|
34
|
-
gf.log_event(event)
|
35
|
-
# Fan out the event to all followers who have access
|
36
|
-
depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
|
37
|
-
follower.log_event(event)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class ContentUpdateEventJob < EventJob
|
16
|
-
def run
|
17
|
-
gf = GenericFile.find(generic_file_id)
|
18
|
-
action = "User #{link_to_profile depositor_id} has updated #{link_to gf.title.first, Sufia::Engine.routes.url_helpers.generic_file_path(gf.noid)}"
|
19
|
-
timestamp = Time.now.to_i
|
20
|
-
depositor = User.find_by_user_key(depositor_id)
|
21
|
-
# Create the event
|
22
|
-
event = depositor.create_event(action, timestamp)
|
23
|
-
# Log the event to the depositor's profile stream
|
24
|
-
depositor.log_profile_event(event)
|
25
|
-
# Log the event to the GF's stream
|
26
|
-
gf.log_event(event)
|
27
|
-
# Fan out the event to all followers who have access
|
28
|
-
depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
|
29
|
-
follower.log_event(event)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class EventJob
|
16
|
-
include Rails.application.routes.url_helpers
|
17
|
-
include ActionView::Helpers
|
18
|
-
include ActionView::Helpers::DateHelper
|
19
|
-
include Hydra::AccessControlsEnforcement
|
20
|
-
include SufiaHelper
|
21
|
-
|
22
|
-
def queue_name
|
23
|
-
:event
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_accessor :generic_file_id, :depositor_id
|
27
|
-
|
28
|
-
def initialize(generic_file_id, depositor_id)
|
29
|
-
self.generic_file_id = generic_file_id
|
30
|
-
self.depositor_id = depositor_id
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class UserEditProfileEventJob < EventJob
|
16
|
-
attr_accessor :editor_id
|
17
|
-
|
18
|
-
def initialize(editor_id)
|
19
|
-
self.editor_id = editor_id
|
20
|
-
end
|
21
|
-
|
22
|
-
def run
|
23
|
-
action = "User #{link_to_profile editor_id} has edited his or her profile"
|
24
|
-
timestamp = Time.now.to_i
|
25
|
-
editor = User.find_by_user_key(editor_id)
|
26
|
-
# Create the event
|
27
|
-
event = editor.create_event(action, timestamp)
|
28
|
-
# Log the event to the editor's stream
|
29
|
-
editor.log_event(event)
|
30
|
-
# Fan out the event to all followers
|
31
|
-
editor.followers.each do |user|
|
32
|
-
user.log_event(event)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class UserFollowEventJob < EventJob
|
16
|
-
attr_accessor :follower_id, :followee_id
|
17
|
-
|
18
|
-
def initialize(follower_id, followee_id)
|
19
|
-
self.follower_id = follower_id
|
20
|
-
self.followee_id = followee_id
|
21
|
-
end
|
22
|
-
|
23
|
-
def run
|
24
|
-
# Create the event
|
25
|
-
follower = User.find_by_user_key(follower_id)
|
26
|
-
event = follower.create_event("User #{link_to_profile follower_id} is now following #{link_to_profile followee_id}", Time.now.to_i)
|
27
|
-
# Log the event to the follower's stream
|
28
|
-
follower.log_event(event)
|
29
|
-
# Fan out the event to followee
|
30
|
-
followee = User.find_by_user_key(followee_id)
|
31
|
-
followee.log_event(event)
|
32
|
-
# Fan out the event to all followers
|
33
|
-
follower.followers.each do |user|
|
34
|
-
user.log_event(event)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# Copyright © 2012 The Pennsylvania State University
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
class UserUnfollowEventJob < EventJob
|
16
|
-
attr_accessor :unfollower_id, :unfollowee_id
|
17
|
-
|
18
|
-
def initialize(unfollower_id, unfollowee_id)
|
19
|
-
self.unfollower_id = unfollower_id
|
20
|
-
self.unfollowee_id = unfollowee_id
|
21
|
-
end
|
22
|
-
def run
|
23
|
-
action = "User #{link_to_profile unfollower_id} has unfollowed #{link_to_profile unfollowee_id}"
|
24
|
-
timestamp = Time.now.to_i
|
25
|
-
unfollower = User.find_by_user_key(unfollower_id)
|
26
|
-
# Create the event
|
27
|
-
event = unfollower.create_event(action, timestamp)
|
28
|
-
# Log the event to the unfollower's stream
|
29
|
-
unfollower.log_event(event)
|
30
|
-
# Fan out the event to unfollowee
|
31
|
-
unfollowee = User.find_by_user_key(unfollowee_id)
|
32
|
-
unfollowee.log_event(event)
|
33
|
-
# Fan out the event to all followers
|
34
|
-
unfollower.followers.each do |user|
|
35
|
-
user.log_event(event)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|