sufia 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/.travis.yml +1 -1
- data/Gemfile +3 -0
- data/README.md +88 -11
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/old_main_tulips.jpg +0 -0
- data/app/assets/javascripts/contact_form.js +0 -16
- data/app/assets/javascripts/jquery.blacklightTagCloud.js +44 -0
- data/app/assets/javascripts/jquery.tagcloud.js +116 -0
- data/app/assets/javascripts/jquery.tinysort.min.js +7 -0
- data/app/assets/javascripts/sufia.js +41 -44
- data/app/assets/javascripts/sufia/edit_metadata.js +1 -1
- data/app/assets/javascripts/sufia/editor.js +12 -0
- data/app/assets/javascripts/sufia/featured_works.js +64 -0
- data/app/assets/javascripts/sufia/fileupload.js +1 -1
- data/app/assets/javascripts/sufia/multiForm.js +1 -1
- data/app/assets/javascripts/sufia/permissions.js +4 -8
- data/app/assets/javascripts/sufia/single_use_link.js +1 -2
- data/app/assets/javascripts/sufia/trophy.js +42 -27
- data/app/assets/javascripts/terms_of_service.js +1 -1
- data/app/assets/stylesheets/dashboard.css.scss +81 -40
- data/app/assets/stylesheets/featured.css.scss +16 -0
- data/app/assets/stylesheets/fileupload/{jquery.fileupload-ui.css → jquery.fileupload-ui.css.erb} +2 -2
- data/app/assets/stylesheets/{generic_files.css → generic_files.css.erb} +6 -7
- data/app/assets/stylesheets/header.css.scss +93 -0
- data/app/assets/stylesheets/home-page.css.scss +50 -0
- data/app/assets/stylesheets/nestable.css.scss +111 -0
- data/app/assets/stylesheets/styles.css.scss +106 -0
- data/app/assets/stylesheets/sufia.css.scss +13 -8
- data/app/assets/stylesheets/tagcloud.css +83 -0
- data/app/assets/stylesheets/usage-stats.css +30 -0
- data/app/controllers/batch_controller.rb +0 -1
- data/app/controllers/concerns/sufia/catalog.rb +64 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +16 -13
- data/app/controllers/content_blocks_controller.rb +8 -0
- data/app/controllers/featured_work_lists_controller.rb +16 -0
- data/app/controllers/featured_works_controller.rb +26 -0
- data/app/controllers/mailbox_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +7 -0
- data/app/controllers/single_use_links_viewer_controller.rb +2 -5
- data/app/controllers/tinymce_assets_controller.rb +12 -0
- data/app/helpers/content_block_helper.rb +21 -0
- data/app/helpers/generic_file_helper.rb +2 -2
- data/app/helpers/sufia_helper.rb +8 -4
- data/app/helpers/trophy_helper.rb +15 -7
- data/app/models/content_block.rb +2 -0
- data/app/models/featured_work_list.rb +42 -0
- data/app/models/tinymce_asset.rb +3 -0
- data/app/uploaders/tinymce_asset_uploader.rb +51 -0
- data/app/views/_add_assets_links.html.erb +0 -16
- data/app/views/_controls.html.erb +17 -0
- data/app/views/_flash_msg.html.erb +2 -18
- data/app/views/_footer.html.erb +10 -15
- data/app/views/_ga.html.erb +0 -16
- data/app/views/_logo.html.erb +2 -2
- data/app/views/_masthead.html.erb +9 -36
- data/app/views/_user_util_links.html.erb +16 -11
- data/app/views/advanced/_advanced_search_facets.html.erb +0 -16
- data/app/views/advanced/_advanced_search_fields.html.erb +0 -16
- data/app/views/advanced/_advanced_search_help.html.erb +0 -16
- data/app/views/advanced/_facet_layout.html.erb +0 -16
- data/app/views/advanced/_facet_limit.html.erb +0 -16
- data/app/views/advanced/index.html.erb +2 -18
- data/app/views/batch/_metadata.html.erb +3 -3
- data/app/views/batch/edit.html.erb +4 -21
- data/app/views/catalog/_facet_limit.html.erb +11 -12
- data/app/views/catalog/_featured_researcher.html.erb +2 -0
- data/app/views/catalog/_home.html.erb +6 -2
- data/app/views/catalog/_home_content.html.erb +36 -0
- data/app/views/catalog/_home_header.html.erb +15 -0
- data/app/views/catalog/_recent_document.html.erb +1 -1
- data/app/views/catalog/_recents.html.erb +3 -4
- data/app/views/catalog/_search_form.html.erb +13 -9
- data/app/views/catalog/_tagcloud.html.erb +7 -0
- data/app/views/catalog/index.html.erb +4 -10
- data/app/views/contact_form/create.html.erb +0 -16
- data/app/views/contact_form/new.html.erb +0 -16
- data/app/views/dashboard/_constraints.html.erb +3 -19
- data/app/views/dashboard/_did_you_mean.html.erb +0 -16
- data/app/views/dashboard/_document_list.html.erb +0 -16
- data/app/views/dashboard/_facet_layout.html.erb +1 -17
- data/app/views/dashboard/_facet_limit.html.erb +5 -5
- data/app/views/dashboard/_facet_selected.html.erb +1 -17
- data/app/views/dashboard/_facets.html.erb +0 -18
- data/app/views/dashboard/_heading.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_default_group.html.erb +7 -23
- data/app/views/dashboard/_index_partials/_list_files.html.erb +62 -57
- data/app/views/dashboard/_search_form.html.erb +10 -7
- data/app/views/dashboard/_show_partials/_default.html.erb +0 -18
- data/app/views/dashboard/_show_partials/_default_details.html.erb +0 -16
- data/app/views/dashboard/_show_partials/_facets.html.erb +0 -16
- data/app/views/dashboard/_sort_and_per_page.html.erb +10 -9
- data/app/views/dashboard/facet.html.erb +4 -19
- data/app/views/dashboard/index.html.erb +27 -49
- data/app/views/error/401.html.erb +1 -17
- data/app/views/error/404.html.erb +0 -16
- data/app/views/error/500.html.erb +0 -16
- data/app/views/error/single_use_error.html.erb +1 -17
- data/app/views/generic_files/_asset_deleted_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_permissions_denial_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_saved_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_updated_flash.html.erb +0 -16
- data/app/views/generic_files/_breadcrumbs.html.erb +0 -16
- data/app/views/generic_files/_browse_everything.html.erb +24 -0
- data/app/views/generic_files/_descriptions.html.erb +1 -1
- data/app/views/generic_files/_field_form.html.erb +5 -5
- data/app/views/generic_files/_media_display.html.erb +3 -3
- data/app/views/generic_files/_permission_form.html.erb +5 -5
- data/app/views/generic_files/_rights_modal.html.erb +13 -29
- data/app/views/generic_files/_show_actions.html.erb +13 -1
- data/app/views/generic_files/_versioning.html.erb +14 -10
- data/app/views/generic_files/citation.html.erb +0 -16
- data/app/views/generic_files/edit.html.erb +10 -12
- data/app/views/generic_files/edit_fields/_default.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_description.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +2 -3
- data/app/views/generic_files/edit_fields/_rights.html.erb +1 -1
- data/app/views/generic_files/new.html.erb +11 -26
- data/app/views/generic_files/show.html.erb +7 -25
- data/app/views/generic_files/stats.html.erb +141 -0
- data/app/views/homepage/_featured.html.erb +11 -0
- data/app/views/homepage/_featured_fields.html.erb +18 -0
- data/app/views/homepage/_featured_works.html.erb +17 -0
- data/app/views/homepage/_sortable_featured.html.erb +26 -0
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/_homepage_sidebar2.html.erb +14 -0
- data/app/views/layouts/error.html.erb +3 -21
- data/app/views/layouts/homepage.html.erb +8 -37
- data/app/views/layouts/sufia-dashboard.html.erb +46 -0
- data/app/views/layouts/sufia-one-column.html.erb +8 -24
- data/app/views/layouts/sufia-two-column.html.erb +9 -8
- data/app/views/pages/show.html.erb +4 -0
- data/app/views/single_use_links_viewer/show.html.erb +2 -2
- data/app/views/static/agreement.html.erb +0 -17
- data/app/views/static/help.html.erb +0 -17
- data/app/views/static/mendeley.html.erb +0 -16
- data/app/views/static/subject_libraries.html.erb +0 -17
- data/app/views/static/terms.html.erb +0 -16
- data/app/views/static/zotero.html.erb +0 -16
- data/app/views/users/_activity_log.html.erb +2 -2
- data/app/views/users/_contributions.html.erb +6 -2
- data/app/views/users/_follower_modal.html.erb +2 -2
- data/app/views/users/_following_modal.html.erb +2 -2
- data/app/views/users/_left_sidebar.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +1 -1
- data/app/views/users/_profile_actions.html.erb +3 -3
- data/app/views/users/_profile_tabs.html.erb +1 -1
- data/app/views/users/_search_form.html.erb +3 -2
- data/app/views/users/_social_media_info.html.erb +3 -3
- data/app/views/users/_trophy_edit.html.erb +2 -2
- data/app/views/users/_user_info.html.erb +27 -27
- data/app/views/users/_vitals.html.erb +2 -2
- data/app/views/users/edit.html.erb +39 -39
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/show.html.erb +7 -9
- data/config/locales/sufia.en.yml +15 -7
- data/config/routes.rb +12 -9
- data/lib/generators/sufia/sufia_generator.rb +18 -15
- data/lib/generators/sufia/templates/catalog_controller.rb +11 -73
- data/lib/generators/sufia/templates/config/tinymce.yml +7 -0
- data/lib/sufia.rb +7 -0
- data/lib/sufia/downloads_controller_behavior.rb +3 -4
- data/lib/sufia/files_controller_behavior.rb +38 -27
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +1 -1
- data/spec/controllers/batch_edits_controller_spec.rb +5 -5
- data/spec/controllers/catalog_controller_spec.rb +37 -58
- data/spec/controllers/content_blocks_controller_spec.rb +37 -0
- data/spec/controllers/downloads_controller_spec.rb +3 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +20 -0
- data/spec/controllers/featured_works_controller_spec.rb +50 -0
- data/spec/controllers/generic_files_controller_spec.rb +74 -9
- data/spec/controllers/mailbox_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +25 -0
- data/spec/controllers/single_use_links_controller_spec.rb +1 -1
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +39 -0
- data/spec/controllers/users_controller_spec.rb +3 -8
- data/spec/factories/content_blocks.rb +4 -0
- data/spec/factories/featured_works.rb +4 -0
- data/spec/factories/generic_files.rb +46 -39
- data/spec/factories/users.rb +18 -18
- data/spec/features/browse_dashboard_files_spec.rb +6 -7
- data/spec/features/browse_files_spec.rb +9 -6
- data/spec/features/cloud_upload_spec.rb +18 -0
- data/spec/features/single_use_links_spec.rb +2 -3
- data/spec/helpers/content_block_helper_spec.rb +31 -0
- data/spec/helpers/generic_file_helper_spec.rb +3 -3
- data/spec/helpers/sufia_helper_spec.rb +13 -81
- data/spec/helpers/trophy_helper_spec.rb +39 -0
- data/spec/jobs/import_url_job_spec.rb +1 -1
- data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
- data/spec/lib/sufia/usage_statistics_spec.rb +75 -0
- data/spec/models/ability_spec.rb +31 -0
- data/spec/models/active_fedora_pid_based_job_spec.rb +1 -1
- data/spec/models/audit_job_spec.rb +1 -1
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/batch_update_job_spec.rb +1 -1
- data/spec/models/event_jobs_spec.rb +1 -1
- data/spec/models/featured_work_list_spec.rb +23 -0
- data/spec/models/featured_work_spec.rb +42 -0
- data/spec/models/fits_datastream_spec.rb +2 -2
- data/spec/models/generic_file/reload_on_save_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +4 -4
- data/spec/models/generic_file_spec.rb +41 -40
- data/spec/models/pageview.rb +19 -0
- data/spec/models/properties_datastream_spec.rb +2 -2
- data/spec/models/solr_document_spec.rb +9 -0
- data/spec/models/user_spec.rb +2 -2
- data/spec/routing/featured_works_route_spec.rb +16 -0
- data/spec/routing/route_spec.rb +10 -15
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/generators/test_app_generator.rb +19 -8
- data/spec/views/dashboard/facet_limit.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/show.html.erb_spec.rb +44 -0
- data/spec/views/generic_file/stats.html.erb_spec.rb +47 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +18 -0
- data/spec/views/users/_following_modal.html.erb_spec.rb +18 -0
- data/spec/views/users/index.html.erb_spec.rb +1 -1
- data/sufia-models/app/models/batch.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +30 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +1 -1
- data/sufia-models/app/models/datastreams/batch_rdf_datastream.rb +4 -7
- data/sufia-models/app/models/datastreams/fits_datastream.rb +3 -0
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +53 -51
- data/sufia-models/app/models/datastreams/properties_datastream.rb +1 -15
- data/sufia-models/app/models/featured_work.rb +22 -0
- data/sufia-models/app/models/sufia/pageview.rb +9 -0
- data/sufia-models/{lib/sufia/models → app/services/sufia}/id_service.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/services/sufia}/noid.rb +0 -0
- data/sufia-models/app/services/sufia/usage_statistics.rb +73 -0
- data/sufia-models/config/locales/sufia.en.yml +3 -4
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +23 -8
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +9 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +6 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +11 -2
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +10 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +12 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +8 -0
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +19 -0
- data/sufia-models/lib/sufia/ability.rb +34 -0
- data/sufia-models/lib/sufia/models/engine.rb +5 -3
- data/sufia-models/lib/sufia/models/generic_file.rb +4 -2
- data/sufia-models/lib/sufia/models/generic_file/export.rb +3 -3
- data/sufia-models/lib/sufia/models/generic_file/featured.rb +14 -0
- data/sufia-models/lib/sufia/models/solr_document_behavior.rb +11 -4
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +6 -5
- data/sufia.gemspec +6 -4
- data/tasks/release.rake +1 -0
- data/tasks/sufia-dev.rake +5 -1
- data/vendor/assets/javascripts/flot/excanvas.js +1428 -0
- data/vendor/assets/javascripts/flot/jquery.flot.js +3137 -0
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +360 -0
- data/vendor/assets/javascripts/flot/jquery.flot.time.js +431 -0
- data/vendor/assets/javascripts/nestable.js +647 -0
- data/vendor/assets/javascripts/video.js +135 -126
- data/{app → vendor}/assets/stylesheets/video-js.css.erb +7 -6
- metadata +155 -33
- data/app/assets/stylesheets/application-bootstrap.css.erb +0 -295
- data/app/assets/stylesheets/audio-js.css +0 -3
- data/app/assets/stylesheets/blacklight_more_facets.css +0 -427
- data/app/assets/stylesheets/bootstrap.min.css.erb +0 -1433
- data/app/assets/stylesheets/contact_form.css +0 -4
- data/app/assets/stylesheets/reset_body.css +0 -4
- data/app/assets/stylesheets/trophy.css +0 -7
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -84
- data/app/helpers/facets_helper.rb +0 -3
- data/app/helpers/sufia/facets_helper_behavior.rb +0 -23
- data/app/views/catalog/_home_text.html.erb +0 -10
- data/app/views/generic_files/_dropbox_import.html.erb +0 -3
- data/app/views/generic_files/upload/_dropbox_chooser.html.erb +0 -39
- data/app/views/static/about.html.erb +0 -21
- data/spec/helpers/render_constraints_helper_behavior_spec.rb +0 -42
@@ -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
|
@@ -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
|
@@ -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?
|