blacklight 7.40.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 +36 -114
- data/.rubocop.yml +243 -14
- data/.rubocop_todo.yml +137 -429
- data/Gemfile +11 -6
- 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 -493
- 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/_constraints.scss +4 -4
- 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 +3 -3
- 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 +1 -1
- data/app/components/blacklight/document_component.rb +16 -78
- 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/facet_component.rb +3 -3
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +4 -4
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_component.html.erb +4 -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/icon_component.rb +4 -9
- 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 +2 -11
- data/app/components/blacklight/response/sort_component.html.erb +6 -1
- data/app/components/blacklight/response/sort_component.rb +1 -16
- data/app/components/blacklight/response/spellcheck_component.rb +18 -7
- data/app/components/blacklight/response/view_type_button_component.rb +3 -7
- data/app/components/blacklight/response/view_type_component.rb +4 -6
- 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 +8 -5
- data/app/components/blacklight/system/flash_message_component.html.erb +4 -2
- data/app/components/blacklight/system/flash_message_component.rb +12 -3
- data/app/components/blacklight/system/modal_component.html.erb +1 -1
- data/app/components/blacklight/system/modal_component.rb +1 -3
- 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 -9
- data/app/controllers/concerns/blacklight/catalog.rb +21 -83
- 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 +13 -1
- 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 -139
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -119
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
- data/app/helpers/blacklight/icon_helper_behavior.rb +5 -7
- data/app/helpers/blacklight/layout_helper_behavior.rb +4 -3
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
- data/app/helpers/blacklight/url_helper_behavior.rb +12 -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 -123
- data/app/javascript/blacklight/core.js +5 -7
- 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 +46 -54
- 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 -10
- 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 +2 -1
- 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 +1 -7
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/clause_presenter.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +23 -50
- 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 +12 -21
- data/app/services/blacklight/search_service.rb +10 -17
- data/app/values/blacklight/types.rb +0 -18
- 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/_citation.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/_per_page_widget.html.erb +10 -1
- 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.html.erb +2 -2
- 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.html.erb +2 -2
- data/app/views/catalog/sms_success.html.erb +5 -6
- data/app/views/catalog/suggest.html.erb +3 -0
- data/app/views/kaminari/blacklight/_page.html.erb +2 -1
- data/app/views/layouts/blacklight/base.html.erb +13 -2
- data/app/views/search_history/index.html.erb +6 -2
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/app/views/shared/_modal.html.erb +3 -3
- data/blacklight.gemspec +7 -11
- 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 +3 -2
- data/lib/blacklight/abstract_repository.rb +1 -6
- data/lib/blacklight/component.rb +47 -10
- 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 +14 -10
- data/lib/blacklight/configuration.rb +310 -365
- data/lib/blacklight/engine.rb +8 -24
- 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 +23 -6
- 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 +4 -24
- 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 +16 -3
- data/lib/blacklight/solr/search_builder_behavior.rb +16 -35
- data/lib/blacklight/solr.rb +7 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/blacklight.rb +26 -14
- 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 -86
- 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/action_component_spec.rb +6 -1
- data/spec/components/blacklight/document_component_spec.rb +22 -131
- data/spec/components/blacklight/facet_component_spec.rb +3 -18
- 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/layout_helper_behavior_spec.rb +3 -20
- 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 +8 -252
- 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/component_spec.rb +27 -32
- 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 -45
- 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 -44
- data/spec/models/blacklight/user_spec.rb +22 -0
- data/spec/models/solr_document_spec.rb +2 -6
- data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +2 -3
- 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 -5
- 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 -30
- 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 +39 -76
- 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/Gemfile.extra +1 -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/_paginate_compact.html.erb_spec.rb +0 -2
- 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 +17 -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 +11 -9
- data/template.demo.rb +7 -7
- metadata +78 -180
- 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/components/blacklight/search/per_page_component.html.erb +0 -2
- data/app/components/blacklight/search/per_page_component.rb +0 -50
- data/app/components/blacklight/system/dropdown_button_component.rb +0 -18
- 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/components/blacklight/icons/icon_component_spec.rb +0 -42
- data/spec/components/blacklight/response/pagination_component_spec.rb +0 -53
- data/spec/controllers/blacklight/facet_spec.rb +0 -33
- data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
- data/spec/features/citation_spec.rb +0 -10
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
- data/spec/features/sms_spec.rb +0 -12
- 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/services/blacklight/field_retriever_spec.rb +0 -17
- 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,9 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Blacklight
|
3
4
|
##
|
4
5
|
# Blacklight::Configuration holds the configuration for a Blacklight::Controller, including
|
5
6
|
# fields to display, facets to show, sort options, and search fields.
|
6
7
|
class Configuration < OpenStructWithHashAccess
|
8
|
+
extend ActiveSupport::Autoload
|
9
|
+
eager_autoload do
|
10
|
+
autoload :Context
|
11
|
+
autoload :ViewConfig
|
12
|
+
autoload :ToolConfig
|
13
|
+
autoload :Fields
|
14
|
+
autoload :Field
|
15
|
+
autoload :NullField
|
16
|
+
autoload :NullDisplayField
|
17
|
+
autoload :SearchField
|
18
|
+
autoload :FacetField
|
19
|
+
autoload :SortField
|
20
|
+
autoload :DisplayField
|
21
|
+
autoload :IndexField
|
22
|
+
autoload :ShowField
|
23
|
+
end
|
24
|
+
|
7
25
|
class_attribute :default_values, default: {}
|
8
26
|
|
9
27
|
# Set up Blacklight::Configuration.default_values to contain the basic, required Blacklight fields
|
@@ -34,304 +52,271 @@ module Blacklight
|
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
37
|
-
property :logo_link
|
38
|
-
property :full_width_layout, default: false
|
39
|
-
property :header_component, default: nil
|
40
|
-
def header_component
|
41
|
-
super || Blacklight::HeaderComponent
|
42
|
-
end
|
43
|
-
|
44
|
-
# === Search request configuration
|
45
|
-
|
46
|
-
# @!attribute http_method
|
47
|
-
# @since v5.0.0
|
48
|
-
# @return [:get, :post] HTTP method used for search
|
49
|
-
property :http_method, default: :get
|
50
|
-
# @!attribute solr_path
|
51
|
-
# @return [String] The path to send requests to solr.
|
52
|
-
property :solr_path, default: 'select'
|
53
|
-
# @!attribute default_solr_params
|
54
|
-
# @return [Hash] Default values of parameters to send with every search request
|
55
|
-
property :default_solr_params, default: {}
|
56
|
-
|
57
|
-
# === Single document request configuration
|
58
|
-
|
59
|
-
# @!attribute document_solr_request_handler
|
60
|
-
# @return [String] The solr request handler to use when requesting only a single document
|
61
|
-
property :document_solr_request_handler, default: nil
|
62
|
-
# @!attribute document_solr_path
|
63
|
-
# @since v5.2.0
|
64
|
-
# @return [String] The url path (relative to the solr base url) to use when requesting only a single document
|
65
|
-
property :document_solr_path, default: 'get'
|
66
|
-
# @!attribute json_solr_path
|
67
|
-
# @since v7.34.0
|
68
|
-
# @return [String] The url path (relative to the solr base url) to use when using Solr's JSON Query DSL (as with the advanced search)
|
69
|
-
property :json_solr_path, default: nil
|
70
|
-
# @!attribute document_unique_id_param
|
71
|
-
# @since v5.2.0
|
72
|
-
# @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
|
73
|
-
property :document_unique_id_param, default: :ids
|
74
|
-
# @!attribute default_document_solr_params
|
75
|
-
# @return [Hash] Default values of parameters to send with every single-document request
|
76
|
-
property :default_document_solr_params, default: {}
|
77
|
-
# @!attribute fetch_many_documents_path
|
78
|
-
# @since v8.4.0
|
79
|
-
# @return [String] The url path (relative to the solr base url) to use when requesting multiple documents by id
|
80
|
-
property :fetch_many_documents_path, default: nil
|
81
|
-
# @!attribute fetch_many_document_params
|
82
|
-
# @since v7.0.0
|
83
|
-
# @return [Hash] Default values of parameters to send with every multi-document request
|
84
|
-
property :fetch_many_document_params, default: {}
|
85
|
-
# @!attribute document_pagination_params
|
86
|
-
# @return [Hash] Default values of parameters to send when getting the previous + next documents
|
87
|
-
property :document_pagination_params, default: {}
|
88
|
-
|
89
|
-
##
|
90
|
-
# == Response models
|
91
|
-
|
92
|
-
# @!attribute repository_class
|
93
|
-
# @return [Class] Class for sending and receiving requests from a search index
|
94
|
-
property :repository_class, default: nil
|
95
|
-
def repository_class
|
96
|
-
super || Blacklight::Solr::Repository
|
97
|
-
end
|
98
|
-
|
99
|
-
# @!attribute search_builder_class
|
100
|
-
# @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
|
101
|
-
property :search_builder_class, default: nil
|
102
|
-
def search_builder_class
|
103
|
-
super || locate_search_builder_class
|
104
|
-
end
|
105
|
-
|
106
|
-
def locate_search_builder_class
|
107
|
-
::SearchBuilder
|
108
|
-
end
|
109
|
-
|
110
|
-
# @!attribute response_model
|
111
|
-
# model that maps index responses to the blacklight response model
|
112
|
-
# @return [Class]
|
113
|
-
property :response_model, default: nil
|
114
|
-
def response_model
|
115
|
-
super || Blacklight::Solr::Response
|
116
|
-
end
|
117
|
-
|
118
|
-
def response_model=(*args)
|
119
|
-
super
|
120
|
-
end
|
121
|
-
|
122
|
-
# @!attribute document_factory
|
123
|
-
# the factory that builds document
|
124
|
-
# @return [Class]
|
125
|
-
property :document_factory, default: nil
|
126
|
-
# A class that builds documents
|
127
|
-
def document_factory
|
128
|
-
super || Blacklight::DocumentFactory
|
129
|
-
end
|
130
|
-
# @!attribute document_model
|
131
|
-
# the model to use for each response document
|
132
|
-
# @return [Class]
|
133
|
-
property :document_model, default: nil
|
134
|
-
def document_model
|
135
|
-
super || ::SolrDocument
|
136
|
-
end
|
137
|
-
|
138
|
-
# only here to support alias_method
|
139
|
-
def document_model=(*args)
|
140
|
-
super
|
141
|
-
end
|
142
|
-
|
143
|
-
# @!attribute facet_paginator_class
|
144
|
-
# Class for paginating long lists of facet fields
|
145
|
-
# @return [Class]
|
146
|
-
property :facet_paginator_class, default: nil
|
147
|
-
def facet_paginator_class
|
148
|
-
super || Blacklight::Solr::FacetPaginator
|
149
|
-
end
|
150
|
-
|
151
|
-
# @!attribute connection_config
|
152
|
-
# repository connection configuration
|
153
|
-
# @since v5.13.0
|
154
|
-
# @return [Class]
|
155
|
-
property :connection_config, default: nil
|
156
|
-
def connection_config
|
157
|
-
super || Blacklight.connection_config
|
158
|
-
end
|
159
|
-
|
160
|
-
##
|
161
|
-
# == Blacklight view configuration
|
162
|
-
|
163
|
-
# @!attribute navbar
|
164
|
-
# @since v5.8.0
|
165
|
-
# @return [#partials]
|
166
|
-
property :navbar, default: OpenStructWithHashAccess.new(partials: {})
|
167
|
-
|
168
|
-
# @!attribute index
|
169
|
-
# General configuration for all views
|
170
|
-
# @return [Blacklight::Configuration::ViewConfig::Index]
|
171
|
-
property :index, default: ViewConfig::Index.new(
|
172
|
-
# document presenter class used by helpers and views
|
173
|
-
document_presenter_class: nil,
|
174
|
-
# component class used to render a document
|
175
|
-
document_component: nil,
|
176
|
-
# solr field to use to render a document title
|
177
|
-
title_field: nil,
|
178
|
-
# solr field to use to render format-specific partials
|
179
|
-
display_type_field: nil,
|
180
|
-
# partials to render for each document(see #render_document_partials)
|
181
|
-
partials: [:index_header, :thumbnail, :index],
|
182
|
-
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
183
|
-
collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
184
|
-
# what field, if any, to use to render grouped results
|
185
|
-
group: false,
|
186
|
-
# additional response formats for search results
|
187
|
-
respond_to: OpenStructWithHashAccess.new,
|
188
|
-
# component class used to render the facet grouping
|
189
|
-
facet_group_component: nil,
|
190
|
-
# component class used to render search constraints
|
191
|
-
constraints_component: nil,
|
192
|
-
# component class used to render the search bar
|
193
|
-
search_bar_component: nil,
|
194
|
-
# pagination parameters to pass to kaminari
|
195
|
-
pagination_options: Blacklight::Engine.config.blacklight.default_pagination_options.dup
|
196
|
-
)
|
197
|
-
|
198
|
-
# @!attribute show
|
199
|
-
# Additional configuration when displaying a single document
|
200
|
-
# @return [Blacklight::Configuration::ViewConfig::Show]
|
201
|
-
property :show, default: ViewConfig::Show.new(
|
202
|
-
# document presenter class used by helpers and views
|
203
|
-
document_presenter_class: nil,
|
204
|
-
document_component: nil,
|
205
|
-
display_type_field: nil,
|
206
|
-
# Default route parameters for 'show' requests.
|
207
|
-
# Set this to a hash with additional arguments to merge into the route,
|
208
|
-
# or set `controller: :current` to route to the current controller.
|
209
|
-
route: nil,
|
210
|
-
# partials to render for each document(see #render_document_partials)
|
211
|
-
partials: [:show_header, :show],
|
212
|
-
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
|
213
|
-
)
|
214
|
-
|
215
|
-
# @!attribute action_mapping
|
216
|
-
# @since v7.16.0
|
217
|
-
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
218
|
-
property :action_mapping, default: NestedOpenStructWithHashAccess.new(
|
219
|
-
ViewConfig,
|
220
|
-
default: { top_level_config: :index },
|
221
|
-
show: { top_level_config: :show },
|
222
|
-
citation: { parent_config: :show }
|
223
|
-
)
|
224
|
-
|
225
|
-
# @!attribute sms
|
226
|
-
# @since v7.21.0
|
227
|
-
# @return [Blacklight::Configuration::ViewConfig]
|
228
|
-
property :sms, default: ViewConfig.new
|
229
|
-
|
230
|
-
# @!attribute email
|
231
|
-
# @since v7.21.0
|
232
|
-
# @return [Blacklight::Configuration::ViewConfig]
|
233
|
-
property :email, default: ViewConfig.new
|
234
|
-
|
235
|
-
# @!attribute
|
236
|
-
# Configurations for specific types of index views
|
237
|
-
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
238
|
-
property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
|
239
|
-
list: {},
|
240
|
-
atom: {
|
241
|
-
if: false, # by default, atom should not show up as an alternative view
|
242
|
-
partials: [:document],
|
243
|
-
summary_partials: [:index]
|
244
|
-
},
|
245
|
-
rss: {
|
246
|
-
if: false, # by default, rss should not show up as an alternative view
|
247
|
-
partials: [:document]
|
248
|
-
})
|
249
|
-
|
250
|
-
##
|
251
|
-
# === Blacklight behavior configuration
|
252
|
-
|
253
|
-
# @!attribute spell_max
|
254
|
-
# Maxiumum number of spelling suggestions to offer
|
255
|
-
# @return [Integer]
|
256
|
-
property :spell_max, default: 5
|
257
|
-
|
258
|
-
# @!attribute max_per_page
|
259
|
-
# Maximum number of results to show per page
|
260
|
-
# @return [Integer]
|
261
|
-
property :max_per_page, default: 100
|
262
|
-
# @!attribute per_page
|
263
|
-
# Options for the user for number of results to show per page
|
264
|
-
# @return [Array<Integer>]
|
265
|
-
property :per_page, default: [10, 20, 50, 100]
|
266
|
-
# @!attribute default_per_page
|
267
|
-
# @return [Integer]
|
268
|
-
property :default_per_page, default: nil
|
269
|
-
# @return [Integer]
|
270
|
-
def default_per_page
|
271
|
-
super || per_page.first
|
272
|
-
end
|
273
|
-
|
274
|
-
# @!attribute search_history_window
|
275
|
-
# how many searches to save in session history
|
276
|
-
# @return [Integer]
|
277
|
-
property :search_history_window, default: 100
|
278
|
-
# @!attribute default_facet_limit
|
279
|
-
# @since v5.10.0
|
280
|
-
# @return [Integer]
|
281
|
-
property :default_facet_limit, default: 10
|
282
|
-
# @!attribute default_more_limit
|
283
|
-
# @since v7.0.0
|
284
|
-
# @return [Integer]
|
285
|
-
property :default_more_limit, default: 20
|
286
|
-
|
287
|
-
# @!attribute crawler_detector
|
288
|
-
# proc for determining whether the session is a crawler/bot
|
289
|
-
# ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
|
290
|
-
# @since v7.0.0
|
291
|
-
# @return [<nil, Proc>]
|
292
|
-
property :crawler_detector, default: nil
|
293
|
-
|
294
|
-
# @!attribute autocomplete_suggester
|
295
|
-
# @since v7.0.0
|
296
|
-
# @return [String]
|
297
|
-
property :autocomplete_suggester, default: 'mySuggester'
|
298
|
-
|
299
|
-
# @!attribute raw_endpoint
|
300
|
-
# @since v7.0.0
|
301
|
-
# @return [#enabled]
|
302
|
-
property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
|
303
|
-
|
304
|
-
# @!attribute track_search_session
|
305
|
-
# @since v7.1.0
|
306
|
-
# @return [Boolean]
|
307
|
-
property :track_search_session, default: true
|
308
|
-
|
309
|
-
# @!attribute advanced_search
|
310
|
-
# @since v7.15.0
|
311
|
-
# @return [#enabled]
|
312
|
-
property :advanced_search, default: OpenStruct.new(enabled: false)
|
313
|
-
|
314
|
-
# @!attribute enable_search_bar_autofocus
|
315
|
-
# @since v7.2.0
|
316
|
-
# @return [Boolean]
|
317
|
-
property :enable_search_bar_autofocus, default: false
|
318
|
-
|
319
55
|
BASIC_SEARCH_PARAMETERS = [:q, :qt, :page, :per_page, :search_field, :sort, :controller, :action, :'facet.page', :'facet.prefix', :'facet.sort', :rows, :format, :view].freeze
|
320
56
|
ADVANCED_SEARCH_PARAMETERS = [{ clause: {} }, :op].freeze
|
321
|
-
|
322
|
-
#
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
57
|
+
|
58
|
+
# rubocop:disable Metrics/BlockLength
|
59
|
+
default_configuration do
|
60
|
+
property :logo_link, default: nil
|
61
|
+
property :header_component, default: Blacklight::HeaderComponent
|
62
|
+
|
63
|
+
# bootstrap_version may be set to 4 or 5
|
64
|
+
bootstrap_version = ENV['BOOTSTRAP_VERSION'].presence || "5"
|
65
|
+
property :bootstrap_version, default: /(\d)(?:\.\d){0,2}/.match(bootstrap_version)[1].to_i
|
66
|
+
|
67
|
+
# === Search request configuration
|
68
|
+
|
69
|
+
# @!attribute http_method
|
70
|
+
# @since v5.0.0
|
71
|
+
# @return [:get, :post] HTTP method used for search
|
72
|
+
property :http_method, default: :get
|
73
|
+
# @!attribute solr_path
|
74
|
+
# @return [String] The path to send requests to solr.
|
75
|
+
property :solr_path, default: 'select'
|
76
|
+
# @!attribute default_solr_params
|
77
|
+
# @return [Hash] Default values of parameters to send with every search request
|
78
|
+
property :default_solr_params, default: {}
|
79
|
+
|
80
|
+
# === Single document request configuration
|
81
|
+
|
82
|
+
# @!attribute document_solr_request_handler
|
83
|
+
# @return [String] The solr request handler to use when requesting only a single document
|
84
|
+
property :document_solr_request_handler, default: nil
|
85
|
+
# @!attribute document_solr_path
|
86
|
+
# @since v5.2.0
|
87
|
+
# @return [String] The url path (relative to the solr base url) to use when requesting only a single document
|
88
|
+
property :document_solr_path, default: 'get'
|
89
|
+
# @!attribute document_unique_id_param
|
90
|
+
# @since v5.2.0
|
91
|
+
# @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
|
92
|
+
property :document_unique_id_param, default: :ids
|
93
|
+
# @!attribute default_document_solr_params
|
94
|
+
# @return [Hash] Default values of parameters to send with every single-document request
|
95
|
+
property :default_document_solr_params, default: {}
|
96
|
+
# @!attribute fetch_many_document_params
|
97
|
+
# @since v7.0.0
|
98
|
+
# @return [Hash] Default values of parameters to send with every multi-document request
|
99
|
+
property :fetch_many_document_params, default: {}
|
100
|
+
# @!attribute document_pagination_params
|
101
|
+
# @return [Hash] Default values of parameters to send when getting the previous + next documents
|
102
|
+
property :document_pagination_params, default: {}
|
103
|
+
|
104
|
+
##
|
105
|
+
# == Response models
|
106
|
+
|
107
|
+
# @!attribute repository_class
|
108
|
+
# @return [Class] Class for sending and receiving requests from a search index
|
109
|
+
property :repository_class, default: Blacklight::Solr::Repository
|
110
|
+
# @!attribute search_builder_class
|
111
|
+
# @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
|
112
|
+
property :search_builder_class, default: ::SearchBuilder
|
113
|
+
# @!attribute response_model
|
114
|
+
# model that maps index responses to the blacklight response model
|
115
|
+
# @return [Class]
|
116
|
+
property :response_model, default: Blacklight::Solr::Response
|
117
|
+
# @!attribute document_model
|
118
|
+
# the model to use for each response document
|
119
|
+
# @return [Class]
|
120
|
+
property :document_model, default: ::SolrDocument
|
121
|
+
# @!attribute document_factory
|
122
|
+
# the factory that builds document
|
123
|
+
# @return [Class]
|
124
|
+
property :document_factory, default: Blacklight::DocumentFactory
|
125
|
+
# @!attribute facet_paginator_class
|
126
|
+
# Class for paginating long lists of facet fields
|
127
|
+
# @return [Class]
|
128
|
+
property :facet_paginator_class, default: Blacklight::Solr::FacetPaginator
|
129
|
+
# @!attribute connection_config
|
130
|
+
# repository connection configuration
|
131
|
+
# @since v5.13.0
|
132
|
+
# @return [Class]
|
133
|
+
property :connection_config, default: Blacklight.connection_config
|
134
|
+
|
135
|
+
##
|
136
|
+
# == Blacklight view configuration
|
137
|
+
|
138
|
+
# @!attribute navbar
|
139
|
+
# @since v5.8.0
|
140
|
+
# @return [#partials]
|
141
|
+
property :navbar, default: OpenStructWithHashAccess.new(partials: {})
|
142
|
+
|
143
|
+
# @!attribute index
|
144
|
+
# General configuration for all views
|
145
|
+
# @return [Blacklight::Configuration::ViewConfig::Index]
|
146
|
+
property :index, default: ViewConfig::Index.new(
|
147
|
+
# document presenter class used by helpers and views
|
148
|
+
document_presenter_class: nil,
|
149
|
+
# component class used to render a document
|
150
|
+
document_component: Blacklight::DocumentComponent,
|
151
|
+
sidebar_component: Blacklight::Search::SidebarComponent,
|
152
|
+
# solr field to use to render a document title
|
153
|
+
title_field: nil,
|
154
|
+
# solr field to use to render format-specific partials
|
155
|
+
display_type_field: nil,
|
156
|
+
# the "field access" key to use to look up the document display fields
|
157
|
+
document_fields_key: :index_fields,
|
158
|
+
# partials to render for each document(see #render_document_partials)
|
159
|
+
partials: [],
|
160
|
+
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
161
|
+
collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
162
|
+
# what field, if any, to use to render grouped results
|
163
|
+
group: false,
|
164
|
+
# additional response formats for search results
|
165
|
+
respond_to: OpenStructWithHashAccess.new,
|
166
|
+
# component class used to render the facet grouping
|
167
|
+
facet_group_component: nil,
|
168
|
+
# component class used to render search constraints
|
169
|
+
constraints_component: nil,
|
170
|
+
# component class used to render the search bar
|
171
|
+
search_bar_component: nil,
|
172
|
+
# component class used to render the header above the documents
|
173
|
+
search_header_component: Blacklight::SearchHeaderComponent
|
174
|
+
)
|
175
|
+
|
176
|
+
# @!attribute show
|
177
|
+
# Additional configuration when displaying a single document
|
178
|
+
# @return [Blacklight::Configuration::ViewConfig::Show]
|
179
|
+
property :show, default: ViewConfig::Show.new(
|
180
|
+
# document presenter class used by helpers and views
|
181
|
+
document_presenter_class: nil,
|
182
|
+
document_component: Blacklight::DocumentComponent,
|
183
|
+
sidebar_component: Blacklight::Document::SidebarComponent,
|
184
|
+
display_type_field: nil,
|
185
|
+
# the "field access" key to use to look up the document display fields
|
186
|
+
document_fields_key: :show_fields,
|
187
|
+
# Default route parameters for 'show' requests.
|
188
|
+
# Set this to a hash with additional arguments to merge into the route,
|
189
|
+
# or set `controller: :current` to route to the current controller.
|
190
|
+
route: nil,
|
191
|
+
# partials to render for each document(see #render_document_partials)
|
192
|
+
partials: [],
|
193
|
+
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
|
194
|
+
)
|
195
|
+
|
196
|
+
# @!attribute action_mapping
|
197
|
+
# @since v7.16.0
|
198
|
+
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
199
|
+
property :action_mapping, default: NestedOpenStructWithHashAccess.new(
|
200
|
+
ViewConfig,
|
201
|
+
default: { top_level_config: :index },
|
202
|
+
show: { top_level_config: :show },
|
203
|
+
citation: { parent_config: :show }
|
204
|
+
)
|
205
|
+
|
206
|
+
# @!attribute sms
|
207
|
+
# @since v7.21.0
|
208
|
+
# @return [Blacklight::Configuration::ViewConfig]
|
209
|
+
property :sms, default: ViewConfig.new
|
210
|
+
|
211
|
+
# @!attribute email
|
212
|
+
# @since v7.21.0
|
213
|
+
# @return [Blacklight::Configuration::ViewConfig]
|
214
|
+
property :email, default: ViewConfig.new
|
215
|
+
|
216
|
+
# @!attribute
|
217
|
+
# Configurations for specific types of index views
|
218
|
+
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
219
|
+
property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
|
220
|
+
list: {},
|
221
|
+
atom: {
|
222
|
+
if: false, # by default, atom should not show up as an alternative view
|
223
|
+
partials: [:document],
|
224
|
+
summary_component: Blacklight::DocumentComponent
|
225
|
+
},
|
226
|
+
rss: {
|
227
|
+
if: false, # by default, rss should not show up as an alternative view
|
228
|
+
partials: [:document]
|
229
|
+
})
|
230
|
+
|
231
|
+
##
|
232
|
+
# === Blacklight behavior configuration
|
233
|
+
|
234
|
+
# @!attribute spell_max
|
235
|
+
# Maxiumum number of spelling suggestions to offer
|
236
|
+
# @return [Integer]
|
237
|
+
property :spell_max, default: 5
|
238
|
+
|
239
|
+
# @!attribute max_per_page
|
240
|
+
# Maximum number of results to show per page
|
241
|
+
# @return [Integer]
|
242
|
+
property :max_per_page, default: 100
|
243
|
+
# @!attribute per_page
|
244
|
+
# Options for the user for number of results to show per page
|
245
|
+
# @return [Array<Integer>]
|
246
|
+
property :per_page, default: [10, 20, 50, 100]
|
247
|
+
# @!attribute default_per_page
|
248
|
+
# @return [Integer]
|
249
|
+
property :default_per_page, default: nil
|
250
|
+
|
251
|
+
# @!attribute search_history_window
|
252
|
+
# how many searches to save in session history
|
253
|
+
# @return [Integer]
|
254
|
+
property :search_history_window, default: 100
|
255
|
+
# @!attribute default_facet_limit
|
256
|
+
# @since v5.10.0
|
257
|
+
# @return [Integer]
|
258
|
+
property :default_facet_limit, default: 10
|
259
|
+
# @!attribute default_more_limit
|
260
|
+
# @since v7.0.0
|
261
|
+
# @return [Integer]
|
262
|
+
property :default_more_limit, default: 20
|
263
|
+
|
264
|
+
# @!attribute crawler_detector
|
265
|
+
# proc for determining whether the session is a crawler/bot
|
266
|
+
# ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
|
267
|
+
# @since v7.0.0
|
268
|
+
# @return [<nil, Proc>]
|
269
|
+
property :crawler_detector, default: nil
|
270
|
+
|
271
|
+
# @!attribute autocomplete_suggester
|
272
|
+
# @since v7.0.0
|
273
|
+
# @return [String]
|
274
|
+
property :autocomplete_suggester, default: 'mySuggester'
|
275
|
+
|
276
|
+
# @!attribute raw_endpoint
|
277
|
+
# @since v7.0.0
|
278
|
+
# @return [#enabled]
|
279
|
+
property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
|
280
|
+
|
281
|
+
# @!attribute track_search_session
|
282
|
+
# @since v7.1.0
|
283
|
+
# @return [Boolean]
|
284
|
+
property :track_search_session, default: true
|
285
|
+
|
286
|
+
# @!attribute advanced_search
|
287
|
+
# @since v7.15.0
|
288
|
+
# @return [#enabled]
|
289
|
+
property :advanced_search, default: OpenStruct.new(enabled: false)
|
290
|
+
|
291
|
+
# @!attribute enable_search_bar_autofocus
|
292
|
+
# @since v7.2.0
|
293
|
+
# @return [Boolean]
|
294
|
+
property :enable_search_bar_autofocus, default: false
|
295
|
+
|
296
|
+
# List the request parameters that compose the SearchState.
|
297
|
+
# If you use a plugin that adds to the search state, then you can add the parameters
|
298
|
+
# by modifiying this field.
|
299
|
+
# @!attribute search_state_fields
|
300
|
+
# @since v8.0.0
|
301
|
+
# @return [Array<Symbol>]
|
302
|
+
property :search_state_fields, default: BASIC_SEARCH_PARAMETERS + ADVANCED_SEARCH_PARAMETERS
|
303
|
+
|
304
|
+
# Have SearchState filter out unknown request parameters
|
305
|
+
#
|
306
|
+
# @!attribute filter_search_state_fields
|
307
|
+
# @since v8.0.0
|
308
|
+
# @return [Boolean]
|
309
|
+
property :filter_search_state_fields, default: true
|
310
|
+
|
311
|
+
# Additional Blacklight configuration setting for document-type specific
|
312
|
+
# configuration.
|
313
|
+
# @!attribute fields_for_type
|
314
|
+
# @since v8.0.0
|
315
|
+
# @return [Hash{Symbol => Blacklight::Configuration}]
|
316
|
+
# @see [#for_display_type]
|
317
|
+
property :fields_for_type, default: {}.with_indifferent_access
|
318
|
+
end
|
319
|
+
# rubocop:enable Metrics/BlockLength
|
335
320
|
|
336
321
|
##
|
337
322
|
# Create collections of solr field configurations.
|
@@ -380,7 +365,7 @@ module Blacklight
|
|
380
365
|
def initialize(hash = {})
|
381
366
|
self.class.initialize_default_configuration unless self.class.initialized_default_configuration?
|
382
367
|
|
383
|
-
super(self.class.default_values.
|
368
|
+
super(self.class.default_values.deep_transform_values(&method(:_deep_copy)).merge(hash))
|
384
369
|
yield(self) if block_given?
|
385
370
|
|
386
371
|
@view_config ||= {}
|
@@ -396,6 +381,11 @@ module Blacklight
|
|
396
381
|
super || Rails.application.routes.url_helpers.root_path
|
397
382
|
end
|
398
383
|
|
384
|
+
# @return [Integer]
|
385
|
+
def default_per_page
|
386
|
+
super || per_page.first
|
387
|
+
end
|
388
|
+
|
399
389
|
# DSL helper
|
400
390
|
# @yield [config]
|
401
391
|
# @yieldparam [Blacklight::Configuration]
|
@@ -409,8 +399,7 @@ module Blacklight
|
|
409
399
|
# if not set, defaults to first defined search field
|
410
400
|
# @return [Blacklight::Configuration::SearchField]
|
411
401
|
def default_search_field
|
412
|
-
|
413
|
-
field || search_fields.values.first
|
402
|
+
@default_search_field ||= super || search_fields.values.find { |f| f.default == true } || search_fields.values.first
|
414
403
|
end
|
415
404
|
|
416
405
|
# Returns default sort field, used for simpler display in history, etc.
|
@@ -488,7 +477,7 @@ module Blacklight
|
|
488
477
|
# Note: Rails provides `#deep_dup`, but it aggressively `#dup`'s class names too, turning them
|
489
478
|
# into anonymous class instances.
|
490
479
|
def deep_copy
|
491
|
-
|
480
|
+
deep_transform_values(&method(:_deep_copy))
|
492
481
|
end
|
493
482
|
|
494
483
|
# builds a copy for the provided controller class
|
@@ -520,14 +509,12 @@ module Blacklight
|
|
520
509
|
view_type = nil
|
521
510
|
end
|
522
511
|
|
523
|
-
@view_config[[view_type, action_name]] ||=
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
end
|
530
|
-
end
|
512
|
+
@view_config[[view_type, action_name]] ||= if view_type.nil?
|
513
|
+
action_config(action_name)
|
514
|
+
else
|
515
|
+
base_config = action_config(action_name)
|
516
|
+
base_config.merge(view.fetch(view_type, {}))
|
517
|
+
end
|
531
518
|
end
|
532
519
|
|
533
520
|
# YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
|
@@ -537,10 +524,13 @@ module Blacklight
|
|
537
524
|
# @!macro partial_if_unless
|
538
525
|
# @param name [String] the name of the document partial
|
539
526
|
# @param opts [Hash]
|
527
|
+
# @option opts [Class] :component draw a component
|
528
|
+
# @option opts [String] :partial partial to draw if component is false
|
540
529
|
# @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true. The proc will receive the action configuration and the document or documents for the action.
|
541
530
|
# @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true. The proc will receive the action configuration and the document or documents for the action.
|
542
531
|
def add_show_tools_partial(name, opts = {})
|
543
532
|
opts[:partial] ||= 'document_action'
|
533
|
+
|
544
534
|
add_action(show.document_actions, name, opts)
|
545
535
|
klass && ActionBuilder.new(klass, name, opts).build
|
546
536
|
end
|
@@ -567,9 +557,9 @@ module Blacklight
|
|
567
557
|
##
|
568
558
|
# Add a section of config that only applies to documents with a matching display type
|
569
559
|
def for_display_type display_type, &_block
|
570
|
-
|
560
|
+
fields_for_type[display_type] ||= self.class.new
|
571
561
|
|
572
|
-
|
562
|
+
fields_for_type[display_type].tap do |conf|
|
573
563
|
yield(conf) if block_given?
|
574
564
|
end
|
575
565
|
end
|
@@ -577,45 +567,21 @@ module Blacklight
|
|
577
567
|
##
|
578
568
|
# Return a list of fields for the index display that should be used for the
|
579
569
|
# provided document. This respects any configuration made using for_display_type
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
else
|
585
|
-
document_or_display_types
|
586
|
-
end
|
587
|
-
|
588
|
-
fields = {}.with_indifferent_access
|
589
|
-
|
590
|
-
Array.wrap(display_types).each do |display_type|
|
591
|
-
fields = fields.merge(for_display_type(display_type).index_fields)
|
570
|
+
# @deprecated
|
571
|
+
def index_fields_for(display_types)
|
572
|
+
Array(display_types).inject(index_fields) do |fields, display_type|
|
573
|
+
fields.merge(for_display_type(display_type).index_fields)
|
592
574
|
end
|
593
|
-
|
594
|
-
fields.merge(index_fields)
|
595
575
|
end
|
596
576
|
|
597
577
|
##
|
598
578
|
# Return a list of fields for the show page that should be used for the
|
599
579
|
# provided document. This respects any configuration made using for_display_type
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
else
|
605
|
-
document_or_display_types
|
606
|
-
end
|
607
|
-
|
608
|
-
unless display_types.respond_to?(:each)
|
609
|
-
Deprecation.warn self, "Calling show_fields_for with a scalar value is deprecated. It must receive an Enumerable."
|
610
|
-
display_types = Array.wrap(display_types)
|
580
|
+
# @deprecated
|
581
|
+
def show_fields_for(display_types)
|
582
|
+
Array(display_types).inject(show_fields) do |fields, display_type|
|
583
|
+
fields.merge(for_display_type(display_type).show_fields)
|
611
584
|
end
|
612
|
-
fields = {}.with_indifferent_access
|
613
|
-
|
614
|
-
display_types.each do |display_type|
|
615
|
-
fields = fields.merge(for_display_type(display_type).show_fields)
|
616
|
-
end
|
617
|
-
|
618
|
-
fields.merge(show_fields)
|
619
585
|
end
|
620
586
|
|
621
587
|
# @!visibility private
|
@@ -638,34 +604,13 @@ module Blacklight
|
|
638
604
|
def _deep_copy(value)
|
639
605
|
case value
|
640
606
|
when Module then value
|
641
|
-
when NestedOpenStructWithHashAccess then value.class.new(value.nested_class,
|
642
|
-
when OpenStruct then value.class.new(
|
607
|
+
when NestedOpenStructWithHashAccess then value.class.new(value.nested_class, value.to_h.deep_transform_values(&method(:_deep_copy)))
|
608
|
+
when OpenStruct then value.class.new(value.to_h.deep_transform_values(&method(:_deep_copy)))
|
643
609
|
else
|
644
610
|
value.dup
|
645
611
|
end
|
646
612
|
end
|
647
613
|
|
648
|
-
# This is a little shim to support Rails 6 (which has Hash#deep_transform_values) and
|
649
|
-
# earlier versions (which use our backport). Once we drop support for Rails 6, this
|
650
|
-
# can go away.
|
651
|
-
def deep_transform_values_in_object(object, &block)
|
652
|
-
return object.deep_transform_values(&block) if object.respond_to?(:deep_transform_values)
|
653
|
-
|
654
|
-
_deep_transform_values_in_object(object, &block)
|
655
|
-
end
|
656
|
-
|
657
|
-
# Ported from Rails 6
|
658
|
-
def _deep_transform_values_in_object(object, &block)
|
659
|
-
case object
|
660
|
-
when Hash
|
661
|
-
object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
|
662
|
-
when Array
|
663
|
-
object.map { |e| _deep_transform_values_in_object(e, &block) }
|
664
|
-
else
|
665
|
-
yield(object)
|
666
|
-
end
|
667
|
-
end
|
668
|
-
|
669
614
|
def action_config(action, default: :index)
|
670
615
|
action_config = action_mapping[action]
|
671
616
|
action_config ||= action_mapping[:default]
|