blacklight-spotlight 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/app/assets/javascripts/spotlight/blocks/link_to_search_block.js +16 -0
- data/app/assets/javascripts/spotlight/exhibits.js +16 -5
- data/app/assets/javascripts/spotlight/form_observer.js +2 -2
- data/app/assets/javascripts/spotlight/pages.js.erb +3 -2
- data/app/assets/javascripts/spotlight/sir-trevor/locales.js +6 -0
- data/app/controllers/spotlight/concerns/application_controller.rb +4 -8
- data/app/controllers/spotlight/contact_email_controller.rb +22 -0
- data/app/controllers/spotlight/searches_controller.rb +3 -1
- data/app/models/concerns/spotlight/blacklight_configuration_defaults.rb +4 -4
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +7 -1
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +3 -1
- data/app/models/sir_trevor_rails/blocks/link_to_search_block.rb +15 -0
- data/app/models/spotlight/ability.rb +1 -1
- data/app/models/spotlight/blacklight_configuration.rb +8 -7
- data/app/models/spotlight/exhibit.rb +2 -0
- data/app/models/spotlight/resource.rb +8 -2
- data/app/services/spotlight/carrierwave_file_resolver.rb +5 -0
- data/app/services/spotlight/upload_solr_document_builder.rb +2 -2
- data/app/views/spotlight/appearances/edit.html.erb +1 -1
- data/app/views/spotlight/exhibits/_confirmation_status.html.erb +1 -1
- data/app/views/spotlight/exhibits/_contact.html.erb +15 -10
- data/app/views/spotlight/exhibits/_exhibit_card_back.html.erb +2 -2
- data/app/views/spotlight/exhibits/_form.html.erb +7 -6
- data/app/views/spotlight/metadata_configurations/edit.html.erb +1 -1
- data/app/views/spotlight/pages/_form.html.erb +1 -1
- data/app/views/spotlight/search_configurations/_facets.html.erb +1 -1
- data/app/views/spotlight/search_configurations/_search_fields.html.erb +1 -1
- data/app/views/spotlight/search_configurations/_sort.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +23 -0
- data/config/locales/spotlight.en.yml +9 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20171005231502_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +23 -0
- data/lib/spotlight/engine.rb +4 -3
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +15 -15
- data/spec/controllers/spotlight/admin_users_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/appearances_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/application_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/attachments_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/browse_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/catalog_controller_spec.rb +15 -15
- data/spec/controllers/spotlight/confirmations_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/contact_email_controller_spec.rb +63 -0
- data/spec/controllers/spotlight/contact_forms_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/contacts_controller_spec.rb +5 -5
- data/spec/controllers/spotlight/custom_fields_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/dashboards_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/exhibits_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +12 -12
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/filters_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +5 -5
- data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/roles_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/search_configurations_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/searches_controller_spec.rb +10 -11
- data/spec/controllers/spotlight/sites_controller_spec.rb +5 -5
- data/spec/controllers/spotlight/solr_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/tags_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/versions_controller_spec.rb +7 -7
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +3 -3
- data/spec/examples.txt +1154 -1136
- data/spec/factories/contact_emails.rb +6 -0
- data/spec/factories/contact_images.rb +1 -1
- data/spec/factories/contacts.rb +1 -1
- data/spec/factories/custom_fields.rb +1 -1
- data/spec/factories/exhibit_thumbnails.rb +1 -1
- data/spec/factories/exhibits.rb +2 -2
- data/spec/factories/featured_images.rb +1 -1
- data/spec/factories/pages.rb +2 -2
- data/spec/factories/reindexing_log_entries.rb +1 -1
- data/spec/factories/resources.rb +1 -1
- data/spec/factories/roles.rb +2 -2
- data/spec/factories/searches.rb +3 -3
- data/spec/factories/tags.rb +3 -3
- data/spec/factories/users.rb +2 -2
- data/spec/features/about_page_spec.rb +6 -6
- data/spec/features/add_contacts_spec.rb +3 -3
- data/spec/features/add_custom_field_metadata_spec.rb +4 -4
- data/spec/features/add_iiif_manifest_spec.rb +2 -2
- data/spec/features/add_items_spec.rb +4 -4
- data/spec/features/autocomplete_typeahead_spec.rb +3 -4
- data/spec/features/browse_category_admin_spec.rb +3 -3
- data/spec/features/browse_category_spec.rb +3 -3
- data/spec/features/catalog_spec.rb +3 -3
- data/spec/features/confirm_email_spec.rb +1 -1
- data/spec/features/create_exhibit_spec.rb +1 -1
- data/spec/features/create_page_spec.rb +5 -5
- data/spec/features/curator_items.rb +2 -2
- data/spec/features/dashboard_spec.rb +4 -4
- data/spec/features/edit_contact_spec.rb +4 -4
- data/spec/features/edit_search_fields_spec.rb +2 -2
- data/spec/features/exhibit_masthead_spec.rb +2 -2
- data/spec/features/exhibit_themes_spec.rb +2 -2
- data/spec/features/exhibits/add_tags_spec.rb +3 -3
- data/spec/features/exhibits/administration_spec.rb +78 -4
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +2 -2
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +2 -2
- data/spec/features/exhibits_index_spec.rb +3 -3
- data/spec/features/feature_page_spec.rb +9 -9
- data/spec/features/home_page_spec.rb +4 -4
- data/spec/features/import_exhibit_spec.rb +2 -2
- data/spec/features/item_admin_spec.rb +2 -2
- data/spec/features/javascript/about_page_admin_spec.rb +2 -2
- data/spec/features/javascript/block_controls_spec.rb +2 -2
- data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +5 -5
- data/spec/features/javascript/blocks/featured_pages_block_spec.rb +4 -4
- data/spec/features/javascript/blocks/link_to_search_block_spec.rb +44 -0
- data/spec/features/javascript/{rule_block_spec.rb → blocks/rule_block_spec.rb} +4 -4
- data/spec/features/javascript/blocks/search_result_block_spec.rb +4 -4
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +5 -6
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +3 -4
- data/spec/features/javascript/edit_in_place_spec.rb +2 -2
- data/spec/features/javascript/feature_page_admin_spec.rb +26 -7
- data/spec/features/javascript/home_page_edit_spec.rb +3 -3
- data/spec/features/javascript/metadata_admin_spec.rb +2 -2
- data/spec/features/javascript/multi_image_select_spec.rb +6 -6
- data/spec/features/javascript/reindex_monitor_spec.rb +4 -4
- data/spec/features/javascript/roles_admin_spec.rb +3 -3
- data/spec/features/javascript/search_config_admin_spec.rb +2 -3
- data/spec/features/javascript/search_context_spec.rb +6 -6
- data/spec/features/main_navigation_spec.rb +2 -2
- data/spec/features/metadata_admin_spec.rb +2 -2
- data/spec/features/report_a_problem_spec.rb +2 -2
- data/spec/features/site_admin_management_spec.rb +4 -4
- data/spec/features/site_masthead_spec.rb +1 -1
- data/spec/features/slideshow_spec.rb +4 -3
- data/spec/features/tags_admin_spec.rb +3 -3
- data/spec/features/user_admin_spec.rb +2 -2
- data/spec/helpers/spotlight/application_helper_spec.rb +2 -2
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +1 -1
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +3 -3
- data/spec/helpers/spotlight/meta_helper_spec.rb +1 -1
- data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +3 -3
- data/spec/jobs/spotlight/reindex_job_spec.rb +3 -3
- data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +1 -1
- data/spec/lib/migration/iiif_spec.rb +3 -3
- data/spec/lib/spotlight/controller_spec.rb +3 -3
- data/spec/models/sir_trevor_rails/blocks/browse_block_spec.rb +19 -1
- data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +9 -1
- data/spec/models/sir_trevor_rails/blocks/search_results_block_spec.rb +1 -1
- data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +2 -2
- data/spec/models/spotlight/ability_spec.rb +9 -9
- data/spec/models/spotlight/about_page_spec.rb +1 -1
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -1
- data/spec/models/spotlight/blacklight_configuration_spec.rb +15 -1
- data/spec/models/spotlight/contact_email_spec.rb +1 -1
- data/spec/models/spotlight/contact_form_spec.rb +1 -1
- data/spec/models/spotlight/contact_spec.rb +1 -1
- data/spec/models/spotlight/custom_field_spec.rb +5 -5
- data/spec/models/spotlight/exhibit_spec.rb +20 -16
- data/spec/models/spotlight/feature_page_spec.rb +14 -14
- data/spec/models/spotlight/field_metadata_spec.rb +1 -1
- data/spec/models/spotlight/home_page_spec.rb +1 -1
- data/spec/models/spotlight/main_navigation_spec.rb +1 -1
- data/spec/models/spotlight/page_spec.rb +12 -8
- data/spec/models/spotlight/reindex_progress_spec.rb +4 -4
- data/spec/models/spotlight/reindexing_log_entry_spec.rb +8 -8
- data/spec/models/spotlight/resource_spec.rb +12 -1
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +1 -1
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +1 -1
- data/spec/models/spotlight/resources/upload_spec.rb +3 -3
- data/spec/models/spotlight/role_spec.rb +3 -3
- data/spec/models/spotlight/search_spec.rb +7 -7
- data/spec/models/spotlight/sitemap_spec.rb +6 -6
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -1
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +1 -1
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +20 -20
- data/spec/services/spotlight/carrierwave_file_resolver_spec.rb +1 -1
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/services/spotlight/solr_document_builder_spec.rb +3 -3
- data/spec/spec_helper.rb +4 -5
- data/spec/support/features/test_features_helpers.rb +2 -2
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +1 -1
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +9 -9
- data/spec/views/shared/_masthead.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +4 -4
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +1 -1
- 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/dashboards/analytics.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/exhibits/_exhibit_card_front.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +8 -8
- data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/pages/_form.html.erb_spec.rb +18 -0
- data/spec/views/spotlight/roles/index.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +14 -2
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +9 -2
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +10 -1
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +8 -8
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb_spec.rb +18 -0
- data/spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/tags/index.html.erb_spec.rb +3 -3
- metadata +226 -200
- data/app/assets/stylesheets/spotlight/application.scss +0 -5
- data/vendor/assets/javascripts/leaflet.js +0 -9
- data/vendor/assets/stylesheets/leaflet.css +0 -624
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6301051ced974a8d8437609d2dd11d82551a2dc0
|
|
4
|
+
data.tar.gz: 1a3d296988ee287cb7aa9575eb4e6a3936222fee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5deb0cdcfb5bd95631a649c14b2b45456ff2767977507e2cb87987512f18b06d40ecce3c87afc9af47e2b8a32e3ad45119bb70b13a1d98415ff0b11f7c2163e6
|
|
7
|
+
data.tar.gz: 200ae22837964033cfc064f50751085e1df04c3209100bacf89e9130a214d12a18d7d536a12469b98d9e436c359f2f619413d7ea91c9e641a1d45af5f0bf628f
|
data/README.md
CHANGED
|
@@ -81,10 +81,6 @@ Our `$ rake ci` and `$ rake spotlight:server` tasks utilize Solr and the testing
|
|
|
81
81
|
|
|
82
82
|
## Tests
|
|
83
83
|
|
|
84
|
-
### Prerequisites
|
|
85
|
-
|
|
86
|
-
PhantomJS (https://github.com/teampoltergeist/poltergeist#installing-phantomjs) is an addition requirement for testing javascript.
|
|
87
|
-
|
|
88
84
|
### Run all the tests:
|
|
89
85
|
|
|
90
86
|
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//= require spotlight/blocks/browse_block
|
|
2
|
+
|
|
3
|
+
SirTrevor.Blocks.LinkToSearch = (function(){
|
|
4
|
+
|
|
5
|
+
return SirTrevor.Blocks.Browse.extend({
|
|
6
|
+
|
|
7
|
+
type: "link_to_search",
|
|
8
|
+
|
|
9
|
+
icon_name: 'search_results',
|
|
10
|
+
|
|
11
|
+
searches_key: "slug",
|
|
12
|
+
view_key: "view",
|
|
13
|
+
plustextable: false,
|
|
14
|
+
|
|
15
|
+
});
|
|
16
|
+
})();
|
|
@@ -16,21 +16,32 @@ Spotlight.onLoad(function() {
|
|
|
16
16
|
$("#another-email").on("click", function() {
|
|
17
17
|
var container = $(this).closest('.form-group');
|
|
18
18
|
var contacts = container.find('.contact');
|
|
19
|
-
var
|
|
19
|
+
var inputContainer = contacts.first().clone();
|
|
20
20
|
|
|
21
21
|
// wipe out any values from the inputs
|
|
22
|
-
|
|
22
|
+
inputContainer.find('input').each(function() {
|
|
23
23
|
$(this).val('');
|
|
24
24
|
$(this).attr('id', $(this).attr('id').replace('0', contacts.length));
|
|
25
25
|
$(this).attr('name', $(this).attr('name').replace('0', contacts.length));
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
inputContainer.find('.contact-email-delete-wrapper').remove();
|
|
29
|
+
inputContainer.find('.confirmation-status').remove();
|
|
29
30
|
|
|
30
31
|
// bootstrap does not render input-groups with only one value in them correctly.
|
|
31
|
-
|
|
32
|
+
inputContainer.find('.input-group input:only-child').closest('.input-group').removeClass('input-group');
|
|
32
33
|
|
|
33
|
-
$(
|
|
34
|
+
$(inputContainer).insertAfter(contacts.last());
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$('.contact-email-delete').on('ajax:success', function() {
|
|
38
|
+
$(this).closest('.contact').fadeOut(250, function() { $(this).remove(); });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
$('.contact-email-delete').on('ajax:error', function(event, _xhr, _status, error) {
|
|
42
|
+
var errSpan = $(this).closest('.contact').find('.contact-email-delete-error');
|
|
43
|
+
errSpan.show();
|
|
44
|
+
errSpan.find('.error-msg').first().text(error || event.detail[1]);
|
|
34
45
|
});
|
|
35
46
|
|
|
36
47
|
$('.btn-with-tooltip').tooltip();
|
|
@@ -52,7 +52,7 @@ function observedFormsStatusHasChanged(){
|
|
|
52
52
|
// Compare stored and current form serializations
|
|
53
53
|
// to determine if the form has changed before
|
|
54
54
|
// unload and before any turbolinks change event
|
|
55
|
-
$(window).on('beforeunload page:before-change', function(event) {
|
|
55
|
+
$(window).on('beforeunload page:before-change turbolinks:before-cache', function(event) {
|
|
56
56
|
if ( observedFormsStatusHasChanged() ) {
|
|
57
57
|
var message = "You have unsaved changes. Are you sure you want to leave this page?";
|
|
58
58
|
if ( event.type == "beforeunload" ) {
|
|
@@ -61,4 +61,4 @@ $(window).on('beforeunload page:before-change', function(event) {
|
|
|
61
61
|
return confirm(message)
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
});
|
|
64
|
+
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// Place all the behaviors and hooks related to the matching controller here.
|
|
2
2
|
// All this logic will automatically be available in application.js.
|
|
3
3
|
Spotlight.onLoad(function(){
|
|
4
|
-
|
|
4
|
+
// Set a ujs adapter to support both rails-ujs and jquery-ujs
|
|
5
|
+
var ujs = typeof Rails === 'undefined' ? $.rails : Rails;
|
|
5
6
|
SirTrevor.setDefaults({
|
|
6
7
|
iconUrl: <%= asset_path('spotlight/blocks/sir-trevor-icons.svg').to_json %>,
|
|
7
8
|
uploadUrl: $('[data-attachment-endpoint]').data('attachment-endpoint'),
|
|
8
9
|
ajaxOptions: {
|
|
9
10
|
headers: {
|
|
10
|
-
'X-CSRF-Token':
|
|
11
|
+
'X-CSRF-Token': ujs.csrfToken() || ''
|
|
11
12
|
},
|
|
12
13
|
credentials: 'same-origin'
|
|
13
14
|
}
|
|
@@ -9,6 +9,12 @@ SirTrevor.Locales.en.blocks = $.extend(SirTrevor.Locales.en.blocks, {
|
|
|
9
9
|
item_counts: "Include item counts?"
|
|
10
10
|
},
|
|
11
11
|
|
|
12
|
+
link_to_search: {
|
|
13
|
+
title: "Saved Searches",
|
|
14
|
+
description: "This widget highlights saved searches. Each highlighted saved search links to the search results page generated by the saved search parameters. Any saved search listed on the Curation > Browse Categories page, whether published or not, can be highlighted as a saved search.",
|
|
15
|
+
item_counts: "Include item counts?"
|
|
16
|
+
},
|
|
17
|
+
|
|
12
18
|
iframe: {
|
|
13
19
|
title: "IFrame",
|
|
14
20
|
description: "This widget embeds iframe-based embed code into pages",
|
|
@@ -27,9 +27,7 @@ module Spotlight
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def enabled_in_spotlight_view_type_configuration?(config, *args)
|
|
30
|
-
if config.respond_to?(:
|
|
31
|
-
!config.upstream_if.nil? &&
|
|
32
|
-
!blacklight_configuration_context.evaluate_configuration_conditional(config.upstream_if, config, *args)
|
|
30
|
+
if config.respond_to?(:original) && !blacklight_configuration_context.evaluate_if_unless_configuration(config.original, *args)
|
|
33
31
|
false
|
|
34
32
|
elsif current_exhibit.nil? || is_a?(Spotlight::PagesController)
|
|
35
33
|
true
|
|
@@ -38,13 +36,11 @@ module Spotlight
|
|
|
38
36
|
end
|
|
39
37
|
end
|
|
40
38
|
|
|
41
|
-
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/
|
|
39
|
+
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
42
40
|
def field_enabled?(field, *args)
|
|
43
41
|
if !field.enabled
|
|
44
42
|
false
|
|
45
|
-
elsif field.respond_to?(:
|
|
46
|
-
!field.upstream_if.nil? &&
|
|
47
|
-
!blacklight_configuration_context.evaluate_configuration_conditional(field.upstream_if, field, *args)
|
|
43
|
+
elsif field.respond_to?(:original) && !blacklight_configuration_context.evaluate_if_unless_configuration(field.original, *args)
|
|
48
44
|
false
|
|
49
45
|
elsif field.is_a?(Blacklight::Configuration::SortField) || field.is_a?(Blacklight::Configuration::SearchField)
|
|
50
46
|
field.enabled
|
|
@@ -54,7 +50,7 @@ module Spotlight
|
|
|
54
50
|
field.send(document_index_view_type)
|
|
55
51
|
end
|
|
56
52
|
end
|
|
57
|
-
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/
|
|
53
|
+
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
58
54
|
|
|
59
55
|
private
|
|
60
56
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Spotlight
|
|
2
|
+
##
|
|
3
|
+
# CRUD actions for exhibit contact emails
|
|
4
|
+
class ContactEmailController < Spotlight::ApplicationController
|
|
5
|
+
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
|
6
|
+
|
|
7
|
+
before_action :authenticate_user!
|
|
8
|
+
load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
|
|
9
|
+
load_and_authorize_resource through: :exhibit
|
|
10
|
+
|
|
11
|
+
def destroy
|
|
12
|
+
@contact_email.destroy
|
|
13
|
+
render json: { success: true, error: nil }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def record_not_found(_error)
|
|
19
|
+
render json: { success: false, error: 'Not Found' }, status: :not_found
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -28,7 +28,9 @@ module Spotlight
|
|
|
28
28
|
def index
|
|
29
29
|
respond_to do |format|
|
|
30
30
|
format.html
|
|
31
|
-
format.json
|
|
31
|
+
format.json do
|
|
32
|
+
render json: @searches.as_json(methods: [:count, :thumbnail_image_url]), root: false
|
|
33
|
+
end
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
36
|
|
|
@@ -26,8 +26,8 @@ module Spotlight
|
|
|
26
26
|
# can't use default_blacklight_config until after the BlacklightConfiguration
|
|
27
27
|
# is created or we run into a circular dependency.
|
|
28
28
|
default_fields = Spotlight::Engine.blacklight_config.search_fields
|
|
29
|
-
self.search_fields = default_fields.each_with_object({}) do |(k,
|
|
30
|
-
obj[k] = { enabled: true }
|
|
29
|
+
self.search_fields = default_fields.each_with_object({}) do |(k, v), obj|
|
|
30
|
+
obj[k] = { enabled: v.fetch(:enabled, true) }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -37,8 +37,8 @@ module Spotlight
|
|
|
37
37
|
# can't use default_blacklight_config until after the BlacklightConfiguration
|
|
38
38
|
# is created or we run into a circular dependency.
|
|
39
39
|
default_fields = Spotlight::Engine.blacklight_config.sort_fields
|
|
40
|
-
self.sort_fields = default_fields.each_with_object({}) do |(k,
|
|
41
|
-
obj[k] = { enabled: true }
|
|
40
|
+
self.sort_fields = default_fields.each_with_object({}) do |(k, v), obj|
|
|
41
|
+
obj[k] = { enabled: v.fetch(:enabled, true) }
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -32,7 +32,13 @@ module SirTrevorRails
|
|
|
32
32
|
def as_json
|
|
33
33
|
result = super
|
|
34
34
|
|
|
35
|
-
result[:data][:item]
|
|
35
|
+
result[:data][:item] ||= {}
|
|
36
|
+
|
|
37
|
+
# TODO: This is a temporary fix that simply removes any item if the search identifier does not exist
|
|
38
|
+
# We should have a more permanent solution that will allow browse blocks to be updated without erroring
|
|
39
|
+
result[:data][:item].select! { |_, v| parent.exhibit.searches.exists?(v['id']) }
|
|
40
|
+
|
|
41
|
+
result[:data][:item].each_value do |v|
|
|
36
42
|
v['thumbnail_image_url'] = parent.exhibit.searches.find(v['id']).thumbnail_image_url
|
|
37
43
|
end
|
|
38
44
|
|
|
@@ -22,7 +22,9 @@ module SirTrevorRails
|
|
|
22
22
|
def as_json
|
|
23
23
|
result = super
|
|
24
24
|
|
|
25
|
-
result[:data][:item]
|
|
25
|
+
result[:data][:item] ||= {}
|
|
26
|
+
|
|
27
|
+
result[:data][:item].each_value do |v|
|
|
26
28
|
v['thumbnail_image_url'] = parent.exhibit.pages.find(v['id']).thumbnail_image_url
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module SirTrevorRails
|
|
2
|
+
module Blocks
|
|
3
|
+
##
|
|
4
|
+
# Embed search results (from a browse category) into the page
|
|
5
|
+
class LinkToSearchBlock < BrowseBlock
|
|
6
|
+
include Displayable
|
|
7
|
+
|
|
8
|
+
def searches
|
|
9
|
+
@searches ||= parent.exhibit.searches.where(slug: item_ids).sort do |a, b|
|
|
10
|
+
ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -14,7 +14,7 @@ module Spotlight
|
|
|
14
14
|
|
|
15
15
|
# exhibit admin
|
|
16
16
|
can [:update, :import, :export, :destroy], Spotlight::Exhibit, id: user.admin_roles.pluck(:resource_id)
|
|
17
|
-
can :manage, Spotlight::BlacklightConfiguration, exhibit_id: user.admin_roles.pluck(:resource_id)
|
|
17
|
+
can :manage, [Spotlight::BlacklightConfiguration, Spotlight::ContactEmail], exhibit_id: user.admin_roles.pluck(:resource_id)
|
|
18
18
|
can :manage, Spotlight::Role, resource_id: user.admin_roles.pluck(:resource_id), resource_type: 'Spotlight::Exhibit'
|
|
19
19
|
|
|
20
20
|
can :manage, PaperTrail::Version if user.roles.any?
|
|
@@ -5,6 +5,8 @@ module Spotlight
|
|
|
5
5
|
# Exhibit-specific blacklight configuration model
|
|
6
6
|
# rubocop:disable Metrics/ClassLength
|
|
7
7
|
class BlacklightConfiguration < ActiveRecord::Base
|
|
8
|
+
has_paper_trail
|
|
9
|
+
|
|
8
10
|
belongs_to :exhibit, touch: true, optional: true
|
|
9
11
|
serialize :facet_fields, Hash
|
|
10
12
|
serialize :index_fields, Hash
|
|
@@ -88,6 +90,7 @@ module Spotlight
|
|
|
88
90
|
|
|
89
91
|
# Update with customizations
|
|
90
92
|
config.index_fields.each do |k, v|
|
|
93
|
+
v.original = v.dup
|
|
91
94
|
if index_fields[k]
|
|
92
95
|
v.merge! index_fields[k].symbolize_keys
|
|
93
96
|
elsif custom_index_fields[k]
|
|
@@ -99,7 +102,6 @@ module Spotlight
|
|
|
99
102
|
v.immutable = Blacklight::OpenStructWithHashAccess.new(v.immutable)
|
|
100
103
|
v.merge! v.immutable.to_h.symbolize_keys
|
|
101
104
|
|
|
102
|
-
v.upstream_if = v.if unless v.if.nil?
|
|
103
105
|
v.if = :field_enabled? unless v.if == false
|
|
104
106
|
|
|
105
107
|
v.normalize! config
|
|
@@ -109,6 +111,7 @@ module Spotlight
|
|
|
109
111
|
config.show_fields.reject! { |_k, v| v.if == false }
|
|
110
112
|
|
|
111
113
|
config.show_fields.reject { |k, _v| config.index_fields[k] }.each do |k, v|
|
|
114
|
+
v.original = v.dup
|
|
112
115
|
config.index_fields[k] = v
|
|
113
116
|
|
|
114
117
|
if index_fields[k]
|
|
@@ -120,7 +123,6 @@ module Spotlight
|
|
|
120
123
|
v.immutable = Blacklight::OpenStructWithHashAccess.new(v.immutable)
|
|
121
124
|
v.merge! v.immutable.to_h.symbolize_keys
|
|
122
125
|
|
|
123
|
-
v.upstream_if = v.if unless v.if.nil?
|
|
124
126
|
v.if = :field_enabled? unless v.if == false
|
|
125
127
|
|
|
126
128
|
v.normalize! config
|
|
@@ -133,7 +135,7 @@ module Spotlight
|
|
|
133
135
|
config.search_fields = Hash[config.search_fields.sort_by { |k, _v| field_weight(search_fields, k) }]
|
|
134
136
|
|
|
135
137
|
config.search_fields.each do |k, v|
|
|
136
|
-
v.
|
|
138
|
+
v.original = v.dup
|
|
137
139
|
v.if = :field_enabled? unless v.if == false
|
|
138
140
|
next if search_fields[k].blank?
|
|
139
141
|
|
|
@@ -147,7 +149,7 @@ module Spotlight
|
|
|
147
149
|
config.sort_fields = Hash[config.sort_fields.sort_by { |k, _v| field_weight(sort_fields, k) }]
|
|
148
150
|
|
|
149
151
|
config.sort_fields.each do |k, v|
|
|
150
|
-
v.
|
|
152
|
+
v.original = v.dup
|
|
151
153
|
v.if = :field_enabled? unless v.if == false
|
|
152
154
|
next if sort_fields[k].blank?
|
|
153
155
|
|
|
@@ -162,13 +164,12 @@ module Spotlight
|
|
|
162
164
|
config.facet_fields = Hash[config.facet_fields.sort_by { |k, _v| field_weight(facet_fields, k) }]
|
|
163
165
|
|
|
164
166
|
config.facet_fields.each do |k, v|
|
|
167
|
+
v.original = v.dup
|
|
165
168
|
next if facet_fields[k].blank?
|
|
166
169
|
|
|
167
170
|
v.merge! facet_fields[k].symbolize_keys
|
|
168
|
-
v.upstream_if = v.if unless v.if.nil?
|
|
169
171
|
v.enabled = v.show
|
|
170
172
|
v.if = :field_enabled? unless v.if == false
|
|
171
|
-
v.upstream_if = nil if v.upstream_if == v.if
|
|
172
173
|
v.normalize! config
|
|
173
174
|
v.validate!
|
|
174
175
|
end
|
|
@@ -182,8 +183,8 @@ module Spotlight
|
|
|
182
183
|
end
|
|
183
184
|
|
|
184
185
|
config.view.each do |k, v|
|
|
186
|
+
v.original = v.dup
|
|
185
187
|
v.key = k
|
|
186
|
-
v.upstream_if = v.if unless v.if.nil?
|
|
187
188
|
v.if = :enabled_in_spotlight_view_type_configuration? unless v.if == false
|
|
188
189
|
end unless document_index_view_types.blank?
|
|
189
190
|
|
|
@@ -7,6 +7,8 @@ module Spotlight
|
|
|
7
7
|
include Spotlight::ExhibitDefaults
|
|
8
8
|
include Spotlight::ExhibitDocuments
|
|
9
9
|
|
|
10
|
+
has_paper_trail
|
|
11
|
+
|
|
10
12
|
scope :published, -> { where(published: true) }
|
|
11
13
|
scope :unpublished, -> { where(published: false) }
|
|
12
14
|
scope :ordered_by_weight, -> { order('weight ASC') }
|
|
@@ -80,9 +80,11 @@ module Spotlight
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def write_to_index(batch)
|
|
83
|
-
|
|
83
|
+
documents = documents_that_have_ids(batch)
|
|
84
|
+
return unless write? && documents.present?
|
|
85
|
+
|
|
84
86
|
blacklight_solr.update params: { commitWithin: 500 },
|
|
85
|
-
data:
|
|
87
|
+
data: documents.to_json,
|
|
86
88
|
headers: { 'Content-Type' => 'application/json' }
|
|
87
89
|
end
|
|
88
90
|
|
|
@@ -100,6 +102,10 @@ module Spotlight
|
|
|
100
102
|
def write?
|
|
101
103
|
Spotlight::Engine.config.writable_index
|
|
102
104
|
end
|
|
105
|
+
|
|
106
|
+
def documents_that_have_ids(document_list)
|
|
107
|
+
document_list.reject { |d| d[document_builder.document_model.unique_key.to_sym].blank? }
|
|
108
|
+
end
|
|
103
109
|
end
|
|
104
110
|
end
|
|
105
111
|
end
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
module Spotlight
|
|
2
2
|
# Used by RIIIF to find files uploaded by carrierwave
|
|
3
3
|
class CarrierwaveFileResolver < Riiif::AbstractFileSystemResolver
|
|
4
|
+
# Override initialzer to avoid deprecation about not providing base path
|
|
5
|
+
def initializer
|
|
6
|
+
# nop
|
|
7
|
+
end
|
|
8
|
+
|
|
4
9
|
def pattern(id)
|
|
5
10
|
uploaded_file = Spotlight::FeaturedImage.find(id).image.file
|
|
6
11
|
raise Riiif::ImageNotFoundError, "unable to find file for #{id}" if uploaded_file.nil?
|
|
@@ -21,8 +21,8 @@ module Spotlight
|
|
|
21
21
|
|
|
22
22
|
def add_image_dimensions(solr_hash)
|
|
23
23
|
dimensions = Riiif::Image.new(resource.upload_id).info
|
|
24
|
-
solr_hash[:spotlight_full_image_width_ssm] = dimensions
|
|
25
|
-
solr_hash[:spotlight_full_image_height_ssm] = dimensions
|
|
24
|
+
solr_hash[:spotlight_full_image_width_ssm] = dimensions.width
|
|
25
|
+
solr_hash[:spotlight_full_image_height_ssm] = dimensions.height
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def add_file_versions(solr_hash)
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
<%= f.form_group :theme, label: { text: t(:'.site_theme.label') } do %>
|
|
42
42
|
<% Spotlight::Engine.config.exhibit_themes.each do |theme| %>
|
|
43
43
|
<div class="col-md-6">
|
|
44
|
-
<%= image_tag "spotlight/themes/#{theme}_preview", width: 100, height: 100 %>
|
|
44
|
+
<%= image_tag "spotlight/themes/#{theme}_preview.png", width: 100, height: 100 %>
|
|
45
45
|
<%= f.radio_button :theme, theme, label: t(:".site_theme.#{theme}", default: theme.to_s.titleize), inline: true %>
|
|
46
46
|
</div>
|
|
47
47
|
<% end %>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class="
|
|
1
|
+
<div class="confirmation-status <%= 'not-validated' unless contact_email.confirmed? or contact_email.recently_sent? %>">
|
|
2
2
|
<% if contact_email.confirmed? %>
|
|
3
3
|
<span class="confirmed"><span class="glyphicon glyphicon-ok-sign"></span> <%= t('.confirmed') %></span>
|
|
4
4
|
<% elsif contact_email.recently_sent? %>
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
<%= contact.hidden_field :id %>
|
|
2
1
|
<div class="row contact">
|
|
2
|
+
<%= contact.hidden_field :id %>
|
|
3
3
|
<div class="col-md-8<%= ' has-error' if contact.object.errors[:email].present? %>">
|
|
4
|
-
|
|
5
|
-
<div class="input-group">
|
|
6
|
-
<%= text_field_tag "#{contact.object_name}[email]", contact.object.email, class: 'exhibit-contact form-control' %>
|
|
7
|
-
<span id='another-email' class="input-group-addon first-row-only">+</span>
|
|
8
|
-
</div>
|
|
9
|
-
<% else %>
|
|
10
|
-
<%= text_field_tag "#{contact.object_name}[email]", contact.object.email, class: 'exhibit-contact form-control' %>
|
|
11
|
-
<% end %>
|
|
4
|
+
<%= text_field_tag "#{contact.object_name}[email]", contact.object.email, class: 'exhibit-contact form-control' %>
|
|
12
5
|
<% if contact.object.errors[:email].present? %>
|
|
13
6
|
<span class="help-block"><%=contact.object.errors[:email].join(", ".html_safe) %></span>
|
|
14
7
|
<% end %>
|
|
8
|
+
<p>
|
|
9
|
+
<span class="contact-email-delete-error text-danger callout-danger" style="display: none;"><%= t('.email_delete_error') %> <span class="error-msg"></span></span>
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="col-md-4">
|
|
13
|
+
<% if contact.object.id %>
|
|
14
|
+
<span class="contact-email-delete-wrapper">
|
|
15
|
+
<%= link_to exhibit_contact_email_path(exhibit_id: exhibit.id, id: contact.object.id), class: 'contact-email-delete btn btn-xs btn-danger', method: :delete, data: { confirm: t('.email_delete_confirmation'), remote: true } do %>
|
|
16
|
+
<%= t('.email_delete_button') %>
|
|
17
|
+
<% end %>
|
|
18
|
+
</span>
|
|
19
|
+
<% end %>
|
|
20
|
+
<%= render partial: 'confirmation_status', locals: {contact_email: contact.object} unless contact.object.new_record? %>
|
|
15
21
|
</div>
|
|
16
|
-
<%= render partial: 'confirmation_status', locals: {contact_email: contact.object} unless contact.object.new_record? %>
|
|
17
22
|
</div>
|