blacklight-spotlight 4.2.0 → 4.3.1
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/javascripts/spotlight/spotlight.esm.js +120 -4
- data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
- data/app/assets/javascripts/spotlight/spotlight.js +120 -4
- data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
- data/app/controllers/concerns/spotlight/search_helper.rb +2 -2
- data/app/controllers/spotlight/appearances_controller.rb +1 -1
- data/app/controllers/spotlight/bulk_actions_controller.rb +1 -1
- data/app/controllers/spotlight/bulk_updates_controller.rb +1 -1
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/groups_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +1 -1
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/roles_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +1 -1
- data/app/controllers/spotlight/translations_controller.rb +2 -2
- data/app/helpers/spotlight/application_helper.rb +2 -2
- data/app/helpers/spotlight/crop_helper.rb +1 -1
- data/app/helpers/spotlight/pages_helper.rb +7 -0
- data/app/helpers/spotlight/title_helper.rb +2 -2
- data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +1 -1
- data/app/javascript/spotlight/admin/blocks/resources_block.js +82 -1
- data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +1 -1
- data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +21 -0
- data/app/javascript/spotlight/admin/sir-trevor/locales.js +11 -0
- data/app/jobs/concerns/spotlight/job_tracking.rb +1 -1
- data/app/jobs/spotlight/add_tags_job.rb +2 -2
- data/app/jobs/spotlight/add_uploads_from_csv.rb +1 -1
- data/app/jobs/spotlight/change_visibility_job.rb +2 -2
- data/app/jobs/spotlight/process_bulk_updates_csv_job.rb +2 -2
- data/app/jobs/spotlight/reindex_exhibit_job.rb +1 -1
- data/app/jobs/spotlight/reindex_job.rb +6 -6
- data/app/jobs/spotlight/remove_tags_job.rb +2 -2
- data/app/jobs/spotlight/rename_tags_job.rb +2 -2
- data/app/models/concerns/spotlight/exhibit_defaults.rb +1 -1
- data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
- data/app/models/concerns/spotlight/solr_document/finder.rb +4 -4
- data/app/models/concerns/spotlight/solr_document.rb +4 -4
- data/app/models/concerns/spotlight/translatables.rb +1 -1
- data/app/models/spotlight/analytics/ga.rb +1 -1
- data/app/models/spotlight/attachment.rb +1 -1
- data/app/models/spotlight/background_job_progress.rb +1 -1
- data/app/models/spotlight/contact_email.rb +1 -1
- data/app/models/spotlight/contact_form.rb +2 -2
- data/app/models/spotlight/custom_field.rb +2 -2
- data/app/models/spotlight/custom_search_field.rb +2 -2
- data/app/models/spotlight/job_tracker.rb +1 -1
- data/app/models/spotlight/page.rb +2 -2
- data/app/models/spotlight/resources/iiif_service.rb +4 -4
- data/app/models/spotlight/role.rb +1 -1
- data/app/models/spotlight/search.rb +9 -6
- data/app/services/spotlight/bulk_updates_csv_template_service.rb +2 -2
- data/app/services/spotlight/clone_translated_page_from_locale.rb +1 -1
- data/app/services/spotlight/etl/pipeline.rb +1 -1
- data/app/views/shared/_exhibit_navbar.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +3 -3
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +3 -3
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +3 -3
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +3 -3
- data/app/views/spotlight/sir_trevor/blocks/_uploaded_items_block.html.erb +3 -2
- data/lib/migration/iiif.rb +3 -3
- data/lib/spotlight/engine.rb +4 -17
- data/lib/spotlight/version.rb +1 -1
- data/lib/tasks/spotlight_tasks.rake +3 -3
- data/spec/factories/exhibits.rb +1 -1
- metadata +4 -4
@@ -6,14 +6,14 @@ module Spotlight
|
|
6
6
|
def search_service(user_params = respond_to?(:search_state, true) ? search_state.to_h : {})
|
7
7
|
klass = respond_to?(:search_service_class) ? search_service_class : Blacklight::SearchService
|
8
8
|
|
9
|
-
klass.new(config: blacklight_config, user_params
|
9
|
+
klass.new(config: blacklight_config, user_params:, **search_service_context)
|
10
10
|
end
|
11
11
|
|
12
12
|
# @return [Hash] a hash of context information to pass through to the search service
|
13
13
|
def search_service_context
|
14
14
|
return {} unless respond_to?(:current_ability)
|
15
15
|
|
16
|
-
{ current_ability:
|
16
|
+
{ current_ability: }
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -16,7 +16,7 @@ module Spotlight
|
|
16
16
|
def update
|
17
17
|
if @exhibit.update(exhibit_params)
|
18
18
|
notice = t(:'helpers.submit.spotlight_default.updated', model: @exhibit.class.model_name.human.downcase)
|
19
|
-
redirect_to edit_exhibit_appearance_path(@exhibit), notice:
|
19
|
+
redirect_to edit_exhibit_appearance_path(@exhibit), notice:
|
20
20
|
else
|
21
21
|
render 'edit'
|
22
22
|
end
|
@@ -46,7 +46,7 @@ module Spotlight
|
|
46
46
|
def csv_template
|
47
47
|
boolean = ActiveModel::Type::Boolean.new
|
48
48
|
Spotlight::BulkUpdatesCsvTemplateService.new(exhibit: current_exhibit).template(
|
49
|
-
view_context
|
49
|
+
view_context:,
|
50
50
|
title: boolean.cast(reference_field_params[:item_title]),
|
51
51
|
tags: boolean.cast(updatable_field_params[:tags]),
|
52
52
|
visibility: boolean.cast(updatable_field_params[:visibility])
|
@@ -7,7 +7,7 @@ module Spotlight
|
|
7
7
|
|
8
8
|
def create
|
9
9
|
if @featured_image.save && @featured_image.file_present?
|
10
|
-
render json: { tilesource
|
10
|
+
render json: { tilesource:, id: @featured_image.id }
|
11
11
|
else
|
12
12
|
render json: { error: 'unable to create image' }, status: :bad_request
|
13
13
|
end
|
@@ -50,7 +50,7 @@ module Spotlight
|
|
50
50
|
else
|
51
51
|
t(:'helpers.submit.group.batch_error', model: human_name)
|
52
52
|
end
|
53
|
-
redirect_to spotlight.exhibit_searches_path(anchor: 'browse-groups'), notice:
|
53
|
+
redirect_to spotlight.exhibit_searches_path(anchor: 'browse-groups'), notice:
|
54
54
|
end
|
55
55
|
|
56
56
|
protected
|
@@ -93,7 +93,7 @@ module Spotlight
|
|
93
93
|
else
|
94
94
|
t(:'helpers.submit.page.batch_error', model: human_name)
|
95
95
|
end
|
96
|
-
redirect_back fallback_location: spotlight.exhibit_dashboard_path(@exhibit), notice:
|
96
|
+
redirect_back fallback_location: spotlight.exhibit_dashboard_path(@exhibit), notice:
|
97
97
|
end
|
98
98
|
|
99
99
|
def clone
|
@@ -36,7 +36,7 @@ module Spotlight
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def data_param_keys
|
39
|
-
Spotlight::Resources::Upload.fields(current_exhibit).map(&:field_name) + current_exhibit.custom_fields.map(&:
|
39
|
+
Spotlight::Resources::Upload.fields(current_exhibit).map(&:field_name) + current_exhibit.custom_fields.map(&:slug)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Gets an IO-like object for the CSV parser to use.
|
@@ -24,7 +24,7 @@ module Spotlight
|
|
24
24
|
if @exhibit.update(exhibit_params)
|
25
25
|
notice = any_deleted ? t(:'helpers.submit.role.destroyed') : t(:'helpers.submit.role.updated')
|
26
26
|
Spotlight::InviteUsersService.call(resource: @exhibit)
|
27
|
-
redirect_to exhibit_roles_path(@exhibit), notice:
|
27
|
+
redirect_to exhibit_roles_path(@exhibit), notice:
|
28
28
|
else
|
29
29
|
flash[:alert] = t(:'helpers.submit.role.batch_error', count: exhibit_params[:roles_attributes].to_unsafe_h.size)
|
30
30
|
render action: 'index'
|
@@ -78,7 +78,7 @@ module Spotlight
|
|
78
78
|
else
|
79
79
|
t(:'helpers.submit.search.batch_error', model: Spotlight::Search.model_name.human.pluralize.downcase)
|
80
80
|
end
|
81
|
-
redirect_back fallback_location: fallback_url, notice:
|
81
|
+
redirect_back fallback_location: fallback_url, notice:
|
82
82
|
end
|
83
83
|
|
84
84
|
protected
|
@@ -21,7 +21,7 @@ module Spotlight
|
|
21
21
|
if current_exhibit.update(exhibit_params)
|
22
22
|
I18n.reload! # reload since we're memoizing
|
23
23
|
notice = t(:'helpers.submit.spotlight_default.updated', model: current_exhibit.class.model_name.human.downcase)
|
24
|
-
redirect_to edit_exhibit_translations_path(current_exhibit, language: @language, tab: @tab), notice:
|
24
|
+
redirect_to edit_exhibit_translations_path(current_exhibit, language: @language, tab: @tab), notice:
|
25
25
|
else
|
26
26
|
render 'edit'
|
27
27
|
end
|
@@ -31,7 +31,7 @@ module Spotlight
|
|
31
31
|
if current_exhibit.update(import_exhibit_params)
|
32
32
|
I18n.reload! # reload since we're memoizing
|
33
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:
|
34
|
+
redirect_to edit_exhibit_translations_path(current_exhibit, language: @language), notice:
|
35
35
|
else
|
36
36
|
render 'edit'
|
37
37
|
end
|
@@ -37,7 +37,7 @@ module Spotlight
|
|
37
37
|
initial_exception = nil
|
38
38
|
|
39
39
|
([self] + additional_locale_routing_scopes).each do |scope|
|
40
|
-
return scope.public_send(:url_for, params.to_unsafe_h.merge(locale:
|
40
|
+
return scope.public_send(:url_for, params.to_unsafe_h.merge(locale:))
|
41
41
|
rescue ActionController::UrlGenerationError => e
|
42
42
|
initial_exception ||= e
|
43
43
|
end
|
@@ -51,7 +51,7 @@ module Spotlight
|
|
51
51
|
|
52
52
|
# Can search for named routes directly in the main app, omitting
|
53
53
|
# the "main_app." prefix
|
54
|
-
def method_missing(method, *args, &
|
54
|
+
def method_missing(method, *args, &)
|
55
55
|
if main_app_url_helper?(method)
|
56
56
|
main_app.send(method, *args)
|
57
57
|
else
|
@@ -11,7 +11,7 @@ module Spotlight
|
|
11
11
|
concat f.hidden_field(:iiif_image_id)
|
12
12
|
concat f.hidden_field(:iiif_region)
|
13
13
|
concat f.hidden_field(:iiif_tilesource)
|
14
|
-
concat iiif_cropper_tag(f, initial_crop_selection:
|
14
|
+
concat iiif_cropper_tag(f, initial_crop_selection:)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -80,5 +80,12 @@ module Spotlight
|
|
80
80
|
def configurations_for_current_page
|
81
81
|
Spotlight::PageConfigurations.new(context: self, page: @page).as_json
|
82
82
|
end
|
83
|
+
|
84
|
+
def resource_alt_text(options, default)
|
85
|
+
return '' if options[:decorative].present?
|
86
|
+
return options[:alt_text] if options[:alt_text].present?
|
87
|
+
|
88
|
+
default
|
89
|
+
end
|
83
90
|
end
|
84
91
|
end
|
@@ -15,7 +15,7 @@ module Spotlight
|
|
15
15
|
def page_title(section, title = nil)
|
16
16
|
title ||= t(:'.header', default: '').presence
|
17
17
|
|
18
|
-
head_content = t(:'spotlight.html_admin_title', section
|
18
|
+
head_content = t(:'spotlight.html_admin_title', section:, title:) if section && title
|
19
19
|
head_content ||= section || title
|
20
20
|
set_html_page_title(head_content)
|
21
21
|
|
@@ -28,7 +28,7 @@ module Spotlight
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def set_html_page_title(title = nil)
|
31
|
-
@page_title = strip_tags(t(:'spotlight.html_title', title: title || t(:'.title', default: :'.header'), application_name:
|
31
|
+
@page_title = strip_tags(t(:'spotlight.html_title', title: title || t(:'.title', default: :'.header'), application_name:)).html_safe
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -82,7 +82,7 @@ SirTrevor.Blocks.BrowseGroupCategories = (function(){
|
|
82
82
|
},
|
83
83
|
|
84
84
|
item_options: function() { return `
|
85
|
-
|
85
|
+
<label>
|
86
86
|
<input type="hidden" name="display-item-counts" value="false" />
|
87
87
|
<input type="checkbox" name="display-item-counts" value="true" checked />
|
88
88
|
${i18n.t("blocks:browse_group_categories:item_counts")}
|
@@ -8,10 +8,24 @@ Core.Block.Resources = (function(){
|
|
8
8
|
formable: true,
|
9
9
|
autocompleteable: true,
|
10
10
|
show_heading: true,
|
11
|
+
show_alt_text: true,
|
11
12
|
|
12
13
|
title: function() { return i18n.t("blocks:" + this.type + ":title"); },
|
13
14
|
description: function() { return i18n.t("blocks:" + this.type + ":description"); },
|
14
|
-
|
15
|
+
alt_text_guidelines: function() {
|
16
|
+
if (this.show_alt_text) {
|
17
|
+
return i18n.t("blocks:alt_text_guidelines:intro");
|
18
|
+
}
|
19
|
+
return "";
|
20
|
+
},
|
21
|
+
alt_text_guidelines_link: function() {
|
22
|
+
if (this.show_alt_text) {
|
23
|
+
var link_url = i18n.t("blocks:alt_text_guidelines:link_url");
|
24
|
+
var link_label = i18n.t("blocks:alt_text_guidelines:link_label");
|
25
|
+
return '<a target="_blank" href="' + link_url + '">' + link_label + '</a>';
|
26
|
+
}
|
27
|
+
return "";
|
28
|
+
},
|
15
29
|
icon_name: "resources",
|
16
30
|
blockGroup: function() { return i18n.t("blocks:group:items") },
|
17
31
|
|
@@ -21,6 +35,8 @@ Core.Block.Resources = (function(){
|
|
21
35
|
show_secondary_field_key: "show-secondary-caption",
|
22
36
|
|
23
37
|
display_checkbox: "display-checkbox",
|
38
|
+
decorative_checkbox: "decorative-checkbox",
|
39
|
+
alt_text_textarea: "alt-text-textarea",
|
24
40
|
|
25
41
|
globalIndex: 0,
|
26
42
|
|
@@ -28,6 +44,13 @@ Core.Block.Resources = (function(){
|
|
28
44
|
return [];
|
29
45
|
},
|
30
46
|
|
47
|
+
_altTextFieldsHTML: function(index, data) {
|
48
|
+
if (this.show_alt_text) {
|
49
|
+
return this.altTextHTML(index, data);
|
50
|
+
}
|
51
|
+
return "";
|
52
|
+
},
|
53
|
+
|
31
54
|
_itemPanel: function(data) {
|
32
55
|
var index = "item_" + this.globalIndex++;
|
33
56
|
var checked;
|
@@ -58,6 +81,7 @@ Core.Block.Resources = (function(){
|
|
58
81
|
<div class="main">
|
59
82
|
<div class="title card-title">${data.title}</div>
|
60
83
|
<div>${(data.slug || data.id)}</div>
|
84
|
+
${this._altTextFieldsHTML(index, data)}
|
61
85
|
</div>
|
62
86
|
<div class="remove float-right float-end">
|
63
87
|
<a data-item-grid-panel-remove="true" href="#">${i18n.t("blocks:resources:panel:remove")}</a>
|
@@ -94,6 +118,7 @@ Core.Block.Resources = (function(){
|
|
94
118
|
|
95
119
|
createItemPanel: function(data) {
|
96
120
|
var panel = this._itemPanel(data);
|
121
|
+
this.attachAltTextHandlers(panel);
|
97
122
|
$(panel).appendTo($('.panels > ol', this.inner));
|
98
123
|
$('[data-behavior="nestable"]', this.inner).trigger('change');
|
99
124
|
},
|
@@ -126,11 +151,67 @@ Core.Block.Resources = (function(){
|
|
126
151
|
return `<div class="form resources-admin clearfix">
|
127
152
|
<div class="widget-header">
|
128
153
|
${this.description()}
|
154
|
+
${this.alt_text_guidelines()}
|
155
|
+
${this.alt_text_guidelines_link()}
|
129
156
|
</div>
|
130
157
|
${this.content()}
|
131
158
|
</div>`
|
132
159
|
},
|
133
160
|
|
161
|
+
_altTextData: function(data) {
|
162
|
+
const isDecorative = data.decorative;
|
163
|
+
const altText = isDecorative ? '' : (data.alt_text || '');
|
164
|
+
const altTextBackup = data.alt_text_backup || '';
|
165
|
+
const placeholderAttr = isDecorative ? '' : `placeholder="${i18n.t("blocks:resources:alt_text:placeholder")}"`;
|
166
|
+
const disabledAttr = isDecorative ? 'disabled' : '';
|
167
|
+
|
168
|
+
return { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr };
|
169
|
+
},
|
170
|
+
|
171
|
+
altTextHTML: function(index, data) {
|
172
|
+
const { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr } = this._altTextData(data);
|
173
|
+
return `<div class="mt-2 pt-2 d-flex">
|
174
|
+
<div class="me-2 mr-2">
|
175
|
+
<label class="col-form-label pb-0 pt-1" for="${this.formId(this.alt_text_textarea + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:alternative_text")}</label>
|
176
|
+
<div class="form-check mb-1 justify-content-end">
|
177
|
+
<input class="form-check-input" type="checkbox"
|
178
|
+
id="${this.formId(this.decorative_checkbox + '_' + data.id)}" name="item[${index}][decorative]" ${isDecorative ? 'checked' : ''}>
|
179
|
+
<label class="form-check-label" for="${this.formId(this.decorative_checkbox + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:decorative")}</label>
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
<div class="flex-grow-1 flex-fill d-flex">
|
183
|
+
<input type="hidden" name="item[${index}][alt_text_backup]" value="${altTextBackup}" />
|
184
|
+
<textarea class="form-control w-100" rows="2" ${placeholderAttr}
|
185
|
+
id="${this.formId(this.alt_text_textarea + '_' + data.id)}" name="item[${index}][alt_text]" ${disabledAttr}>${altText}</textarea>
|
186
|
+
</div>
|
187
|
+
</div>`
|
188
|
+
},
|
189
|
+
|
190
|
+
attachAltTextHandlers: function(panel) {
|
191
|
+
if (this.show_alt_text) {
|
192
|
+
const decorativeCheckbox = $('input[name$="[decorative]"]', panel);
|
193
|
+
const altTextInput = $('textarea[name$="[alt_text]"]', panel);
|
194
|
+
const altTextBackupInput = $('input[name$="[alt_text_backup]"]', panel);
|
195
|
+
|
196
|
+
decorativeCheckbox.on('change', function() {
|
197
|
+
const isDecorative = this.checked;
|
198
|
+
if (isDecorative) {
|
199
|
+
altTextBackupInput.val(altTextInput.val());
|
200
|
+
altTextInput.val('');
|
201
|
+
} else {
|
202
|
+
altTextInput.val(altTextBackupInput.val());
|
203
|
+
}
|
204
|
+
altTextInput
|
205
|
+
.prop('disabled', isDecorative)
|
206
|
+
.attr('placeholder', isDecorative ? '' : i18n.t("blocks:resources:alt_text:placeholder"));
|
207
|
+
});
|
208
|
+
|
209
|
+
altTextInput.on('input', function() {
|
210
|
+
$(this).data('lastValue', $(this).val());
|
211
|
+
});
|
212
|
+
}
|
213
|
+
},
|
214
|
+
|
134
215
|
onBlockRender: function() {
|
135
216
|
SpotlightNestable.init($('[data-behavior="nestable"]', this.inner));
|
136
217
|
|
@@ -96,6 +96,7 @@ SirTrevor.Blocks.UploadedItems = (function(){
|
|
96
96
|
<label for="${this.formId('link_' + dataId)}" class="col-form-label col-md-3">${i18n.t("blocks:uploaded_items:link")}</label>
|
97
97
|
<input type="text" class="form-control col" id="${this.formId('link_' + dataId)}" name="item[${index}][link]" data-field="link"/>
|
98
98
|
</div>
|
99
|
+
${this._altTextFieldsHTML(index, data)}
|
99
100
|
</div>
|
100
101
|
<div class="remove float-right float-end">
|
101
102
|
<a data-item-grid-panel-remove="true" href="#">${i18n.t("blocks:resources:panel:remove")}</a>
|
@@ -123,6 +124,8 @@ SirTrevor.Blocks.UploadedItems = (function(){
|
|
123
124
|
return `<div class="form oembed-text-admin clearfix">
|
124
125
|
<div class="widget-header">
|
125
126
|
${this.description()}
|
127
|
+
${this.alt_text_guidelines()}
|
128
|
+
${this.alt_text_guidelines_link()}
|
126
129
|
</div>
|
127
130
|
<div class="row">
|
128
131
|
<div class="form-group mb-3 col-md-8">
|
@@ -142,6 +145,24 @@ SirTrevor.Blocks.UploadedItems = (function(){
|
|
142
145
|
</div>`
|
143
146
|
},
|
144
147
|
|
148
|
+
altTextHTML: function(index, data) {
|
149
|
+
const { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr } = this._altTextData(data);
|
150
|
+
return `
|
151
|
+
<div class="field row mr-3 me-3">
|
152
|
+
<div class="col-lg-3 ps-md-2 pl-md-2">
|
153
|
+
<label class="col-form-label text-nowrap pb-0 pt-1 justify-content-md-start justify-content-lg-end d-flex" for="${this.formId(this.alt_text_textarea + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:alternative_text")}</label>
|
154
|
+
<div class="form-check d-flex justify-content-md-start justify-content-lg-end">
|
155
|
+
<input class="form-check-input" type="checkbox"
|
156
|
+
id="${this.formId(this.decorative_checkbox + '_' + data.id)}" name="item[${index}][decorative]" ${isDecorative ? 'checked' : ''}>
|
157
|
+
<label class="form-check-label" for="${this.formId(this.decorative_checkbox + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:decorative")}</label>
|
158
|
+
</div>
|
159
|
+
</div>
|
160
|
+
<input type="hidden" name="item[${index}][alt_text_backup]" value="${altTextBackup}" />
|
161
|
+
<textarea class="col-lg-9" rows="2" ${placeholderAttr}
|
162
|
+
id="${this.formId(this.alt_text_textarea + '_' + data.id)}" name="item[${index}][alt_text]" ${disabledAttr}>${altText}</textarea>
|
163
|
+
</div>`
|
164
|
+
},
|
165
|
+
|
145
166
|
zpr_key: 'zpr_link'
|
146
167
|
});
|
147
168
|
})();
|
@@ -51,6 +51,11 @@ SirTrevor.Locales.en.blocks = $.extend(SirTrevor.Locales.en.blocks, {
|
|
51
51
|
drag: "Drag",
|
52
52
|
display: "Display?",
|
53
53
|
remove: "Remove"
|
54
|
+
},
|
55
|
+
alt_text: {
|
56
|
+
decorative: "Decorative",
|
57
|
+
alternative_text: "Alternative text",
|
58
|
+
placeholder: "Enter alt text for this item..."
|
54
59
|
}
|
55
60
|
},
|
56
61
|
|
@@ -116,5 +121,11 @@ SirTrevor.Locales.en.blocks = $.extend(SirTrevor.Locales.en.blocks, {
|
|
116
121
|
group: {
|
117
122
|
undefined: "Standard widgets",
|
118
123
|
items: "Exhibit item widgets"
|
124
|
+
},
|
125
|
+
|
126
|
+
alt_text_guidelines: {
|
127
|
+
intro: 'For each item, please enter alternative text or appropriately check the decorative box. ',
|
128
|
+
link_label: 'Guidelines for writing alt text.',
|
129
|
+
link_url: 'https://www.w3.org/WAI/tutorials/images/'
|
119
130
|
}
|
120
131
|
});
|
@@ -55,7 +55,7 @@ module Spotlight
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def find_or_initialize_job_tracker
|
58
|
-
JobTracker.find_or_create_by(job_id:
|
58
|
+
JobTracker.find_or_create_by(job_id:) do |tracker|
|
59
59
|
tracker.job_class = self.class.name
|
60
60
|
tracker.status = 'enqueued'
|
61
61
|
end
|
@@ -19,12 +19,12 @@ module Spotlight
|
|
19
19
|
document.reindex(update_params: {})
|
20
20
|
progress&.increment
|
21
21
|
rescue StandardError => e
|
22
|
-
job_tracker.append_log_entry(type: :error, exhibit
|
22
|
+
job_tracker.append_log_entry(type: :error, exhibit:, message: e.to_s)
|
23
23
|
@errors += 1
|
24
24
|
mark_job_as_failed!
|
25
25
|
end
|
26
26
|
exhibit.blacklight_config.repository.connection.commit
|
27
|
-
job_tracker.append_log_entry(type: :info, exhibit
|
27
|
+
job_tracker.append_log_entry(type: :info, exhibit:, message: "#{progress.progress} of #{progress.total} (#{@errors} errors)")
|
28
28
|
end
|
29
29
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
30
30
|
end
|
@@ -21,12 +21,12 @@ module Spotlight
|
|
21
21
|
document.reindex(update_params: {})
|
22
22
|
progress&.increment
|
23
23
|
rescue StandardError => e
|
24
|
-
job_tracker.append_log_entry(type: :error, exhibit
|
24
|
+
job_tracker.append_log_entry(type: :error, exhibit:, message: e.to_s)
|
25
25
|
@errors += 1
|
26
26
|
mark_job_as_failed!
|
27
27
|
end
|
28
28
|
exhibit.blacklight_config.repository.connection.commit
|
29
|
-
job_tracker.append_log_entry(type: :info, exhibit
|
29
|
+
job_tracker.append_log_entry(type: :info, exhibit:, message: "#{progress.progress} of #{progress.total} (#{@errors} errors)")
|
30
30
|
end
|
31
31
|
# rubocop:enable Metrics/MethodLength
|
32
32
|
end
|
@@ -20,13 +20,13 @@ module Spotlight
|
|
20
20
|
process_row(exhibit, row)
|
21
21
|
progress&.increment
|
22
22
|
rescue StandardError => e
|
23
|
-
job_tracker.append_log_entry(type: :error, exhibit
|
23
|
+
job_tracker.append_log_entry(type: :error, exhibit:, message: e.to_s)
|
24
24
|
errors += 1
|
25
25
|
mark_job_as_failed!
|
26
26
|
end
|
27
27
|
|
28
28
|
exhibit.blacklight_config.repository.connection.commit
|
29
|
-
job_tracker.append_log_entry(type: :info, exhibit
|
29
|
+
job_tracker.append_log_entry(type: :info, exhibit:, message: "#{progress&.progress} of #{progress&.total} (#{errors} errors)")
|
30
30
|
end
|
31
31
|
end
|
32
32
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -30,7 +30,7 @@ module Spotlight
|
|
30
30
|
|
31
31
|
def perform_later_in_batches(exhibit, of:)
|
32
32
|
last = 0
|
33
|
-
exhibit.resources.select(:id).in_batches(of:
|
33
|
+
exhibit.resources.select(:id).in_batches(of:) do |batch|
|
34
34
|
last = batch.last.id
|
35
35
|
Spotlight::ReindexJob.perform_later(exhibit, reports_on: job_tracker, start: batch.first.id, finish: batch.last.id)
|
36
36
|
end
|
@@ -29,7 +29,7 @@ module Spotlight
|
|
29
29
|
error_handler = lambda do |pipeline, exception, _data|
|
30
30
|
job_tracker.append_log_entry(
|
31
31
|
type: :error,
|
32
|
-
exhibit
|
32
|
+
exhibit:,
|
33
33
|
message: exception.to_s,
|
34
34
|
backtrace: exception.backtrace.first(5).join("\n"),
|
35
35
|
resource_id: (pipeline.source.id if pipeline.source.respond_to?(:id))
|
@@ -38,8 +38,8 @@ module Spotlight
|
|
38
38
|
errors += 1
|
39
39
|
end
|
40
40
|
|
41
|
-
resource_list(exhibit_or_resources, start
|
42
|
-
resource.reindex(touch: false, commit: false, job_tracker
|
41
|
+
resource_list(exhibit_or_resources, start:, finish:).each do |resource|
|
42
|
+
resource.reindex(touch: false, commit: false, job_tracker:, additional_data: job_data, on_error: error_handler) do |*|
|
43
43
|
progress&.increment
|
44
44
|
end
|
45
45
|
rescue StandardError => e
|
@@ -48,14 +48,14 @@ module Spotlight
|
|
48
48
|
|
49
49
|
job_tracker.append_log_entry(
|
50
50
|
type: :summary,
|
51
|
-
exhibit
|
51
|
+
exhibit:,
|
52
52
|
message: I18n.t(
|
53
53
|
'spotlight.job_trackers.show.messages.status.in_progress',
|
54
54
|
progress: progress.progress,
|
55
55
|
total: progress.total,
|
56
56
|
errors: (I18n.t('spotlight.job_trackers.show.messages.errors', count: errors) if errors.positive?)
|
57
57
|
),
|
58
|
-
progress: progress.progress, total: progress.total, errors:
|
58
|
+
progress: progress.progress, total: progress.total, errors:
|
59
59
|
)
|
60
60
|
end
|
61
61
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -85,7 +85,7 @@ module Spotlight
|
|
85
85
|
|
86
86
|
def resource_list(exhibit_or_resources, start: nil, finish: nil)
|
87
87
|
if exhibit_or_resources.is_a?(Spotlight::Exhibit)
|
88
|
-
exhibit_or_resources.resources.find_each(start
|
88
|
+
exhibit_or_resources.resources.find_each(start:, finish:)
|
89
89
|
else
|
90
90
|
Array(exhibit_or_resources)
|
91
91
|
end
|
@@ -19,12 +19,12 @@ module Spotlight
|
|
19
19
|
document.reindex(update_params: {})
|
20
20
|
progress&.increment
|
21
21
|
rescue StandardError => e
|
22
|
-
job_tracker.append_log_entry(type: :error, exhibit
|
22
|
+
job_tracker.append_log_entry(type: :error, exhibit:, message: e.to_s)
|
23
23
|
@errors += 1
|
24
24
|
mark_job_as_failed!
|
25
25
|
end
|
26
26
|
exhibit.blacklight_config.repository.connection.commit
|
27
|
-
job_tracker.append_log_entry(type: :info, exhibit
|
27
|
+
job_tracker.append_log_entry(type: :info, exhibit:, message: "#{progress.progress} of #{progress.total} (#{@errors} errors)")
|
28
28
|
end
|
29
29
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
30
30
|
end
|
@@ -20,13 +20,13 @@ module Spotlight
|
|
20
20
|
exhibit.tag(sidecar, with: all_tags, on: :tags)
|
21
21
|
sidecar.document.reindex(update_params: {})
|
22
22
|
rescue StandardError => e
|
23
|
-
job_tracker.append_log_entry(type: :error, exhibit
|
23
|
+
job_tracker.append_log_entry(type: :error, exhibit:, message: e.to_s)
|
24
24
|
@errors += 1
|
25
25
|
mark_job_as_failed!
|
26
26
|
end
|
27
27
|
|
28
28
|
exhibit.blacklight_config.repository.connection.commit
|
29
|
-
job_tracker.append_log_entry(type: :info, exhibit
|
29
|
+
job_tracker.append_log_entry(type: :info, exhibit:, message: "#{progress.progress} of #{progress.total} (#{@errors} errors)")
|
30
30
|
end
|
31
31
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
32
32
|
end
|
@@ -8,7 +8,7 @@ module Spotlight
|
|
8
8
|
# filtered by the exhibit-specific solr field.
|
9
9
|
#
|
10
10
|
# @return [Enumerable<SolrDocument>]
|
11
|
-
def solr_documents(&
|
11
|
+
def solr_documents(&)
|
12
12
|
return to_enum(:solr_documents) unless block_given?
|
13
13
|
|
14
14
|
start = 0
|
@@ -17,7 +17,7 @@ module Spotlight
|
|
17
17
|
response = repository.search(search_params.start(start).to_h)
|
18
18
|
|
19
19
|
while response.documents.present?
|
20
|
-
response.documents.each(&
|
20
|
+
response.documents.each(&)
|
21
21
|
start += response.documents.length
|
22
22
|
response = repository.search(search_params.start(start).to_h)
|
23
23
|
end
|
@@ -19,17 +19,17 @@ module Spotlight
|
|
19
19
|
@index ||= blacklight_config.repository_class.new(blacklight_config)
|
20
20
|
end
|
21
21
|
|
22
|
-
def find_each(&
|
22
|
+
def find_each(&)
|
23
23
|
return to_enum(:find_each) unless block_given?
|
24
24
|
|
25
25
|
start = 0
|
26
26
|
search_params = { q: '*:*', fl: 'id', facet: false }
|
27
|
-
response = index.search(search_params.merge(start:
|
27
|
+
response = index.search(search_params.merge(start:))
|
28
28
|
|
29
29
|
while response.documents.present?
|
30
|
-
response.documents.each(&
|
30
|
+
response.documents.each(&)
|
31
31
|
start += response.documents.length
|
32
|
-
response = index.search(search_params.merge(start:
|
32
|
+
response = index.search(search_params.merge(start:))
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -87,7 +87,7 @@ module Spotlight
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def sidecar(exhibit)
|
90
|
-
sidecars.find_or_initialize_by exhibit
|
90
|
+
sidecars.find_or_initialize_by exhibit:, document_id: id, document_type: self.class.to_s
|
91
91
|
end
|
92
92
|
|
93
93
|
def to_solr
|
@@ -156,12 +156,12 @@ module Spotlight
|
|
156
156
|
deep_compact(attributes)
|
157
157
|
end
|
158
158
|
|
159
|
-
def deep_transform_values(object, &
|
159
|
+
def deep_transform_values(object, &)
|
160
160
|
# Available in Rails 6
|
161
161
|
if object.respond_to?(:deep_transform_values)
|
162
|
-
object.deep_transform_values(&
|
162
|
+
object.deep_transform_values(&)
|
163
163
|
else
|
164
|
-
_deep_transform_values(object, &
|
164
|
+
_deep_transform_values(object, &)
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|