blacklight 7.34.0 → 8.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +2 -3
- data/.github/workflows/ruby.yml +32 -127
- data/.rubocop.yml +241 -2
- data/.rubocop_todo.yml +214 -270
- data/Gemfile +7 -10
- data/README.md +11 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
- data/app/assets/javascripts/blacklight/blacklight.js +374 -489
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
- data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +72 -44
- data/app/assets/stylesheets/blacklight/_header.scss +0 -15
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
- data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
- data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
- data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
- data/app/builders/blacklight/action_builder.rb +18 -9
- data/app/components/blacklight/advanced_search_form_component.html.erb +2 -2
- data/app/components/blacklight/advanced_search_form_component.rb +8 -10
- data/app/components/blacklight/constraints_component.rb +27 -37
- data/app/components/blacklight/document/action_component.rb +9 -9
- data/app/components/blacklight/document/actions_component.rb +2 -2
- data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
- data/app/components/blacklight/document/bookmark_component.rb +4 -2
- data/app/components/blacklight/document/citation_component.rb +5 -3
- data/app/components/blacklight/document/group_component.rb +7 -3
- data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
- data/app/components/blacklight/document/sidebar_component.rb +16 -0
- data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
- data/app/components/blacklight/document/thumbnail_component.rb +1 -9
- data/app/components/blacklight/document_component.html.erb +4 -0
- data/app/components/blacklight/document_component.rb +14 -53
- data/app/components/blacklight/document_metadata_component.html.erb +2 -4
- data/app/components/blacklight/document_metadata_component.rb +5 -10
- data/app/components/blacklight/document_title_component.rb +4 -1
- data/app/components/blacklight/facet_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_component.html.erb +5 -5
- data/app/components/blacklight/facet_field_component.rb +9 -2
- data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
- data/app/components/blacklight/facet_field_list_component.rb +37 -5
- data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
- data/app/components/blacklight/facet_item_component.rb +1 -43
- data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
- data/app/components/blacklight/header_component.rb +1 -1
- data/app/components/blacklight/hidden_search_state_component.rb +1 -2
- data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
- data/app/components/blacklight/icons/list_component.rb +16 -0
- data/app/components/blacklight/icons/search_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +24 -8
- data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
- data/app/components/blacklight/response/facet_group_component.rb +29 -8
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/pagination_component.rb +1 -5
- data/app/components/blacklight/response/sort_component.rb +1 -1
- data/app/components/blacklight/response/spellcheck_component.rb +17 -6
- data/app/components/blacklight/response/view_type_button_component.rb +2 -6
- data/app/components/blacklight/response/view_type_component.rb +3 -5
- data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
- data/app/components/blacklight/search/sidebar_component.rb +17 -0
- data/app/components/blacklight/search_bar_component.html.erb +20 -15
- data/app/components/blacklight/search_bar_component.rb +2 -16
- data/app/components/blacklight/search_button_component.rb +3 -3
- data/app/components/blacklight/search_context_component.rb +43 -9
- data/app/components/blacklight/search_header_component.html.erb +2 -0
- data/app/components/blacklight/search_header_component.rb +6 -0
- data/app/components/blacklight/start_over_button_component.rb +5 -3
- data/app/components/blacklight/system/dropdown_component.rb +2 -2
- data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
- data/app/components/blacklight/system/flash_message_component.rb +11 -2
- data/app/components/blacklight/system/modal_component.html.erb +1 -1
- data/app/components/blacklight/system/modal_component.rb +0 -2
- data/app/components/blacklight/top_navbar_component.html.erb +1 -1
- data/app/components/blacklight/top_navbar_component.rb +0 -4
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +10 -5
- data/app/controllers/concerns/blacklight/catalog.rb +21 -75
- data/app/controllers/concerns/blacklight/controller.rb +3 -41
- data/app/controllers/concerns/blacklight/search_context.rb +25 -7
- data/app/controllers/concerns/blacklight/search_history.rb +2 -0
- data/app/controllers/concerns/blacklight/searchable.rb +12 -1
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
- data/app/controllers/search_history_controller.rb +1 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
- data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -137
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
- data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
- data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
- data/app/helpers/blacklight/url_helper_behavior.rb +13 -97
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/javascript/blacklight/bookmark_toggle.js +13 -19
- data/app/javascript/blacklight/button_focus.js +12 -10
- data/app/javascript/blacklight/checkbox_submit.js +68 -122
- data/app/javascript/blacklight/core.js +6 -5
- data/app/javascript/blacklight/index.js +13 -0
- data/app/javascript/blacklight/modal.js +99 -164
- data/app/javascript/blacklight/modalForm.js +60 -0
- data/app/javascript/blacklight/search_context.js +45 -55
- data/app/models/blacklight/facet_paginator.rb +3 -2
- data/app/models/blacklight/icon.rb +4 -2
- data/app/models/bookmark.rb +0 -2
- data/app/models/concerns/blacklight/configurable.rb +5 -4
- data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
- data/app/models/concerns/blacklight/document/email.rb +1 -0
- data/app/models/concerns/blacklight/document/export.rb +2 -1
- data/app/models/concerns/blacklight/document/extensions.rb +1 -0
- data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
- data/app/models/concerns/blacklight/document/sms.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +1 -0
- data/app/models/concerns/blacklight/user.rb +17 -8
- data/app/models/record_mailer.rb +13 -12
- data/app/models/search.rb +0 -1
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/clause_presenter.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +13 -21
- data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
- data/app/presenters/blacklight/field_presenter.rb +1 -0
- data/app/presenters/blacklight/index_presenter.rb +2 -40
- data/app/presenters/blacklight/json_presenter.rb +7 -5
- data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
- data/app/presenters/blacklight/show_presenter.rb +1 -9
- data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
- data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
- data/app/services/blacklight/field_retriever.rb +1 -8
- data/app/services/blacklight/search_service.rb +8 -7
- data/app/values/blacklight/types.rb +0 -4
- data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
- data/app/views/bookmarks/_tools.html.erb +7 -12
- data/app/views/catalog/_advanced_search_form.html.erb +0 -1
- data/app/views/catalog/_bookmark_control.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +1 -14
- data/app/views/catalog/_document.atom.builder +12 -14
- data/app/views/catalog/_document.html.erb +5 -3
- data/app/views/catalog/_document.rss.builder +2 -4
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facets.html.erb +5 -4
- data/app/views/catalog/_home_text.html.erb +2 -14
- data/app/views/catalog/_search_form.html.erb +2 -2
- data/app/views/catalog/_search_header.html.erb +1 -2
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/catalog/_search_sidebar.html.erb +5 -1
- data/app/views/catalog/_show_main_content.html.erb +11 -16
- data/app/views/catalog/_show_sidebar.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +8 -14
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/app/views/catalog/email_success.html.erb +5 -6
- data/app/views/catalog/facet.html.erb +7 -5
- data/app/views/catalog/index.atom.builder +12 -14
- data/app/views/catalog/index.html.erb +4 -1
- data/app/views/catalog/index.json.jbuilder +19 -19
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +1 -1
- data/app/views/catalog/sms_success.html.erb +5 -6
- data/app/views/catalog/suggest.html.erb +3 -0
- data/app/views/layouts/blacklight/base.html.erb +13 -2
- data/app/views/search_history/index.html.erb +6 -2
- data/app/views/shared/_modal.html.erb +3 -3
- data/blacklight.gemspec +8 -9
- data/config/importmap.rb +3 -0
- data/config/locales/blacklight.ar.yml +0 -1
- data/config/locales/blacklight.ca.yml +0 -1
- data/config/locales/blacklight.de.yml +0 -1
- data/config/locales/blacklight.en.yml +0 -2
- data/config/locales/blacklight.es.yml +0 -1
- data/config/locales/blacklight.fr.yml +0 -1
- data/config/locales/blacklight.hu.yml +0 -1
- data/config/locales/blacklight.it.yml +0 -1
- data/config/locales/blacklight.nl.yml +0 -1
- data/config/locales/blacklight.pt-BR.yml +0 -1
- data/config/locales/blacklight.sq.yml +0 -1
- data/config/locales/blacklight.zh.yml +0 -1
- data/config/routes.rb +3 -2
- data/db/migrate/20140202020201_create_searches.rb +1 -0
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
- data/docker-compose.yml +0 -1
- data/lib/blacklight/abstract_repository.rb +1 -0
- data/lib/blacklight/configuration/context.rb +4 -4
- data/lib/blacklight/configuration/display_field.rb +7 -9
- data/lib/blacklight/configuration/facet_field.rb +17 -11
- data/lib/blacklight/configuration/field.rb +1 -0
- data/lib/blacklight/configuration/fields.rb +12 -15
- data/lib/blacklight/configuration/index_field.rb +1 -0
- data/lib/blacklight/configuration/null_display_field.rb +17 -0
- data/lib/blacklight/configuration/search_field.rb +1 -0
- data/lib/blacklight/configuration/show_field.rb +1 -0
- data/lib/blacklight/configuration/sort_field.rb +1 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +16 -6
- data/lib/blacklight/configuration.rb +294 -358
- data/lib/blacklight/engine.rb +8 -13
- data/lib/blacklight/exceptions.rb +2 -2
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
- data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
- data/lib/blacklight/parameters.rb +7 -21
- data/lib/blacklight/routes/exportable.rb +1 -0
- data/lib/blacklight/routes/searchable.rb +2 -1
- data/lib/blacklight/routes.rb +1 -0
- data/lib/blacklight/search_builder.rb +10 -10
- data/lib/blacklight/search_state/filter_field.rb +8 -25
- data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
- data/lib/blacklight/search_state.rb +23 -79
- data/lib/blacklight/solr/document.rb +1 -0
- data/lib/blacklight/solr/facet_paginator.rb +1 -0
- data/lib/blacklight/solr/repository.rb +3 -14
- data/lib/blacklight/solr/request.rb +1 -0
- data/lib/blacklight/solr/response/facets.rb +21 -5
- data/lib/blacklight/solr/response/group.rb +1 -0
- data/lib/blacklight/solr/response/group_response.rb +1 -0
- data/lib/blacklight/solr/response/more_like_this.rb +1 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
- data/lib/blacklight/solr/response/params.rb +5 -4
- data/lib/blacklight/solr/response/response.rb +1 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/blacklight/solr/response.rb +4 -3
- data/lib/blacklight/solr/search_builder_behavior.rb +17 -34
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/blacklight.rb +7 -10
- data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
- data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
- data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
- data/lib/generators/blacklight/assets_generator.rb +13 -89
- data/lib/generators/blacklight/controller_generator.rb +3 -2
- data/lib/generators/blacklight/document_generator.rb +1 -0
- data/lib/generators/blacklight/install_generator.rb +4 -3
- data/lib/generators/blacklight/models_generator.rb +1 -0
- data/lib/generators/blacklight/search_builder_generator.rb +1 -0
- data/lib/generators/blacklight/solr_generator.rb +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
- data/lib/generators/blacklight/test_support_generator.rb +4 -2
- data/lib/generators/blacklight/user_generator.rb +7 -9
- data/lib/railties/blacklight.rake +6 -7
- data/package.json +10 -13
- data/rollup.config.js +27 -0
- data/spec/components/blacklight/constraints_component_spec.rb +17 -13
- data/spec/components/blacklight/document_component_spec.rb +23 -82
- data/spec/components/blacklight/facet_component_spec.rb +2 -7
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
- data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
- data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context_component_spec.rb +40 -0
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
- data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
- data/spec/controllers/bookmarks_controller_spec.rb +2 -3
- data/spec/controllers/catalog_controller_spec.rb +13 -135
- data/spec/features/advanced_search_spec.rb +0 -56
- data/spec/features/autocomplete_spec.rb +1 -1
- data/spec/features/axe_spec.rb +1 -6
- data/spec/features/bookmarks_spec.rb +1 -1
- data/spec/features/facets_spec.rb +1 -1
- data/spec/features/search_context_spec.rb +4 -10
- data/spec/features/search_results_spec.rb +0 -33
- data/spec/features/sitelinks_search_box.rb +13 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
- data/spec/helpers/blacklight_helper_spec.rb +3 -242
- data/spec/helpers/catalog_helper_spec.rb +7 -118
- data/spec/i18n_spec.rb +1 -0
- data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
- data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
- data/spec/lib/blacklight/parameters_spec.rb +1 -4
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
- data/spec/lib/blacklight/search_state_spec.rb +80 -198
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
- data/spec/models/blacklight/configuration_spec.rb +17 -51
- data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
- data/spec/models/blacklight/icon_spec.rb +31 -15
- data/spec/models/blacklight/search_builder_spec.rb +9 -9
- data/spec/models/blacklight/solr/document_spec.rb +3 -3
- data/spec/models/blacklight/solr/repository_spec.rb +0 -27
- data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
- data/spec/models/blacklight/solr/response_spec.rb +9 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +24 -31
- data/spec/models/blacklight/user_spec.rb +22 -0
- data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
- data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
- data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
- data/spec/presenters/blacklight/index_presenter_spec.rb +2 -4
- data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
- data/spec/presenters/blacklight/show_presenter_spec.rb +20 -29
- data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
- data/spec/requests/load_suggestions_spec.rb +16 -0
- data/spec/routing/catalog_routing_spec.rb +2 -1
- data/spec/services/blacklight/search_service_spec.rb +31 -68
- data/spec/spec_helper.rb +6 -4
- data/spec/support/controller_level_helpers.rb +1 -2
- data/spec/support/features/search_helpers.rb +39 -0
- data/spec/support/features/session_helpers.rb +1 -0
- data/spec/support/features.rb +3 -0
- data/spec/support/view_component_capybara_test_helpers.rb +8 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
- data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
- data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
- data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
- data/spec/views/catalog/index.html.erb_spec.rb +5 -6
- data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
- data/spec/views/catalog/show.html.erb_spec.rb +3 -25
- data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
- data/tasks/blacklight.rake +6 -4
- metadata +79 -126
- data/.babelrc +0 -11
- data/app/assets/images/blacklight/list.svg +0 -1
- data/app/assets/images/blacklight/search.svg +0 -1
- data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
- data/app/components/blacklight/content_areas_shim.rb +0 -13
- data/app/controllers/concerns/blacklight/base.rb +0 -12
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
- data/app/controllers/concerns/blacklight/facet.rb +0 -69
- data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
- data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
- data/app/javascript/blacklight/autocomplete.js +0 -36
- data/app/javascript/blacklight/facet_load.js +0 -22
- data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
- data/app/views/catalog/_constraints_element.html.erb +0 -14
- data/app/views/catalog/_document_action.html.erb +0 -5
- data/app/views/catalog/_facet_group.html.erb +0 -5
- data/app/views/catalog/_facet_limit.html.erb +0 -3
- data/app/views/catalog/_index.html.erb +0 -1
- data/app/views/catalog/_index_header.html.erb +0 -22
- data/app/views/catalog/_previous_next_doc.html.erb +0 -2
- data/app/views/catalog/_show.html.erb +0 -6
- data/app/views/catalog/_show_header.html.erb +0 -2
- data/app/views/catalog/_thumbnail.html.erb +0 -1
- data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
- data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
- data/spec/components/blacklight/header_component_spec.rb +0 -20
- data/spec/controllers/blacklight/facet_spec.rb +0 -33
- data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
- data/spec/lib/blacklight/engine_spec.rb +0 -41
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
- data/spec/support/view_component_test_helpers.rb +0 -35
- data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
- data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
- data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
- data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
- data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
- data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -1,21 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'blacklight/deprecations/search_state_normalization'
|
4
3
|
require 'blacklight/search_state/filter_field'
|
4
|
+
require 'blacklight/search_state/pivot_filter_field'
|
5
5
|
|
6
6
|
module Blacklight
|
7
7
|
# This class encapsulates the search state as represented by the query
|
8
8
|
# parameters namely: :f, :q, :page, :per_page and, :sort
|
9
9
|
class SearchState
|
10
|
-
extend Deprecation
|
11
|
-
include Blacklight::Deprecations::SearchStateNormalization
|
12
|
-
|
13
10
|
attr_reader :blacklight_config # Must be called blacklight_config, because Blacklight::Facet calls blacklight_config.
|
14
|
-
attr_reader :params
|
15
11
|
|
16
12
|
# This method is never accessed in this class, but may be used by subclasses that need
|
17
13
|
# to access the url_helpers
|
18
|
-
attr_reader :controller
|
14
|
+
attr_reader :controller, :params
|
19
15
|
|
20
16
|
delegate :facet_configuration_for_field, to: :blacklight_config
|
21
17
|
|
@@ -33,34 +29,8 @@ module Blacklight
|
|
33
29
|
end
|
34
30
|
alias to_h to_hash
|
35
31
|
|
36
|
-
def to_unsafe_h
|
37
|
-
Deprecation.warn(self.class, 'Use SearchState#to_h instead of SearchState#to_unsafe_h')
|
38
|
-
to_hash
|
39
|
-
end
|
40
|
-
|
41
|
-
def method_missing(method_name, *arguments, &block)
|
42
|
-
if @params.respond_to?(method_name)
|
43
|
-
Deprecation.warn(self.class, "Calling `#{method_name}` on Blacklight::SearchState " \
|
44
|
-
'is deprecated and will be removed in Blacklight 8. Call #to_h first if you ' \
|
45
|
-
' need to use hash methods (or, preferably, use your own SearchState implementation)')
|
46
|
-
@params.public_send(method_name, *arguments, &block)
|
47
|
-
else
|
48
|
-
super
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def respond_to_missing?(method_name, include_private = false)
|
53
|
-
@params.respond_to?(method_name, include_private) || super
|
54
|
-
end
|
55
|
-
|
56
|
-
# Tiny shim to make it easier to migrate raw params access to using this class
|
57
|
-
delegate :[], to: :params
|
58
|
-
deprecation_deprecate :[]
|
59
|
-
|
60
32
|
def has_constraints?
|
61
|
-
|
62
|
-
!(query_param.blank? && filter_params.blank? && filters.blank? && clause_params.blank?)
|
63
|
-
end
|
33
|
+
!(query_param.blank? && filters.blank? && clause_params.blank?)
|
64
34
|
end
|
65
35
|
|
66
36
|
def query_param
|
@@ -71,11 +41,6 @@ module Blacklight
|
|
71
41
|
params[:clause] || {}
|
72
42
|
end
|
73
43
|
|
74
|
-
def filter_params
|
75
|
-
params[:f] || {}
|
76
|
-
end
|
77
|
-
deprecation_deprecate filter_params: 'Use #filters instead'
|
78
|
-
|
79
44
|
# @return [Blacklight::SearchState]
|
80
45
|
def reset(params = nil)
|
81
46
|
self.class.new(params || {}, blacklight_config, controller)
|
@@ -91,15 +56,20 @@ module Blacklight
|
|
91
56
|
# to provide more interesting routing to
|
92
57
|
# documents
|
93
58
|
def url_for_document(doc, options = {})
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
59
|
+
return doc unless routable?(doc)
|
60
|
+
|
61
|
+
route = blacklight_config.view_config(:show).route.merge(action: :show, id: doc).merge(options)
|
62
|
+
route[:controller] = params[:controller] if route[:controller] == :current
|
63
|
+
route
|
64
|
+
end
|
65
|
+
|
66
|
+
# To build a show route, we must have a blacklight_config that has
|
67
|
+
# configured show views, and the doc must appropriate to the config
|
68
|
+
# @return [Boolean]
|
69
|
+
def routable?(doc)
|
70
|
+
return false unless respond_to?(:blacklight_config) && blacklight_config.view_config(:show).route
|
71
|
+
|
72
|
+
doc.is_a? routable_model_for(blacklight_config)
|
103
73
|
end
|
104
74
|
|
105
75
|
def remove_query_params
|
@@ -116,6 +86,7 @@ module Blacklight
|
|
116
86
|
@filters ||= filter_fields.select(&:any?)
|
117
87
|
end
|
118
88
|
|
89
|
+
# @return [FilterField]
|
119
90
|
def filter(field_key_or_field)
|
120
91
|
field = field_key_or_field if field_key_or_field.is_a? Blacklight::Configuration::Field
|
121
92
|
field ||= blacklight_config.facet_fields[field_key_or_field]
|
@@ -124,15 +95,6 @@ module Blacklight
|
|
124
95
|
(field.filter_class || FilterField).new(field, self)
|
125
96
|
end
|
126
97
|
|
127
|
-
# adds the value and/or field to params[:f]
|
128
|
-
# Does NOT remove request keys and otherwise ensure that the hash
|
129
|
-
# is suitable for a redirect. See
|
130
|
-
# add_facet_params_and_redirect
|
131
|
-
def add_facet_params(field, item)
|
132
|
-
filter(field).add(item).params
|
133
|
-
end
|
134
|
-
deprecation_deprecate add_facet_params: 'Use filter(field).add(item) instead'
|
135
|
-
|
136
98
|
# Used in catalog/facet action, facets.rb view, for a click
|
137
99
|
# on a facet value. Add on the facet params to existing
|
138
100
|
# search constraints. Remove any paginator-specific request
|
@@ -141,9 +103,7 @@ module Blacklight
|
|
141
103
|
# Change the action to 'index' to send them back to
|
142
104
|
# catalog/index with their new facet choice.
|
143
105
|
def add_facet_params_and_redirect(field, item)
|
144
|
-
new_params =
|
145
|
-
add_facet_params(field, item).to_h.with_indifferent_access
|
146
|
-
end
|
106
|
+
new_params = filter(field).add(item).to_h
|
147
107
|
|
148
108
|
# Delete any request params from facet-specific action, needed
|
149
109
|
# to redir to index action properly.
|
@@ -153,26 +113,6 @@ module Blacklight
|
|
153
113
|
new_params
|
154
114
|
end
|
155
115
|
|
156
|
-
# copies the current params (or whatever is passed in as the 3rd arg)
|
157
|
-
# removes the field value from params[:f]
|
158
|
-
# removes the field if there are no more values in params[:f][field]
|
159
|
-
# removes additional params (page, id, etc..)
|
160
|
-
# @param [String] field
|
161
|
-
# @param [String] item
|
162
|
-
def remove_facet_params(field, item)
|
163
|
-
filter(field).remove(item).params
|
164
|
-
end
|
165
|
-
deprecation_deprecate remove_facet_params: 'Use filter(field).remove(item) instead'
|
166
|
-
|
167
|
-
def has_facet?(config, value: nil)
|
168
|
-
if value
|
169
|
-
filter(config).include?(value)
|
170
|
-
else
|
171
|
-
filter(config).any?
|
172
|
-
end
|
173
|
-
end
|
174
|
-
deprecation_deprecate has_facet?: 'Use filter(field).include?(value) or .any? instead'
|
175
|
-
|
176
116
|
# Merge the source params with the params_to_merge hash
|
177
117
|
# @param [Hash] params_to_merge to merge into above
|
178
118
|
# @return [ActionController::Parameters] the current search parameters after being sanitized by Blacklight::Parameters.sanitize
|
@@ -230,6 +170,10 @@ module Blacklight
|
|
230
170
|
|
231
171
|
private
|
232
172
|
|
173
|
+
def routable_model_for(blacklight_config)
|
174
|
+
blacklight_config.document_model || ::SolrDocument
|
175
|
+
end
|
176
|
+
|
233
177
|
def search_field_key
|
234
178
|
params[:search_field]
|
235
179
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Blacklight::Solr
|
3
4
|
class Repository < Blacklight::AbstractRepository
|
4
5
|
##
|
@@ -20,7 +21,7 @@ module Blacklight::Solr
|
|
20
21
|
# Execute a search query against solr
|
21
22
|
# @param [Hash] params solr query parameters
|
22
23
|
def search params = {}
|
23
|
-
send_and_receive
|
24
|
+
send_and_receive blacklight_config.solr_path, params.reverse_merge(qt: blacklight_config.qt)
|
24
25
|
end
|
25
26
|
|
26
27
|
# @param [Hash] request_params
|
@@ -77,7 +78,7 @@ module Blacklight::Solr
|
|
77
78
|
# @return [Hash]
|
78
79
|
# @!visibility private
|
79
80
|
def build_solr_request(solr_params)
|
80
|
-
if
|
81
|
+
if solr_params[:json].present?
|
81
82
|
{
|
82
83
|
data: { params: solr_params.to_hash.except(:json) }.merge(solr_params[:json]).to_json,
|
83
84
|
method: :post,
|
@@ -121,17 +122,5 @@ module Blacklight::Solr
|
|
121
122
|
[]
|
122
123
|
end
|
123
124
|
end
|
124
|
-
|
125
|
-
# @return [String]
|
126
|
-
def search_path(solr_params)
|
127
|
-
return blacklight_config.json_solr_path if blacklight_config.json_solr_path && uses_json_query_dsl?(solr_params)
|
128
|
-
|
129
|
-
blacklight_config.solr_path
|
130
|
-
end
|
131
|
-
|
132
|
-
# @return [Boolean]
|
133
|
-
def uses_json_query_dsl?(solr_params)
|
134
|
-
solr_params[:json].present?
|
135
|
-
end
|
136
125
|
end
|
137
126
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'ostruct'
|
3
4
|
|
4
5
|
module Blacklight::Solr::Response::Facets
|
@@ -109,7 +110,7 @@ module Blacklight::Solr::Response::Facets
|
|
109
110
|
# Get all the Solr facet data (fields, queries, pivots) as a hash keyed by
|
110
111
|
# both the Solr field name and/or by the blacklight field name
|
111
112
|
def aggregations
|
112
|
-
@aggregations ||=
|
113
|
+
@aggregations ||= default_aggregations.merge(facet_field_aggregations).merge(facet_query_aggregations).merge(facet_pivot_aggregations).merge(json_facet_aggregations)
|
113
114
|
end
|
114
115
|
|
115
116
|
def facet_counts
|
@@ -123,7 +124,7 @@ module Blacklight::Solr::Response::Facets
|
|
123
124
|
|
124
125
|
# this is some old solr (1.4? earlier?) serialization of facet fields
|
125
126
|
if val.is_a? Array
|
126
|
-
|
127
|
+
val.to_h
|
127
128
|
else
|
128
129
|
val
|
129
130
|
end
|
@@ -151,6 +152,21 @@ module Blacklight::Solr::Response::Facets
|
|
151
152
|
|
152
153
|
private
|
153
154
|
|
155
|
+
# @return [Hash] establish a null object pattern for facet data look-up, allowing
|
156
|
+
# the response and applied parameters to get passed through even if there was no
|
157
|
+
# facet data in the response
|
158
|
+
def default_aggregations
|
159
|
+
@default_aggregations ||= begin
|
160
|
+
h = Hash.new { |key| null_facet_field_object(key) }
|
161
|
+
h.with_indifferent_access
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# @return [Blacklight::Solr::Response::FacetField] a "null object" facet field
|
166
|
+
def null_facet_field_object(key)
|
167
|
+
Blacklight::Solr::Response::FacetField.new(key, [], facet_field_aggregation_options(key).merge(response: self))
|
168
|
+
end
|
169
|
+
|
154
170
|
##
|
155
171
|
# Convert Solr responses of various json.nl flavors to
|
156
172
|
def list_as_hash solr_list
|
@@ -161,10 +177,10 @@ module Blacklight::Solr::Response::Facets
|
|
161
177
|
solr_list.transform_values do |values|
|
162
178
|
if values.first.is_a? Array
|
163
179
|
# arrarr
|
164
|
-
|
180
|
+
values.to_h
|
165
181
|
else
|
166
182
|
# flat
|
167
|
-
|
183
|
+
values.each_slice(2).to_a.to_h
|
168
184
|
end
|
169
185
|
end
|
170
186
|
end
|
@@ -180,7 +196,7 @@ module Blacklight::Solr::Response::Facets
|
|
180
196
|
|
181
197
|
# legacy solr facet.missing serialization
|
182
198
|
if value.nil?
|
183
|
-
i.label = I18n.t(:"blacklight.search.fields.facet.missing.#{facet_field_name}", default: [:
|
199
|
+
i.label = I18n.t(:"blacklight.search.fields.facet.missing.#{facet_field_name}", default: [:'blacklight.search.facets.missing'])
|
184
200
|
i.fq = "-#{facet_field_name}:[* TO *]" # this explicit fq is deprecated; the missing attribute below is a better thing to check for this case
|
185
201
|
i.value = Blacklight::SearchState::FilterField::MISSING
|
186
202
|
i.missing = true
|
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Blacklight::Solr::Response::PaginationMethods
|
3
4
|
include Kaminari::PageScopeMethods
|
4
5
|
include Kaminari::ConfigurationMethods::ClassMethods
|
5
6
|
|
6
|
-
def limit_value
|
7
|
+
def limit_value # :nodoc:
|
7
8
|
rows
|
8
9
|
end
|
9
10
|
|
10
|
-
def offset_value
|
11
|
+
def offset_value # :nodoc:
|
11
12
|
start
|
12
13
|
end
|
13
14
|
|
14
|
-
def total_count
|
15
|
+
def total_count # :nodoc:
|
15
16
|
total
|
16
17
|
end
|
17
18
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Blacklight::Solr::Response::Params
|
3
4
|
# From https://solr.apache.org/guide/8_8/json-request-api.html#supported-properties-and-syntax
|
4
5
|
QUERY_PARAMETER_TO_JSON_PARAMETER_MAPPING = {
|
@@ -29,9 +30,9 @@ module Blacklight::Solr::Response::Params
|
|
29
30
|
def facet_field_aggregation_options(facet_field_name)
|
30
31
|
defaults = {
|
31
32
|
sort: single_valued_param(:'facet.sort'),
|
32
|
-
limit: single_valued_param(:
|
33
|
-
offset: single_valued_param(:
|
34
|
-
prefix: single_valued_param(:
|
33
|
+
limit: single_valued_param(:'facet.limit')&.to_i || 100,
|
34
|
+
offset: single_valued_param(:'facet.offset')&.to_i || 0,
|
35
|
+
prefix: single_valued_param(:'facet.prefix')
|
35
36
|
}
|
36
37
|
|
37
38
|
json_facet = json_params.dig('facet', facet_field_name)&.slice(:limit, :offset, :prefix, :sort)&.symbolize_keys || {}
|
@@ -41,7 +42,7 @@ module Blacklight::Solr::Response::Params
|
|
41
42
|
limit: single_valued_param(:"f.#{facet_field_name}.facet.limit")&.to_i,
|
42
43
|
offset: single_valued_param(:"f.#{facet_field_name}.facet.offset")&.to_i,
|
43
44
|
prefix: single_valued_param(:"f.#{facet_field_name}.facet.prefix")
|
44
|
-
}.
|
45
|
+
}.compact
|
45
46
|
|
46
47
|
options = defaults.merge(json_facet).merge(param_facet)
|
47
48
|
options[:sort] ||= options[:limit].positive? ? 'count' : 'index'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
3
4
|
extend ActiveSupport::Autoload
|
4
5
|
eager_autoload do
|
@@ -78,11 +79,11 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
78
79
|
when Array
|
79
80
|
value.each { |v| force_to_utf8(v) }
|
80
81
|
when String
|
81
|
-
if value.encoding
|
82
|
+
if value.encoding == Encoding::UTF_8
|
83
|
+
value
|
84
|
+
else
|
82
85
|
Blacklight.logger&.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
|
83
86
|
value.dup.force_encoding('UTF-8')
|
84
|
-
else
|
85
|
-
value
|
86
87
|
end
|
87
88
|
end
|
88
89
|
value
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Blacklight::Solr
|
3
4
|
module SearchBuilderBehavior
|
4
5
|
extend ActiveSupport::Concern
|
@@ -30,16 +31,6 @@ module Blacklight::Solr
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def add_search_field_default_parameters(solr_parameters)
|
33
|
-
###
|
34
|
-
# legacy behavior of user param :qt is passed through, but over-ridden
|
35
|
-
# by actual search field config if present. We might want to remove
|
36
|
-
# this legacy behavior at some point. It does not seem to be currently
|
37
|
-
# rspec'd.
|
38
|
-
if search_state.params[:qt]
|
39
|
-
Deprecation.warn(Blacklight::Solr::SearchBuilderBehavior, 'Passing the Solr qt as a parameter is deprecated.')
|
40
|
-
solr_parameters[:qt] = blacklight_params[:qt]
|
41
|
-
end
|
42
|
-
|
43
34
|
###
|
44
35
|
# Merge in search field configured values, if present, over-writing general
|
45
36
|
# defaults
|
@@ -55,11 +46,6 @@ module Blacklight::Solr
|
|
55
46
|
# including config's "search field" params for current search field.
|
56
47
|
# also include setting spellcheck.q.
|
57
48
|
def add_query_to_solr(solr_parameters)
|
58
|
-
unless processor_chain.include?(:add_search_field_default_parameters)
|
59
|
-
Deprecation.warn(Blacklight::Solr::SearchBuilderBehavior, 'Please include :add_search_field_default_parameters in your process chain')
|
60
|
-
add_search_field_default_parameters(solr_parameters)
|
61
|
-
end
|
62
|
-
|
63
49
|
##
|
64
50
|
# Create Solr 'q' including the user-entered q, prefixed by any
|
65
51
|
# solr LocalParams in config, using solr LocalParams syntax.
|
@@ -71,12 +57,7 @@ module Blacklight::Solr
|
|
71
57
|
add_search_field_with_json_query_parameters(solr_parameters)
|
72
58
|
elsif search_field&.solr_local_parameters.present?
|
73
59
|
add_search_field_with_local_parameters(solr_parameters)
|
74
|
-
elsif search_state
|
75
|
-
if search_state.query_param == @additional_filters && !processor_chain.include?(:add_additional_filters)
|
76
|
-
Deprecation.warn(Blacklight::Solr::SearchBuilderBehavior, 'Expecting to see the processor step add_additional_filters; falling back to legacy query handling')
|
77
|
-
add_additional_filters(solr_parameters, search_state.query_param)
|
78
|
-
end
|
79
|
-
elsif search_state.query_param
|
60
|
+
elsif !search_state&.query_param.is_a?(Hash)
|
80
61
|
solr_parameters.append_query search_state.query_param
|
81
62
|
end
|
82
63
|
end
|
@@ -102,9 +83,8 @@ module Blacklight::Solr
|
|
102
83
|
end
|
103
84
|
|
104
85
|
def add_search_field_with_json_query_parameters(solr_parameters)
|
105
|
-
return unless search_state.query_param
|
106
|
-
|
107
86
|
bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
|
87
|
+
|
108
88
|
solr_parameters.append_boolean_query(:must, bool_query)
|
109
89
|
end
|
110
90
|
|
@@ -152,9 +132,9 @@ module Blacklight::Solr
|
|
152
132
|
end
|
153
133
|
solr_parameters.merge!(subqueries) if subqueries
|
154
134
|
else
|
155
|
-
filter.values.
|
135
|
+
filter.values.compact_blank.each do |value|
|
156
136
|
filter_query, subqueries = if value.is_a?(Array)
|
157
|
-
facet_inclusive_value_to_fq_string(filter.key, value.
|
137
|
+
facet_inclusive_value_to_fq_string(filter.key, value.compact_blank)
|
158
138
|
else
|
159
139
|
facet_value_to_fq_string(filter.config.key, value)
|
160
140
|
end
|
@@ -283,7 +263,7 @@ module Blacklight::Solr
|
|
283
263
|
|
284
264
|
# Now override with our specific things for fetching facet values
|
285
265
|
facet_ex = facet_config.respond_to?(:ex) ? facet_config.ex : nil
|
286
|
-
solr_params[:
|
266
|
+
solr_params[:'facet.field'] = with_ex_local_param(facet_ex, facet_config.field)
|
287
267
|
|
288
268
|
# Need to set as f.facet_field.facet.* to make sure we
|
289
269
|
# override any field-specific default in the solr request handler.
|
@@ -340,9 +320,9 @@ module Blacklight::Solr
|
|
340
320
|
options[:quote] ||= '"'
|
341
321
|
unless val =~ /^[a-zA-Z0-9$_\-\^]+$/
|
342
322
|
val = options[:quote] +
|
343
|
-
|
344
|
-
|
345
|
-
|
323
|
+
# Yes, we need crazy escaping here, to deal with regexp esc too!
|
324
|
+
val.gsub("'", "\\\\\'").gsub('"', "\\\\\"") +
|
325
|
+
options[:quote]
|
346
326
|
end
|
347
327
|
val
|
348
328
|
end
|
@@ -351,6 +331,7 @@ module Blacklight::Solr
|
|
351
331
|
|
352
332
|
##
|
353
333
|
# Convert a facet/value pair into a solr fq parameter
|
334
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
354
335
|
def facet_value_to_fq_string(facet_field, value, use_local_params: true)
|
355
336
|
facet_config = blacklight_config.facet_fields[facet_field]
|
356
337
|
|
@@ -373,9 +354,10 @@ module Blacklight::Solr
|
|
373
354
|
elsif value == Blacklight::SearchState::FilterField::MISSING
|
374
355
|
"-#{solr_field}:[* TO *]"
|
375
356
|
else
|
376
|
-
"{!term f=#{solr_field}#{
|
357
|
+
"{!term f=#{solr_field}#{" #{local_params.join(' ')}" unless local_params.empty?}}#{convert_to_term_value(value)}"
|
377
358
|
end
|
378
359
|
end
|
360
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
379
361
|
|
380
362
|
def facet_inclusive_value_to_fq_string(facet_field, values)
|
381
363
|
return if values.blank?
|
@@ -395,13 +377,14 @@ module Blacklight::Solr
|
|
395
377
|
"{!query v=$#{k}}"
|
396
378
|
end.join(' OR ')
|
397
379
|
|
398
|
-
["{!lucene#{
|
380
|
+
["{!lucene#{" #{local_params.join(' ')}" unless local_params.empty?}}#{filter_query}", solr_filters]
|
399
381
|
end
|
400
382
|
|
401
383
|
def convert_to_term_value(value)
|
402
|
-
|
384
|
+
case value
|
385
|
+
when DateTime, Time
|
403
386
|
value.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
404
|
-
|
387
|
+
when Date
|
405
388
|
value.to_time(:local).strftime("%Y-%m-%dT%H:%M:%SZ")
|
406
389
|
else
|
407
390
|
value.to_s
|
@@ -435,7 +418,7 @@ module Blacklight::Solr
|
|
435
418
|
|
436
419
|
def add_search_field_with_local_parameters(solr_parameters)
|
437
420
|
local_params = search_field.solr_local_parameters.map do |key, val|
|
438
|
-
key
|
421
|
+
"#{key}=#{solr_param_quote(val, quote: "'")}"
|
439
422
|
end.join(" ")
|
440
423
|
solr_parameters.append_query "{!#{local_params}}#{search_state.query_param}"
|
441
424
|
|
data/lib/blacklight/solr.rb
CHANGED
data/lib/blacklight/version.rb
CHANGED
data/lib/blacklight.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'kaminari'
|
3
|
-
require 'deprecation'
|
4
4
|
require 'blacklight/open_struct_with_hash_access'
|
5
5
|
require 'blacklight/nested_open_struct_with_hash_access'
|
6
6
|
require 'jbuilder'
|
@@ -17,8 +17,6 @@ module Blacklight
|
|
17
17
|
autoload :SearchState, 'blacklight/search_state'
|
18
18
|
autoload :Solr, 'blacklight/solr'
|
19
19
|
|
20
|
-
extend Deprecation
|
21
|
-
|
22
20
|
require 'blacklight/version'
|
23
21
|
require 'blacklight/engine' if defined?(Rails)
|
24
22
|
|
@@ -69,9 +67,6 @@ module Blacklight
|
|
69
67
|
|
70
68
|
def defaults_version
|
71
69
|
@defaults_version ||= blacklight_yml['load_defaults'] ||
|
72
|
-
# this config parameter was introduced in Blacklight 7.11, so to be safe,
|
73
|
-
# we pin any 7.x app to the 7.10 behavior
|
74
|
-
(Blacklight::VERSION.starts_with?('7') && '7.10.0') ||
|
75
70
|
Blacklight::VERSION
|
76
71
|
|
77
72
|
@defaults_version == 'latest' ? Blacklight::VERSION : @defaults_version
|
@@ -87,7 +82,7 @@ module Blacklight
|
|
87
82
|
end
|
88
83
|
|
89
84
|
begin
|
90
|
-
blacklight_erb = ERB.new(
|
85
|
+
blacklight_erb = ERB.new(File.read(blacklight_config_file)).result(binding)
|
91
86
|
rescue StandardError, SyntaxError => e
|
92
87
|
raise("#{blacklight_config_file} was found, but could not be parsed with ERB. \n#{e.inspect}")
|
93
88
|
end
|
@@ -114,9 +109,7 @@ module Blacklight
|
|
114
109
|
end
|
115
110
|
|
116
111
|
def self.logger
|
117
|
-
@logger ||=
|
118
|
-
::Rails.logger if defined? Rails && Rails.respond_to?(:logger)
|
119
|
-
end
|
112
|
+
@logger ||= (::Rails.logger if defined? Rails && Rails.respond_to?(:logger))
|
120
113
|
end
|
121
114
|
|
122
115
|
def self.logger= logger
|
@@ -135,4 +128,8 @@ module Blacklight
|
|
135
128
|
def self.root
|
136
129
|
@root ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
|
137
130
|
end
|
131
|
+
|
132
|
+
def self.deprecation
|
133
|
+
@deprecation ||= ActiveSupport::Deprecation.new('9.0', 'Blacklight')
|
134
|
+
end
|
138
135
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
module Assets
|
5
|
+
class ImportmapGenerator < Rails::Generators::Base
|
6
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.1'), desc: "Set the generated app's bootstrap version"
|
7
|
+
|
8
|
+
# This could be skipped if you want to use webpacker
|
9
|
+
def add_javascript_dependencies
|
10
|
+
gem 'bootstrap', options[:'bootstrap-version'].presence # in rails 7, only for stylesheets
|
11
|
+
gem 'jquery-rails' if bootstrap_4? # Bootstrap 4 has a dependency on jquery
|
12
|
+
end
|
13
|
+
|
14
|
+
def import_javascript_assets
|
15
|
+
append_to_file 'config/importmap.rb' do
|
16
|
+
<<~CONTENT
|
17
|
+
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js"
|
18
|
+
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.2.2'}/dist/js/bootstrap.js"
|
19
|
+
pin "blacklight", to: "blacklight/blacklight.js"
|
20
|
+
pin "dialog-polyfill", to: "https://ga.jspm.io/npm:dialog-polyfill@0.5.6/dist/dialog-polyfill.js"
|
21
|
+
CONTENT
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def append_blacklight_javascript
|
26
|
+
append_to_file 'app/javascript/application.js' do
|
27
|
+
<<~CONTENT
|
28
|
+
import bootstrap from "bootstrap"
|
29
|
+
import "blacklight"
|
30
|
+
import dialogPolyfill from "dialog-polyfill"
|
31
|
+
Blacklight.onLoad(() => {
|
32
|
+
const dialog = document.querySelector('dialog')
|
33
|
+
dialogPolyfill.registerDialog(dialog)
|
34
|
+
})
|
35
|
+
CONTENT
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_stylesheet
|
40
|
+
gem "sassc-rails", "~> 2.1" if Rails.version > '7'
|
41
|
+
|
42
|
+
create_file 'app/assets/stylesheets/blacklight.scss' do
|
43
|
+
<<~CONTENT
|
44
|
+
@import 'bootstrap';
|
45
|
+
@import 'blacklight/blacklight';
|
46
|
+
CONTENT
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def bootstrap_4?
|
51
|
+
options[:'bootstrap-version'].match?(/\A[^0-9]*4\./)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|