sufia-models 3.7.2 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/batch.rb +1 -1
- data/app/models/concerns/sufia/properties_datastream_behavior.rb +30 -0
- data/app/models/concerns/sufia/user.rb +1 -1
- data/app/models/datastreams/batch_rdf_datastream.rb +4 -7
- data/app/models/datastreams/fits_datastream.rb +3 -0
- data/app/models/datastreams/generic_file_rdf_datastream.rb +53 -51
- data/app/models/datastreams/properties_datastream.rb +1 -15
- data/app/models/featured_work.rb +22 -0
- data/app/models/sufia/pageview.rb +9 -0
- data/{lib/sufia/models → app/services/sufia}/id_service.rb +0 -0
- data/{lib/sufia/models → app/services/sufia}/noid.rb +0 -0
- data/app/services/sufia/usage_statistics.rb +73 -0
- data/config/locales/sufia.en.yml +3 -4
- data/lib/generators/sufia/models/install_generator.rb +23 -8
- data/lib/generators/sufia/models/templates/config/analytics.yml +9 -0
- data/lib/generators/sufia/models/templates/config/mime_types.rb +6 -0
- data/lib/generators/sufia/models/templates/config/sufia.rb +11 -2
- data/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +10 -0
- data/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +12 -0
- data/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +8 -0
- data/lib/generators/sufia/models/usagestats_generator.rb +19 -0
- data/lib/sufia/ability.rb +34 -0
- data/lib/sufia/models/engine.rb +5 -3
- data/lib/sufia/models/generic_file.rb +4 -2
- data/lib/sufia/models/generic_file/export.rb +3 -3
- data/lib/sufia/models/generic_file/featured.rb +14 -0
- data/lib/sufia/models/solr_document_behavior.rb +11 -4
- data/lib/sufia/models/version.rb +1 -1
- data/sufia-models.gemspec +6 -5
- metadata +66 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 301cddec8289b8f56306d83bacadcf50b0941c72
|
4
|
+
data.tar.gz: 7e994e58c86d1b11f27c121ee7705875a4e136a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eb36508044dd1d918bebf9a96fd82c0db4b1d8a815a8c37c477a39e6c6db57c3bb8c346be9135e37b6abe87f7fdefb57fcdbd3589bd4a85f3f04ee9f5cd94ff
|
7
|
+
data.tar.gz: 336e723cfbe0fa1a1c447ef05175e9537427d272712e6fd208acd3cd0b12dd8f0f6a1927f88316123ee0fc2fc4d9aa94d0e962ffcc80587a8124bebfda846058
|
data/app/models/batch.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Sufia
|
2
|
+
module PropertiesDatastreamBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
set_terminology do |t|
|
7
|
+
t.root(:path=>"fields" )
|
8
|
+
# This is where we put the user id of the object depositor -- impacts permissions/access controls
|
9
|
+
t.depositor :index_as=>[:stored_searchable]
|
10
|
+
# This is where we put the relative path of the file if submitted as a folder
|
11
|
+
t.relative_path
|
12
|
+
t.import_url path: 'importUrl', :index_as=>:symbol
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def xml_template
|
18
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
19
|
+
xml.fields
|
20
|
+
end
|
21
|
+
builder.doc
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def prefix
|
26
|
+
""
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
class BatchRdfDatastream < ActiveFedora::NtriplesRDFDatastream
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
map.status(:to => "type", :in => RDF::DC)
|
7
|
-
end
|
2
|
+
property :part, predicate: RDF::DC.hasPart
|
3
|
+
property :creator, predicate: RDF::DC.creator
|
4
|
+
property :title, predicate: RDF::DC.title
|
5
|
+
property :status, predicate: RDF::DC.type
|
8
6
|
end
|
9
|
-
|
@@ -1,56 +1,58 @@
|
|
1
1
|
class GenericFileRdfDatastream < ActiveFedora::NtriplesRDFDatastream
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
index.as :stored_searchable, :facetable
|
6
|
-
end
|
7
|
-
map.title(:in => RDF::DC) do |index|
|
8
|
-
index.as :stored_searchable
|
9
|
-
end
|
10
|
-
map.creator(:in => RDF::DC) do |index|
|
11
|
-
index.as :stored_searchable, :facetable
|
12
|
-
end
|
13
|
-
map.contributor(:in => RDF::DC) do |index|
|
14
|
-
index.as :stored_searchable, :facetable
|
15
|
-
end
|
16
|
-
map.description(:in => RDF::DC) do |index|
|
17
|
-
index.type :text
|
18
|
-
index.as :stored_searchable
|
19
|
-
end
|
20
|
-
map.tag(:to => "relation", :in => RDF::DC) do |index|
|
21
|
-
index.as :stored_searchable, :facetable
|
22
|
-
end
|
23
|
-
map.rights(:in => RDF::DC) do |index|
|
24
|
-
index.as :stored_searchable
|
25
|
-
end
|
26
|
-
map.publisher(:in => RDF::DC) do |index|
|
27
|
-
index.as :stored_searchable, :facetable
|
28
|
-
end
|
29
|
-
map.date_created(:to => "created", :in => RDF::DC) do |index|
|
30
|
-
index.as :stored_searchable
|
31
|
-
end
|
32
|
-
map.date_uploaded(:to => "dateSubmitted", :in => RDF::DC) do |index|
|
33
|
-
index.type :date
|
34
|
-
index.as :stored_sortable
|
35
|
-
end
|
36
|
-
map.date_modified(:to => "modified", :in => RDF::DC) do |index|
|
37
|
-
index.type :date
|
38
|
-
index.as :stored_sortable
|
39
|
-
end
|
40
|
-
map.subject(:in => RDF::DC) do |index|
|
41
|
-
index.as :stored_searchable, :facetable
|
42
|
-
end
|
43
|
-
map.language(:in => RDF::DC) do |index|
|
44
|
-
index.as :stored_searchable, :facetable
|
45
|
-
end
|
46
|
-
map.identifier(:in => RDF::DC) do |index|
|
47
|
-
index.as :stored_searchable
|
48
|
-
end
|
49
|
-
map.based_near(:in => RDF::FOAF) do |index|
|
50
|
-
index.as :stored_searchable, :facetable
|
51
|
-
end
|
52
|
-
map.related_url(:to => "seeAlso", :in => RDF::RDFS)
|
2
|
+
property :part_of, predicate: RDF::DC.isPartOf
|
3
|
+
property :resource_type, predicate: RDF::DC.type do |index|
|
4
|
+
index.as :stored_searchable, :facetable
|
53
5
|
end
|
6
|
+
property :title, predicate: RDF::DC.title do |index|
|
7
|
+
index.as :stored_searchable
|
8
|
+
end
|
9
|
+
property :creator, predicate: RDF::DC.creator do |index|
|
10
|
+
index.as :stored_searchable, :facetable
|
11
|
+
end
|
12
|
+
property :contributor, predicate: RDF::DC.contributor do |index|
|
13
|
+
index.as :stored_searchable, :facetable
|
14
|
+
end
|
15
|
+
property :description, predicate: RDF::DC.description do |index|
|
16
|
+
index.type :text
|
17
|
+
index.as :stored_searchable
|
18
|
+
end
|
19
|
+
property :tag, predicate: RDF::DC.relation do |index|
|
20
|
+
index.as :stored_searchable, :facetable
|
21
|
+
end
|
22
|
+
property :rights, predicate: RDF::DC.rights do |index|
|
23
|
+
index.as :stored_searchable
|
24
|
+
end
|
25
|
+
property :publisher, predicate: RDF::DC.publisher do |index|
|
26
|
+
index.as :stored_searchable, :facetable
|
27
|
+
end
|
28
|
+
property :date_created, predicate: RDF::DC.created do |index|
|
29
|
+
index.as :stored_searchable
|
30
|
+
end
|
31
|
+
property :date_uploaded, predicate: RDF::DC.dateSubmitted do |index|
|
32
|
+
index.type :date
|
33
|
+
index.as :stored_sortable
|
34
|
+
end
|
35
|
+
property :date_modified, predicate: RDF::DC.modified do |index|
|
36
|
+
index.type :date
|
37
|
+
index.as :stored_sortable
|
38
|
+
end
|
39
|
+
property :subject, predicate: RDF::DC.subject do |index|
|
40
|
+
index.as :stored_searchable, :facetable
|
41
|
+
end
|
42
|
+
property :language, predicate: RDF::DC.language do |index|
|
43
|
+
index.as :stored_searchable, :facetable
|
44
|
+
end
|
45
|
+
property :identifier, predicate: RDF::DC.identifier do |index|
|
46
|
+
index.as :stored_searchable
|
47
|
+
end
|
48
|
+
property :based_near, predicate: RDF::FOAF.based_near do |index|
|
49
|
+
index.as :stored_searchable, :facetable
|
50
|
+
end
|
51
|
+
property :related_url, predicate: RDF::RDFS.seeAlso do |index|
|
52
|
+
index.as :stored_searchable
|
53
|
+
end
|
54
|
+
|
55
|
+
# TODO: Move this somewhere more appropriate
|
54
56
|
begin
|
55
57
|
LocalAuthority.register_vocabulary(self, "subject", "lc_subjects")
|
56
58
|
LocalAuthority.register_vocabulary(self, "language", "lexvo_languages")
|
@@ -1,18 +1,4 @@
|
|
1
1
|
# properties datastream: catch-all for info that didn't have another home. Particularly depositor.
|
2
2
|
class PropertiesDatastream < ActiveFedora::OmDatastream
|
3
|
-
|
4
|
-
t.root(:path=>"fields" )
|
5
|
-
# This is where we put the user id of the object depositor -- impacts permissions/access controls
|
6
|
-
t.depositor :index_as=>[:stored_searchable]
|
7
|
-
# This is where we put the relative path of the file if submitted as a folder
|
8
|
-
t.relative_path
|
9
|
-
t.import_url path: 'importUrl', :index_as=>:symbol
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.xml_template
|
13
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
14
|
-
xml.fields
|
15
|
-
end
|
16
|
-
builder.doc
|
17
|
-
end
|
3
|
+
include Sufia::PropertiesDatastreamBehavior
|
18
4
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class FeaturedWork < ActiveRecord::Base
|
2
|
+
FEATURE_LIMIT = 5
|
3
|
+
validate :count_within_limit, on: :create
|
4
|
+
validates :order, inclusion: { in: Proc.new{ 0..FEATURE_LIMIT } }
|
5
|
+
|
6
|
+
default_scope { order(:order) }
|
7
|
+
|
8
|
+
def count_within_limit
|
9
|
+
unless FeaturedWork.can_create_another?
|
10
|
+
errors.add(:base, "Limited to #{FEATURE_LIMIT} featured works.")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :generic_file_solr_document
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def can_create_another?
|
18
|
+
FeaturedWork.count < FEATURE_LIMIT
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
File without changes
|
File without changes
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'google/api_client'
|
2
|
+
require 'oauth2'
|
3
|
+
require 'legato'
|
4
|
+
|
5
|
+
module Sufia
|
6
|
+
module UsageStatistics
|
7
|
+
# Loads configuration options from config/analytics.yml. Expected structure:
|
8
|
+
# `analytics:`
|
9
|
+
# ` app_name: GOOGLE_OAUTH_APP_NAME`
|
10
|
+
# ` app_version: GOOGLE_OAUTH_APP_VERSION`
|
11
|
+
# ` privkey_path: GOOGLE_OAUTH_PRIVATE_KEY_PATH`
|
12
|
+
# ` privkey_secret: GOOGLE_OAUTH_PRIVATE_KEY_SECRET`
|
13
|
+
# ` client_email: GOOGLE_OAUTH_CLIENT_EMAIL`
|
14
|
+
# @return [Hash] A hash containing five keys: 'app_name', 'app_version', 'client_email', 'privkey_path', 'privkey_secret'
|
15
|
+
def self.config
|
16
|
+
@config ||= YAML.load(File.read(File.join(Rails.root, 'config', 'analytics.yml')))['analytics']
|
17
|
+
end
|
18
|
+
|
19
|
+
# Convert query results into json for plotting in JQuery Flot
|
20
|
+
# @param [Legato::Query] A Legato query object containing the results
|
21
|
+
# @return [Array] An array of arrays represented in JSON: `[[1388563200000,4],[1388649600000,8],...]`
|
22
|
+
def self.as_flot_json(ga_results)
|
23
|
+
# Convert Legato query to hash
|
24
|
+
results_list = ga_results.map(&:marshal_dump)
|
25
|
+
# Results should look like: [[DATE_INT, NUM_HITS], ...]
|
26
|
+
values = results_list.map do |result_hash|
|
27
|
+
result_hash[:date] = Date.parse(result_hash[:date]).to_time.to_i * 1000
|
28
|
+
result_hash[:pageviews] = result_hash[:pageviews].to_i
|
29
|
+
result_hash.values
|
30
|
+
end
|
31
|
+
|
32
|
+
values.to_json
|
33
|
+
end
|
34
|
+
|
35
|
+
# Calculate total pageviews based on query results
|
36
|
+
# @param [Legato::Query] A Legato query object containing the results
|
37
|
+
# @return [Fixnum] An integer representing how many pageviews were recorded
|
38
|
+
def self.total_pageviews(ga_results)
|
39
|
+
ga_results.map(&:marshal_dump).reduce(0) { |total, result| total + result[:pageviews].to_i }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Generate an OAuth2 token for Google Analytics
|
43
|
+
# @return [OAuth2::AccessToken] An OAuth2 access token for GA
|
44
|
+
def self.token
|
45
|
+
scope = 'https://www.googleapis.com/auth/analytics.readonly'
|
46
|
+
client = Google::APIClient.new(application_name: self.config['app_name'],
|
47
|
+
application_version: self.config['app_version'])
|
48
|
+
key = Google::APIClient::PKCS12.load_key(self.config['privkey_path'],
|
49
|
+
self.config['privkey_secret'])
|
50
|
+
service_account = Google::APIClient::JWTAsserter.new(self.config['client_email'], scope,
|
51
|
+
key)
|
52
|
+
client.authorization = service_account.authorize
|
53
|
+
oauth_client = OAuth2::Client.new('', '', {
|
54
|
+
authorize_url: 'https://accounts.google.com/o/oauth2/auth',
|
55
|
+
token_url: 'https://accounts.google.com/o/oauth2/token'})
|
56
|
+
OAuth2::AccessToken.new(oauth_client, client.authorization.access_token)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Return a user object linked to a Google Analytics account
|
60
|
+
# @return [Legato::User] A user account wit GA access
|
61
|
+
def self.user
|
62
|
+
Legato::User.new(self.token)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Return a Google Analytics profile matching specified ID
|
66
|
+
# @ return [Legato::Management::Profile] A user profile associated with GA
|
67
|
+
def self.profile
|
68
|
+
self.user.profiles.detect do |profile|
|
69
|
+
profile.web_property_id == Sufia.config.google_analytics_id
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/config/locales/sufia.en.yml
CHANGED
@@ -15,6 +15,7 @@ This generator makes the following changes to your application:
|
|
15
15
|
3. Creates the sufia.rb configuration file
|
16
16
|
4. Adds Sufia::SolrDocumentBehavior to app/models/solr_document.rb
|
17
17
|
5. Generates mailboxer
|
18
|
+
6. Generates usage stats config
|
18
19
|
"""
|
19
20
|
|
20
21
|
# Implement the required interface for Rails::Generators::Migration.
|
@@ -32,6 +33,10 @@ This generator makes the following changes to your application:
|
|
32
33
|
@prev_migration_nr.to_s
|
33
34
|
end
|
34
35
|
|
36
|
+
def banner
|
37
|
+
say_status("warning", "GENERATING SUFIA MODELS", :yellow)
|
38
|
+
end
|
39
|
+
|
35
40
|
# Setup the database migrations
|
36
41
|
def copy_migrations
|
37
42
|
# Can't get this any more DRY, because we need this order.
|
@@ -46,7 +51,10 @@ This generator makes the following changes to your application:
|
|
46
51
|
"add_groups_to_users.rb",
|
47
52
|
"create_local_authorities.rb",
|
48
53
|
"create_trophies.rb",
|
49
|
-
'add_linkedin_to_users.rb'
|
54
|
+
'add_linkedin_to_users.rb',
|
55
|
+
'create_tinymce_assets.rb',
|
56
|
+
'create_content_blocks.rb',
|
57
|
+
'create_featured_works.rb'
|
50
58
|
].each do |file|
|
51
59
|
better_migration_template file
|
52
60
|
end
|
@@ -66,19 +74,22 @@ This generator makes the following changes to your application:
|
|
66
74
|
end
|
67
75
|
|
68
76
|
def create_configuration_files
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
copy_file
|
73
|
-
copy_file
|
77
|
+
inject_into_file 'config/initializers/mime_types.rb',
|
78
|
+
"\nMime::Type.register 'application/x-endnote-refer', :endnote",
|
79
|
+
{ :after => /# Mime::Type.register_alias "text\/html", :iphone/, :verbose => false }
|
80
|
+
copy_file 'config/sufia.rb', 'config/initializers/sufia.rb'
|
81
|
+
copy_file 'config/redis.yml', 'config/redis.yml'
|
82
|
+
copy_file 'config/redis_config.rb', 'config/initializers/redis_config.rb'
|
83
|
+
copy_file 'config/resque_admin.rb', 'config/initializers/resque_admin.rb'
|
84
|
+
copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb'
|
74
85
|
end
|
75
86
|
|
76
87
|
# Add behaviors to the SolrDocument model
|
77
88
|
def inject_sufia_solr_document_behavior
|
78
89
|
file_path = "app/models/solr_document.rb"
|
79
90
|
if File.exists?(file_path)
|
80
|
-
|
81
|
-
" # Adds Sufia behaviors to the SolrDocument.\n" +
|
91
|
+
inject_into_file file_path, after: /include Blacklight::Solr::Document.*$/ do
|
92
|
+
"\n # Adds Sufia behaviors to the SolrDocument.\n" +
|
82
93
|
" include Sufia::SolrDocumentBehavior\n"
|
83
94
|
end
|
84
95
|
else
|
@@ -90,6 +101,10 @@ This generator makes the following changes to your application:
|
|
90
101
|
generate "mailboxer:install"
|
91
102
|
end
|
92
103
|
|
104
|
+
def configure_usage_stats
|
105
|
+
generate 'sufia:models:usagestats'
|
106
|
+
end
|
107
|
+
|
93
108
|
private
|
94
109
|
|
95
110
|
def better_migration_template(file)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#
|
2
|
+
# To integrate your app with Google Analytics, uncomment the lines below and add your API key information.
|
3
|
+
#
|
4
|
+
# analytics:
|
5
|
+
# :app_name: GOOGLE_OAUTH_APP_NAME
|
6
|
+
# :app_version: GOOGLE_OAUTH_APP_VERSION
|
7
|
+
# :privkey_path: GOOGLE_OAUTH_PRIVATE_KEY_PATH
|
8
|
+
# :privkey_secret: GOOGLE_OAUTH_PRIVATE_KEY_SECRET
|
9
|
+
# :client_email: GOOGLE_OAUTH_CLIENT_EMAIL
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new mime types for use in respond_to blocks:
|
4
|
+
# Mime::Type.register "text/richtext", :rtf
|
5
|
+
# Mime::Type.register_alias "text/html", :iphone
|
6
|
+
Mime::Type.register 'application/x-endnote-refer', :endnote
|
@@ -60,9 +60,11 @@ Sufia.config do |config|
|
|
60
60
|
|
61
61
|
config.queue = Sufia::Resque::Queue
|
62
62
|
|
63
|
-
#
|
64
|
-
|
63
|
+
# Enable displaying usage statistics in the UI
|
64
|
+
config.usage_statistics = true
|
65
65
|
|
66
|
+
# Specify a Google Analytics tracking ID to gather usage statistics
|
67
|
+
# config.google_analytics_id = 'UA-99999999-1'
|
66
68
|
|
67
69
|
# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)
|
68
70
|
# config.temp_file_base = '/home/developer1'
|
@@ -76,6 +78,13 @@ Sufia.config do |config|
|
|
76
78
|
# Specify the path to the file characterization tool:
|
77
79
|
# config.fits_path = "fits.sh"
|
78
80
|
|
81
|
+
# If browse-everything has been configured, load the configs. Otherwise, set to nil.
|
82
|
+
begin
|
83
|
+
config.browse_everything = BrowseEverything.config
|
84
|
+
rescue Errno::ENOENT
|
85
|
+
config.browse_everything = nil
|
86
|
+
end
|
87
|
+
|
79
88
|
end
|
80
89
|
|
81
90
|
Date::DATE_FORMATS[:standard] = "%m/%d/%Y"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateFeaturedWorks < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :featured_works do |t|
|
4
|
+
t.integer :order, default: 5
|
5
|
+
t.string :generic_file_id
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :featured_works, :generic_file_id
|
10
|
+
add_index :featured_works, :order
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
class Sufia::Models::UsagestatsGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc """
|
8
|
+
This generator makes the following changes to your application:
|
9
|
+
1. Generates usage stats config
|
10
|
+
"""
|
11
|
+
|
12
|
+
def banner
|
13
|
+
say_status("warning", "GENERATING SUFIA USAGE STATS", :yellow)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_configuration_file
|
17
|
+
copy_file 'config/analytics.yml', 'config/analytics.yml'
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Sufia
|
2
|
+
module Ability
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
included do
|
5
|
+
self.ability_logic += [:sufia_abilities]
|
6
|
+
end
|
7
|
+
|
8
|
+
def sufia_abilities
|
9
|
+
generic_file_abilities
|
10
|
+
featured_work_abilities
|
11
|
+
editor_abilities
|
12
|
+
stats_abilities
|
13
|
+
end
|
14
|
+
|
15
|
+
def featured_work_abilities
|
16
|
+
can [:create, :destroy, :update], FeaturedWork if user_groups.include? 'admin'
|
17
|
+
end
|
18
|
+
|
19
|
+
def generic_file_abilities
|
20
|
+
can :create, GenericFile if user_groups.include? 'registered'
|
21
|
+
end
|
22
|
+
|
23
|
+
def editor_abilities
|
24
|
+
if user_groups.include? 'admin'
|
25
|
+
can :create, TinymceAsset
|
26
|
+
can :update, ContentBlock
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def stats_abilities
|
31
|
+
alias_action :stats, to: :read
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/sufia/models/engine.rb
CHANGED
@@ -21,7 +21,7 @@ module Sufia
|
|
21
21
|
config.id_namespace = "sufia"
|
22
22
|
config.fits_path = "fits.sh"
|
23
23
|
config.enable_contact_form_delivery = false
|
24
|
-
config.
|
24
|
+
config.browse_everything = nil
|
25
25
|
config.enable_local_ingest = nil
|
26
26
|
config.queue = Sufia::Resque::Queue
|
27
27
|
|
@@ -44,7 +44,6 @@ module Sufia
|
|
44
44
|
require 'activerecord-import'
|
45
45
|
require 'hydra/derivatives'
|
46
46
|
require 'sufia/models/model_methods'
|
47
|
-
require 'sufia/models/noid'
|
48
47
|
require 'sufia/models/file_content'
|
49
48
|
require 'sufia/models/file_content/versions'
|
50
49
|
require 'sufia/models/generic_file/audit'
|
@@ -55,8 +54,11 @@ module Sufia
|
|
55
54
|
require 'sufia/models/generic_file/thumbnail'
|
56
55
|
require 'sufia/models/generic_file'
|
57
56
|
require 'sufia/models/user_local_directory_behavior'
|
58
|
-
require 'sufia/models/id_service'
|
59
57
|
require 'sufia/models/solr_document_behavior'
|
58
|
+
require 'sufia/noid'
|
59
|
+
require 'sufia/id_service'
|
60
|
+
require 'sufia/usage_statistics'
|
61
|
+
require 'sufia/pageview'
|
60
62
|
end
|
61
63
|
|
62
64
|
initializer 'configure' do
|
@@ -8,6 +8,7 @@ module Sufia
|
|
8
8
|
autoload :WebForm, 'sufia/models/generic_file/web_form'
|
9
9
|
autoload :AccessibleAttributes, 'sufia/models/generic_file/accessible_attributes'
|
10
10
|
autoload :Trophies, 'sufia/models/generic_file/trophies'
|
11
|
+
autoload :Featured, 'sufia/models/generic_file/featured'
|
11
12
|
autoload :Metadata, 'sufia/models/generic_file/metadata'
|
12
13
|
autoload :Versions, 'sufia/models/generic_file/versions'
|
13
14
|
autoload :VirusCheck, 'sufia/models/generic_file/virus_check'
|
@@ -23,6 +24,7 @@ module Sufia
|
|
23
24
|
include Sufia::GenericFile::WebForm
|
24
25
|
include Sufia::GenericFile::Derivatives
|
25
26
|
include Sufia::GenericFile::Trophies
|
27
|
+
include Sufia::GenericFile::Featured
|
26
28
|
include Sufia::GenericFile::Metadata
|
27
29
|
include Sufia::GenericFile::Versions
|
28
30
|
include Sufia::GenericFile::VirusCheck
|
@@ -76,7 +78,7 @@ module Sufia
|
|
76
78
|
# to each file when it is done uploading. The Batch object is not created
|
77
79
|
# until all objects are done uploading and the user is redirected to
|
78
80
|
# BatchController#edit. Therefore, we must handle the case where
|
79
|
-
# self.batch_id is set but self.batch returns nil.
|
81
|
+
# self.batch_id is set but self.batch returns nil.
|
80
82
|
# This can get a major overhaul with ActiveFedora 7
|
81
83
|
def related_files
|
82
84
|
relateds = begin
|
@@ -96,7 +98,7 @@ module Sufia
|
|
96
98
|
end
|
97
99
|
|
98
100
|
def to_solr(solr_doc={}, opts={})
|
99
|
-
super(solr_doc, opts)
|
101
|
+
solr_doc = super(solr_doc, opts)
|
100
102
|
solr_doc[Solrizer.solr_name('label')] = self.label
|
101
103
|
solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)] = noid
|
102
104
|
solr_doc[Solrizer.solr_name('file_format')] = file_format
|
@@ -22,7 +22,7 @@ module Sufia
|
|
22
22
|
'%[' => [:date_modified],
|
23
23
|
'%9' => [:resource_type],
|
24
24
|
'%~' => Application.config.application_name,
|
25
|
-
'%W' => '
|
25
|
+
'%W' => t('sufia.institution_name')
|
26
26
|
}
|
27
27
|
text = []
|
28
28
|
text << "%0 GenericFile"
|
@@ -32,7 +32,7 @@ module Sufia
|
|
32
32
|
else
|
33
33
|
values = self.send(mapping[0]) if self.respond_to? mapping[0]
|
34
34
|
values = mapping[1].call(values) if mapping.length == 2
|
35
|
-
values =
|
35
|
+
values = Array(values)
|
36
36
|
end
|
37
37
|
next if values.empty? or values.first.nil?
|
38
38
|
spaced_values = values.join("; ")
|
@@ -64,7 +64,7 @@ module Sufia
|
|
64
64
|
values = self.send(element)
|
65
65
|
next if values.empty? or values.first.nil?
|
66
66
|
values.each do |value|
|
67
|
-
export_text << "rft.#{kev}=#{CGI::escape(value)}"
|
67
|
+
export_text << "rft.#{kev}=#{CGI::escape(value.to_s)}"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
export_text.join('&') unless export_text.blank?
|
@@ -11,6 +11,10 @@ module Sufia
|
|
11
11
|
get(Solrizer.solr_name('has_model', :symbol)).split(':').last.downcase
|
12
12
|
end
|
13
13
|
|
14
|
+
def to_param
|
15
|
+
noid
|
16
|
+
end
|
17
|
+
|
14
18
|
##
|
15
19
|
# Offer the source (ActiveFedora-based) model to Rails for some of the
|
16
20
|
# Rails methods (e.g. link_to).
|
@@ -65,20 +69,24 @@ module Sufia
|
|
65
69
|
Array(self[Solrizer.solr_name("desc_metadata__tag")])
|
66
70
|
end
|
67
71
|
|
72
|
+
def resource_type
|
73
|
+
Array(self[Solrizer.solr_name("desc_metadata__resource_type")])
|
74
|
+
end
|
75
|
+
|
68
76
|
def mime_type
|
69
77
|
Array(self[Solrizer.solr_name("mime_type")]).first
|
70
78
|
end
|
71
79
|
|
72
80
|
def read_groups
|
73
|
-
Array(self[Ability.read_group_field])
|
81
|
+
Array(self[::Ability.read_group_field])
|
74
82
|
end
|
75
83
|
|
76
84
|
def edit_groups
|
77
|
-
Array(self[Ability.edit_group_field])
|
85
|
+
Array(self[::Ability.edit_group_field])
|
78
86
|
end
|
79
87
|
|
80
88
|
def edit_people
|
81
|
-
Array(self[Ability.
|
89
|
+
Array(self[::Ability.edit_user_field])
|
82
90
|
end
|
83
91
|
|
84
92
|
def public?
|
@@ -89,7 +97,6 @@ module Sufia
|
|
89
97
|
read_groups.include?('registered')
|
90
98
|
end
|
91
99
|
|
92
|
-
|
93
100
|
def pdf?
|
94
101
|
['application/pdf'].include? self.mime_type
|
95
102
|
end
|
data/lib/sufia/models/version.rb
CHANGED
data/sufia-models.gemspec
CHANGED
@@ -26,19 +26,20 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
|
29
|
-
spec.add_dependency 'rails', '
|
29
|
+
spec.add_dependency 'rails', '~> 4.0.0'
|
30
30
|
spec.add_dependency 'activeresource', "~>4.0.0" # No longer a dependency of rails 4.0
|
31
31
|
|
32
|
-
spec.add_dependency "
|
33
|
-
spec.add_dependency "hydra-head", "~> 6.5.0"
|
34
|
-
spec.add_dependency "rubydora", "~> 1.7.0"
|
32
|
+
spec.add_dependency "hydra-head", "~> 7.0.1"
|
35
33
|
spec.add_dependency 'nest', '~> 1.1.1'
|
36
34
|
spec.add_dependency 'resque', '~> 1.23'
|
37
35
|
spec.add_dependency 'resque-pool', '0.3.0'
|
38
36
|
spec.add_dependency 'noid', '~> 0.6.6'
|
39
|
-
spec.add_dependency 'mailboxer', '~> 0.
|
37
|
+
spec.add_dependency 'mailboxer', '~> 0.12.0.rc1'
|
40
38
|
spec.add_dependency 'acts_as_follower', '>= 0.1.1', '< 0.3'
|
41
39
|
spec.add_dependency 'carrierwave', '~> 0.9.0'
|
42
40
|
spec.add_dependency 'hydra-derivatives', '~> 0.0.5'
|
41
|
+
spec.add_dependency 'oauth2', '~> 0.9.3'
|
42
|
+
spec.add_dependency 'google-api-client', '~> 0.7.1'
|
43
|
+
spec.add_dependency 'legato', '~> 0.3.0'
|
43
44
|
spec.add_dependency 'activerecord-import'
|
44
45
|
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:
|
4
|
+
version: 4.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,22 +42,16 @@ dependencies:
|
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 4.0.0
|
48
|
-
- - <
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '5.0'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
|
-
- -
|
52
|
+
- - ~>
|
56
53
|
- !ruby/object:Gem::Version
|
57
54
|
version: 4.0.0
|
58
|
-
- - <
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '5.0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: activeresource
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,48 +66,20 @@ dependencies:
|
|
72
66
|
- - ~>
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: 4.0.0
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: blacklight
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ~>
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 4.7.0
|
82
|
-
type: :runtime
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ~>
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 4.7.0
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: hydra-head
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
92
72
|
requirements:
|
93
73
|
- - ~>
|
94
74
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
75
|
+
version: 7.0.1
|
96
76
|
type: :runtime
|
97
77
|
prerelease: false
|
98
78
|
version_requirements: !ruby/object:Gem::Requirement
|
99
79
|
requirements:
|
100
80
|
- - ~>
|
101
81
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: rubydora
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 1.7.0
|
110
|
-
type: :runtime
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - ~>
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 1.7.0
|
82
|
+
version: 7.0.1
|
117
83
|
- !ruby/object:Gem::Dependency
|
118
84
|
name: nest
|
119
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,14 +142,14 @@ dependencies:
|
|
176
142
|
requirements:
|
177
143
|
- - ~>
|
178
144
|
- !ruby/object:Gem::Version
|
179
|
-
version: 0.
|
145
|
+
version: 0.12.0.rc1
|
180
146
|
type: :runtime
|
181
147
|
prerelease: false
|
182
148
|
version_requirements: !ruby/object:Gem::Requirement
|
183
149
|
requirements:
|
184
150
|
- - ~>
|
185
151
|
- !ruby/object:Gem::Version
|
186
|
-
version: 0.
|
152
|
+
version: 0.12.0.rc1
|
187
153
|
- !ruby/object:Gem::Dependency
|
188
154
|
name: acts_as_follower
|
189
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,6 +198,48 @@ dependencies:
|
|
232
198
|
- - ~>
|
233
199
|
- !ruby/object:Gem::Version
|
234
200
|
version: 0.0.5
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: oauth2
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ~>
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 0.9.3
|
208
|
+
type: :runtime
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ~>
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: 0.9.3
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: google-api-client
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ~>
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: 0.7.1
|
222
|
+
type: :runtime
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ~>
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: 0.7.1
|
229
|
+
- !ruby/object:Gem::Dependency
|
230
|
+
name: legato
|
231
|
+
requirement: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - ~>
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: 0.3.0
|
236
|
+
type: :runtime
|
237
|
+
prerelease: false
|
238
|
+
version_requirements: !ruby/object:Gem::Requirement
|
239
|
+
requirements:
|
240
|
+
- - ~>
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: 0.3.0
|
235
243
|
- !ruby/object:Gem::Dependency
|
236
244
|
name: activerecord-import
|
237
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -260,6 +268,7 @@ files:
|
|
260
268
|
- Rakefile
|
261
269
|
- app/models/batch.rb
|
262
270
|
- app/models/checksum_audit_log.rb
|
271
|
+
- app/models/concerns/sufia/properties_datastream_behavior.rb
|
263
272
|
- app/models/concerns/sufia/user.rb
|
264
273
|
- app/models/datastreams/batch_rdf_datastream.rb
|
265
274
|
- app/models/datastreams/file_content_datastream.rb
|
@@ -268,6 +277,7 @@ files:
|
|
268
277
|
- app/models/datastreams/paranoid_rights_datastream.rb
|
269
278
|
- app/models/datastreams/properties_datastream.rb
|
270
279
|
- app/models/domain_term.rb
|
280
|
+
- app/models/featured_work.rb
|
271
281
|
- app/models/follow.rb
|
272
282
|
- app/models/generic_file.rb
|
273
283
|
- app/models/geo_names_resource.rb
|
@@ -278,12 +288,18 @@ files:
|
|
278
288
|
- app/models/subject_local_authority_entry.rb
|
279
289
|
- app/models/sufia/avatar_uploader.rb
|
280
290
|
- app/models/sufia/avatar_validator.rb
|
291
|
+
- app/models/sufia/pageview.rb
|
281
292
|
- app/models/trophy.rb
|
282
293
|
- app/models/version_committer.rb
|
294
|
+
- app/services/sufia/id_service.rb
|
295
|
+
- app/services/sufia/noid.rb
|
296
|
+
- app/services/sufia/usage_statistics.rb
|
283
297
|
- config/locales/sufia.en.yml
|
284
298
|
- lib/generators/sufia/models/install_generator.rb
|
299
|
+
- lib/generators/sufia/models/templates/config/analytics.yml
|
285
300
|
- lib/generators/sufia/models/templates/config/clamav.rb
|
286
301
|
- lib/generators/sufia/models/templates/config/mailboxer.rb
|
302
|
+
- lib/generators/sufia/models/templates/config/mime_types.rb
|
287
303
|
- lib/generators/sufia/models/templates/config/redis.yml
|
288
304
|
- lib/generators/sufia/models/templates/config/redis_config.rb
|
289
305
|
- lib/generators/sufia/models/templates/config/resque_admin.rb
|
@@ -297,10 +313,15 @@ files:
|
|
297
313
|
- lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb
|
298
314
|
- lib/generators/sufia/models/templates/migrations/add_social_to_users.rb
|
299
315
|
- lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb
|
316
|
+
- lib/generators/sufia/models/templates/migrations/create_content_blocks.rb
|
317
|
+
- lib/generators/sufia/models/templates/migrations/create_featured_works.rb
|
300
318
|
- lib/generators/sufia/models/templates/migrations/create_local_authorities.rb
|
301
319
|
- lib/generators/sufia/models/templates/migrations/create_single_use_links.rb
|
320
|
+
- lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb
|
302
321
|
- lib/generators/sufia/models/templates/migrations/create_trophies.rb
|
303
322
|
- lib/generators/sufia/models/templates/migrations/create_version_committers.rb
|
323
|
+
- lib/generators/sufia/models/usagestats_generator.rb
|
324
|
+
- lib/sufia/ability.rb
|
304
325
|
- lib/sufia/models.rb
|
305
326
|
- lib/sufia/models/active_fedora/redis.rb
|
306
327
|
- lib/sufia/models/active_record/redis.rb
|
@@ -314,6 +335,7 @@ files:
|
|
314
335
|
- lib/sufia/models/generic_file/characterization.rb
|
315
336
|
- lib/sufia/models/generic_file/derivatives.rb
|
316
337
|
- lib/sufia/models/generic_file/export.rb
|
338
|
+
- lib/sufia/models/generic_file/featured.rb
|
317
339
|
- lib/sufia/models/generic_file/metadata.rb
|
318
340
|
- lib/sufia/models/generic_file/mime_types.rb
|
319
341
|
- lib/sufia/models/generic_file/permissions.rb
|
@@ -323,7 +345,6 @@ files:
|
|
323
345
|
- lib/sufia/models/generic_file/versions.rb
|
324
346
|
- lib/sufia/models/generic_file/virus_check.rb
|
325
347
|
- lib/sufia/models/generic_file/web_form.rb
|
326
|
-
- lib/sufia/models/id_service.rb
|
327
348
|
- lib/sufia/models/jobs/active_fedora_pid_based_job.rb
|
328
349
|
- lib/sufia/models/jobs/audit_job.rb
|
329
350
|
- lib/sufia/models/jobs/batch_update_job.rb
|
@@ -333,7 +354,6 @@ files:
|
|
333
354
|
- lib/sufia/models/jobs/transcode_audio_job.rb
|
334
355
|
- lib/sufia/models/jobs/transcode_video_job.rb
|
335
356
|
- lib/sufia/models/model_methods.rb
|
336
|
-
- lib/sufia/models/noid.rb
|
337
357
|
- lib/sufia/models/resque.rb
|
338
358
|
- lib/sufia/models/solr_document_behavior.rb
|
339
359
|
- lib/sufia/models/user_local_directory_behavior.rb
|
@@ -357,9 +377,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
357
377
|
version: '0'
|
358
378
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
359
379
|
requirements:
|
360
|
-
- - '
|
380
|
+
- - '>'
|
361
381
|
- !ruby/object:Gem::Version
|
362
|
-
version:
|
382
|
+
version: 1.3.1
|
363
383
|
requirements: []
|
364
384
|
rubyforge_project:
|
365
385
|
rubygems_version: 2.2.1
|