curation_concerns 0.12.0.pre1 → 0.12.0.pre2
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/.rubocop.yml +24 -16
- data/Gemfile +0 -4
- data/README.md +14 -0
- data/RELEASING.md +2 -2
- data/Rakefile +2 -0
- data/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb +28 -0
- data/app/actors/curation_concerns/abstract_actor.rb +28 -0
- data/app/actors/curation_concerns/add_to_collection_actor.rb +38 -0
- data/app/actors/curation_concerns/apply_order_actor.rb +24 -0
- data/app/actors/curation_concerns/assign_identifier_actor.rb +7 -0
- data/app/actors/curation_concerns/assign_representative_actor.rb +18 -0
- data/app/actors/curation_concerns/attach_files_actor.rb +39 -0
- data/app/actors/curation_concerns/base_actor.rb +71 -0
- data/app/actors/curation_concerns/embargo_actor.rb +19 -0
- data/app/actors/curation_concerns/file_actor.rb +79 -0
- data/app/actors/curation_concerns/file_set_actor.rb +146 -0
- data/app/actors/curation_concerns/interpret_visibility_actor.rb +123 -0
- data/app/actors/curation_concerns/lease_actor.rb +19 -0
- data/app/actors/curation_concerns/root_actor.rb +17 -0
- data/app/actors/curation_concerns/work_actor_behavior.rb +8 -0
- data/app/assets/javascripts/curation_concerns/batch_select.js +42 -0
- data/app/assets/javascripts/curation_concerns/collections.js +13 -0
- data/app/assets/javascripts/curation_concerns/curation_concerns.js +2 -0
- data/app/assets/stylesheets/curation_concerns/_curation_concerns.scss +0 -3
- data/app/assets/stylesheets/curation_concerns/_modules.scss +1 -1
- data/app/assets/stylesheets/curation_concerns/_positioning.scss +3 -6
- data/app/assets/stylesheets/curation_concerns/_theme.scss +0 -39
- data/app/assets/stylesheets/curation_concerns/_typography.scss +0 -69
- data/app/assets/stylesheets/curation_concerns/modules/classify_work.scss +0 -2
- data/app/assets/stylesheets/curation_concerns/modules/collections.scss +4 -0
- data/app/assets/stylesheets/curation_concerns/modules/forms.scss +0 -4
- data/app/assets/stylesheets/curation_concerns/modules/site_actions.scss +34 -29
- data/app/assets/stylesheets/curation_concerns/modules/site_search.scss +0 -46
- data/app/assets/stylesheets/curation_concerns.scss +4 -0
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +166 -21
- data/app/controllers/concerns/curation_concerns/embargoes_controller_behavior.rb +1 -1
- data/app/controllers/concerns/curation_concerns/leases_controller_behavior.rb +1 -1
- data/app/controllers/concerns/curation_concerns/selects_collections.rb +65 -0
- data/app/forms/curation_concerns/forms/collection_edit_form.rb +0 -29
- data/app/forms/curation_concerns/forms/work_form.rb +2 -1
- data/app/helpers/batch_select_helper.rb +23 -0
- data/app/helpers/collections_helper.rb +4 -0
- data/app/helpers/curation_concerns/collections_helper.rb +2 -2
- data/app/helpers/curation_concerns/collections_helper_behavior.rb +56 -0
- data/app/helpers/curation_concerns/render_constraints_helper.rb +14 -35
- data/app/helpers/curation_concerns/title_helper.rb +4 -0
- data/app/indexers/curation_concerns/collection_indexer.rb +16 -0
- data/app/indexers/curation_concerns/file_set_indexer.rb +46 -0
- data/app/indexers/curation_concerns/work_indexer.rb +15 -0
- data/app/jobs/audit_job.rb +49 -0
- data/app/jobs/characterize_job.rb +11 -0
- data/app/jobs/create_derivatives_job.rb +21 -0
- data/app/jobs/import_url_job.rb +48 -0
- data/app/jobs/ingest_file_job.rb +30 -0
- data/app/jobs/ingest_local_file_job.rb +20 -0
- data/app/jobs/resolrize_job.rb +7 -0
- data/app/models/checksum_audit_log.rb +20 -0
- data/app/models/collection.rb +6 -0
- data/app/models/concerns/curation_concerns/ability.rb +49 -0
- data/app/models/concerns/curation_concerns/basic_metadata.rb +64 -0
- data/app/models/concerns/curation_concerns/collection.rb +16 -0
- data/app/models/concerns/curation_concerns/collection_behavior.rb +62 -0
- data/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb +47 -0
- data/app/models/concerns/curation_concerns/file_set/derivatives.rb +65 -0
- data/app/models/concerns/curation_concerns/file_set/full_text_indexing.rb +11 -0
- data/app/models/concerns/curation_concerns/file_set/indexing.rb +14 -0
- data/app/models/concerns/curation_concerns/file_set/querying.rb +17 -0
- data/app/models/concerns/curation_concerns/file_set_behavior.rb +36 -0
- data/app/models/concerns/curation_concerns/has_representative.rb +13 -0
- data/app/models/concerns/curation_concerns/human_readable_type.rb +17 -0
- data/app/models/concerns/curation_concerns/naming.rb +17 -0
- data/app/models/concerns/curation_concerns/permissions/readable.rb +18 -0
- data/app/models/concerns/curation_concerns/permissions/writable.rb +34 -0
- data/app/models/concerns/curation_concerns/permissions.rb +7 -0
- data/app/models/concerns/curation_concerns/required_metadata.rb +30 -0
- data/app/models/concerns/curation_concerns/serializers.rb +13 -0
- data/app/models/concerns/curation_concerns/solr_document_behavior.rb +147 -0
- data/app/models/concerns/curation_concerns/user.rb +18 -0
- data/app/models/concerns/curation_concerns/with_file_sets.rb +37 -0
- data/app/models/concerns/curation_concerns/work_behavior.rb +45 -0
- data/app/models/curation_concerns/classify_concern.rb +49 -0
- data/app/models/curation_concerns/quick_classification_query.rb +38 -0
- data/app/models/single_use_link.rb +34 -0
- data/app/models/version_committer.rb +2 -0
- data/app/search_builders/curation_concerns/collection_member_search_builder.rb +1 -1
- data/app/search_builders/curation_concerns/collection_search_builder.rb +33 -0
- data/app/search_builders/curation_concerns/member_search_builder.rb +17 -0
- data/app/services/curation_concerns/derivative_path.rb +49 -0
- data/app/services/curation_concerns/file_set_audit_service.rb +105 -0
- data/app/services/curation_concerns/indexes_thumbnails.rb +30 -0
- data/app/services/curation_concerns/local_file_service.rb +10 -0
- data/app/services/curation_concerns/lock_manager.rb +39 -0
- data/app/services/curation_concerns/lockable.rb +16 -0
- data/app/services/curation_concerns/noid.rb +23 -0
- data/app/services/curation_concerns/persist_derivatives.rb +33 -0
- data/app/services/curation_concerns/persist_directly_contained_output_file_service.rb +26 -0
- data/app/services/curation_concerns/repository_audit_service.rb +7 -0
- data/app/services/curation_concerns/thumbnail_path_service.rb +46 -0
- data/app/services/curation_concerns/time_service.rb +7 -0
- data/app/services/curation_concerns/versioning_service.rb +26 -0
- data/app/validators/has_one_title_validator.rb +8 -0
- data/app/views/batch_select/_add_button.html.erb +3 -0
- data/app/views/batch_select/_check_all.html.erb +4 -0
- data/app/views/batch_select/_tools.html.erb +10 -0
- data/app/views/catalog/_action_menu_partials/_collection.html.erb +3 -3
- data/app/views/catalog/_action_menu_partials/_default.html.erb +1 -1
- data/app/views/catalog/_document_list.html.erb +1 -1
- data/app/views/collections/_bookmark_control.html.erb +2 -0
- data/app/views/collections/_button_create_collection.html.erb +2 -0
- data/app/views/collections/_button_for_creating_empty_collection.html.erb +1 -1
- data/app/views/collections/_button_for_delete_collection.html.erb +4 -0
- data/app/views/collections/_button_for_remove_selected_from_collection.html.erb +8 -0
- data/app/views/collections/_button_for_update_collection.html.erb +4 -0
- data/app/views/collections/_button_remove_from_collection.html.erb +4 -0
- data/app/views/collections/_document_header.html.erb +9 -0
- data/app/views/collections/_edit_actions.html.erb +1 -1
- data/app/views/collections/_edit_descriptions.html.erb +1 -1
- data/app/views/collections/_form.html.erb +2 -2
- data/app/views/collections/_form_for_select_destination_collection.html.erb +21 -0
- data/app/views/collections/_form_to_add_member.html.erb +1 -1
- data/app/views/collections/_index_default.html.erb +2 -0
- data/app/views/collections/_index_header_default.html.erb +2 -0
- data/app/views/collections/_media_display.html.erb +1 -1
- data/app/views/collections/_paginate.html.erb +1 -1
- data/app/views/collections/_paginate_compact.html.erb +1 -0
- data/app/views/collections/_results_pagination.html.erb +9 -0
- data/app/views/collections/_search_collection_dashboard_form.html.erb +1 -1
- data/app/views/collections/_search_form.html.erb +1 -1
- data/app/views/collections/_search_results.html.erb +23 -0
- data/app/views/collections/_show_actions.html.erb +1 -1
- data/app/views/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/index.html.erb +9 -0
- data/app/views/collections/new.html.erb +3 -0
- data/app/views/curation_concerns/base/_form_permission.html.erb +10 -11
- data/app/views/curation_concerns/base/_form_permission_embargo.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_permission_lease.html.erb +1 -1
- data/app/views/curation_concerns/base/_legally_binding_text.html.erb +7 -7
- data/app/views/curation_concerns/base/_related_files.html.erb +1 -1
- data/app/views/curation_concerns/base/_visibility.html.erb +2 -2
- data/app/views/curation_concerns/file_sets/_actions.html.erb +1 -1
- data/app/views/embargoes/_list_expired_active_embargoes.html.erb +1 -1
- data/app/views/error/single_use_error.html.erb +1 -1
- data/app/views/shared/_add_content.html.erb +17 -15
- data/app/views/shared/_brand_bar.html.erb +19 -10
- data/app/views/shared/_header.html.erb +2 -6
- data/app/views/shared/_my_actions.html.erb +28 -27
- data/app/views/shared/_site_actions.html.erb +5 -1
- data/app/views/shared/_site_search.html.erb +3 -2
- data/app/views/shared/_title_bar.html.erb +7 -16
- data/app/views/welcome/index.html.erb +2 -2
- data/config/locales/curation_concerns.en.yml +25 -1
- data/curation_concerns.gemspec +21 -5
- data/lib/curation_concerns/collections/accepts_batches.rb +53 -0
- data/lib/curation_concerns/collections/search_service.rb +57 -0
- data/lib/curation_concerns/collections.rb +10 -0
- data/lib/curation_concerns/configuration.rb +167 -0
- data/lib/curation_concerns/engine.rb +22 -1
- data/lib/curation_concerns/messages.rb +68 -0
- data/lib/curation_concerns/models.rb +42 -0
- data/lib/curation_concerns/name.rb +20 -0
- data/lib/curation_concerns/null_logger.rb +10 -0
- data/lib/curation_concerns/rails/routes.rb +1 -3
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/curation_concerns.rb +2 -0
- data/lib/generators/curation_concerns/abstract_migration_generator.rb +31 -0
- data/lib/generators/curation_concerns/clamav_generator.rb +19 -0
- data/lib/generators/curation_concerns/collection_generator.rb +15 -0
- data/lib/generators/curation_concerns/install_generator.rb +1 -2
- data/lib/generators/curation_concerns/models_generator.rb +62 -0
- data/lib/generators/curation_concerns/templates/app/models/collection.rb +6 -0
- data/lib/generators/curation_concerns/templates/app/models/file_set.rb +4 -0
- data/lib/generators/curation_concerns/templates/config/clamav.rb +1 -0
- data/lib/generators/curation_concerns/templates/config/curation_concerns.rb +61 -0
- data/lib/generators/curation_concerns/templates/config/mime_types.rb +6 -0
- data/lib/generators/curation_concerns/templates/config/redis.yml +9 -0
- data/lib/generators/curation_concerns/templates/config/redis_config.rb +29 -0
- data/lib/generators/curation_concerns/templates/config/resque-pool.yml +1 -0
- data/lib/generators/curation_concerns/templates/config/resque_config.rb +6 -0
- data/lib/generators/curation_concerns/templates/curation_concerns.scss +3 -2
- data/lib/generators/curation_concerns/templates/migrations/create_checksum_audit_logs.rb +19 -0
- data/lib/generators/curation_concerns/templates/migrations/create_single_use_links.rb +12 -0
- data/lib/generators/curation_concerns/templates/migrations/create_version_committers.rb +15 -0
- data/lib/tasks/migrate.rake +11 -0
- data/lib/tasks/resque.rake +14 -0
- data/lib/tasks/solr_reindex.rake +8 -0
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +31 -0
- data/spec/controllers/accepts_batches_controller_spec.rb +65 -0
- data/spec/controllers/collections_controller_spec.rb +272 -0
- data/spec/controllers/curation_concerns/collections_controller_spec.rb +1 -2
- data/spec/controllers/selects_collections_controller_spec.rb +109 -0
- data/spec/features/create_work_spec.rb +1 -1
- data/spec/features/work_generator_spec.rb +1 -1
- data/spec/forms/collection_edit_form_spec.rb +2 -9
- data/spec/forms/work_form_spec.rb +5 -0
- data/spec/helpers/collections_helper_spec.rb +129 -0
- data/spec/helpers/curation_concerns/collections_helper_spec.rb +2 -2
- data/spec/helpers/render_constraints_helper_spec.rb +23 -1
- data/spec/lib/curation_concerns/collections/search_service_spec.rb +33 -0
- data/spec/models/collection_spec.rb +165 -0
- data/spec/tasks/rake_spec.rb +1 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb +4 -1
- data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +1 -0
- data/spec/views/shared/_add_content.html.erb_spec.rb +3 -3
- metadata +341 -24
- data/VERSION +0 -1
- data/app/assets/stylesheets/curation_concerns/_global-variables.scss +0 -5
- data/app/assets/stylesheets/curation_concerns/modules/multi_value_fields.scss +0 -52
- data/app/views/collections/_form_required_information.html.erb +0 -11
- data/tasks/release.rake +0 -93
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module CurationConcerns
|
|
2
|
+
module Collections
|
|
3
|
+
class SearchService
|
|
4
|
+
include Blacklight::Configurable
|
|
5
|
+
include Blacklight::SearchHelper
|
|
6
|
+
|
|
7
|
+
def initialize(session, user_key)
|
|
8
|
+
@session = session
|
|
9
|
+
@user_key = user_key
|
|
10
|
+
self.class.copy_blacklight_config_from(::CatalogController)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# self.search_params_logic << :apply_gated_search
|
|
14
|
+
|
|
15
|
+
def last_search_documents
|
|
16
|
+
return [] if @session[:history].blank?
|
|
17
|
+
last_search_id = @session[:history].first
|
|
18
|
+
search = Search.find(last_search_id)
|
|
19
|
+
_, document_list = get_search_results(search.query_params, fl: 'id', rows: 1000)
|
|
20
|
+
document_list
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# filter that sets up access-controlled lucene query in order to provide gated search behavior
|
|
24
|
+
# @param solr_parameters the current solr parameters
|
|
25
|
+
# @param user_parameters the current user-submitted parameters
|
|
26
|
+
def apply_gated_search(solr_parameters, _user_parameters)
|
|
27
|
+
solr_parameters[:fq] ||= []
|
|
28
|
+
|
|
29
|
+
# Grant access to public content
|
|
30
|
+
user_access_filters = []
|
|
31
|
+
user_access_filters << "#{solr_access_control_suffix(:group)}:public"
|
|
32
|
+
|
|
33
|
+
# Grant access based on user id & role
|
|
34
|
+
unless @user_key.blank?
|
|
35
|
+
# for roles
|
|
36
|
+
::RoleMapper.roles(@user_key).each do |role|
|
|
37
|
+
user_access_filters << "#{solr_access_control_suffix(:group)}:#{escape_slashes(role)}"
|
|
38
|
+
end
|
|
39
|
+
# for individual person access
|
|
40
|
+
user_access_filters << "#{solr_access_control_suffix(:individual)}:#{escape_slashes(@user_key)}"
|
|
41
|
+
end
|
|
42
|
+
solr_parameters[:fq] << user_access_filters.join(' OR ')
|
|
43
|
+
solr_parameters
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def escape_slashes(value)
|
|
47
|
+
value.gsub('/', '\/')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @param [Symbol] key The permission type to return. Must be `:group` or `:individual`
|
|
51
|
+
def solr_access_control_suffix(key)
|
|
52
|
+
raise ArgumentError, 'you must provide :group or :individual' unless [:group, :individual].include?(key)
|
|
53
|
+
Hydra.config[:permissions][:edit][key]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
require 'curation_concerns/callbacks'
|
|
2
|
+
|
|
3
|
+
module CurationConcerns
|
|
4
|
+
extend Deprecation
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :config
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.configure
|
|
10
|
+
self.config ||= Configuration.new
|
|
11
|
+
yield(config)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class Configuration
|
|
15
|
+
include Callbacks
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@registered_concerns = []
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# An anonymous function that receives a path to a file
|
|
22
|
+
# and returns AntiVirusScanner::NO_VIRUS_FOUND_RETURN_VALUE if no
|
|
23
|
+
# virus is found; Any other returned value means a virus was found
|
|
24
|
+
attr_writer :default_antivirus_instance
|
|
25
|
+
def default_antivirus_instance
|
|
26
|
+
@default_antivirus_instance ||= lambda do |_file_path|
|
|
27
|
+
AntiVirusScanner::NO_VIRUS_FOUND_RETURN_VALUE
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Path on the local file system where derivatives will be stored
|
|
32
|
+
attr_writer :derivatives_path
|
|
33
|
+
def derivatives_path
|
|
34
|
+
@derivatives_path ||= File.join(Rails.root, 'tmp', 'derivatives')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Path on the local file system where originals will be staged before being ingested into Fedora.
|
|
38
|
+
attr_writer :working_path
|
|
39
|
+
def working_path
|
|
40
|
+
@working_path ||= File.join(Rails.root, 'tmp', 'uploads')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
attr_writer :enable_ffmpeg
|
|
44
|
+
def enable_ffmpeg
|
|
45
|
+
return @enable_ffmpeg unless @enable_ffmpeg.nil?
|
|
46
|
+
@enable_ffmpeg = false
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
attr_writer :ffmpeg_path
|
|
50
|
+
def ffmpeg_path
|
|
51
|
+
@ffmpeg_path ||= 'ffmpeg'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
attr_writer :fits_message_length
|
|
55
|
+
def fits_message_length
|
|
56
|
+
@fits_message_length ||= 5
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
attr_accessor :temp_file_base, :enable_local_ingest,
|
|
60
|
+
:analytics, :analytic_start_date
|
|
61
|
+
|
|
62
|
+
attr_writer :display_microdata
|
|
63
|
+
def display_microdata
|
|
64
|
+
return @display_microdata unless @display_microdata.nil?
|
|
65
|
+
@display_microdata = true
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
attr_writer :microdata_default_type
|
|
69
|
+
def microdata_default_type
|
|
70
|
+
@microdata_default_type ||= 'http://schema.org/CreativeWork'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
attr_writer :max_days_between_audits
|
|
74
|
+
def max_days_between_audits
|
|
75
|
+
@max_days_between_audits ||= 7
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
attr_writer :enable_noids
|
|
79
|
+
def enable_noids
|
|
80
|
+
return @enable_noids unless @enable_noids.nil?
|
|
81
|
+
@enable_noids = true
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
attr_writer :noid_template
|
|
85
|
+
def noid_template
|
|
86
|
+
@noid_template ||= '.reeddeeddk'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
attr_writer :minter_statefile
|
|
90
|
+
def minter_statefile
|
|
91
|
+
@minter_statefile ||= '/tmp/minter-state'
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
attr_writer :redis_namespace
|
|
95
|
+
def redis_namespace
|
|
96
|
+
@redis_namespace ||= 'curation_concerns'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
attr_writer :fits_path
|
|
100
|
+
def fits_path
|
|
101
|
+
@fits_path ||= 'fits.sh'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Override characterization runner
|
|
105
|
+
attr_accessor :characterization_runner
|
|
106
|
+
|
|
107
|
+
# Attributes for the lock manager which ensures a single process/thread is mutating a ore:Aggregation at once.
|
|
108
|
+
# @!attribute [w] lock_retry_count
|
|
109
|
+
# How many times to retry to acquire the lock before raising UnableToAcquireLockError
|
|
110
|
+
attr_writer :lock_retry_count
|
|
111
|
+
def lock_retry_count
|
|
112
|
+
@lock_retry_count ||= 600 # Up to 2 minutes of trying at intervals up to 200ms
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# @!attribute [w] lock_time_to_live
|
|
116
|
+
# How long to hold the lock in milliseconds
|
|
117
|
+
attr_writer :lock_time_to_live
|
|
118
|
+
def lock_time_to_live
|
|
119
|
+
@lock_time_to_live ||= 60_000 # milliseconds
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# @!attribute [w] lock_retry_delay
|
|
123
|
+
# Maximum wait time in milliseconds before retrying. Wait time is a random value between 0 and retry_delay.
|
|
124
|
+
attr_writer :lock_retry_delay
|
|
125
|
+
def lock_retry_delay
|
|
126
|
+
@lock_retry_delay ||= 200 # milliseconds
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
callback.enable :after_create_content, :after_update_content,
|
|
130
|
+
:after_revert_content, :after_update_metadata,
|
|
131
|
+
:after_import_local_file_success,
|
|
132
|
+
:after_import_local_file_failure, :after_audit_failure,
|
|
133
|
+
:after_destroy, :after_import_url_success, :after_import_url_failure
|
|
134
|
+
|
|
135
|
+
# Registers the given curation concern model in the configuration
|
|
136
|
+
# @param [Array<Symbol>,Symbol] curation_concern_types
|
|
137
|
+
def register_curation_concern(*curation_concern_types)
|
|
138
|
+
Array(curation_concern_types).flatten.compact.each do |cc_type|
|
|
139
|
+
unless @registered_concerns.include?(cc_type)
|
|
140
|
+
@registered_concerns << cc_type
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# The normalization done by this method must occur after the initialization process
|
|
146
|
+
# so it can take advantage of irregular inflections from config/initializers/inflections.rb
|
|
147
|
+
# @return [Array<String>] the class names of the registered curation concerns
|
|
148
|
+
def registered_curation_concern_types
|
|
149
|
+
@registered_concerns.map { |cc_type| normalize_concern_name(cc_type) }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# @return [Array<Class>] the registered curation concerns
|
|
153
|
+
def curation_concerns
|
|
154
|
+
registered_curation_concern_types.map(&:constantize)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
private
|
|
158
|
+
|
|
159
|
+
# @param [Symbol] the symbol representing the model
|
|
160
|
+
# @return [String] the class name for the model
|
|
161
|
+
def normalize_concern_name(c)
|
|
162
|
+
c.to_s.camelize
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
configure {}
|
|
167
|
+
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Load blacklight which will give curation_concerns views a higher preference than those in blacklight
|
|
2
2
|
require 'blacklight'
|
|
3
3
|
require 'curation_concerns/models'
|
|
4
|
-
require 'hydra-collections'
|
|
5
4
|
require 'hydra-editor'
|
|
6
5
|
require 'jquery-ui-rails'
|
|
7
6
|
require 'qa'
|
|
@@ -18,6 +17,7 @@ module CurationConcerns
|
|
|
18
17
|
require 'breadcrumbs_on_rails'
|
|
19
18
|
|
|
20
19
|
config.autoload_paths += %W(
|
|
20
|
+
#{config.root}/app/actors/concerns
|
|
21
21
|
#{config.root}/lib
|
|
22
22
|
)
|
|
23
23
|
|
|
@@ -30,5 +30,26 @@ module CurationConcerns
|
|
|
30
30
|
|
|
31
31
|
app.config.assets.precompile += %w(*.png *.gif)
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
initializer 'requires' do
|
|
35
|
+
require 'active_fedora/noid'
|
|
36
|
+
require 'curation_concerns/noid'
|
|
37
|
+
require 'curation_concerns/permissions'
|
|
38
|
+
require 'curation_concerns/lockable'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
initializer 'configure' do
|
|
42
|
+
CurationConcerns.config.tap do |c|
|
|
43
|
+
Hydra::Derivatives.ffmpeg_path = c.ffmpeg_path
|
|
44
|
+
Hydra::Derivatives.temp_file_base = c.temp_file_base
|
|
45
|
+
Hydra::Derivatives.fits_path = c.fits_path
|
|
46
|
+
Hydra::Derivatives.enable_ffmpeg = c.enable_ffmpeg
|
|
47
|
+
|
|
48
|
+
ActiveFedora::Base.translate_uri_to_id = ActiveFedora::Noid.config.translate_uri_to_id
|
|
49
|
+
ActiveFedora::Base.translate_id_to_uri = ActiveFedora::Noid.config.translate_id_to_uri
|
|
50
|
+
ActiveFedora::Noid.config.template = c.noid_template
|
|
51
|
+
ActiveFedora::Noid.config.statefile = c.minter_statefile
|
|
52
|
+
end
|
|
53
|
+
end
|
|
33
54
|
end
|
|
34
55
|
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module CurationConcerns
|
|
2
|
+
module Messages
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
# Borrowed from AbstractController so we can render html content tags
|
|
6
|
+
attr_accessor :output_buffer
|
|
7
|
+
include ActionView::Helpers::TagHelper
|
|
8
|
+
include ActionView::Helpers::UrlHelper
|
|
9
|
+
|
|
10
|
+
def success_subject
|
|
11
|
+
I18n.t('curation_concerns.messages.success.subject')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def failure_subject
|
|
15
|
+
I18n.t('curation_concerns.messages.failure.subject')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def single_success(id, file)
|
|
19
|
+
content_tag :span, id: 'ss-' + id do
|
|
20
|
+
[link_to_file(file), I18n.t('curation_concerns.messages.success.single')].join(' ').html_safe
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def multiple_success(id, files)
|
|
25
|
+
content_tag :span, id: 'ss-' + id do
|
|
26
|
+
[success_link(files), I18n.t('curation_concerns.messages.success.multiple.tag')].join(' ').html_safe
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def single_failure(id, file)
|
|
31
|
+
content_tag :span, id: 'ss-' + id do
|
|
32
|
+
[link_to_file(file), I18n.t('curation_concerns.messages.failure.single')].join(' ').html_safe
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def multiple_failure(id, files)
|
|
37
|
+
content_tag :span, id: 'ss-' + id do
|
|
38
|
+
[failure_link(files), I18n.t('curation_concerns.messages.failure.multiple.tag')].join(' ').html_safe
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Double-quotes are replaced with single ones so this list can be included in a data block. Ex:
|
|
43
|
+
# <a href="#" data-content="<a href='#'>embedded link</a>" data-toggle="popover">Click me</a>
|
|
44
|
+
def file_list(files)
|
|
45
|
+
files.map { |fs| link_to_file(fs) }.join(', ').tr("\"", "'")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def link_to_file(file)
|
|
49
|
+
link_to(file.to_s, Rails.application.class.routes.url_helpers.curation_concerns_file_set_path(file))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def success_link(files)
|
|
55
|
+
link_to I18n.t('curation_concerns.messages.success.multiple.link'), '#',
|
|
56
|
+
data: { toggle: 'popover',
|
|
57
|
+
content: file_list(files).html_safe,
|
|
58
|
+
title: I18n.t('curation_concerns.messages.success.title') }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def failure_link(files)
|
|
62
|
+
link_to I18n.t('curation_concerns.messages.failure.multiple.link'), '#',
|
|
63
|
+
data: { toggle: 'popover',
|
|
64
|
+
content: file_list(files).html_safe,
|
|
65
|
+
title: I18n.t('curation_concerns.messages.failure.title') }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'hydra/head'
|
|
2
|
+
|
|
3
|
+
module CurationConcerns
|
|
4
|
+
extend ActiveSupport::Autoload
|
|
5
|
+
|
|
6
|
+
module Models
|
|
7
|
+
module Utils
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
def retry_unless(number_of_tries, condition, &block)
|
|
11
|
+
self.class.retry_unless(number_of_tries, condition, &block)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module ClassMethods
|
|
15
|
+
def retry_unless(number_of_tries, condition, &_block)
|
|
16
|
+
fail ArgumentError, 'First argument must be an enumerator' unless number_of_tries.is_a? Enumerator
|
|
17
|
+
fail ArgumentError, 'Second argument must be a lambda' unless condition.respond_to? :call
|
|
18
|
+
fail ArgumentError, 'Must pass a block of code to retry' unless block_given?
|
|
19
|
+
number_of_tries.each do
|
|
20
|
+
result = yield
|
|
21
|
+
return result unless condition.call
|
|
22
|
+
end
|
|
23
|
+
fail 'retry_unless could not complete successfully. Try upping the # of tries?'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
autoload :Permissions
|
|
30
|
+
autoload :Messages
|
|
31
|
+
autoload :NullLogger
|
|
32
|
+
eager_autoload do
|
|
33
|
+
autoload :Configuration
|
|
34
|
+
autoload :Name
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
attr_writer :queue
|
|
38
|
+
|
|
39
|
+
def self.queue
|
|
40
|
+
@queue ||= config.queue.new('curation_concerns')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module CurationConcerns
|
|
2
|
+
# A model name that provides routes that are namespaced to CurationConcerns,
|
|
3
|
+
# without changing the param key.
|
|
4
|
+
#
|
|
5
|
+
# Example:
|
|
6
|
+
# name = CurationConcerns::Name.new(GenericWork)
|
|
7
|
+
# name.param_key
|
|
8
|
+
# # => 'generic_work'
|
|
9
|
+
# name.route_key
|
|
10
|
+
# # => 'curation_concerns_generic_works'
|
|
11
|
+
#
|
|
12
|
+
class Name < ActiveModel::Name
|
|
13
|
+
def initialize(klass, namespace = nil, name = nil)
|
|
14
|
+
super
|
|
15
|
+
@route_key = "curation_concerns_#{ActiveSupport::Inflector.pluralize(@param_key)}"
|
|
16
|
+
@singular_route_key = ActiveSupport::Inflector.singularize(@route_key)
|
|
17
|
+
@route_key << "_index" if @plural == @singular
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -35,13 +35,11 @@ module ActionDispatch::Routing
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
# Used in conjunction with Hydra::Collections::Engine routes.
|
|
39
38
|
# Adds routes for doing paginated searches within a collection's contents
|
|
40
39
|
# @example in routes.rb:
|
|
41
|
-
# mount Hydra::Collections::Engine => '/'
|
|
42
40
|
# curation_concerns_collections
|
|
43
41
|
def curation_concerns_collections
|
|
44
|
-
resources :collections
|
|
42
|
+
resources :collections do
|
|
45
43
|
member do
|
|
46
44
|
get 'page/:page', action: :index
|
|
47
45
|
get 'facet/:id', action: :facet, as: :dashboard_facet
|
data/lib/curation_concerns.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'curation_concerns/version'
|
|
2
2
|
require 'curation_concerns/engine'
|
|
3
3
|
require 'curation_concerns/configuration'
|
|
4
|
+
require 'curation_concerns/models'
|
|
5
|
+
require 'curation_concerns/collections'
|
|
4
6
|
require 'blacklight_advanced_search'
|
|
5
7
|
require 'kaminari_route_prefix'
|
|
6
8
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
require 'rails/generators'
|
|
3
|
+
require 'rails/generators/migration'
|
|
4
|
+
|
|
5
|
+
class CurationConcerns::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
|
+
last_migration = Dir[File.join(path, '*.rb')].sort.last
|
|
15
|
+
@prev_migration_nr = if last_migration
|
|
16
|
+
last_migration.sub(File.join(path, '/'), '').to_i + 1
|
|
17
|
+
else
|
|
18
|
+
Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
@prev_migration_nr.to_s
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
|
|
26
|
+
def better_migration_template(file)
|
|
27
|
+
migration_template "migrations/#{file}", "db/migrate/#{file}"
|
|
28
|
+
rescue Rails::Generators::Error => e
|
|
29
|
+
say_status('warning', e.message, :yellow)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
require 'rails/generators'
|
|
3
|
+
|
|
4
|
+
class CurationConcerns::ClamavGenerator < 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 clamav initializer
|
|
10
|
+
'
|
|
11
|
+
|
|
12
|
+
def banner
|
|
13
|
+
say_status('info', 'Generating clamav initializers', :blue)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_initializer_file
|
|
17
|
+
copy_file 'config/clamav.rb', 'config/initializers/clamav.rb'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
|
|
3
|
+
module CurationConcerns
|
|
4
|
+
class CollectionGenerator < Rails::Generators::Base
|
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
6
|
+
|
|
7
|
+
desc 'This generator makes the following changes to your application:
|
|
8
|
+
1. Creates a collection model.
|
|
9
|
+
'
|
|
10
|
+
|
|
11
|
+
def create_collection
|
|
12
|
+
copy_file 'app/models/collection.rb', 'app/models/collection.rb'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -25,7 +25,7 @@ module CurationConcerns
|
|
|
25
25
|
say_status('warning', '[CurationConcerns] GENERATING HYDRA-HEAD', :yellow)
|
|
26
26
|
generate 'hydra:head -f'
|
|
27
27
|
say_status('warning', '[CurationConcerns] GENERATING CURATION_CONCERNS MODELS', :yellow)
|
|
28
|
-
generate "curation_concerns:models
|
|
28
|
+
generate "curation_concerns:models#{options[:force] ? ' -f' : ''}"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def inject_application_controller_behavior
|
|
@@ -51,7 +51,6 @@ module CurationConcerns
|
|
|
51
51
|
gsub_file 'config/routes.rb', /root (:to =>|to:) "catalog#index"/, ''
|
|
52
52
|
|
|
53
53
|
inject_into_file 'config/routes.rb', after: /devise_for :users\s*\n/ do
|
|
54
|
-
" mount Hydra::Collections::Engine => '/'\n"\
|
|
55
54
|
" mount CurationConcerns::Engine, at: '/'\n"\
|
|
56
55
|
" resources :welcome, only: 'index'\n"\
|
|
57
56
|
" root 'welcome#index'\n"\
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_relative 'abstract_migration_generator'
|
|
2
|
+
|
|
3
|
+
class CurationConcerns::ModelsGenerator < CurationConcerns::AbstractMigrationGenerator
|
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
+
argument :model_name, type: :string, default: 'user'
|
|
6
|
+
desc '
|
|
7
|
+
This generator makes the following changes to your application:
|
|
8
|
+
1. Creates several database migrations if they do not exist in /db/migrate
|
|
9
|
+
2. Creates the curation_concerns.rb configuration file and several others
|
|
10
|
+
3. Creates the file_set.rb and collection.rb models
|
|
11
|
+
'
|
|
12
|
+
def banner
|
|
13
|
+
say_status('warning', 'GENERATING CURATION_CONCERNS MODELS', :yellow)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Setup the database migrations
|
|
17
|
+
def copy_migrations
|
|
18
|
+
[
|
|
19
|
+
'create_version_committers.rb',
|
|
20
|
+
'create_checksum_audit_logs.rb',
|
|
21
|
+
'create_single_use_links.rb' # ,
|
|
22
|
+
].each do |file|
|
|
23
|
+
better_migration_template file
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Add behaviors to the user model
|
|
28
|
+
def inject_curation_concerns_user_behavior
|
|
29
|
+
file_path = "app/models/#{model_name.underscore}.rb"
|
|
30
|
+
if File.exist?(file_path)
|
|
31
|
+
inject_into_file file_path, after: /include Hydra\:\:User.*$/ do
|
|
32
|
+
"\n # Connects this user object to Curation Concerns behaviors." \
|
|
33
|
+
"\n include CurationConcerns::User\n"
|
|
34
|
+
end
|
|
35
|
+
else
|
|
36
|
+
puts " \e[31mFailure\e[0m CurationConcerns requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g curation_concerns client"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create_configuration_files
|
|
41
|
+
append_file 'config/initializers/mime_types.rb',
|
|
42
|
+
"\nMime::Type.register 'application/x-endnote-refer', :endnote", verbose: false
|
|
43
|
+
copy_file 'config/curation_concerns.rb', 'config/initializers/curation_concerns.rb'
|
|
44
|
+
copy_file 'config/redis.yml', 'config/redis.yml'
|
|
45
|
+
copy_file 'config/resque-pool.yml', 'config/resque-pool.yml'
|
|
46
|
+
copy_file 'config/redis_config.rb', 'config/initializers/redis_config.rb'
|
|
47
|
+
copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def create_collection
|
|
51
|
+
copy_file 'app/models/collection.rb', 'app/models/collection.rb'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def create_file_set
|
|
55
|
+
copy_file 'app/models/file_set.rb', 'app/models/file_set.rb'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Adds clamav initializtion
|
|
59
|
+
def clamav
|
|
60
|
+
generate 'curation_concerns:clamav'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ClamAV.instance.loaddb if defined? ClamAV
|