blacklight 7.33.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +3 -2
- data/.github/workflows/ruby.yml +38 -107
- data/.gitignore +1 -0
- data/.rubocop.yml +243 -2
- data/.rubocop_todo.yml +216 -270
- data/Gemfile +7 -6
- data/README.md +12 -4
- data/Rakefile +18 -0
- data/VERSION +1 -1
- data/app/assets/config/blacklight/manifest.js +3 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js +376 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
- data/app/assets/javascripts/blacklight/blacklight.js +332 -485
- 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 +104 -49
- 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 +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +7 -9
- data/app/components/blacklight/constraints_component.rb +27 -37
- data/app/components/blacklight/document/action_component.html.erb +2 -9
- data/app/components/blacklight/document/action_component.rb +26 -8
- 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/show_tools_component.html.erb +12 -0
- data/app/components/blacklight/document/show_tools_component.rb +23 -0
- 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 +54 -42
- data/app/components/blacklight/document_metadata_component.html.erb +4 -2
- data/app/components/blacklight/document_metadata_component.rb +11 -6
- 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.html.erb +2 -0
- data/app/components/blacklight/header_component.rb +26 -0
- 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 +7 -22
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +17 -0
- data/app/components/blacklight/response/facet_group_component.html.erb +5 -6
- data/app/components/blacklight/response/facet_group_component.rb +29 -8
- data/app/components/blacklight/response/sort_component.rb +2 -2
- 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/server_applied_params_component.html.erb +4 -0
- data/app/components/blacklight/search_context/server_applied_params_component.rb +13 -0
- data/app/components/blacklight/search_context/server_item_pagination_component.rb +71 -0
- 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/search_navbar_component.html.erb +5 -0
- data/app/components/blacklight/search_navbar_component.rb +34 -0
- data/app/components/blacklight/start_over_button_component.rb +5 -3
- data/app/components/blacklight/system/dropdown_component.rb +3 -3
- data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
- 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 +12 -0
- data/app/components/blacklight/top_navbar_component.rb +17 -0
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +11 -6
- data/app/controllers/concerns/blacklight/catalog.rb +21 -72
- data/app/controllers/concerns/blacklight/controller.rb +6 -43
- data/app/controllers/concerns/blacklight/search_context.rb +71 -13
- 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 +1 -400
- data/app/helpers/blacklight/catalog_helper_behavior.rb +40 -182
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -63
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
- data/app/helpers/blacklight/document_helper_behavior.rb +76 -0
- 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 +60 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +12 -30
- data/app/helpers/blacklight/url_helper_behavior.rb +21 -97
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/javascript/blacklight/bookmark_toggle.js +9 -22
- data/app/javascript/blacklight/button_focus.js +9 -7
- data/app/javascript/blacklight/checkbox_submit.js +68 -122
- data/app/javascript/blacklight/core.js +6 -5
- data/app/javascript/blacklight/index.js +14 -0
- data/app/javascript/blacklight/modal.js +100 -165
- data/app/javascript/blacklight/modalForm.js +60 -0
- data/app/javascript/blacklight/search_context.js +13 -29
- 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/attributes.rb +50 -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/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.rb +23 -20
- 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 +23 -18
- 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 +24 -30
- 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/abstract_step.rb +4 -0
- data/app/presenters/blacklight/rendering/join.rb +7 -1
- data/app/presenters/blacklight/rendering/link_to_facet.rb +3 -6
- data/app/presenters/blacklight/rendering/microdata.rb +1 -1
- 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 +9 -7
- data/app/values/blacklight/types.rb +95 -11
- 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 +3 -6
- data/app/views/catalog/_document.rss.builder +2 -4
- data/app/views/catalog/_document_list.html.erb +2 -1
- 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 +3 -3
- 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 +8 -19
- data/app/views/catalog/_show_sidebar.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +1 -19
- 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 +7 -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/show.html.erb +1 -6
- 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 +19 -9
- data/app/views/record_mailer/email_record.text.erb +4 -3
- data/app/views/record_mailer/sms_record.text.erb +4 -4
- data/app/views/search_history/index.html.erb +6 -2
- data/app/views/shared/_header_navbar.html.erb +1 -22
- data/app/views/shared/_modal.html.erb +3 -3
- data/blacklight.gemspec +8 -10
- data/config/importmap.rb +3 -0
- data/config/locales/blacklight.ar.yml +209 -233
- data/config/locales/blacklight.ca.yml +0 -7
- data/config/locales/blacklight.de.yml +197 -216
- data/config/locales/blacklight.en.yml +2 -7
- data/config/locales/blacklight.es.yml +196 -216
- data/config/locales/blacklight.fr.yml +196 -220
- data/config/locales/blacklight.hu.yml +193 -213
- data/config/locales/blacklight.it.yml +197 -216
- data/config/locales/blacklight.nl.yml +193 -213
- data/config/locales/blacklight.pt-BR.yml +195 -216
- data/config/locales/blacklight.sq.yml +193 -213
- data/config/locales/blacklight.zh.yml +194 -214
- 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 +1 -0
- 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/session_tracking_config.rb +45 -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 -10
- data/lib/blacklight/configuration.rb +322 -341
- data/lib/blacklight/engine.rb +13 -15
- 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 +3 -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 +1 -0
- data/lib/blacklight/solr/request.rb +3 -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 +16 -32
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/blacklight.rb +8 -11
- data/lib/generators/blacklight/assets/importmap_generator.rb +56 -0
- data/lib/generators/blacklight/assets/propshaft_generator.rb +34 -0
- data/lib/generators/blacklight/assets/sprockets_generator.rb +68 -0
- data/lib/generators/blacklight/assets_generator.rb +14 -88
- 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 +7 -4
- 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 +37 -7
- data/lib/generators/blacklight/templates/solr_document.rb +1 -7
- data/lib/generators/blacklight/test_support_generator.rb +4 -2
- data/lib/generators/blacklight/user_generator.rb +7 -9
- data/lib/railties/blacklight.rake +2 -3
- data/package.json +10 -10
- data/rollup.config.js +37 -0
- data/spec/components/blacklight/constraints_component_spec.rb +17 -13
- data/spec/components/blacklight/document_component_spec.rb +74 -33
- 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 +9 -7
- data/spec/components/blacklight/header_component_spec.rb +20 -0
- data/spec/components/blacklight/response/view_type_component_spec.rb +83 -0
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +29 -0
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +51 -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 +24 -126
- data/spec/features/autocomplete_spec.rb +1 -1
- data/spec/features/axe_spec.rb +1 -1
- data/spec/features/bookmarks_spec.rb +1 -1
- data/spec/features/component_template_override_spec.rb +8 -0
- data/spec/features/facets_spec.rb +1 -1
- data/spec/features/modal_spec.rb +12 -0
- data/spec/features/search_context_spec.rb +4 -10
- data/spec/features/search_results_spec.rb +0 -33
- data/spec/features/sitelinks_search_box_spec.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 +10 -132
- data/spec/helpers/blacklight_helper_spec.rb +3 -298
- data/spec/helpers/catalog_helper_spec.rb +60 -115
- 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/session_tracking_config_spec.rb +38 -0
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +4 -4
- 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 +41 -53
- data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
- data/spec/models/blacklight/icon_spec.rb +29 -15
- data/spec/models/blacklight/search_builder_spec.rb +12 -12
- data/spec/models/blacklight/solr/document_spec.rb +3 -3
- data/spec/models/blacklight/solr/request_spec.rb +2 -2
- 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 +32 -23
- data/spec/models/blacklight/user_spec.rb +22 -0
- data/spec/models/record_mailer_spec.rb +36 -23
- data/spec/models/solr_document_spec.rb +21 -3
- data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -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 +2 -16
- data/spec/presenters/blacklight/index_presenter_spec.rb +3 -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 +11 -25
- data/spec/presenters/pipeline_spec.rb +13 -2
- 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 +6 -1
- data/spec/services/blacklight/search_service_spec.rb +31 -68
- data/spec/spec_helper.rb +4 -3
- 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_test_helpers.rb +21 -0
- data/spec/test_app_templates/Gemfile.extra +4 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -2
- data/spec/views/catalog/_document.html.erb_spec.rb +23 -33
- data/spec/views/catalog/_document_list.html.erb_spec.rb +7 -2
- 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 +7 -54
- 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 +3 -3
- 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 +7 -5
- metadata +95 -123
- 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_context_component.rb +0 -34
- data/app/controllers/concerns/blacklight/base.rb +0 -7
- 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/models/concerns/blacklight/document/email.rb +0 -26
- data/app/models/concerns/blacklight/document/sms.rb +0 -24
- 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/controllers/blacklight/facet_spec.rb +0 -33
- data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
- data/spec/features/sitelinks_search_box.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 -108
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
- data/spec/lib/blacklight/engine_spec.rb +0 -41
- data/spec/models/blacklight/document/email_spec.rb +0 -57
- data/spec/models/blacklight/document/sms_spec.rb +0 -58
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
- data/spec/support/view_component_capybara_test_helpers.rb +0 -8
- 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
- /data/app/components/blacklight/{search_context_component.html.erb → search_context/server_item_pagination_component.html.erb} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
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
|
|
@@ -12,305 +13,314 @@ module Blacklight
|
|
|
12
13
|
autoload :Fields
|
|
13
14
|
autoload :Field
|
|
14
15
|
autoload :NullField
|
|
16
|
+
autoload :NullDisplayField
|
|
15
17
|
autoload :SearchField
|
|
16
18
|
autoload :FacetField
|
|
17
19
|
autoload :SortField
|
|
18
20
|
autoload :DisplayField
|
|
19
21
|
autoload :IndexField
|
|
20
22
|
autoload :ShowField
|
|
23
|
+
autoload :SessionTrackingConfig
|
|
21
24
|
end
|
|
22
25
|
|
|
26
|
+
class_attribute :default_values, default: {}
|
|
27
|
+
|
|
23
28
|
# Set up Blacklight::Configuration.default_values to contain the basic, required Blacklight fields
|
|
24
29
|
class << self
|
|
25
30
|
def property(key, default: nil)
|
|
26
31
|
default_values[key] = default
|
|
27
32
|
end
|
|
28
33
|
|
|
29
|
-
def
|
|
30
|
-
@
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
# === Search request configuration
|
|
34
|
-
|
|
35
|
-
# @!attribute http_method
|
|
36
|
-
# @since v5.0.0
|
|
37
|
-
# @return [:get, :post] HTTP method used for search
|
|
38
|
-
property :http_method, default: :get
|
|
39
|
-
# @!attribute solr_path
|
|
40
|
-
# @return [String] The path to send requests to solr.
|
|
41
|
-
property :solr_path, default: 'select'
|
|
42
|
-
# @!attribute default_solr_params
|
|
43
|
-
# @return [Hash] Default values of parameters to send with every search request
|
|
44
|
-
property :default_solr_params, default: {}
|
|
45
|
-
|
|
46
|
-
# === Single document request configuration
|
|
47
|
-
|
|
48
|
-
# @!attribute document_solr_request_handler
|
|
49
|
-
# @return [String] The solr request handler to use when requesting only a single document
|
|
50
|
-
property :document_solr_request_handler, default: nil
|
|
51
|
-
# @!attribute document_solr_path
|
|
52
|
-
# @since v5.2.0
|
|
53
|
-
# @return [String] The url path (relative to the solr base url) to use when requesting only a single document
|
|
54
|
-
property :document_solr_path, default: 'get'
|
|
55
|
-
# @!attribute document_unique_id_param
|
|
56
|
-
# @since v5.2.0
|
|
57
|
-
# @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
|
|
58
|
-
property :document_unique_id_param, default: :ids
|
|
59
|
-
# @!attribute default_document_solr_params
|
|
60
|
-
# @return [Hash] Default values of parameters to send with every single-document request
|
|
61
|
-
property :default_document_solr_params, default: {}
|
|
62
|
-
# @!attribute fetch_many_document_params
|
|
63
|
-
# @since v7.0.0
|
|
64
|
-
# @return [Hash] Default values of parameters to send with every multi-document request
|
|
65
|
-
property :fetch_many_document_params, default: {}
|
|
66
|
-
# @!attribute document_pagination_params
|
|
67
|
-
# @return [Hash] Default values of parameters to send when getting the previous + next documents
|
|
68
|
-
property :document_pagination_params, default: {}
|
|
69
|
-
|
|
70
|
-
##
|
|
71
|
-
# == Response models
|
|
72
|
-
|
|
73
|
-
# @!attribute repository_class
|
|
74
|
-
# @return [Class] Class for sending and receiving requests from a search index
|
|
75
|
-
property :repository_class, default: nil
|
|
76
|
-
def repository_class
|
|
77
|
-
super || Blacklight::Solr::Repository
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# @!attribute search_builder_class
|
|
81
|
-
# @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
|
|
82
|
-
property :search_builder_class, default: nil
|
|
83
|
-
def search_builder_class
|
|
84
|
-
super || locate_search_builder_class
|
|
85
|
-
end
|
|
34
|
+
def default_configuration(&block)
|
|
35
|
+
@default_configurations ||= []
|
|
86
36
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# @!attribute response_model
|
|
92
|
-
# model that maps index responses to the blacklight response model
|
|
93
|
-
# @return [Class]
|
|
94
|
-
property :response_model, default: nil
|
|
95
|
-
def response_model
|
|
96
|
-
super || Blacklight::Solr::Response
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def response_model=(*args)
|
|
100
|
-
super
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
# @!attribute document_factory
|
|
104
|
-
# the factory that builds document
|
|
105
|
-
# @return [Class]
|
|
106
|
-
property :document_factory, default: nil
|
|
107
|
-
# A class that builds documents
|
|
108
|
-
def document_factory
|
|
109
|
-
super || Blacklight::DocumentFactory
|
|
110
|
-
end
|
|
111
|
-
# @!attribute document_model
|
|
112
|
-
# the model to use for each response document
|
|
113
|
-
# @return [Class]
|
|
114
|
-
property :document_model, default: nil
|
|
115
|
-
def document_model
|
|
116
|
-
super || ::SolrDocument
|
|
117
|
-
end
|
|
37
|
+
if block
|
|
38
|
+
@default_configurations << block
|
|
118
39
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
super
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# @!attribute facet_paginator_class
|
|
125
|
-
# Class for paginating long lists of facet fields
|
|
126
|
-
# @return [Class]
|
|
127
|
-
property :facet_paginator_class, default: nil
|
|
128
|
-
def facet_paginator_class
|
|
129
|
-
super || Blacklight::Solr::FacetPaginator
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# @!attribute connection_config
|
|
133
|
-
# repository connection configuration
|
|
134
|
-
# @since v5.13.0
|
|
135
|
-
# @return [Class]
|
|
136
|
-
property :connection_config, default: nil
|
|
137
|
-
def connection_config
|
|
138
|
-
super || Blacklight.connection_config
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
##
|
|
142
|
-
# == Blacklight view configuration
|
|
143
|
-
|
|
144
|
-
# @!attribute navbar
|
|
145
|
-
# @since v5.8.0
|
|
146
|
-
# @return [#partials]
|
|
147
|
-
property :navbar, default: OpenStructWithHashAccess.new(partials: {})
|
|
148
|
-
|
|
149
|
-
# @!attribute index
|
|
150
|
-
# General configuration for all views
|
|
151
|
-
# @return [Blacklight::Configuration::ViewConfig::Index]
|
|
152
|
-
property :index, default: ViewConfig::Index.new(
|
|
153
|
-
# document presenter class used by helpers and views
|
|
154
|
-
document_presenter_class: nil,
|
|
155
|
-
# component class used to render a document
|
|
156
|
-
document_component: nil,
|
|
157
|
-
# solr field to use to render a document title
|
|
158
|
-
title_field: nil,
|
|
159
|
-
# solr field to use to render format-specific partials
|
|
160
|
-
display_type_field: nil,
|
|
161
|
-
# partials to render for each document(see #render_document_partials)
|
|
162
|
-
partials: [:index_header, :thumbnail, :index],
|
|
163
|
-
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
|
164
|
-
collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
|
165
|
-
# what field, if any, to use to render grouped results
|
|
166
|
-
group: false,
|
|
167
|
-
# additional response formats for search results
|
|
168
|
-
respond_to: OpenStructWithHashAccess.new,
|
|
169
|
-
# component class used to render the facet grouping
|
|
170
|
-
facet_group_component: nil,
|
|
171
|
-
# component class used to render search constraints
|
|
172
|
-
constraints_component: nil,
|
|
173
|
-
# component class used to render the search bar
|
|
174
|
-
search_bar_component: nil
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
# @!attribute show
|
|
178
|
-
# Additional configuration when displaying a single document
|
|
179
|
-
# @return [Blacklight::Configuration::ViewConfig::Show]
|
|
180
|
-
property :show, default: ViewConfig::Show.new(
|
|
181
|
-
# document presenter class used by helpers and views
|
|
182
|
-
document_presenter_class: nil,
|
|
183
|
-
document_component: nil,
|
|
184
|
-
display_type_field: nil,
|
|
185
|
-
# Default route parameters for 'show' requests.
|
|
186
|
-
# Set this to a hash with additional arguments to merge into the route,
|
|
187
|
-
# or set `controller: :current` to route to the current controller.
|
|
188
|
-
route: nil,
|
|
189
|
-
# partials to render for each document(see #render_document_partials)
|
|
190
|
-
partials: [:show_header, :show],
|
|
191
|
-
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
# @!attribute action_mapping
|
|
195
|
-
# @since v7.16.0
|
|
196
|
-
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
|
197
|
-
property :action_mapping, default: NestedOpenStructWithHashAccess.new(
|
|
198
|
-
ViewConfig,
|
|
199
|
-
default: { top_level_config: :index },
|
|
200
|
-
show: { top_level_config: :show },
|
|
201
|
-
citation: { parent_config: :show }
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
# @!attribute sms
|
|
205
|
-
# @since v7.21.0
|
|
206
|
-
# @return [Blacklight::Configuration::ViewConfig]
|
|
207
|
-
property :sms, default: ViewConfig.new
|
|
208
|
-
|
|
209
|
-
# @!attribute email
|
|
210
|
-
# @since v7.21.0
|
|
211
|
-
# @return [Blacklight::Configuration::ViewConfig]
|
|
212
|
-
property :email, default: ViewConfig.new
|
|
213
|
-
|
|
214
|
-
# @!attribute
|
|
215
|
-
# Configurations for specific types of index views
|
|
216
|
-
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
|
217
|
-
property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
|
|
218
|
-
list: {},
|
|
219
|
-
atom: {
|
|
220
|
-
if: false, # by default, atom should not show up as an alternative view
|
|
221
|
-
partials: [:document],
|
|
222
|
-
summary_partials: [:index]
|
|
223
|
-
},
|
|
224
|
-
rss: {
|
|
225
|
-
if: false, # by default, rss should not show up as an alternative view
|
|
226
|
-
partials: [:document]
|
|
227
|
-
})
|
|
40
|
+
block.call if @default_configuration_initialized
|
|
41
|
+
end
|
|
228
42
|
|
|
229
|
-
|
|
230
|
-
|
|
43
|
+
@default_configurations
|
|
44
|
+
end
|
|
231
45
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
46
|
+
def initialize_default_configuration
|
|
47
|
+
@default_configurations&.map(&:call)
|
|
48
|
+
@default_configuration_initialized = true
|
|
49
|
+
end
|
|
236
50
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
property :max_per_page, default: 100
|
|
241
|
-
# @!attribute per_page
|
|
242
|
-
# Options for the user for number of results to show per page
|
|
243
|
-
# @return [Array<Integer>]
|
|
244
|
-
property :per_page, default: [10, 20, 50, 100]
|
|
245
|
-
# @!attribute default_per_page
|
|
246
|
-
# @return [Integer]
|
|
247
|
-
property :default_per_page, default: nil
|
|
248
|
-
# @return [Integer]
|
|
249
|
-
def default_per_page
|
|
250
|
-
super || per_page.first
|
|
51
|
+
def initialized_default_configuration?
|
|
52
|
+
@default_configuration_initialized
|
|
53
|
+
end
|
|
251
54
|
end
|
|
252
55
|
|
|
253
|
-
# @!attribute search_history_window
|
|
254
|
-
# how many searches to save in session history
|
|
255
|
-
# @return [Integer]
|
|
256
|
-
property :search_history_window, default: 100
|
|
257
|
-
# @!attribute default_facet_limit
|
|
258
|
-
# @since v5.10.0
|
|
259
|
-
# @return [Integer]
|
|
260
|
-
property :default_facet_limit, default: 10
|
|
261
|
-
# @!attribute default_more_limit
|
|
262
|
-
# @since v7.0.0
|
|
263
|
-
# @return [Integer]
|
|
264
|
-
property :default_more_limit, default: 20
|
|
265
|
-
|
|
266
|
-
# @!attribute crawler_detector
|
|
267
|
-
# proc for determining whether the session is a crawler/bot
|
|
268
|
-
# ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
|
|
269
|
-
# @since v7.0.0
|
|
270
|
-
# @return [<nil, Proc>]
|
|
271
|
-
property :crawler_detector, default: nil
|
|
272
|
-
|
|
273
|
-
# @!attribute autocomplete_suggester
|
|
274
|
-
# @since v7.0.0
|
|
275
|
-
# @return [String]
|
|
276
|
-
property :autocomplete_suggester, default: 'mySuggester'
|
|
277
|
-
|
|
278
|
-
# @!attribute raw_endpoint
|
|
279
|
-
# @since v7.0.0
|
|
280
|
-
# @return [#enabled]
|
|
281
|
-
property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
|
|
282
|
-
|
|
283
|
-
# @!attribute track_search_session
|
|
284
|
-
# @since v7.1.0
|
|
285
|
-
# @return [Boolean]
|
|
286
|
-
property :track_search_session, default: true
|
|
287
|
-
|
|
288
|
-
# @!attribute advanced_search
|
|
289
|
-
# @since v7.15.0
|
|
290
|
-
# @return [#enabled]
|
|
291
|
-
property :advanced_search, default: OpenStruct.new(enabled: false)
|
|
292
|
-
|
|
293
|
-
# @!attribute enable_search_bar_autofocus
|
|
294
|
-
# @since v7.2.0
|
|
295
|
-
# @return [Boolean]
|
|
296
|
-
property :enable_search_bar_autofocus, default: false
|
|
297
|
-
|
|
298
56
|
BASIC_SEARCH_PARAMETERS = [:q, :qt, :page, :per_page, :search_field, :sort, :controller, :action, :'facet.page', :'facet.prefix', :'facet.sort', :rows, :format, :view].freeze
|
|
299
57
|
ADVANCED_SEARCH_PARAMETERS = [{ clause: {} }, :op].freeze
|
|
300
|
-
|
|
301
|
-
#
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
58
|
+
|
|
59
|
+
# rubocop:disable Metrics/BlockLength
|
|
60
|
+
default_configuration do
|
|
61
|
+
property :logo_link, default: nil
|
|
62
|
+
property :header_component, default: Blacklight::HeaderComponent
|
|
63
|
+
|
|
64
|
+
# bootstrap_version may be set to 4 or 5
|
|
65
|
+
bootstrap_version = ENV['BOOTSTRAP_VERSION'].presence || "5"
|
|
66
|
+
property :bootstrap_version, default: /(\d)(?:\.\d){0,2}/.match(bootstrap_version)[1].to_i
|
|
67
|
+
|
|
68
|
+
# === Search request configuration
|
|
69
|
+
|
|
70
|
+
# @!attribute http_method
|
|
71
|
+
# @since v5.0.0
|
|
72
|
+
# @return [:get, :post] HTTP method used for search
|
|
73
|
+
property :http_method, default: :get
|
|
74
|
+
# @!attribute solr_path
|
|
75
|
+
# @return [String] The path to send requests to solr.
|
|
76
|
+
property :solr_path, default: 'select'
|
|
77
|
+
# @!attribute default_solr_params
|
|
78
|
+
# @return [Hash] Default values of parameters to send with every search request
|
|
79
|
+
property :default_solr_params, default: {}
|
|
80
|
+
|
|
81
|
+
# === Single document request configuration
|
|
82
|
+
|
|
83
|
+
# @!attribute document_solr_request_handler
|
|
84
|
+
# @return [String] The solr request handler to use when requesting only a single document
|
|
85
|
+
property :document_solr_request_handler, default: nil
|
|
86
|
+
# @!attribute document_solr_path
|
|
87
|
+
# @since v5.2.0
|
|
88
|
+
# @return [String] The url path (relative to the solr base url) to use when requesting only a single document
|
|
89
|
+
property :document_solr_path, default: 'get'
|
|
90
|
+
# @!attribute document_unique_id_param
|
|
91
|
+
# @since v5.2.0
|
|
92
|
+
# @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
|
|
93
|
+
property :document_unique_id_param, default: :ids
|
|
94
|
+
# @!attribute default_document_solr_params
|
|
95
|
+
# @return [Hash] Default values of parameters to send with every single-document request
|
|
96
|
+
property :default_document_solr_params, default: {}
|
|
97
|
+
# @!attribute fetch_many_document_params
|
|
98
|
+
# @since v7.0.0
|
|
99
|
+
# @return [Hash] Default values of parameters to send with every multi-document request
|
|
100
|
+
property :fetch_many_document_params, default: {}
|
|
101
|
+
# @!attribute document_pagination_params
|
|
102
|
+
# @return [Hash] Default values of parameters to send when getting the previous + next documents
|
|
103
|
+
property :document_pagination_params, default: {}
|
|
104
|
+
|
|
105
|
+
##
|
|
106
|
+
# == Response models
|
|
107
|
+
|
|
108
|
+
# @!attribute repository_class
|
|
109
|
+
# @return [Class] Class for sending and receiving requests from a search index
|
|
110
|
+
property :repository_class, default: Blacklight::Solr::Repository
|
|
111
|
+
# @!attribute search_builder_class
|
|
112
|
+
# @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
|
|
113
|
+
property :search_builder_class, default: ::SearchBuilder
|
|
114
|
+
# @!attribute response_model
|
|
115
|
+
# model that maps index responses to the blacklight response model
|
|
116
|
+
# @return [Class]
|
|
117
|
+
property :response_model, default: Blacklight::Solr::Response
|
|
118
|
+
# @!attribute document_model
|
|
119
|
+
# the model to use for each response document
|
|
120
|
+
# @return [Class]
|
|
121
|
+
property :document_model, default: ::SolrDocument
|
|
122
|
+
# @!attribute document_factory
|
|
123
|
+
# the factory that builds document
|
|
124
|
+
# @return [Class]
|
|
125
|
+
property :document_factory, default: Blacklight::DocumentFactory
|
|
126
|
+
# @!attribute facet_paginator_class
|
|
127
|
+
# Class for paginating long lists of facet fields
|
|
128
|
+
# @return [Class]
|
|
129
|
+
property :facet_paginator_class, default: Blacklight::Solr::FacetPaginator
|
|
130
|
+
# @!attribute connection_config
|
|
131
|
+
# repository connection configuration
|
|
132
|
+
# @since v5.13.0
|
|
133
|
+
# @return [Class]
|
|
134
|
+
property :connection_config, default: Blacklight.connection_config
|
|
135
|
+
|
|
136
|
+
##
|
|
137
|
+
# == Blacklight view configuration
|
|
138
|
+
|
|
139
|
+
# @!attribute navbar
|
|
140
|
+
# @since v5.8.0
|
|
141
|
+
# @return [#partials]
|
|
142
|
+
property :navbar, default: OpenStructWithHashAccess.new(partials: {})
|
|
143
|
+
|
|
144
|
+
# @!attribute index
|
|
145
|
+
# General configuration for all views
|
|
146
|
+
# @return [Blacklight::Configuration::ViewConfig::Index]
|
|
147
|
+
property :index, default: ViewConfig::Index.new(
|
|
148
|
+
# document presenter class used by helpers and views
|
|
149
|
+
document_presenter_class: nil,
|
|
150
|
+
# component class used to render a document
|
|
151
|
+
document_component: Blacklight::DocumentComponent,
|
|
152
|
+
sidebar_component: Blacklight::Search::SidebarComponent,
|
|
153
|
+
# solr field to use to render a document title
|
|
154
|
+
title_field: nil,
|
|
155
|
+
# solr field to use to render format-specific partials
|
|
156
|
+
display_type_field: nil,
|
|
157
|
+
# the "field access" key to use to look up the document display fields
|
|
158
|
+
document_fields_key: :index_fields,
|
|
159
|
+
# partials to render for each document(see #render_document_partials)
|
|
160
|
+
partials: [],
|
|
161
|
+
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
|
162
|
+
collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
|
163
|
+
# what field, if any, to use to render grouped results
|
|
164
|
+
group: false,
|
|
165
|
+
# additional response formats for search results
|
|
166
|
+
respond_to: OpenStructWithHashAccess.new,
|
|
167
|
+
# component class used to render the facet grouping
|
|
168
|
+
facet_group_component: nil,
|
|
169
|
+
# component class used to render search constraints
|
|
170
|
+
constraints_component: nil,
|
|
171
|
+
# component class used to render the search bar
|
|
172
|
+
search_bar_component: nil,
|
|
173
|
+
# component class used to render the header above the documents
|
|
174
|
+
search_header_component: Blacklight::SearchHeaderComponent
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
# @!attribute show
|
|
178
|
+
# Additional configuration when displaying a single document
|
|
179
|
+
# @return [Blacklight::Configuration::ViewConfig::Show]
|
|
180
|
+
property :show, default: ViewConfig::Show.new(
|
|
181
|
+
# document presenter class used by helpers and views
|
|
182
|
+
document_presenter_class: nil,
|
|
183
|
+
document_component: Blacklight::DocumentComponent,
|
|
184
|
+
sidebar_component: Blacklight::Document::SidebarComponent,
|
|
185
|
+
display_type_field: nil,
|
|
186
|
+
# the "field access" key to use to look up the document display fields
|
|
187
|
+
document_fields_key: :show_fields,
|
|
188
|
+
# Default route parameters for 'show' requests.
|
|
189
|
+
# Set this to a hash with additional arguments to merge into the route,
|
|
190
|
+
# or set `controller: :current` to route to the current controller.
|
|
191
|
+
route: nil,
|
|
192
|
+
# partials to render for each document(see #render_document_partials)
|
|
193
|
+
partials: [],
|
|
194
|
+
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
# @!attribute action_mapping
|
|
198
|
+
# @since v7.16.0
|
|
199
|
+
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
|
200
|
+
property :action_mapping, default: NestedOpenStructWithHashAccess.new(
|
|
201
|
+
ViewConfig,
|
|
202
|
+
default: { top_level_config: :index },
|
|
203
|
+
show: { top_level_config: :show },
|
|
204
|
+
citation: { parent_config: :show },
|
|
205
|
+
email_record: { top_level_config: :email },
|
|
206
|
+
sms_record: { top_level_config: :sms }
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
# @!attribute sms
|
|
210
|
+
# @since v7.21.0
|
|
211
|
+
# @return [Blacklight::Configuration::ViewConfig]
|
|
212
|
+
property :sms, default: ViewConfig.new
|
|
213
|
+
|
|
214
|
+
# @!attribute email
|
|
215
|
+
# @since v7.21.0
|
|
216
|
+
# @return [Blacklight::Configuration::ViewConfig]
|
|
217
|
+
property :email, default: ViewConfig.new
|
|
218
|
+
|
|
219
|
+
# @!attribute
|
|
220
|
+
# Configurations for specific types of index views
|
|
221
|
+
# @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
|
|
222
|
+
property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
|
|
223
|
+
list: {},
|
|
224
|
+
atom: {
|
|
225
|
+
if: false, # by default, atom should not show up as an alternative view
|
|
226
|
+
partials: [:document],
|
|
227
|
+
summary_component: Blacklight::DocumentComponent
|
|
228
|
+
},
|
|
229
|
+
rss: {
|
|
230
|
+
if: false, # by default, rss should not show up as an alternative view
|
|
231
|
+
partials: [:document]
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
##
|
|
235
|
+
# === Blacklight behavior configuration
|
|
236
|
+
|
|
237
|
+
# @!attribute spell_max
|
|
238
|
+
# Maxiumum number of spelling suggestions to offer
|
|
239
|
+
# @return [Integer]
|
|
240
|
+
property :spell_max, default: 5
|
|
241
|
+
|
|
242
|
+
# @!attribute max_per_page
|
|
243
|
+
# Maximum number of results to show per page
|
|
244
|
+
# @return [Integer]
|
|
245
|
+
property :max_per_page, default: 100
|
|
246
|
+
# @!attribute per_page
|
|
247
|
+
# Options for the user for number of results to show per page
|
|
248
|
+
# @return [Array<Integer>]
|
|
249
|
+
property :per_page, default: [10, 20, 50, 100]
|
|
250
|
+
# @!attribute default_per_page
|
|
251
|
+
# @return [Integer]
|
|
252
|
+
property :default_per_page, default: nil
|
|
253
|
+
|
|
254
|
+
# @!attribute search_history_window
|
|
255
|
+
# how many searches to save in session history
|
|
256
|
+
# @return [Integer]
|
|
257
|
+
property :search_history_window, default: 100
|
|
258
|
+
# @!attribute default_facet_limit
|
|
259
|
+
# @since v5.10.0
|
|
260
|
+
# @return [Integer]
|
|
261
|
+
property :default_facet_limit, default: 10
|
|
262
|
+
# @!attribute default_more_limit
|
|
263
|
+
# @since v7.0.0
|
|
264
|
+
# @return [Integer]
|
|
265
|
+
property :default_more_limit, default: 20
|
|
266
|
+
|
|
267
|
+
# @!attribute crawler_detector
|
|
268
|
+
# proc for determining whether the session is a crawler/bot
|
|
269
|
+
# ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
|
|
270
|
+
# @since v7.0.0
|
|
271
|
+
# @return [<nil, Proc>]
|
|
272
|
+
property :crawler_detector, default: nil
|
|
273
|
+
|
|
274
|
+
# @!attribute autocomplete_suggester
|
|
275
|
+
# @since v7.0.0
|
|
276
|
+
# @return [String]
|
|
277
|
+
property :autocomplete_suggester, default: 'mySuggester'
|
|
278
|
+
|
|
279
|
+
# @!attribute raw_endpoint
|
|
280
|
+
# @since v7.0.0
|
|
281
|
+
# @return [#enabled]
|
|
282
|
+
property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
|
|
283
|
+
|
|
284
|
+
# @!attribute track_search_session
|
|
285
|
+
# { storage: false } value: do no tracking
|
|
286
|
+
# @since v8.0.0
|
|
287
|
+
# @return [Blacklight::Configuration::SessionTrackingConfig]
|
|
288
|
+
property :track_search_session, default: Blacklight::Configuration::SessionTrackingConfig.new
|
|
289
|
+
|
|
290
|
+
# @!attribute advanced_search
|
|
291
|
+
# @since v7.15.0
|
|
292
|
+
# @return [#enabled]
|
|
293
|
+
property :advanced_search, default: OpenStruct.new(enabled: false)
|
|
294
|
+
|
|
295
|
+
# @!attribute enable_search_bar_autofocus
|
|
296
|
+
# @since v7.2.0
|
|
297
|
+
# @return [Boolean]
|
|
298
|
+
property :enable_search_bar_autofocus, default: false
|
|
299
|
+
|
|
300
|
+
# List the request parameters that compose the SearchState.
|
|
301
|
+
# If you use a plugin that adds to the search state, then you can add the parameters
|
|
302
|
+
# by modifiying this field.
|
|
303
|
+
# @!attribute search_state_fields
|
|
304
|
+
# @since v8.0.0
|
|
305
|
+
# @return [Array<Symbol>]
|
|
306
|
+
property :search_state_fields, default: BASIC_SEARCH_PARAMETERS + ADVANCED_SEARCH_PARAMETERS
|
|
307
|
+
|
|
308
|
+
# Have SearchState filter out unknown request parameters
|
|
309
|
+
#
|
|
310
|
+
# @!attribute filter_search_state_fields
|
|
311
|
+
# @since v8.0.0
|
|
312
|
+
# @return [Boolean]
|
|
313
|
+
property :filter_search_state_fields, default: true
|
|
314
|
+
|
|
315
|
+
# Additional Blacklight configuration setting for document-type specific
|
|
316
|
+
# configuration.
|
|
317
|
+
# @!attribute fields_for_type
|
|
318
|
+
# @since v8.0.0
|
|
319
|
+
# @return [Hash{Symbol => Blacklight::Configuration}]
|
|
320
|
+
# @see [#for_display_type]
|
|
321
|
+
property :fields_for_type, default: {}.with_indifferent_access
|
|
322
|
+
end
|
|
323
|
+
# rubocop:enable Metrics/BlockLength
|
|
314
324
|
|
|
315
325
|
##
|
|
316
326
|
# Create collections of solr field configurations.
|
|
@@ -357,7 +367,9 @@ module Blacklight
|
|
|
357
367
|
define_field_access :email_field, Blacklight::Configuration::DisplayField
|
|
358
368
|
|
|
359
369
|
def initialize(hash = {})
|
|
360
|
-
|
|
370
|
+
self.class.initialize_default_configuration unless self.class.initialized_default_configuration?
|
|
371
|
+
|
|
372
|
+
super(self.class.default_values.deep_transform_values(&method(:_deep_copy)).merge(hash))
|
|
361
373
|
yield(self) if block_given?
|
|
362
374
|
|
|
363
375
|
@view_config ||= {}
|
|
@@ -368,6 +380,16 @@ module Blacklight
|
|
|
368
380
|
repository_class.new(self)
|
|
369
381
|
end
|
|
370
382
|
|
|
383
|
+
# @return [String] The destination for the link around the logo in the header
|
|
384
|
+
def logo_link
|
|
385
|
+
super || Rails.application.routes.url_helpers.root_path
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# @return [Integer]
|
|
389
|
+
def default_per_page
|
|
390
|
+
super || per_page.first
|
|
391
|
+
end
|
|
392
|
+
|
|
371
393
|
# DSL helper
|
|
372
394
|
# @yield [config]
|
|
373
395
|
# @yieldparam [Blacklight::Configuration]
|
|
@@ -381,8 +403,7 @@ module Blacklight
|
|
|
381
403
|
# if not set, defaults to first defined search field
|
|
382
404
|
# @return [Blacklight::Configuration::SearchField]
|
|
383
405
|
def default_search_field
|
|
384
|
-
|
|
385
|
-
field || search_fields.values.first
|
|
406
|
+
@default_search_field ||= super || search_fields.values.find { |f| f.default == true } || search_fields.values.first
|
|
386
407
|
end
|
|
387
408
|
|
|
388
409
|
# Returns default sort field, used for simpler display in history, etc.
|
|
@@ -460,7 +481,7 @@ module Blacklight
|
|
|
460
481
|
# Note: Rails provides `#deep_dup`, but it aggressively `#dup`'s class names too, turning them
|
|
461
482
|
# into anonymous class instances.
|
|
462
483
|
def deep_copy
|
|
463
|
-
|
|
484
|
+
deep_transform_values(&method(:_deep_copy))
|
|
464
485
|
end
|
|
465
486
|
|
|
466
487
|
# builds a copy for the provided controller class
|
|
@@ -492,14 +513,12 @@ module Blacklight
|
|
|
492
513
|
view_type = nil
|
|
493
514
|
end
|
|
494
515
|
|
|
495
|
-
@view_config[[view_type, action_name]] ||=
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
end
|
|
502
|
-
end
|
|
516
|
+
@view_config[[view_type, action_name]] ||= if view_type.nil?
|
|
517
|
+
action_config(action_name)
|
|
518
|
+
else
|
|
519
|
+
base_config = action_config(action_name)
|
|
520
|
+
base_config.merge(view.fetch(view_type, {}))
|
|
521
|
+
end
|
|
503
522
|
end
|
|
504
523
|
|
|
505
524
|
# YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
|
|
@@ -509,10 +528,13 @@ module Blacklight
|
|
|
509
528
|
# @!macro partial_if_unless
|
|
510
529
|
# @param name [String] the name of the document partial
|
|
511
530
|
# @param opts [Hash]
|
|
531
|
+
# @option opts [Class] :component draw a component
|
|
532
|
+
# @option opts [String] :partial partial to draw if component is false
|
|
512
533
|
# @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.
|
|
513
534
|
# @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.
|
|
514
535
|
def add_show_tools_partial(name, opts = {})
|
|
515
536
|
opts[:partial] ||= 'document_action'
|
|
537
|
+
|
|
516
538
|
add_action(show.document_actions, name, opts)
|
|
517
539
|
klass && ActionBuilder.new(klass, name, opts).build
|
|
518
540
|
end
|
|
@@ -539,9 +561,9 @@ module Blacklight
|
|
|
539
561
|
##
|
|
540
562
|
# Add a section of config that only applies to documents with a matching display type
|
|
541
563
|
def for_display_type display_type, &_block
|
|
542
|
-
|
|
564
|
+
fields_for_type[display_type] ||= self.class.new
|
|
543
565
|
|
|
544
|
-
|
|
566
|
+
fields_for_type[display_type].tap do |conf|
|
|
545
567
|
yield(conf) if block_given?
|
|
546
568
|
end
|
|
547
569
|
end
|
|
@@ -549,41 +571,21 @@ module Blacklight
|
|
|
549
571
|
##
|
|
550
572
|
# Return a list of fields for the index display that should be used for the
|
|
551
573
|
# provided document. This respects any configuration made using for_display_type
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
else
|
|
557
|
-
document_or_display_types
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
fields = {}.with_indifferent_access
|
|
561
|
-
|
|
562
|
-
Array.wrap(display_types).each do |display_type|
|
|
563
|
-
fields = fields.merge(for_display_type(display_type).index_fields)
|
|
574
|
+
# @deprecated
|
|
575
|
+
def index_fields_for(display_types)
|
|
576
|
+
Array(display_types).inject(index_fields) do |fields, display_type|
|
|
577
|
+
fields.merge(for_display_type(display_type).index_fields)
|
|
564
578
|
end
|
|
565
|
-
|
|
566
|
-
fields.merge(index_fields)
|
|
567
579
|
end
|
|
568
580
|
|
|
569
581
|
##
|
|
570
582
|
# Return a list of fields for the show page that should be used for the
|
|
571
583
|
# provided document. This respects any configuration made using for_display_type
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
else
|
|
577
|
-
document_or_display_types
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
fields = {}.with_indifferent_access
|
|
581
|
-
|
|
582
|
-
Array.wrap(display_types).each do |display_type|
|
|
583
|
-
fields = fields.merge(for_display_type(display_type).show_fields)
|
|
584
|
+
# @deprecated
|
|
585
|
+
def show_fields_for(display_types)
|
|
586
|
+
Array(display_types).inject(show_fields) do |fields, display_type|
|
|
587
|
+
fields.merge(for_display_type(display_type).show_fields)
|
|
584
588
|
end
|
|
585
|
-
|
|
586
|
-
fields.merge(show_fields)
|
|
587
589
|
end
|
|
588
590
|
|
|
589
591
|
# @!visibility private
|
|
@@ -606,34 +608,13 @@ module Blacklight
|
|
|
606
608
|
def _deep_copy(value)
|
|
607
609
|
case value
|
|
608
610
|
when Module then value
|
|
609
|
-
when NestedOpenStructWithHashAccess then value.class.new(value.nested_class,
|
|
610
|
-
when OpenStruct then value.class.new(
|
|
611
|
+
when NestedOpenStructWithHashAccess then value.class.new(value.nested_class, value.to_h.deep_transform_values(&method(:_deep_copy)))
|
|
612
|
+
when OpenStruct then value.class.new(value.to_h.deep_transform_values(&method(:_deep_copy)))
|
|
611
613
|
else
|
|
612
614
|
value.dup
|
|
613
615
|
end
|
|
614
616
|
end
|
|
615
617
|
|
|
616
|
-
# This is a little shim to support Rails 6 (which has Hash#deep_transform_values) and
|
|
617
|
-
# earlier versions (which use our backport). Once we drop support for Rails 6, this
|
|
618
|
-
# can go away.
|
|
619
|
-
def deep_transform_values_in_object(object, &block)
|
|
620
|
-
return object.deep_transform_values(&block) if object.respond_to?(:deep_transform_values)
|
|
621
|
-
|
|
622
|
-
_deep_transform_values_in_object(object, &block)
|
|
623
|
-
end
|
|
624
|
-
|
|
625
|
-
# Ported from Rails 6
|
|
626
|
-
def _deep_transform_values_in_object(object, &block)
|
|
627
|
-
case object
|
|
628
|
-
when Hash
|
|
629
|
-
object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
|
|
630
|
-
when Array
|
|
631
|
-
object.map { |e| _deep_transform_values_in_object(e, &block) }
|
|
632
|
-
else
|
|
633
|
-
yield(object)
|
|
634
|
-
end
|
|
635
|
-
end
|
|
636
|
-
|
|
637
618
|
def action_config(action, default: :index)
|
|
638
619
|
action_config = action_mapping[action]
|
|
639
620
|
action_config ||= action_mapping[:default]
|