sufia 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -5
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +2 -1
- data/History.md +69 -0
- data/README.md +84 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/zotero.png +0 -0
- data/app/assets/javascripts/sufia/featured_works.js +20 -3
- data/app/assets/stylesheets/generic_files.css.erb +2 -2
- data/app/assets/stylesheets/sufia.css.scss +2 -2
- data/app/assets/stylesheets/sufia/_buttons.scss +2 -2
- data/app/assets/stylesheets/sufia/_collections.scss +4 -4
- data/app/assets/stylesheets/sufia/_dashboard.scss +1 -1
- data/app/assets/stylesheets/sufia/_file-listing.scss +3 -0
- data/app/assets/stylesheets/sufia/_modal.scss +4 -0
- data/app/assets/stylesheets/sufia/_settings.scss +4 -3
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/controllers/admin/stats_controller.rb +68 -0
- data/app/controllers/api/items_controller.rb +78 -0
- data/app/controllers/api/zotero_controller.rb +70 -0
- data/app/controllers/authorities_controller.rb +6 -5
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +2 -1
- data/app/controllers/concerns/sufia/breadcrumbs.rb +1 -1
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +11 -0
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +23 -11
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +1 -7
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +1 -2
- data/app/controllers/my/collections_controller.rb +1 -0
- data/app/controllers/my/files_controller.rb +1 -1
- data/app/helpers/sufia/sufia_helper_behavior.rb +28 -16
- data/app/models/my_search_builder.rb +4 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +20 -0
- data/app/search_builders/sufia/search_builder.rb +1 -1
- data/app/views/admin/stats/index.html.erb +68 -0
- data/app/views/collections/_action_menu.html.erb +22 -20
- data/app/views/collections/_collection.html.erb +1 -1
- data/app/views/collections/_form_for_select_collection.html.erb +5 -3
- data/app/views/generic_files/_show_actions.html.erb +4 -2
- data/app/views/generic_files/show.html.erb +1 -1
- data/app/views/layouts/sufia-dashboard.html.erb +5 -4
- data/app/views/layouts/sufia-one-column.html.erb +2 -0
- data/app/views/layouts/sufia-two-column.html.erb +6 -4
- data/app/views/my/_facet_layout.html.erb +2 -2
- data/app/views/my/_facets.html.erb +4 -6
- data/app/views/my/index.html.erb +4 -3
- data/app/views/users/_edit_primary.html.erb +18 -17
- data/app/views/users/_follower_modal.html.erb +5 -1
- data/app/views/users/_following_modal.html.erb +5 -1
- data/app/views/users/_user_info.html.erb +6 -1
- data/app/views/users/_zotero.html.erb +12 -0
- data/config/locales/sufia.en.yml +10 -1
- data/config/routes.rb +23 -1
- data/lib/generators/sufia/admin_stat_generator.rb +17 -0
- data/lib/generators/sufia/install_generator.rb +8 -3
- data/{sufia-models/lib/generators/sufia/models/templates/config/resque_admin.rb → lib/generators/sufia/templates/sufia/stats_admin.rb} +3 -3
- data/lib/generators/sufia/upgrade400_generator.rb +2 -2
- data/lib/sufia.rb +3 -0
- data/lib/sufia/arkivo.rb +11 -0
- data/lib/sufia/arkivo/actor.rb +95 -0
- data/lib/sufia/arkivo/config.rb +11 -0
- data/lib/sufia/arkivo/create_subscription_job.rb +67 -0
- data/lib/sufia/arkivo/metadata_munger.rb +51 -0
- data/lib/sufia/arkivo/schema_validator.rb +55 -0
- data/lib/sufia/form_builder.rb +1 -1
- data/lib/sufia/inflections.rb +3 -0
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero.rb +6 -0
- data/lib/sufia/zotero/config.rb +15 -0
- data/solr_conf/conf/solrconfig.xml +11 -0
- data/spec/controllers/admin_stats_controller_spec.rb +73 -0
- data/spec/controllers/api/items_controller_spec.rb +476 -0
- data/spec/controllers/api/zotero_controller_spec.rb +178 -0
- data/spec/controllers/batch_edits_controller_spec.rb +7 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/dashboard_controller_spec.rb +1 -1
- data/spec/controllers/depositors_controller_spec.rb +9 -5
- data/spec/controllers/generic_files_controller_spec.rb +5 -4
- data/spec/controllers/mailbox_controller_spec.rb +2 -2
- data/spec/controllers/my/collections_controller_spec.rb +1 -2
- data/spec/controllers/my/files_controller_spec.rb +5 -5
- data/spec/controllers/my/shares_controller_spec.rb +15 -3
- data/spec/controllers/pages_controller_spec.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +10 -9
- data/spec/factories/api_items.rb +91 -0
- data/spec/factories/generic_files.rb +4 -0
- data/spec/factories/users.rb +4 -4
- data/spec/features/featured_item_spec.rb +26 -0
- data/spec/features/ingest_upload_files_spec.rb +2 -3
- data/spec/features/proxy_spec.rb +0 -1
- data/spec/helpers/permissions_helper_spec.rb +2 -2
- data/spec/helpers/sufia_helper_spec.rb +11 -5
- data/spec/inputs/select_with_help_input_spec.rb +2 -2
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +832 -0
- data/spec/javascripts/jasmine_spec.rb +31 -0
- data/spec/javascripts/notify_update_link_spec.js +8 -0
- data/spec/javascripts/single_use_link_spec.js.coffee +23 -0
- data/spec/javascripts/support/jasmine.yml +124 -0
- data/spec/javascripts/support/jasmine_helper.rb +15 -0
- data/spec/javascripts/terms_of_service_spec.js.coffee +32 -0
- data/spec/javascripts/toggle_icon_spec.js +11 -0
- data/spec/jobs/active_fedora_id_based_job_spec.rb +3 -3
- data/spec/jobs/import_url_job_spec.rb +0 -2
- data/spec/lib/sufia/arkivo/actor_spec.rb +139 -0
- data/spec/lib/sufia/arkivo/create_subscription_job_spec.rb +54 -0
- data/spec/lib/sufia/arkivo/metadata_munger_spec.rb +48 -0
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +65 -0
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +1 -1
- data/spec/lib/sufia/user_stat_importer_spec.rb +60 -0
- data/spec/lib/sufia/zotero/config_spec.rb +30 -0
- data/spec/models/collection_spec.rb +36 -7
- data/spec/models/file_download_stat_spec.rb +5 -5
- data/spec/models/file_usage_spec.rb +23 -0
- data/spec/models/file_view_stat_spec.rb +6 -6
- data/spec/models/fits_datastream_spec.rb +0 -5
- data/spec/models/generic_file_spec.rb +49 -14
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/proxy_deposit_request_spec.rb +1 -1
- data/spec/models/trophy_spec.rb +8 -8
- data/spec/models/user_spec.rb +33 -0
- data/spec/presenters/sufia/collection_presenter_spec.rb +1 -1
- data/spec/routing/api_route_spec.rb +91 -0
- data/spec/routing/route_spec.rb +1 -1
- data/spec/services/generic_file_audit_service_spec.rb +44 -8
- data/spec/spec_helper.rb +18 -3
- data/spec/support/features.rb +0 -2
- data/spec/support/locations.rb +0 -21
- data/spec/support/rake.rb +41 -0
- data/spec/support/selectors.rb +0 -50
- data/spec/tasks/rake_spec.rb +33 -12
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -0
- data/spec/views/admin/stats/index.html.erb_spec.rb +45 -0
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/dashboard/index_spec.rb +1 -1
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +1 -3
- data/spec/views/users/_follower_modal.html.erb_spec.rb +44 -7
- data/spec/views/users/_following_modal.html.erb_spec.rb +49 -7
- data/spec/views/users/edit.html.erb_spec.rb +72 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia.gemspec +6 -2
- data/tasks/sufia-user.rake +14 -0
- metadata +130 -156
- data/spec/lib/sufia/id_service_spec.rb +0 -32
- data/spec/services/noid_spec.rb +0 -9
- data/spec/support/poltergeist.rb +0 -11
- data/spec/support/rake_output.rb +0 -20
- data/sufia-models/.gitignore +0 -17
- data/sufia-models/Gemfile +0 -4
- data/sufia-models/LICENSE.md +0 -177
- data/sufia-models/README.md +0 -39
- data/sufia-models/Rakefile +0 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +0 -137
- data/sufia-models/app/jobs/active_fedora_id_based_job.rb +0 -22
- data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +0 -7
- data/sufia-models/app/jobs/audit_job.rb +0 -62
- data/sufia-models/app/jobs/batch_update_job.rb +0 -72
- data/sufia-models/app/jobs/characterize_job.rb +0 -10
- data/sufia-models/app/jobs/create_derivatives_job.rb +0 -14
- data/sufia-models/app/jobs/import_url_job.rb +0 -52
- data/sufia-models/app/jobs/ingest_local_file_job.rb +0 -46
- data/sufia-models/app/jobs/resolrize_job.rb +0 -9
- data/sufia-models/app/models/batch.rb +0 -36
- data/sufia-models/app/models/checksum_audit_log.rb +0 -21
- data/sufia-models/app/models/concerns/sufia/ability.rb +0 -61
- data/sufia-models/app/models/concerns/sufia/collection_behavior.rb +0 -24
- data/sufia-models/app/models/concerns/sufia/file_stat_utils.rb +0 -35
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -25
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +0 -28
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +0 -89
- data/sufia-models/app/models/concerns/sufia/generic_file/content.rb +0 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +0 -26
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +0 -343
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +0 -43
- data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +0 -98
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +0 -69
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +0 -31
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +0 -16
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +0 -37
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +0 -20
- data/sufia-models/app/models/concerns/sufia/user.rb +0 -137
- data/sufia-models/app/models/concerns/sufia/user_usage_stats.rb +0 -15
- data/sufia-models/app/models/datastreams/file_content_datastream.rb +0 -4
- data/sufia-models/app/models/datastreams/fits_datastream.rb +0 -152
- data/sufia-models/app/models/domain_term.rb +0 -5
- data/sufia-models/app/models/featured_work.rb +0 -22
- data/sufia-models/app/models/file_download_stat.rb +0 -18
- data/sufia-models/app/models/file_usage.rb +0 -34
- data/sufia-models/app/models/file_view_stat.rb +0 -18
- data/sufia-models/app/models/follow.rb +0 -12
- data/sufia-models/app/models/generic_file.rb +0 -3
- data/sufia-models/app/models/geo_names_resource.rb +0 -18
- data/sufia-models/app/models/group.rb +0 -8
- data/sufia-models/app/models/local_authority.rb +0 -86
- data/sufia-models/app/models/local_authority_entry.rb +0 -3
- data/sufia-models/app/models/proxy_deposit_request.rb +0 -85
- data/sufia-models/app/models/proxy_deposit_rights.rb +0 -4
- data/sufia-models/app/models/single_use_link.rb +0 -42
- data/sufia-models/app/models/subject_local_authority_entry.rb +0 -2
- data/sufia-models/app/models/sufia/avatar_uploader.rb +0 -20
- data/sufia-models/app/models/sufia/avatar_validator.rb +0 -8
- data/sufia-models/app/models/sufia/collection.rb +0 -5
- data/sufia-models/app/models/sufia/download.rb +0 -9
- data/sufia-models/app/models/sufia/orcid_validator.rb +0 -12
- data/sufia-models/app/models/sufia/pageview.rb +0 -9
- data/sufia-models/app/models/trophy.rb +0 -10
- data/sufia-models/app/models/user_stat.rb +0 -2
- data/sufia-models/app/models/version_committer.rb +0 -2
- data/sufia-models/app/services/sufia/analytics.rb +0 -50
- data/sufia-models/app/services/sufia/generic_file_audit_service.rb +0 -83
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +0 -12
- data/sufia-models/app/services/sufia/id_service.rb +0 -45
- data/sufia-models/app/services/sufia/noid.rb +0 -22
- data/sufia-models/app/services/sufia/repository_audit_service.rb +0 -9
- data/sufia-models/config/locales/sufia.en.yml +0 -6
- data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +0 -30
- data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +0 -106
- data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +0 -2
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/clamav.rb +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/mailboxer.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/config/redis.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/redis_config.rb +0 -32
- data/sufia-models/lib/generators/sufia/models/templates/config/resque-pool.yml +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +0 -3
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +0 -223
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +0 -144
- data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_ldap_attrs_to_user.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_social_to_users.rb +0 -13
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_audit_log_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_proxy_deposit_request_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_download_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_view_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +0 -50
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +0 -16
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_single_use_links.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +0 -8
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_trophies.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_user_stats.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_version_committers.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +0 -18
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +0 -54
- data/sufia-models/lib/generators/sufia/models/upgrade600_generator.rb +0 -21
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +0 -31
- data/sufia-models/lib/sufia/messages.rb +0 -66
- data/sufia-models/lib/sufia/models.rb +0 -34
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -43
- data/sufia-models/lib/sufia/models/active_record/redis.rb +0 -56
- data/sufia-models/lib/sufia/models/engine.rb +0 -79
- data/sufia-models/lib/sufia/models/file_content.rb +0 -6
- data/sufia-models/lib/sufia/models/file_content/versions.rb +0 -21
- data/sufia-models/lib/sufia/models/resque.rb +0 -36
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +0 -108
- data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +0 -29
- data/sufia-models/lib/sufia/models/utils.rb +0 -22
- data/sufia-models/lib/sufia/models/version.rb +0 -5
- data/sufia-models/lib/sufia/models/virus_found_error.rb +0 -4
- data/sufia-models/lib/sufia/permissions.rb +0 -9
- data/sufia-models/lib/sufia/permissions/readable.rb +0 -20
- data/sufia-models/lib/sufia/permissions/writable.rb +0 -74
- data/sufia-models/lib/tasks/batch_cleanup.rake +0 -19
- data/sufia-models/lib/tasks/migrate.rake +0 -21
- data/sufia-models/lib/tasks/resque.rake +0 -13
- data/sufia-models/lib/tasks/stats_tasks.rake +0 -12
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +0 -80
- data/sufia-models/sufia-models.gemspec +0 -52
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
class SingleUseLink < ActiveRecord::Base
|
|
2
|
-
|
|
3
|
-
validate :expiration_date_cannot_be_in_the_past
|
|
4
|
-
validate :cannot_be_destroyed
|
|
5
|
-
|
|
6
|
-
after_initialize :set_defaults
|
|
7
|
-
|
|
8
|
-
def create_for_path path
|
|
9
|
-
self.class.create itemId: itemId, path: path
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def expired?
|
|
13
|
-
DateTime.now > expires
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def to_param
|
|
18
|
-
downloadKey
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
protected
|
|
22
|
-
|
|
23
|
-
def expiration_date_cannot_be_in_the_past
|
|
24
|
-
if expired?
|
|
25
|
-
errors.add(:expires, "can't be in the past")
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def cannot_be_destroyed
|
|
30
|
-
if destroyed?
|
|
31
|
-
errors[:base] << "Single Use Link has already been used"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def set_defaults
|
|
36
|
-
if new_record?
|
|
37
|
-
self.expires ||= DateTime.now.advance(hours:24)
|
|
38
|
-
self.downloadKey ||= (Digest::SHA2.new << rand(1000000000).to_s).to_s
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
class Sufia::AvatarUploader < CarrierWave::Uploader::Base
|
|
2
|
-
include CarrierWave::MiniMagick
|
|
3
|
-
include CarrierWave::Compatibility::Paperclip
|
|
4
|
-
|
|
5
|
-
version :medium do
|
|
6
|
-
process resize_to_limit: [300, 300]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
version :thumb do
|
|
10
|
-
process resize_to_limit: [100, 100]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def default_url
|
|
14
|
-
"missing_#{version_name}.png"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def extension_white_list
|
|
18
|
-
%w(jpg jpeg png gif bmp tif tiff)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Sufia
|
|
2
|
-
class OrcidValidator < ActiveModel::Validator
|
|
3
|
-
def validate(record)
|
|
4
|
-
return if record.orcid.blank?
|
|
5
|
-
record.errors.add(:orcid, 'must be a string of 19 characters, e.g., "0000-0000-0000-0000"') unless self.class.match(record.orcid)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.match(string)
|
|
9
|
-
/\d{4}-\d{4}-\d{4}-\d{3}[\dX]/.match(string)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'google/api_client'
|
|
2
|
-
require 'oauth2'
|
|
3
|
-
require 'legato'
|
|
4
|
-
|
|
5
|
-
module Sufia
|
|
6
|
-
module Analytics
|
|
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
|
-
# Generate an OAuth2 token for Google Analytics
|
|
20
|
-
# @return [OAuth2::AccessToken] An OAuth2 access token for GA
|
|
21
|
-
def self.token
|
|
22
|
-
scope = 'https://www.googleapis.com/auth/analytics.readonly'
|
|
23
|
-
client = Google::APIClient.new(application_name: self.config['app_name'],
|
|
24
|
-
application_version: self.config['app_version'])
|
|
25
|
-
key = Google::APIClient::PKCS12.load_key(self.config['privkey_path'],
|
|
26
|
-
self.config['privkey_secret'])
|
|
27
|
-
service_account = Google::APIClient::JWTAsserter.new(self.config['client_email'], scope,
|
|
28
|
-
key)
|
|
29
|
-
client.authorization = service_account.authorize
|
|
30
|
-
oauth_client = OAuth2::Client.new('', '', {
|
|
31
|
-
authorize_url: 'https://accounts.google.com/o/oauth2/auth',
|
|
32
|
-
token_url: 'https://accounts.google.com/o/oauth2/token'})
|
|
33
|
-
OAuth2::AccessToken.new(oauth_client, client.authorization.access_token)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Return a user object linked to a Google Analytics account
|
|
37
|
-
# @return [Legato::User] A user account wit GA access
|
|
38
|
-
def self.user
|
|
39
|
-
Legato::User.new(self.token)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Return a Google Analytics profile matching specified ID
|
|
43
|
-
# @ return [Legato::Management::Profile] A user profile associated with GA
|
|
44
|
-
def self.profile
|
|
45
|
-
self.user.profiles.detect do |profile|
|
|
46
|
-
profile.web_property_id == Sufia.config.google_analytics_id
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
module Sufia
|
|
2
|
-
class GenericFileAuditService
|
|
3
|
-
attr_reader :generic_file
|
|
4
|
-
def initialize(file)
|
|
5
|
-
@generic_file = file
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
NO_RUNS = 999
|
|
9
|
-
|
|
10
|
-
# provides a human readable version of the audit status
|
|
11
|
-
def human_readable_audit_status
|
|
12
|
-
stat = audit_stat
|
|
13
|
-
case stat
|
|
14
|
-
when 0
|
|
15
|
-
'failing'
|
|
16
|
-
when 1
|
|
17
|
-
'passing'
|
|
18
|
-
else
|
|
19
|
-
stat
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# TODO: Run audits on all attached files. We're only auditing "content" at tht moment
|
|
24
|
-
# Pushes an AuditJob for each version of content if it hasn't been audited recently
|
|
25
|
-
# Returns the set of most recent audit status for each version of the content file
|
|
26
|
-
def audit
|
|
27
|
-
audit_content([])
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
def audit_content(log)
|
|
33
|
-
if generic_file.content.has_versions?
|
|
34
|
-
audit_file_versions("content", log)
|
|
35
|
-
else
|
|
36
|
-
log << audit_file("content", generic_file.content.uri)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def audit_file_versions file, log
|
|
41
|
-
generic_file.attached_files[file].versions.all.each do |version|
|
|
42
|
-
log << audit_file(file, version.uri, version.label)
|
|
43
|
-
end
|
|
44
|
-
log
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def audit_stat
|
|
48
|
-
audit_results = audit.collect { |result| result["pass"] }
|
|
49
|
-
|
|
50
|
-
# check how many non runs we had
|
|
51
|
-
non_runs = audit_results.reduce(0) { |sum, value| value == NO_RUNS ? sum += 1 : sum }
|
|
52
|
-
if non_runs == 0
|
|
53
|
-
audit_results.reduce(true) { |sum, value| sum && value }
|
|
54
|
-
elsif non_runs < audit_results.length
|
|
55
|
-
result = audit_results.reduce(true) { |sum, value| value == NO_RUNS ? sum : sum && value }
|
|
56
|
-
"Some audits have not been run, but the ones run were #{result ? 'passing' : 'failing'}."
|
|
57
|
-
else
|
|
58
|
-
'Audits have not yet been run on this file.'
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def audit_file(file, uri, label = nil)
|
|
63
|
-
latest_audit = ChecksumAuditLog.logs_for(generic_file.id, file).first
|
|
64
|
-
return latest_audit unless needs_audit?(latest_audit)
|
|
65
|
-
Sufia.queue.push(AuditJob.new(generic_file.id, file, uri))
|
|
66
|
-
latest_audit || ChecksumAuditLog.new(pass: NO_RUNS, generic_file_id: generic_file.id, dsid: file, version: label)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def needs_audit?(latest_audit)
|
|
70
|
-
return true unless latest_audit
|
|
71
|
-
unless latest_audit.updated_at
|
|
72
|
-
logger.warn "***AUDIT*** problem with audit log! Latest Audit is not nil, but updated_at is not set #{latest_audit}"
|
|
73
|
-
return true
|
|
74
|
-
end
|
|
75
|
-
days_since_last_audit(latest_audit) >= Sufia.config.max_days_between_audits
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def days_since_last_audit(latest_audit)
|
|
79
|
-
(DateTime.now - latest_audit.updated_at.to_date).to_i
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Sufia
|
|
2
|
-
class GenericFileIndexingService < ActiveFedora::IndexingService
|
|
3
|
-
def generate_solr_document
|
|
4
|
-
super.tap do |solr_doc|
|
|
5
|
-
solr_doc[Solrizer.solr_name('label')] = object.label
|
|
6
|
-
solr_doc[Solrizer.solr_name('file_format')] = object.file_format
|
|
7
|
-
solr_doc[Solrizer.solr_name('file_format', :facetable)] = object.file_format
|
|
8
|
-
solr_doc['all_text_timv'] = object.full_text.content
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'noid'
|
|
2
|
-
|
|
3
|
-
module Sufia
|
|
4
|
-
module IdService
|
|
5
|
-
|
|
6
|
-
def self.noid_template
|
|
7
|
-
Sufia.config.noid_template
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
@minter = ::Noid::Minter.new(template: noid_template)
|
|
11
|
-
@semaphore = Mutex.new
|
|
12
|
-
def self.valid?(identifier)
|
|
13
|
-
# remove the fedora namespace since it's not part of the noid
|
|
14
|
-
noid = identifier#.split(":").last
|
|
15
|
-
@minter.valid? noid
|
|
16
|
-
end
|
|
17
|
-
def self.mint
|
|
18
|
-
@semaphore.synchronize do
|
|
19
|
-
while true
|
|
20
|
-
id = self.next_id
|
|
21
|
-
return id unless ActiveFedora::Base.exists?(id)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
protected
|
|
27
|
-
|
|
28
|
-
def self.next_id
|
|
29
|
-
id = ''
|
|
30
|
-
File.open(Sufia.config.minter_statefile, File::RDWR|File::CREAT, 0644) do |f|
|
|
31
|
-
f.flock(File::LOCK_EX)
|
|
32
|
-
yaml = YAML::load(f.read)
|
|
33
|
-
yaml = {template: noid_template} unless yaml
|
|
34
|
-
minter = ::Noid::Minter.new(yaml)
|
|
35
|
-
id = minter.mint
|
|
36
|
-
f.rewind
|
|
37
|
-
yaml = YAML::dump(minter.dump)
|
|
38
|
-
f.write yaml
|
|
39
|
-
f.flush
|
|
40
|
-
f.truncate(f.pos)
|
|
41
|
-
end
|
|
42
|
-
id
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Sufia
|
|
2
|
-
module Noid
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
## This overrides the default behavior, which is to ask Fedora for an id
|
|
6
|
-
# @see ActiveFedora::Persistence.assign_id
|
|
7
|
-
def assign_id
|
|
8
|
-
Sufia::IdService.mint if Sufia.config.enable_noids
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def to_param
|
|
12
|
-
id
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class << self
|
|
16
|
-
# Create a pairtree like path for the given identifier
|
|
17
|
-
def treeify(identifier)
|
|
18
|
-
(identifier.scan(/..?/).first(4) + [identifier]).join('/')
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
require 'rails/generators'
|
|
3
|
-
require 'rails/generators/migration'
|
|
4
|
-
|
|
5
|
-
class Sufia::Models::AbstractMigrationGenerator < Rails::Generators::Base
|
|
6
|
-
include Rails::Generators::Migration
|
|
7
|
-
|
|
8
|
-
# Implement the required interface for Rails::Generators::Migration.
|
|
9
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
|
10
|
-
def self.next_migration_number(path)
|
|
11
|
-
if @prev_migration_nr
|
|
12
|
-
@prev_migration_nr += 1
|
|
13
|
-
else
|
|
14
|
-
if last_migration = Dir[File.join(path, '*.rb')].sort.last
|
|
15
|
-
@prev_migration_nr = last_migration.sub(File.join(path, '/'), '').to_i + 1
|
|
16
|
-
else
|
|
17
|
-
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
@prev_migration_nr.to_s
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
protected
|
|
24
|
-
|
|
25
|
-
def better_migration_template(file)
|
|
26
|
-
migration_template "migrations/#{file}", "db/migrate/#{file}"
|
|
27
|
-
rescue Rails::Generators::Error => e
|
|
28
|
-
say_status("warning", e.message, :yellow)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require_relative 'abstract_migration_generator'
|
|
2
|
-
|
|
3
|
-
class Sufia::Models::CachedStatsGenerator < Sufia::Models::AbstractMigrationGenerator
|
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
-
|
|
6
|
-
desc """
|
|
7
|
-
This generator adds the ability to cache usage stats to your application:
|
|
8
|
-
1. Creates several database migrations if they do not exist in /db/migrate
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
def banner
|
|
12
|
-
say_status("warning", "ADDING STATS CACHING-RELATED SUFIA MODELS", :yellow)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Setup the database migrations
|
|
16
|
-
def copy_migrations
|
|
17
|
-
[
|
|
18
|
-
'create_file_view_stats.rb',
|
|
19
|
-
'create_file_download_stats.rb'
|
|
20
|
-
].each do |file|
|
|
21
|
-
better_migration_template file
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
require 'rails/generators'
|
|
3
|
-
|
|
4
|
-
class Sufia::Models::FulltextGenerator < 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. Copies solrconfig.xml into solr_conf/conf/
|
|
10
|
-
2. Reconfigures jetty
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def banner
|
|
14
|
-
say_status("warning", "GENERATING SUFIA FULL-TEXT", :yellow)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Copy Sufia's solrconfig into the dir from which the jetty:config task pulls
|
|
18
|
-
# Sufia's solrconfig includes full-text extraction
|
|
19
|
-
def copy_solr_config
|
|
20
|
-
copy_file 'config/solrconfig.xml', 'solr_conf/conf/solrconfig.xml', force: true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Copy config, schema, and jars into jetty dir if it exists
|
|
24
|
-
def reconfigure_jetty
|
|
25
|
-
rake "sufia:jetty:config" if File.directory?('jetty')
|
|
26
|
-
end
|
|
27
|
-
end
|