blacklight-spotlight 3.0.0.alpha.8 → 3.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/assets/images/blacklight/arrow-alt-circle-left.svg +1 -0
- data/app/assets/images/blacklight/arrow-alt-circle-right.svg +1 -0
- data/app/assets/javascripts/spotlight/admin/{add_new_page_button.js → add_new_button.js} +7 -0
- data/app/assets/javascripts/spotlight/admin/block_mixins/autocompleteable.js +4 -4
- data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +55 -1
- data/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
- data/app/assets/javascripts/spotlight/admin/blocks/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js +1 -1
- data/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +7 -2
- data/app/assets/javascripts/spotlight/admin/crop.es6 +11 -0
- data/app/assets/javascripts/spotlight/admin/croppable.js +1 -1
- data/app/assets/javascripts/spotlight/admin/index.js +0 -2
- data/app/assets/javascripts/spotlight/admin/search_typeahead.js +2 -2
- data/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +21 -12
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +11 -3
- data/app/assets/javascripts/spotlight/user/browse_group_categories.js +59 -0
- data/app/assets/javascripts/spotlight/user/index.js +1 -0
- data/app/assets/stylesheets/spotlight/_accessibility.scss +1 -1
- data/app/assets/stylesheets/spotlight/_breadcrumbs.scss +8 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_catalog.scss +6 -6
- data/app/assets/stylesheets/spotlight/_curation.scss +6 -0
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +214 -83
- data/app/assets/stylesheets/spotlight/_header.scss +1 -1
- data/app/assets/stylesheets/spotlight/_item_text_block.scss +6 -0
- data/app/assets/stylesheets/spotlight/_pages.scss +10 -5
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +5 -2
- data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -0
- data/app/assets/stylesheets/spotlight/_translations.scss +7 -0
- data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +69 -0
- data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +1 -2
- data/app/controllers/concerns/spotlight/search_helper.rb +2 -8
- data/app/controllers/spotlight/appearances_controller.rb +0 -12
- data/app/controllers/spotlight/browse_controller.rb +7 -3
- data/app/controllers/spotlight/catalog_controller.rb +1 -1
- data/app/controllers/spotlight/concerns/application_controller.rb +13 -2
- data/app/controllers/spotlight/exhibits_controller.rb +2 -3
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/groups_controller.rb +80 -0
- data/app/controllers/spotlight/pages_controller.rb +6 -9
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +7 -19
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/application_helper.rb +1 -1
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/helpers/spotlight/crud_link_helpers.rb +1 -1
- data/app/helpers/spotlight/main_app_helpers.rb +1 -1
- data/app/jobs/spotlight/add_uploads_from_csv.rb +30 -5
- data/app/mailers/spotlight/indexing_complete_mailer.rb +3 -2
- data/app/models/concerns/spotlight/exhibit_defaults.rb +1 -1
- data/app/models/concerns/spotlight/translatables.rb +17 -1
- data/app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb +25 -0
- data/app/models/spotlight/ability.rb +2 -0
- data/app/models/spotlight/about_page.rb +3 -1
- data/app/models/spotlight/blacklight_configuration.rb +2 -1
- data/app/models/spotlight/contact.rb +1 -1
- data/app/models/spotlight/custom_field.rb +3 -3
- data/app/models/spotlight/exhibit.rb +18 -4
- data/app/models/spotlight/feature_page.rb +3 -1
- data/app/models/spotlight/featured_image.rb +29 -12
- data/app/models/spotlight/group.rb +22 -0
- data/app/models/spotlight/group_member.rb +11 -0
- data/app/models/spotlight/home_page.rb +3 -1
- data/app/models/spotlight/main_navigation.rb +2 -2
- data/app/models/spotlight/masthead.rb +1 -1
- data/app/models/spotlight/page.rb +5 -1
- data/app/models/spotlight/page_configurations.rb +6 -0
- data/app/models/spotlight/page_content.rb +2 -0
- data/app/models/spotlight/resources/csv_upload.rb +2 -1
- data/app/models/spotlight/resources/iiif_manifest.rb +8 -6
- data/app/models/spotlight/resources/upload.rb +1 -1
- data/app/models/spotlight/search.rb +10 -1
- data/app/models/spotlight/solr_document_sidecar.rb +7 -5
- data/app/models/spotlight/temporary_image.rb +8 -0
- data/app/services/spotlight/exhibit_import_export_service.rb +482 -0
- data/app/services/spotlight/solr_document_builder.rb +1 -0
- data/app/values/custom_field_name.rb +1 -0
- data/app/views/catalog/_save_search.html.erb +1 -1
- data/app/views/spotlight/about_pages/_empty.html.erb +5 -5
- data/app/views/spotlight/browse/_search.html.erb +5 -3
- data/app/views/spotlight/browse/_search_title.html.erb +2 -1
- data/app/views/spotlight/browse/index.html.erb +13 -0
- data/app/views/spotlight/catalog/_document.html.erb +2 -4
- data/app/views/spotlight/catalog/index.iiif_json.jbuilder +22 -0
- data/app/views/spotlight/contacts/_form.html.erb +1 -1
- data/app/views/spotlight/feature_pages/_empty.html.erb +5 -5
- data/app/views/spotlight/featured_images/_form.html.erb +1 -1
- data/app/views/spotlight/featured_images/_upload_form.html.erb +1 -1
- data/app/views/spotlight/home_pages/_empty.html.erb +3 -3
- data/app/views/spotlight/indexing_complete_mailer/documents_indexed.html.erb +9 -0
- data/app/views/spotlight/pages/_form.html.erb +2 -2
- data/app/views/spotlight/searches/_form.html.erb +13 -0
- data/app/views/spotlight/searches/_group.html.erb +27 -0
- data/app/views/spotlight/searches/_search.html.erb +1 -0
- data/app/views/spotlight/searches/index.html.erb +58 -17
- data/app/views/spotlight/shared/_honeypot_field.html.erb +4 -0
- data/app/views/spotlight/shared/_report_a_problem.html.erb +7 -10
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -0
- data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +44 -0
- data/app/views/spotlight/sir_trevor/blocks/_uploaded_items_block.html.erb +7 -1
- data/app/views/spotlight/translations/_browse_categories.html.erb +29 -3
- data/app/views/spotlight/translations/_general.html.erb +7 -7
- data/app/views/spotlight/translations/_groups.html.erb +34 -0
- data/app/views/spotlight/translations/_import.html.erb +24 -0
- data/app/views/spotlight/translations/_metadata.html.erb +1 -1
- data/app/views/spotlight/translations/_page.html.erb +5 -5
- data/app/views/spotlight/translations/_pages.html.erb +4 -4
- data/app/views/spotlight/translations/_pages_table.html.erb +5 -5
- data/app/views/spotlight/translations/_search_fields.html.erb +3 -3
- data/app/views/spotlight/translations/edit.html.erb +14 -6
- data/app/views/spotlight/translations/show.yaml.yamlbuilder +81 -0
- data/config/i18n-tasks.yml +7 -0
- data/config/locales/spotlight.ar.yml +47 -24
- data/config/locales/spotlight.en.yml +182 -127
- data/config/routes.rb +16 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/db/migrate/20210113092223_create_spotlight_groups.rb +23 -0
- data/lib/generators/spotlight/install_generator.rb +23 -2
- data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +10 -0
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +3 -1
- data/lib/spotlight/engine.rb +27 -3
- data/lib/spotlight/upload_field_config.rb +1 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/browse_controller_spec.rb +24 -1
- data/spec/controllers/spotlight/catalog_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/contacts_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +11 -0
- data/spec/controllers/spotlight/groups_controller_spec.rb +103 -0
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/searches_controller_spec.rb +10 -3
- data/spec/controllers/spotlight/translations_controller_spec.rb +53 -2
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +1 -1
- data/spec/examples.txt +1437 -1389
- data/spec/factories/featured_images.rb +4 -0
- data/spec/factories/group.rb +17 -0
- data/spec/factories/searches.rb +11 -1
- data/spec/features/add_contacts_spec.rb +1 -1
- data/spec/features/browse_category_admin_spec.rb +39 -7
- data/spec/features/browse_category_navigation_spec.rb +44 -0
- data/spec/features/browse_category_spec.rb +2 -2
- data/spec/features/catalog_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +5 -4
- data/spec/features/dashboard_spec.rb +7 -7
- data/spec/features/edit_search_fields_spec.rb +2 -2
- data/spec/features/exhibits/administration_spec.rb +3 -3
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +1 -1
- data/spec/features/exhibits/language_create_edit_spec.rb +3 -3
- data/spec/features/exhibits/translation_editing_spec.rb +57 -8
- data/spec/features/home_page_spec.rb +13 -4
- data/spec/features/item_admin_spec.rb +4 -4
- data/spec/features/javascript/about_page_admin_spec.rb +1 -1
- data/spec/features/javascript/block_controls_spec.rb +3 -1
- data/spec/features/javascript/blocks/browse_group_categories_block_spec.rb +64 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/features/javascript/browse_group_admin_spec.rb +45 -0
- data/spec/features/javascript/edit_in_place_spec.rb +3 -3
- data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
- data/spec/features/javascript/search_config_admin_spec.rb +1 -1
- data/spec/features/report_a_problem_spec.rb +6 -5
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +3 -3
- data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
- data/spec/i18n_spec.rb +0 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +13 -1
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +11 -1
- data/spec/models/sir_trevor_rails/blocks/browse_group_categories_block_spec.rb +41 -0
- data/spec/models/solr_document_spec.rb +2 -3
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -0
- data/spec/models/spotlight/exhibit_spec.rb +18 -2
- data/spec/models/spotlight/featured_image_spec.rb +27 -0
- data/spec/models/spotlight/group_spec.rb +19 -0
- data/spec/models/spotlight/main_navigation_spec.rb +1 -1
- data/spec/models/spotlight/page_spec.rb +6 -1
- data/spec/models/spotlight/resources/upload_spec.rb +43 -79
- data/spec/models/spotlight/role_spec.rb +3 -3
- data/spec/models/spotlight/search_spec.rb +30 -3
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +168 -23
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/services/spotlight/solr_document_builder_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/features/test_features_helpers.rb +15 -0
- data/spec/test_app_templates/Gemfile.extra +1 -3
- data/spec/test_app_templates/catalog_controller.rb +6 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +2 -0
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +1 -0
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +7 -8
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +46 -21
- data/vendor/assets/javascripts/tiny-slider.js +3218 -0
- data/vendor/assets/stylesheets/tiny-slider.css +1 -0
- metadata +399 -284
- data/app/serializers/spotlight/exhibit_export_serializer.rb +0 -205
- data/app/serializers/spotlight/featured_image_representer.rb +0 -29
- data/app/serializers/spotlight/main_navigation_representer.rb +0 -13
- data/app/serializers/spotlight/page_representer.rb +0 -33
- data/vendor/assets/javascripts/handlebars-v1.3.0.js +0 -2746
@@ -16,7 +16,7 @@ module Spotlight
|
|
16
16
|
|
17
17
|
def create
|
18
18
|
csv = CSV.parse(csv_io_param, headers: true, return_headers: false).map(&:to_hash)
|
19
|
-
Spotlight::
|
19
|
+
Spotlight::AddUploadsFromCsv.perform_later(csv, current_exhibit, current_user)
|
20
20
|
flash[:notice] = t('spotlight.resources.upload.csv.success', file_name: csv_io_name)
|
21
21
|
redirect_to spotlight.admin_exhibit_catalog_path(current_exhibit)
|
22
22
|
end
|
@@ -5,9 +5,8 @@ module Spotlight
|
|
5
5
|
# CRUD actions for curating browse categories (see
|
6
6
|
# {Spotlight::BrowseController} for the end-user read and index actions)
|
7
7
|
class SearchesController < Spotlight::ApplicationController
|
8
|
-
|
8
|
+
load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit', parent_action: :curate
|
9
9
|
before_action :authenticate_user!
|
10
|
-
before_action :only_curators!
|
11
10
|
before_action :create_or_load_resource, only: [:create]
|
12
11
|
load_and_authorize_resource through: :exhibit
|
13
12
|
before_action :attach_breadcrumbs, only: %i[index edit], unless: -> { request.format.json? }
|
@@ -28,10 +27,11 @@ module Spotlight
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def index
|
30
|
+
@groups = @exhibit.groups
|
31
31
|
respond_to do |format|
|
32
32
|
format.html
|
33
33
|
format.json do
|
34
|
-
render json: @searches.as_json(methods: %i[count thumbnail_image_url]), root: false
|
34
|
+
render json: @searches.as_json(methods: %i[full_title count thumbnail_image_url]), root: false
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -50,7 +50,8 @@ module Spotlight
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def edit
|
53
|
-
|
53
|
+
@groups = @exhibit.groups
|
54
|
+
add_breadcrumb @search.full_title, edit_exhibit_search_path(@search.exhibit, @search)
|
54
55
|
@exhibit = @search.exhibit
|
55
56
|
end
|
56
57
|
|
@@ -105,9 +106,11 @@ module Spotlight
|
|
105
106
|
def search_params
|
106
107
|
params.require(:search).permit(
|
107
108
|
:title,
|
109
|
+
:subtitle,
|
108
110
|
:long_description,
|
109
111
|
:search_box,
|
110
112
|
:default_index_view_type,
|
113
|
+
group_ids: [],
|
111
114
|
masthead_attributes: featured_image_params,
|
112
115
|
thumbnail_attributes: featured_image_params
|
113
116
|
)
|
@@ -117,21 +120,6 @@ module Spotlight
|
|
117
120
|
params.to_unsafe_h.with_indifferent_access.except(:exhibit_id, :search, *blacklisted_search_session_params).reject { |_k, v| v.blank? }
|
118
121
|
end
|
119
122
|
|
120
|
-
def featured_image_params
|
121
|
-
%i[
|
122
|
-
iiif_region iiif_tilesource
|
123
|
-
iiif_manifest_url iiif_canvas_id iiif_image_id
|
124
|
-
display
|
125
|
-
source
|
126
|
-
image
|
127
|
-
document_global_id
|
128
|
-
]
|
129
|
-
end
|
130
|
-
|
131
|
-
def only_curators!
|
132
|
-
authorize! :curate, @exhibit if @exhibit
|
133
|
-
end
|
134
|
-
|
135
123
|
def blacklisted_search_session_params
|
136
124
|
%i[id commit counter total search_id page per_page authenticity_token utf8 action controller]
|
137
125
|
end
|
@@ -21,6 +21,22 @@ module Spotlight
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def show
|
25
|
+
respond_to do |format|
|
26
|
+
format.yaml
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def import
|
31
|
+
if current_exhibit.update(import_exhibit_params)
|
32
|
+
I18n.reload! # reload since we're memoizing
|
33
|
+
notice = t(:'helpers.submit.spotlight_default.updated', model: current_exhibit.class.model_name.human.downcase)
|
34
|
+
redirect_to edit_exhibit_translations_path(current_exhibit, language: @language), notice: notice
|
35
|
+
else
|
36
|
+
render 'edit'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
24
40
|
private
|
25
41
|
|
26
42
|
def attach_breadcrumbs
|
@@ -33,6 +49,21 @@ module Spotlight
|
|
33
49
|
params.require(:exhibit).permit(translations_attributes: %i[id locale key value])
|
34
50
|
end
|
35
51
|
|
52
|
+
def import_exhibit_params
|
53
|
+
imported_translations = YAML.safe_load(params.require(:file).read)
|
54
|
+
|
55
|
+
# set language from YML root locale
|
56
|
+
language = imported_translations.keys.first
|
57
|
+
|
58
|
+
# convert YML to hash
|
59
|
+
translation = unfold(imported_translations.values.first).map do |k, v|
|
60
|
+
current_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: k, locale: language)
|
61
|
+
{ key: k, value: v, locale: language, id: current_translation.id }
|
62
|
+
end
|
63
|
+
|
64
|
+
{ translations_attributes: translation }
|
65
|
+
end
|
66
|
+
|
36
67
|
def set_language
|
37
68
|
@language = params[:language] || current_exhibit.available_locales.first
|
38
69
|
end
|
@@ -40,5 +71,20 @@ module Spotlight
|
|
40
71
|
def set_tab
|
41
72
|
@tab = params[:tab]
|
42
73
|
end
|
74
|
+
|
75
|
+
def unfold(value, key = nil)
|
76
|
+
return to_enum(:unfold, value, key) unless block_given?
|
77
|
+
|
78
|
+
if value.is_a? Hash
|
79
|
+
value.each do |k, v|
|
80
|
+
arr = unfold(v, [key, k].compact.join('.'))
|
81
|
+
arr.each do |k1, v1|
|
82
|
+
yield k1, v1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
else
|
86
|
+
yield key, value
|
87
|
+
end
|
88
|
+
end
|
43
89
|
end
|
44
90
|
end
|
@@ -132,7 +132,7 @@ module Spotlight
|
|
132
132
|
|
133
133
|
def uploaded_field_label(config)
|
134
134
|
solr_field = Array(config.solr_field || config.field_name).first.to_s
|
135
|
-
blacklight_config.index_fields[solr_field]
|
135
|
+
blacklight_config.index_fields[solr_field]&.label || config.label || t(".#{solr_field}")
|
136
136
|
end
|
137
137
|
|
138
138
|
def available_view_fields
|
@@ -25,7 +25,10 @@ module Spotlight
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def iiif_upload_tag(f)
|
28
|
-
|
28
|
+
content_tag(:div) do
|
29
|
+
concat f.file_field_without_bootstrap :file, name: 'featured_image[image]', data: { endpoint: polymorphic_path(f.object.model_name.route_key) }
|
30
|
+
concat f.hidden_field :upload_id
|
31
|
+
end
|
29
32
|
end
|
30
33
|
|
31
34
|
def form_prefix(f)
|
@@ -112,7 +112,7 @@ module Spotlight
|
|
112
112
|
defaults << :"helpers.action.#{object_name}.#{key}"
|
113
113
|
defaults << :"helpers.action.#{key}"
|
114
114
|
defaults << "#{key.to_s.humanize} #{model}"
|
115
|
-
I18n.t(defaults.shift, model: model, default: defaults)
|
115
|
+
I18n.t(defaults.shift, model: model.downcase, default: defaults)
|
116
116
|
end
|
117
117
|
# rubocop:enable Metrics/MethodLength
|
118
118
|
end
|
@@ -24,7 +24,7 @@ module Spotlight
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def link_back_to_catalog(opts = { label: nil })
|
27
|
-
opts[:route_set] ||= spotlight if (current_search_session
|
27
|
+
opts[:route_set] ||= spotlight if (current_search_session&.query_params || {}).fetch(:controller, '').starts_with? 'spotlight'
|
28
28
|
super
|
29
29
|
end
|
30
30
|
|
@@ -3,15 +3,41 @@
|
|
3
3
|
module Spotlight
|
4
4
|
##
|
5
5
|
# Process a CSV upload into new Spotlight::Resource::Upload objects
|
6
|
-
class
|
6
|
+
class AddUploadsFromCsv < ActiveJob::Base
|
7
|
+
attr_reader :count
|
8
|
+
attr_reader :errors
|
9
|
+
|
7
10
|
queue_as :default
|
8
11
|
|
9
12
|
after_perform do |job|
|
10
13
|
csv_data, exhibit, user = job.arguments
|
11
|
-
Spotlight::IndexingCompleteMailer.documents_indexed(
|
14
|
+
Spotlight::IndexingCompleteMailer.documents_indexed(
|
15
|
+
csv_data,
|
16
|
+
exhibit,
|
17
|
+
user,
|
18
|
+
indexed_count: job.count,
|
19
|
+
errors: job.errors
|
20
|
+
).deliver_now
|
12
21
|
end
|
13
22
|
|
14
23
|
def perform(csv_data, exhibit, _user)
|
24
|
+
@count = 0
|
25
|
+
@errors = {}
|
26
|
+
|
27
|
+
resources(csv_data, exhibit).each_with_index do |resource, index|
|
28
|
+
if resource.save_and_index
|
29
|
+
@count += 1
|
30
|
+
else
|
31
|
+
@errors[index + 1] = resource.errors.full_messages + resource.upload&.errors&.full_messages
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def resources(csv_data, exhibit)
|
39
|
+
return to_enum(:resources, csv_data, exhibit) unless block_given?
|
40
|
+
|
15
41
|
encoded_csv(csv_data).each do |row|
|
16
42
|
url = row.delete('url')
|
17
43
|
next unless url.present?
|
@@ -21,12 +47,11 @@ module Spotlight
|
|
21
47
|
exhibit: exhibit
|
22
48
|
)
|
23
49
|
resource.build_upload(remote_image_url: url) unless url == '~'
|
24
|
-
|
50
|
+
|
51
|
+
yield resource
|
25
52
|
end
|
26
53
|
end
|
27
54
|
|
28
|
-
private
|
29
|
-
|
30
55
|
def encoded_csv(csv)
|
31
56
|
csv.map do |row|
|
32
57
|
row.map do |label, column|
|
@@ -5,9 +5,10 @@ module Spotlight
|
|
5
5
|
# Notify the curator that we're finished processing a
|
6
6
|
# batch upload
|
7
7
|
class IndexingCompleteMailer < ActionMailer::Base
|
8
|
-
def documents_indexed(csv_data, exhibit, user)
|
9
|
-
@number = csv_data.length
|
8
|
+
def documents_indexed(csv_data, exhibit, user, indexed_count: nil, errors: [])
|
9
|
+
@number = indexed_count || csv_data.length
|
10
10
|
@exhibit = exhibit
|
11
|
+
@errors = errors
|
11
12
|
mail(to: user.email, subject: 'Document indexing complete')
|
12
13
|
end
|
13
14
|
end
|
@@ -15,8 +15,24 @@ module Spotlight
|
|
15
15
|
# Set up a reader for the specified attribute that uses the I18n backend,
|
16
16
|
# and defaults to the ActiveRecord value
|
17
17
|
def define_translated_attr_reader(attr_name)
|
18
|
+
# Define a dynamic method for translating database-backed attributes,
|
19
|
+
# falling back to the database information as needed.
|
20
|
+
#
|
21
|
+
# Note: the empty string is provided as the final fallback to avoid i18n blowing
|
22
|
+
# up on nil attributes.
|
18
23
|
define_method(:"#{attr_name}") do
|
19
|
-
|
24
|
+
send("translated_#{attr_name}", default: [attr_translation(attr_name), ''])
|
25
|
+
end
|
26
|
+
|
27
|
+
# Define an accessor that gets the value of the attribute in a given locale,
|
28
|
+
# returning `nil` for untranslated values.
|
29
|
+
#
|
30
|
+
# Note: For the default locale, we actually want to dig into the database,
|
31
|
+
# because that is the source of truth for the data.
|
32
|
+
define_method(:"translated_#{attr_name}") do |default: [], **options|
|
33
|
+
default = Array.wrap(default)
|
34
|
+
default.prepend(attr_translation(attr_name)) if I18n.locale == I18n.default_locale
|
35
|
+
I18n.translate(attr_name, scope: slug, default: default, **options).presence
|
20
36
|
end
|
21
37
|
end
|
22
38
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SirTrevorRails
|
4
|
+
module Blocks
|
5
|
+
##
|
6
|
+
# Browese Group Categories
|
7
|
+
class BrowseGroupCategoriesBlock < SirTrevorRails::Block
|
8
|
+
include Displayable
|
9
|
+
|
10
|
+
def display_item_counts?
|
11
|
+
send(:'display-item-counts') == 'true'
|
12
|
+
end
|
13
|
+
|
14
|
+
def groups
|
15
|
+
@groups ||= parent.exhibit.groups.published.where(slug: item_ids).sort do |a, b|
|
16
|
+
ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def groups?
|
21
|
+
!groups.empty?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -25,6 +25,7 @@ module Spotlight
|
|
25
25
|
can :manage, [
|
26
26
|
Spotlight::Attachment,
|
27
27
|
Spotlight::Search,
|
28
|
+
Spotlight::Group,
|
28
29
|
Spotlight::Resource,
|
29
30
|
Spotlight::Page,
|
30
31
|
Spotlight::Contact,
|
@@ -43,6 +44,7 @@ module Spotlight
|
|
43
44
|
can :read, Spotlight::Exhibit, published: true
|
44
45
|
can :read, Spotlight::Page, published: true
|
45
46
|
can :read, Spotlight::Search, published: true
|
47
|
+
can :read, Spotlight::Group, published: true
|
46
48
|
can :read, Spotlight::Language, public: true
|
47
49
|
end
|
48
50
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -5,6 +5,8 @@ module Spotlight
|
|
5
5
|
# About pages
|
6
6
|
class AboutPage < Spotlight::Page
|
7
7
|
extend FriendlyId
|
8
|
-
friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale]
|
8
|
+
friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale] do |config|
|
9
|
+
config.reserved_words&.concat(%w[update_all contacts])
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
@@ -76,6 +76,7 @@ module Spotlight
|
|
76
76
|
|
77
77
|
config.show.merge! show unless show.blank?
|
78
78
|
config.index.merge! index unless index.blank?
|
79
|
+
config.index.respond_to[:iiif_json] = true
|
79
80
|
|
80
81
|
config.index.thumbnail_field ||= Spotlight::Engine.config.thumbnail_field
|
81
82
|
|
@@ -353,7 +354,7 @@ module Spotlight
|
|
353
354
|
def title_only_by_default?(view)
|
354
355
|
return false if %i[show enabled].include?(view)
|
355
356
|
|
356
|
-
title_only = default_blacklight_config.view.send(:[], view)
|
357
|
+
title_only = default_blacklight_config.view.send(:[], view)&.title_only_by_default
|
357
358
|
title_only.nil? ? false : title_only
|
358
359
|
end
|
359
360
|
|
@@ -18,10 +18,10 @@ module Spotlight
|
|
18
18
|
self.field_type ||= 'text'
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
before_update :update_field_name, if: -> { field_type_changed? || readonly_field_changed? }
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
after_update_commit :update_blacklight_configuration_after_field_name_change, if: -> { saved_change_to_field? || saved_change_to_slug? }
|
24
|
+
after_update_commit :update_sidecar_data_after_field_name_change, if: -> { saved_change_to_field? || saved_change_to_slug? }
|
25
25
|
|
26
26
|
def label=(label)
|
27
27
|
configuration['label'] = label
|
@@ -4,6 +4,7 @@ require 'mail'
|
|
4
4
|
module Spotlight
|
5
5
|
##
|
6
6
|
# Spotlight exhibit
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
7
8
|
class Exhibit < ActiveRecord::Base
|
8
9
|
class_attribute :themes_selector
|
9
10
|
include Spotlight::ExhibitAnalytics
|
@@ -22,11 +23,16 @@ module Spotlight
|
|
22
23
|
paginates_per 48
|
23
24
|
|
24
25
|
extend FriendlyId
|
25
|
-
friendly_id :title, use: %i[slugged finders]
|
26
|
+
friendly_id :title, use: %i[slugged finders] do |config|
|
27
|
+
config.reserved_words&.concat(%w[site])
|
28
|
+
end
|
29
|
+
|
26
30
|
validates :title, presence: true, if: -> { I18n.locale == I18n.default_locale }
|
27
31
|
validates :slug, uniqueness: true
|
28
32
|
validates :theme, inclusion: { in: Spotlight::Engine.config.exhibit_themes }, allow_blank: true
|
29
33
|
|
34
|
+
after_validation :move_friendly_id_error_to_slug
|
35
|
+
|
30
36
|
acts_as_tagger
|
31
37
|
acts_as_taggable
|
32
38
|
delegate :blacklight_config, to: :blacklight_configuration
|
@@ -50,6 +56,7 @@ module Spotlight
|
|
50
56
|
has_many :custom_search_fields, dependent: :delete_all
|
51
57
|
|
52
58
|
has_many :feature_pages, -> { for_default_locale }, extend: FriendlyId::FinderMethods
|
59
|
+
has_many :groups, dependent: :delete_all
|
53
60
|
has_many :main_navigations, dependent: :delete_all
|
54
61
|
has_many :reindexing_log_entries, dependent: :destroy
|
55
62
|
has_many :resources
|
@@ -70,7 +77,7 @@ module Spotlight
|
|
70
77
|
belongs_to :masthead, dependent: :destroy, optional: true
|
71
78
|
belongs_to :thumbnail, class_name: 'Spotlight::ExhibitThumbnail', dependent: :destroy, optional: true
|
72
79
|
|
73
|
-
accepts_nested_attributes_for :about_pages, :attachments, :contacts, :custom_fields, :feature_pages, :languages,
|
80
|
+
accepts_nested_attributes_for :about_pages, :attachments, :contacts, :custom_fields, :feature_pages, :groups, :languages,
|
74
81
|
:main_navigations, :owned_taggings, :pages, :resources, :searches, :solr_document_sidecars, :translations
|
75
82
|
accepts_nested_attributes_for :blacklight_configuration, :home_page, :filters, update_only: true
|
76
83
|
accepts_nested_attributes_for :masthead, :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }
|
@@ -100,8 +107,10 @@ module Spotlight
|
|
100
107
|
end
|
101
108
|
|
102
109
|
def import(hash)
|
103
|
-
|
104
|
-
|
110
|
+
ActiveRecord::Base.transaction do
|
111
|
+
Spotlight::ExhibitImportExportService.new(self).from_hash!(hash)
|
112
|
+
save
|
113
|
+
end
|
105
114
|
end
|
106
115
|
|
107
116
|
def solr_data
|
@@ -149,5 +158,10 @@ module Spotlight
|
|
149
158
|
def current_reindexing_log_entry
|
150
159
|
reindexing_log_entries.started_or_completed.first || reindexing_log_entries.build
|
151
160
|
end
|
161
|
+
|
162
|
+
def move_friendly_id_error_to_slug
|
163
|
+
errors.add :slug, *errors.delete(:friendly_id) if errors[:friendly_id].present?
|
164
|
+
end
|
152
165
|
end
|
166
|
+
# rubocop:enable Metrics/ClassLength
|
153
167
|
end
|