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
data/config/locales/sufia.en.yml
CHANGED
|
@@ -133,9 +133,16 @@ en:
|
|
|
133
133
|
user_profile:
|
|
134
134
|
no_followers: "No one is following you."
|
|
135
135
|
no_following: "You are not following anyone."
|
|
136
|
+
no_followers_other: "No one is following this user."
|
|
137
|
+
no_following_other: "This user is not following anyone."
|
|
136
138
|
orcid:
|
|
137
139
|
alt: "ORCID icon"
|
|
138
140
|
label: "ORCID Profile"
|
|
141
|
+
zotero:
|
|
142
|
+
alt: "Zotero icon"
|
|
143
|
+
label: "Zotero Profile"
|
|
144
|
+
connected: "Connected!"
|
|
145
|
+
unlinked: "Link with Zotero"
|
|
139
146
|
batch:
|
|
140
147
|
help:
|
|
141
148
|
title: "Filename will be the default title. Please provide a more meaningful title, and filenames will still be preserved by the system."
|
|
@@ -162,6 +169,9 @@ en:
|
|
|
162
169
|
browse_view: "Browse View"
|
|
163
170
|
footer:
|
|
164
171
|
copyright_html: "<strong>Copyright © 2015 Project Hydra</strong> Licensed under the Apache License, Version 2.0"
|
|
172
|
+
admin:
|
|
173
|
+
stats:
|
|
174
|
+
registered: "Registered"
|
|
165
175
|
|
|
166
176
|
simple_form:
|
|
167
177
|
labels:
|
|
@@ -204,4 +214,3 @@ en:
|
|
|
204
214
|
description: "Usage information for abstract or summary"
|
|
205
215
|
tag: "Usage information for keyword"
|
|
206
216
|
rights: "Usage information for rights"
|
|
207
|
-
|
data/config/routes.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Sufia::Engine.routes.draw do
|
|
2
|
-
|
|
3
2
|
# Downloads controller route
|
|
4
3
|
resources :homepage, only: 'index'
|
|
5
4
|
|
|
@@ -105,6 +104,21 @@ Sufia::Engine.routes.draw do
|
|
|
105
104
|
post 'contact' => 'contact_form#create', as: :contact_form_index
|
|
106
105
|
get 'contact' => 'contact_form#new'
|
|
107
106
|
|
|
107
|
+
# API routes
|
|
108
|
+
if Sufia.config.arkivo_api
|
|
109
|
+
namespace :api do
|
|
110
|
+
if defined?(Sufia::ArkivoConstraint)
|
|
111
|
+
constraints Sufia::ArkivoConstraint do
|
|
112
|
+
resources :items, except: [:index, :edit, :new], defaults: { format: :json }
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
get 'zotero' => 'zotero#initiate', as: :zotero_initiate
|
|
117
|
+
get 'zotero/callback' => 'zotero#callback', as: :zotero_callback
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Collections routes
|
|
108
122
|
mount Hydra::Collections::Engine => '/'
|
|
109
123
|
|
|
110
124
|
# Resque monitoring routes. Don't bother with this route unless Sufia::ResqueAdmin
|
|
@@ -117,6 +131,14 @@ Sufia::Engine.routes.draw do
|
|
|
117
131
|
end
|
|
118
132
|
end
|
|
119
133
|
|
|
134
|
+
if defined?(Sufia::StatsAdmin)
|
|
135
|
+
namespace :admin do
|
|
136
|
+
constraints Sufia::StatsAdmin do
|
|
137
|
+
get 'stats' => 'stats#index', as: :stats
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
120
142
|
resources :content_blocks, only: ['create', 'update']
|
|
121
143
|
get 'featured_researchers' => 'content_blocks#index', as: :featured_researchers
|
|
122
144
|
post '/tinymce_assets' => 'tinymce_assets#create'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
require 'rails/generators'
|
|
3
|
+
|
|
4
|
+
class Sufia::AdminStatGenerator < Rails::Generators::Base
|
|
5
|
+
|
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
7
|
+
|
|
8
|
+
desc """
|
|
9
|
+
This is a generator for adding Admin Stats into sufia
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def insert_stats_admin
|
|
13
|
+
copy_file 'sufia/stats_admin.rb', 'config/initializers/stats_admin.rb'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
@@ -19,13 +19,15 @@ module Sufia
|
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
def run_required_generators
|
|
22
|
+
say_status("info", "GENERATING BLACKLIGHT", :blue)
|
|
22
23
|
generate "blacklight:install --devise"
|
|
24
|
+
say_status("info", "GENERATING HYDRA", :blue)
|
|
23
25
|
generate "hydra:head -f"
|
|
24
26
|
generate "sufia:models:install"
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def banner
|
|
28
|
-
say_status("
|
|
30
|
+
say_status("info", "GENERATING SUFIA", :blue)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def insert_abilities
|
|
@@ -40,7 +42,7 @@ module Sufia
|
|
|
40
42
|
file_path = "app/controllers/application_controller.rb"
|
|
41
43
|
if File.exists?(file_path)
|
|
42
44
|
insert_into_file file_path, after: 'include Blacklight::Controller' do
|
|
43
|
-
" \n# Adds Sufia behaviors into the application controller \n" +
|
|
45
|
+
" \n# Adds Sufia behaviors into the application controller (#{controller_name}) \n" +
|
|
44
46
|
" include Sufia::Controller\n"
|
|
45
47
|
end
|
|
46
48
|
gsub_file file_path, "layout 'blacklight'", "layout 'sufia-one-column'"
|
|
@@ -70,7 +72,6 @@ module Sufia
|
|
|
70
72
|
'//= require_tree .', '//= require sufia'
|
|
71
73
|
end
|
|
72
74
|
|
|
73
|
-
|
|
74
75
|
def tinymce_config
|
|
75
76
|
copy_file "config/tinymce.yml", "config/tinymce.yml"
|
|
76
77
|
end
|
|
@@ -109,5 +110,9 @@ module Sufia
|
|
|
109
110
|
generate "blacklight_gallery:install"
|
|
110
111
|
end
|
|
111
112
|
|
|
113
|
+
def install_admin_stats
|
|
114
|
+
generate "sufia:admin_stat"
|
|
115
|
+
end
|
|
116
|
+
|
|
112
117
|
end
|
|
113
118
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
1
2
|
module Sufia
|
|
2
|
-
class
|
|
3
|
+
class StatsAdmin
|
|
3
4
|
def self.matches?(request)
|
|
4
5
|
current_user = request.env['warden'].user
|
|
5
6
|
return false if current_user.blank?
|
|
6
|
-
|
|
7
|
-
#current_user.groups.include? 'umg/up.dlt.scholarsphere-admin'
|
|
7
|
+
current_user.groups.include? 'admin'
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -21,7 +21,7 @@ This generator for upgrading sufia from 3.7.2 to 4.0 makes the following changes
|
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
23
|
def banner
|
|
24
|
-
say_status("
|
|
24
|
+
say_status("info", "UPGRADING SUFIA", :blue)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# The engine routes have to come after the devise routes so that /users/sign_in will work
|
|
@@ -42,7 +42,7 @@ This generator for upgrading sufia from 3.7.2 to 4.0 makes the following changes
|
|
|
42
42
|
file_path = "app/controllers/catalog_controller.rb"
|
|
43
43
|
if File.exists?(file_path)
|
|
44
44
|
insert_into_file file_path, after: 'include Hydra::Controller::ControllerBehavior' do
|
|
45
|
-
"\n # Adds Sufia behaviors to the catalog controller\n" +
|
|
45
|
+
"\n # Adds Sufia behaviors to the catalog controller (#{controller_name})\n" +
|
|
46
46
|
" include Sufia::Catalog\n"
|
|
47
47
|
end
|
|
48
48
|
else
|
data/lib/sufia.rb
CHANGED
data/lib/sufia/arkivo.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'sufia/arkivo/config'
|
|
2
|
+
require 'sufia/arkivo/schema_validator'
|
|
3
|
+
require 'sufia/arkivo/metadata_munger'
|
|
4
|
+
require 'sufia/arkivo/actor'
|
|
5
|
+
require 'sufia/arkivo/create_subscription_job'
|
|
6
|
+
|
|
7
|
+
module Sufia
|
|
8
|
+
module Arkivo
|
|
9
|
+
VERSION = Sufia::VERSION
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
require 'base64'
|
|
2
|
+
require 'tempfile'
|
|
3
|
+
|
|
4
|
+
# Ugly monkeypatch to make Tempfiles quack like UploadedFiles
|
|
5
|
+
Tempfile.class_eval do
|
|
6
|
+
attr_accessor :original_filename, :content_type
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
module Sufia
|
|
10
|
+
module Arkivo
|
|
11
|
+
class Actor
|
|
12
|
+
attr_reader :user, :item
|
|
13
|
+
|
|
14
|
+
def initialize(user, item)
|
|
15
|
+
@user = user
|
|
16
|
+
@item = item
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create_file_from_item
|
|
20
|
+
batch = Batch.create
|
|
21
|
+
file_actor = Sufia::GenericFile::Actor.new(::GenericFile.new, user)
|
|
22
|
+
file_actor.create_metadata(batch.id)
|
|
23
|
+
store_checksum(file_actor.generic_file)
|
|
24
|
+
file_actor.create_content(file, item['file']['filename'], file_path, item['file']['contentType'])
|
|
25
|
+
BatchUpdateJob.new(user.user_key, batch.id, item['metadata']['title'], attributes, default_visibility).run
|
|
26
|
+
file_actor.generic_file
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def update_file_from_item(gf)
|
|
30
|
+
file_actor = Sufia::GenericFile::Actor.new(gf, user)
|
|
31
|
+
reset_metadata(file_actor)
|
|
32
|
+
file_actor.update_metadata(attributes, default_visibility)
|
|
33
|
+
store_checksum(file_actor.generic_file)
|
|
34
|
+
file_actor.update_content(file, file_path)
|
|
35
|
+
file_actor.generic_file
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def destroy_file(gf)
|
|
39
|
+
gf.destroy
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def reset_metadata(actor)
|
|
45
|
+
actor.generic_file.tap do |gf|
|
|
46
|
+
gf.resource_type = []
|
|
47
|
+
gf.title = []
|
|
48
|
+
gf.rights = []
|
|
49
|
+
gf.tag = []
|
|
50
|
+
gf.creator = []
|
|
51
|
+
gf.description = []
|
|
52
|
+
gf.publisher = []
|
|
53
|
+
gf.date_created = []
|
|
54
|
+
gf.based_near = []
|
|
55
|
+
gf.identifier = []
|
|
56
|
+
gf.related_url = []
|
|
57
|
+
gf.language = []
|
|
58
|
+
gf.contributor = []
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def store_checksum(gf)
|
|
63
|
+
gf.arkivo_checksum = item['file']['md5']
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def default_visibility
|
|
67
|
+
'open'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def attributes
|
|
71
|
+
Sufia::Arkivo::MetadataMunger.new(item['metadata']).call
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def file_path
|
|
75
|
+
'content'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def file
|
|
79
|
+
extract_file_from_item
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def extract_file_from_item
|
|
83
|
+
encoded = item['file']['base64']
|
|
84
|
+
content = Base64.decode64(encoded)
|
|
85
|
+
tmp = Tempfile.new(item['file']['md5'], { encoding: Encoding::UTF_8 })
|
|
86
|
+
tmp.binmode
|
|
87
|
+
tmp.original_filename = item['file']['filename']
|
|
88
|
+
tmp.content_type = item['file']['contentType']
|
|
89
|
+
tmp.write(content)
|
|
90
|
+
tmp.rewind
|
|
91
|
+
tmp
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Sufia
|
|
2
|
+
module Arkivo
|
|
3
|
+
def self.config
|
|
4
|
+
@config ||= YAML.load(ERB.new(IO.read(File.join(Rails.root, 'config', 'arkivo.yml'))).result).with_indifferent_access[Rails.env]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.new_subscription_url
|
|
8
|
+
'/api/subscription'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Sufia
|
|
2
|
+
module Arkivo
|
|
3
|
+
class SubscriptionError < RuntimeError
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class CreateSubscriptionJob
|
|
7
|
+
attr_reader :user
|
|
8
|
+
|
|
9
|
+
def queue_name
|
|
10
|
+
:arkivo_subscription
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def initialize(user_key)
|
|
14
|
+
@user = ::User.find_by_user_key(user_key)
|
|
15
|
+
validate_user!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def run
|
|
19
|
+
# post json to API
|
|
20
|
+
response = post_to_api
|
|
21
|
+
# parse results
|
|
22
|
+
subscription_path = response.headers['Location']
|
|
23
|
+
# create subscription
|
|
24
|
+
user.arkivo_subscription = subscription_path
|
|
25
|
+
user.save
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def logger
|
|
31
|
+
ActiveFedora::Base.logger
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def validate_user!
|
|
35
|
+
log_and_raise('User not found') if user.blank?
|
|
36
|
+
log_and_raise('User does not have an Arkivo token') if user.arkivo_token.blank?
|
|
37
|
+
log_and_raise('User has not yet connected with Zotero') if user.zotero_userid.blank?
|
|
38
|
+
log_and_raise('User already has a subscription') if user.arkivo_subscription.present?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def log_and_raise(message)
|
|
42
|
+
logger.error "*** Arkivo error: #{message}: #{user}"
|
|
43
|
+
raise SubscriptionError.new(message)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def post_to_api
|
|
47
|
+
Faraday.new(url: Sufia::Arkivo.config[:url]).post do |request|
|
|
48
|
+
request.url Sufia::Arkivo.new_subscription_url
|
|
49
|
+
request.headers['Content-Type'] = 'application/json'
|
|
50
|
+
request.body = new_subscription_json
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def new_subscription_json
|
|
55
|
+
{
|
|
56
|
+
url: Sufia::Zotero.publications_url(@user.zotero_userid),
|
|
57
|
+
plugins: [
|
|
58
|
+
{
|
|
59
|
+
name: "sufia",
|
|
60
|
+
options: { token: @user.arkivo_token }
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}.to_json
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Sufia
|
|
2
|
+
module Arkivo
|
|
3
|
+
CREATOR_TYPES = ['author', 'interviewer', 'director', 'scriptwriter',
|
|
4
|
+
'inventor', 'composer', 'cartographer', 'programmer', 'artist',
|
|
5
|
+
'bookAuthor'
|
|
6
|
+
]
|
|
7
|
+
|
|
8
|
+
CONTRIBUTOR_TYPES = ['contributor', 'editor', 'translator', 'seriesEditor',
|
|
9
|
+
'interviewee', 'producer', 'castMember', 'sponsor', 'counsel',
|
|
10
|
+
'attorneyAgent', 'recipient', 'performer', 'wordsBy', 'commenter',
|
|
11
|
+
'presenter', 'guest', 'podcaster', 'reviewedAuthor', 'cosponsor'
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
class MetadataMunger
|
|
15
|
+
def initialize(metadata)
|
|
16
|
+
@metadata = metadata
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def call
|
|
20
|
+
munged = {}
|
|
21
|
+
|
|
22
|
+
# First, normalize camelCase symbols to underscore strings
|
|
23
|
+
@metadata.each do |key, value|
|
|
24
|
+
munged[key.to_s.underscore] = Array(value)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Then, rename the url key to related_url
|
|
28
|
+
munged['related_url'] = munged.delete('url') if munged['url']
|
|
29
|
+
|
|
30
|
+
# Then, rename the tags key to tag
|
|
31
|
+
munged['tag'] = munged.delete('tags') if munged['tags']
|
|
32
|
+
|
|
33
|
+
# Then, normalize creator names
|
|
34
|
+
munged_creators = munged['creators'].each do |entry|
|
|
35
|
+
next if entry['name']
|
|
36
|
+
entry['name'] = "#{entry.delete('lastName')}, #{entry.delete('firstName')}".strip
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Then, parse creators and contributors out
|
|
40
|
+
creator_names = munged_creators.select { |c| Sufia::Arkivo::CREATOR_TYPES.include? c['creatorType'] }.map { |c| c['name'] }
|
|
41
|
+
contributor_names = munged_creators.select { |c| Sufia::Arkivo::CONTRIBUTOR_TYPES.include? c['creatorType'] }.map { |c| c['name'] }
|
|
42
|
+
munged['creator'] = creator_names unless creator_names.blank?
|
|
43
|
+
munged['contributor'] = contributor_names unless contributor_names.blank?
|
|
44
|
+
|
|
45
|
+
# And remove the original creators array
|
|
46
|
+
munged.delete('creators') if munged['creators']
|
|
47
|
+
munged
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'json-schema'
|
|
2
|
+
|
|
3
|
+
module Sufia
|
|
4
|
+
module Arkivo
|
|
5
|
+
ITEM_SCHEMA = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
token: { type: 'string', required: true },
|
|
9
|
+
metadata: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
required: true,
|
|
12
|
+
properties: {
|
|
13
|
+
title: { type: 'string', required: true },
|
|
14
|
+
rights: { type: 'string', required: true },
|
|
15
|
+
resourceType: { type: 'string' },
|
|
16
|
+
description: { type: 'string' },
|
|
17
|
+
publisher: { type: 'string' },
|
|
18
|
+
dateCreated: { type: 'string' },
|
|
19
|
+
basedNear: { type: 'string' },
|
|
20
|
+
identifier: { type: 'string' },
|
|
21
|
+
url: { type: 'string' },
|
|
22
|
+
language: { type: 'string' }
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
file: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
required: true,
|
|
28
|
+
properties: {
|
|
29
|
+
base64: { type: 'string', required: true },
|
|
30
|
+
md5: { type: 'string', required: true },
|
|
31
|
+
filename: { type: 'string', required: true },
|
|
32
|
+
contentType: { type: 'string', required: true }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class InvalidItem < RuntimeError
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class SchemaValidator
|
|
42
|
+
attr_reader :item
|
|
43
|
+
|
|
44
|
+
def initialize(item)
|
|
45
|
+
@item = item
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def call
|
|
49
|
+
JSON::Validator.validate!(Sufia::Arkivo::ITEM_SCHEMA, item, version: :draft3)
|
|
50
|
+
rescue JSON::Schema::ValidationError => exception
|
|
51
|
+
raise Sufia::Arkivo::InvalidItem.new(exception.message)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|