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,309 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
module Blacklight::FacetsHelperBehavior
|
3
|
-
extend Deprecation
|
4
|
-
self.deprecation_horizon = 'blacklight 8.0'
|
5
|
-
|
6
|
-
include Blacklight::Facet
|
7
|
-
|
8
|
-
##
|
9
|
-
# Check if any of the given fields have values
|
10
|
-
#
|
11
|
-
# @deprecated
|
12
|
-
# @param [Array<String>] fields
|
13
|
-
# @return [Boolean]
|
14
|
-
def has_facet_values? fields = facet_field_names, response = nil
|
15
|
-
deprecated_method(:has_facet_values?)
|
16
|
-
unless response
|
17
|
-
Deprecation.warn(self, 'Calling has_facet_values? without passing the ' \
|
18
|
-
'second argument (response) is deprecated and will be removed in Blacklight ' \
|
19
|
-
'8.0.0')
|
20
|
-
response = @response
|
21
|
-
end
|
22
|
-
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
23
|
-
Deprecation.silence(Blacklight::Facet) do
|
24
|
-
facets_from_request(fields, response).any? { |display_facet| should_render_facet?(display_facet) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
##
|
30
|
-
# Render a collection of facet fields.
|
31
|
-
# @see #render_facet_limit
|
32
|
-
#
|
33
|
-
# @deprecated
|
34
|
-
# @param [Array<String>] fields
|
35
|
-
# @param [Hash] options
|
36
|
-
# @option options [Blacklight::Solr::Response] :response the Solr response object
|
37
|
-
# @return String
|
38
|
-
def render_facet_partials fields = nil, options = {}
|
39
|
-
deprecated_method(:render_facet_partials)
|
40
|
-
|
41
|
-
unless fields
|
42
|
-
Deprecation.warn(self.class, 'Calling render_facet_partials without passing the ' \
|
43
|
-
'first argument (fields) is deprecated and will be removed in Blacklight ' \
|
44
|
-
'8.0.0')
|
45
|
-
fields = facet_field_names
|
46
|
-
end
|
47
|
-
|
48
|
-
response = options.delete(:response)
|
49
|
-
unless response
|
50
|
-
Deprecation.warn(self.class, 'Calling render_facet_partials without passing the ' \
|
51
|
-
'response keyword is deprecated and will be removed in Blacklight ' \
|
52
|
-
'8.0.0')
|
53
|
-
response = @response
|
54
|
-
end
|
55
|
-
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
56
|
-
Deprecation.silence(Blacklight::Facet) do
|
57
|
-
safe_join(facets_from_request(fields, response).map do |display_facet|
|
58
|
-
render_facet_limit(display_facet, options)
|
59
|
-
end.compact, "\n")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
##
|
65
|
-
# Renders a single section for facet limit with a specified
|
66
|
-
# solr field used for faceting. Can be over-ridden for custom
|
67
|
-
# display on a per-facet basis.
|
68
|
-
#
|
69
|
-
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
70
|
-
# @param [Hash] options parameters to use for rendering the facet limit partial
|
71
|
-
# @option options [String] :partial partial to render
|
72
|
-
# @option options [String] :layout partial layout to render
|
73
|
-
# @option options [Hash] :locals locals to pass to the partial
|
74
|
-
# @return [String]
|
75
|
-
def render_facet_limit(display_facet, options = {})
|
76
|
-
field_config = facet_configuration_for_field(display_facet.name)
|
77
|
-
|
78
|
-
if field_config.component
|
79
|
-
return render(
|
80
|
-
Blacklight::FacetComponent.new(
|
81
|
-
display_facet: display_facet,
|
82
|
-
field_config: field_config,
|
83
|
-
layout: (params[:action] == 'facet' ? false : options[:layout])
|
84
|
-
)
|
85
|
-
)
|
86
|
-
end
|
87
|
-
|
88
|
-
Deprecation.warn(Blacklight::FacetsHelperBehavior, 'Calling #render_facet_limit on a non-componentized'\
|
89
|
-
' facet is deprecated and will be removed in Blacklight 8')
|
90
|
-
|
91
|
-
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
92
|
-
return unless should_render_facet?(display_facet, field_config)
|
93
|
-
end
|
94
|
-
options = options.dup
|
95
|
-
|
96
|
-
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
97
|
-
options[:partial] ||= facet_partial_name(display_facet)
|
98
|
-
end
|
99
|
-
|
100
|
-
options[:layout] ||= "facet_layout" unless options.key?(:layout)
|
101
|
-
options[:locals] ||= {}
|
102
|
-
options[:locals][:field_name] ||= display_facet.name
|
103
|
-
options[:locals][:facet_field] ||= field_config
|
104
|
-
options[:locals][:display_facet] ||= display_facet
|
105
|
-
|
106
|
-
render(options)
|
107
|
-
end
|
108
|
-
|
109
|
-
##
|
110
|
-
# Renders the list of values
|
111
|
-
# removes any elements where render_facet_item returns a nil value. This enables an application
|
112
|
-
# to filter undesireable facet items so they don't appear in the UI
|
113
|
-
# @deprecated
|
114
|
-
def render_facet_limit_list(paginator, facet_field, wrapping_element = :li)
|
115
|
-
facet_config ||= facet_configuration_for_field(facet_field)
|
116
|
-
|
117
|
-
collection = paginator.items.map do |item|
|
118
|
-
facet_item_presenter(facet_config, item, facet_field)
|
119
|
-
end
|
120
|
-
|
121
|
-
render(facet_item_component_class(facet_config).with_collection(collection, wrapping_element: wrapping_element))
|
122
|
-
end
|
123
|
-
deprecation_deprecate :render_facet_limit_list
|
124
|
-
|
125
|
-
##
|
126
|
-
# Renders a single facet item
|
127
|
-
# @deprecated
|
128
|
-
def render_facet_item(facet_field, item)
|
129
|
-
deprecated_method(:render_facet_item)
|
130
|
-
if facet_in_params?(facet_field, item.value)
|
131
|
-
render_selected_facet_value(facet_field, item)
|
132
|
-
else
|
133
|
-
render_facet_value(facet_field, item)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
##
|
138
|
-
# Determine if Blacklight should render the display_facet or not
|
139
|
-
#
|
140
|
-
# By default, only render facets with items.
|
141
|
-
#
|
142
|
-
# @deprecated
|
143
|
-
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
144
|
-
# @param [Blacklight::Configuration::FacetField] facet_config
|
145
|
-
# @return [Boolean]
|
146
|
-
def should_render_facet? display_facet, facet_config = nil
|
147
|
-
return false if display_facet.items.blank?
|
148
|
-
|
149
|
-
# display when show is nil or true
|
150
|
-
facet_config ||= facet_configuration_for_field(display_facet.name)
|
151
|
-
should_render_field?(facet_config, display_facet)
|
152
|
-
end
|
153
|
-
deprecation_deprecate :should_render_facet?
|
154
2
|
|
155
|
-
|
156
|
-
|
157
|
-
# - if the facet is 'active', don't collapse
|
158
|
-
# - if the facet is configured to collapse (the default), collapse
|
159
|
-
# - if the facet is configured not to collapse, don't collapse
|
160
|
-
#
|
161
|
-
# @deprecated
|
162
|
-
# @param [Blacklight::Configuration::FacetField] facet_field
|
163
|
-
# @return [Boolean]
|
164
|
-
def should_collapse_facet? facet_field
|
165
|
-
Deprecation.silence(Blacklight::FacetsHelperBehavior) do
|
166
|
-
!facet_field_in_params?(facet_field.key) && facet_field.collapse
|
167
|
-
end
|
168
|
-
end
|
169
|
-
deprecation_deprecate :should_collapse_facet?
|
170
|
-
|
171
|
-
##
|
172
|
-
# The name of the partial to use to render a facet field.
|
173
|
-
# uses the value of the "partial" field if set in the facet configuration
|
174
|
-
# otherwise uses "facet_pivot" if this facet is a pivot facet
|
175
|
-
# defaults to 'facet_limit'
|
176
|
-
#
|
177
|
-
# @return [String]
|
178
|
-
def facet_partial_name(display_facet = nil)
|
179
|
-
config = facet_configuration_for_field(display_facet.name)
|
180
|
-
name = config.partial
|
181
|
-
name ||= "facet_pivot" if config.pivot
|
182
|
-
name || "facet_limit"
|
183
|
-
end
|
184
|
-
deprecation_deprecate :facet_partial_name
|
3
|
+
module Blacklight::FacetsHelperBehavior
|
4
|
+
delegate :facet_configuration_for_field, to: :blacklight_config
|
185
5
|
|
186
6
|
def facet_field_presenter(facet_config, display_facet)
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
##
|
191
|
-
# Standard display of a facet value in a list. Used in both _facets sidebar
|
192
|
-
# partial and catalog/facet expanded list. Will output facet value name as
|
193
|
-
# a link to add that to your restrictions, with count in parens.
|
194
|
-
#
|
195
|
-
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
196
|
-
# @param [Blacklight::Solr::Response::Facets::FacetItem] item
|
197
|
-
# @param [Hash] options
|
198
|
-
# @option options [Boolean] :suppress_link display the facet, but don't link to it
|
199
|
-
# @return [String]
|
200
|
-
def render_facet_value(facet_field, item, options = {})
|
201
|
-
deprecated_method(:render_facet_value)
|
202
|
-
facet_config = facet_configuration_for_field(facet_field)
|
203
|
-
facet_item_component(facet_config, item, facet_field, **options).render_facet_value
|
204
|
-
end
|
205
|
-
|
206
|
-
##
|
207
|
-
# Where should this facet link to?
|
208
|
-
#
|
209
|
-
# @deprecated
|
210
|
-
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
211
|
-
# @param [String] item
|
212
|
-
# @return [String]
|
213
|
-
def path_for_facet(facet_field, item, path_options = {})
|
214
|
-
facet_config = facet_configuration_for_field(facet_field)
|
215
|
-
facet_item_presenter(facet_config, item, facet_field).href(path_options)
|
216
|
-
end
|
217
|
-
deprecation_deprecate :path_for_facet
|
218
|
-
|
219
|
-
##
|
220
|
-
# Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
|
221
|
-
#
|
222
|
-
# @deprecated
|
223
|
-
# @see #render_facet_value
|
224
|
-
# @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
|
225
|
-
# @param [String] item
|
226
|
-
def render_selected_facet_value(facet_field, item)
|
227
|
-
deprecated_method(:render_selected_facet_value)
|
228
|
-
facet_config = facet_configuration_for_field(facet_field)
|
229
|
-
facet_item_component(facet_config, item, facet_field).render_selected_facet_value
|
230
|
-
end
|
231
|
-
|
232
|
-
##
|
233
|
-
# Renders a count value for facet limits. Can be over-ridden locally
|
234
|
-
# to change style. And can be called by plugins to get consistent display.
|
235
|
-
#
|
236
|
-
# @deprecated
|
237
|
-
# @param [Integer] num number of facet results
|
238
|
-
# @param [Hash] options
|
239
|
-
# @option options [Array<String>] an array of classes to add to count span.
|
240
|
-
# @return [String]
|
241
|
-
def render_facet_count(num, options = {})
|
242
|
-
deprecated_method(:render_facet_count)
|
243
|
-
classes = (options[:classes] || []) << "facet-count"
|
244
|
-
tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(num)), class: classes)
|
245
|
-
end
|
246
|
-
|
247
|
-
##
|
248
|
-
# Are any facet restrictions for a field in the query parameters?
|
249
|
-
# @private
|
250
|
-
# @param [String] field
|
251
|
-
# @return [Boolean]
|
252
|
-
def facet_field_in_params? field
|
253
|
-
config = facet_configuration_for_field(field)
|
254
|
-
|
255
|
-
Deprecation.silence(Blacklight::SearchState) do
|
256
|
-
search_state.has_facet? config
|
257
|
-
end
|
7
|
+
facet_config.presenter.new(facet_config, display_facet, self)
|
258
8
|
end
|
259
|
-
# Left undeprecated for the sake of temporary backwards compatibility
|
260
|
-
# deprecation_deprecate :facet_field_in_params?
|
261
|
-
|
262
|
-
##
|
263
|
-
# Check if the query parameters have the given facet field with the
|
264
|
-
# given value.
|
265
|
-
#
|
266
|
-
# @deprecated
|
267
|
-
# @param [String] field
|
268
|
-
# @param [String] item facet value
|
269
|
-
# @return [Boolean]
|
270
|
-
def facet_in_params?(field, item)
|
271
|
-
config = facet_configuration_for_field(field)
|
272
|
-
|
273
|
-
Deprecation.silence(Blacklight::SearchState) do
|
274
|
-
search_state.has_facet? config, value: facet_value_for_facet_item(item)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
deprecation_deprecate :facet_in_params?
|
278
|
-
|
279
|
-
##
|
280
|
-
# Get the values of the facet set in the blacklight query string
|
281
|
-
# @deprecated
|
282
|
-
def facet_params field
|
283
|
-
config = facet_configuration_for_field(field)
|
284
|
-
|
285
|
-
search_state.params.dig(:f, config.key)
|
286
|
-
end
|
287
|
-
deprecation_deprecate :facet_params
|
288
|
-
|
289
|
-
##
|
290
|
-
# Get the displayable version of a facet's value
|
291
|
-
#
|
292
|
-
# @param [Object] field
|
293
|
-
# @param [String] item value
|
294
|
-
# @return [String]
|
295
|
-
# @deprecated
|
296
|
-
def facet_display_value field, item
|
297
|
-
deprecated_method(:facet_display_value)
|
298
|
-
facet_config = facet_configuration_for_field(field)
|
299
|
-
facet_item_presenter(facet_config, item, field).label
|
300
|
-
end
|
301
|
-
|
302
|
-
# @deprecated
|
303
|
-
def facet_field_id facet_field
|
304
|
-
"facet-#{facet_field.key.parameterize}"
|
305
|
-
end
|
306
|
-
deprecation_deprecate :facet_field_id
|
307
9
|
|
308
10
|
private
|
309
11
|
|
@@ -316,25 +18,6 @@ module Blacklight::FacetsHelperBehavior
|
|
316
18
|
end
|
317
19
|
|
318
20
|
def facet_item_presenter(facet_config, facet_item, facet_field)
|
319
|
-
|
320
|
-
end
|
321
|
-
|
322
|
-
def facet_item_component(facet_config, facet_item, facet_field, **args)
|
323
|
-
facet_item_component_class(facet_config).new(facet_item: facet_item_presenter(facet_config, facet_item, facet_field), **args).with_view_context(self)
|
324
|
-
end
|
325
|
-
|
326
|
-
def facet_item_component_class(facet_config)
|
327
|
-
default_component = facet_config.pivot ? Blacklight::FacetItemPivotComponent : Blacklight::FacetItemComponent
|
328
|
-
facet_config.fetch(:item_component, default_component)
|
329
|
-
end
|
330
|
-
|
331
|
-
# We can't use .deprecation_deprecate here, because the new components need to
|
332
|
-
# see the originally defined location for these methods in order to properly
|
333
|
-
# call back into the helpers for backwards compatibility
|
334
|
-
def deprecated_method(method_name)
|
335
|
-
Deprecation.warn(Blacklight::FacetsHelperBehavior,
|
336
|
-
Deprecation.deprecated_method_warning(Blacklight::FacetsHelperBehavior,
|
337
|
-
method_name, {}),
|
338
|
-
caller)
|
21
|
+
facet_config.item_presenter.new(facet_item, facet_config, self, facet_field)
|
339
22
|
end
|
340
23
|
end
|
@@ -10,14 +10,12 @@ module Blacklight::IconHelperBehavior
|
|
10
10
|
# @param [String, Symbol] icon_name
|
11
11
|
# @return [String]
|
12
12
|
def blacklight_icon(icon_name, **kwargs)
|
13
|
-
return render(icon_name.new) if icon_name.is_a?(Class)
|
14
|
-
return render(icon_name) if icon_name.is_a?(ViewComponent::Base)
|
15
|
-
|
16
13
|
render "Blacklight::Icons::#{icon_name.to_s.camelize}Component".constantize.new(**kwargs)
|
17
14
|
rescue NameError
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
Blacklight.deprecation.warn(
|
16
|
+
"Falling back on the LegacyIconComponent with \"#{icon_name}\" is deprecated. Instead create the component `Blacklight::Icons::#{icon_name.to_s.camelize}Component` for this icon."
|
17
|
+
)
|
18
|
+
|
19
|
+
render Blacklight::Icons::LegacyIconComponent.new(name: icon_name, **kwargs)
|
22
20
|
end
|
23
21
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Methods added to this helper will be available to all templates in the hosting
|
3
4
|
# application
|
4
5
|
module Blacklight
|
@@ -40,11 +41,11 @@ module Blacklight
|
|
40
41
|
end
|
41
42
|
|
42
43
|
##
|
43
|
-
# Class used for specifying main layout container classes.
|
44
|
-
#
|
44
|
+
# Class used for specifying main layout container classes. Can be
|
45
|
+
# overwritten to return 'container-fluid' for Bootstrap full-width layout
|
45
46
|
# @return [String]
|
46
47
|
def container_classes
|
47
|
-
|
48
|
+
'container'
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -1,28 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
module Blacklight::RenderPartialsHelperBehavior
|
3
|
-
extend Deprecation
|
4
2
|
|
3
|
+
module Blacklight::RenderPartialsHelperBehavior
|
5
4
|
##
|
6
5
|
# Render the document index view
|
7
6
|
#
|
8
7
|
# @param [Array<SolrDocument>] documents list of documents to render
|
9
8
|
# @param [Hash] locals to pass to the render call
|
10
9
|
# @return [String]
|
11
|
-
def render_document_index documents
|
12
|
-
unless documents
|
13
|
-
Deprecation.warn(self, "Calling render_document_index without documents is deprecated and will be removed in version 8")
|
14
|
-
documents = @response.documents
|
15
|
-
end
|
10
|
+
def render_document_index documents, locals = {}
|
16
11
|
render_document_index_with_view(document_index_view_type, documents, locals)
|
17
12
|
end
|
18
13
|
|
19
|
-
##
|
20
|
-
# Render the document index for a grouped response
|
21
|
-
def render_grouped_document_index
|
22
|
-
render 'catalog/group'
|
23
|
-
end
|
24
|
-
deprecation_deprecate render_grouped_document_index: 'Removed without replacement'
|
25
|
-
|
26
14
|
##
|
27
15
|
# Return the list of partials for a given solr document
|
28
16
|
# @param [SolrDocument] doc solr document to render partials for
|
@@ -34,6 +22,8 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
34
22
|
render_document_partial(doc, action_name, locals)
|
35
23
|
end, "\n")
|
36
24
|
end
|
25
|
+
Blacklight.deprecation.deprecate_methods(self, render_document_partials: 'Replace this call with: "document_component = blacklight_config.view_config(:atom).summary_component
|
26
|
+
render document_component.new(presenter: document_presenter(document), component: :div, show: true)"')
|
37
27
|
|
38
28
|
##
|
39
29
|
# Return the list of xml for a given solr document. Doesn't safely escape for HTML.
|
@@ -60,7 +50,7 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
60
50
|
# @param [String] base_name base name for the partial
|
61
51
|
# @param [Hash] locals local variables to pass through to the partials
|
62
52
|
def render_document_partial(doc, base_name, locals = {})
|
63
|
-
format =
|
53
|
+
format = document_partial_name(doc, base_name)
|
64
54
|
|
65
55
|
view_type = document_index_view_type
|
66
56
|
template = cached_view ['show', view_type, base_name, format].join('_') do
|
@@ -69,7 +59,6 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
69
59
|
if template
|
70
60
|
template.render(self, locals.merge(document: doc))
|
71
61
|
else
|
72
|
-
logger.warn("No template was found for base_name: '#{base_name}', view_type: '#{view_type}' in render_document_partial")
|
73
62
|
''
|
74
63
|
end
|
75
64
|
end
|
@@ -119,6 +108,8 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
119
108
|
]
|
120
109
|
end
|
121
110
|
|
111
|
+
private
|
112
|
+
|
122
113
|
##
|
123
114
|
# Return a normalized partial name for rendering a single document
|
124
115
|
#
|
@@ -131,9 +122,6 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
131
122
|
|
132
123
|
type_field_to_partial_name(document, display_type)
|
133
124
|
end
|
134
|
-
deprecation_deprecate document_partial_name: 'Moving to a private method'
|
135
|
-
|
136
|
-
private
|
137
125
|
|
138
126
|
##
|
139
127
|
# Return a partial name for rendering a document
|
@@ -191,21 +179,13 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
191
179
|
def find_document_index_template_with_view view_type, locals
|
192
180
|
document_index_path_templates.each do |str|
|
193
181
|
partial = format(str, index_view_type: view_type)
|
182
|
+
name = partial.split('/').last
|
183
|
+
prefix = partial.split('/').first if partial.include?('/')
|
194
184
|
logger&.debug "Looking for document index partial #{partial}"
|
195
|
-
|
196
|
-
template =
|
197
|
-
name = partial.split('/').last
|
198
|
-
prefix = partial.split('/').first if partial.include?('/')
|
199
|
-
|
200
|
-
prefixes = lookup_context.prefixes + [prefix, ""].compact
|
201
|
-
lookup_context.find_all(name, prefixes, true, locals.keys + [:documents], {}).first
|
202
|
-
else
|
203
|
-
lookup_context.find_all(partial, lookup_context.prefixes + [""], true, locals.keys + [:documents], {}).first
|
204
|
-
end
|
205
|
-
|
185
|
+
prefixes = lookup_context.prefixes + [prefix, ""].compact
|
186
|
+
template = lookup_context.find_all(name, prefixes, true, locals.keys + [:documents], {}).first
|
206
187
|
return template if template
|
207
188
|
end
|
208
|
-
|
209
189
|
nil
|
210
190
|
end
|
211
191
|
|
@@ -1,15 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
##
|
3
4
|
# URL helper methods
|
4
5
|
module Blacklight::UrlHelperBehavior
|
5
|
-
extend Deprecation
|
6
|
-
|
7
|
-
# @deprecated
|
8
|
-
def url_for_document(doc, options = {})
|
9
|
-
search_state.url_for_document(doc, options)
|
10
|
-
end
|
11
|
-
deprecation_deprecate url_for_document: 'Use SearchState#url_for_document directly'
|
12
|
-
|
13
6
|
# Uses the catalog_path route to create a link to the show page for an item.
|
14
7
|
# catalog_path accepts a hash. The solr query params are stored in the session,
|
15
8
|
# so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
|
@@ -19,9 +12,9 @@ module Blacklight::UrlHelperBehavior
|
|
19
12
|
# @param opts [Hash] the options to create the link with
|
20
13
|
# @option opts [Number] :counter (nil) the count to set in the session (for paging through a query result)
|
21
14
|
# @example Passing in an image
|
22
|
-
# link_to_document(doc, '<img src="thumbnail.png">', counter: 3) #=> "<a href=\"catalog/123\" data-
|
15
|
+
# link_to_document(doc, '<img src="thumbnail.png">', counter: 3) #=> "<a href=\"catalog/123\" data-context-href=\"/catalog/123/track?counter=3&search_id=999\"><img src="thumbnail.png"></a>
|
23
16
|
# @example With the default document link field
|
24
|
-
# link_to_document(doc, counter: 3) #=> "<a href=\"catalog/123\" data-
|
17
|
+
# link_to_document(doc, counter: 3) #=> "<a href=\"catalog/123\" data-context-href=\"/catalog/123/track?counter=3&search_id=999\">My Title</a>
|
25
18
|
def link_to_document(doc, field_or_opts = nil, opts = { counter: nil })
|
26
19
|
label = case field_or_opts
|
27
20
|
when NilClass
|
@@ -29,18 +22,11 @@ module Blacklight::UrlHelperBehavior
|
|
29
22
|
when Hash
|
30
23
|
opts = field_or_opts
|
31
24
|
document_presenter(doc).heading
|
32
|
-
when Proc, Symbol
|
33
|
-
Deprecation.warn(self, "passing a #{field_or_opts.class} to link_to_document is deprecated and will be removed in Blacklight 8")
|
34
|
-
Deprecation.silence(Blacklight::IndexPresenter) do
|
35
|
-
index_presenter(doc).label field_or_opts, opts
|
36
|
-
end
|
37
25
|
else # String
|
38
26
|
field_or_opts
|
39
27
|
end
|
40
28
|
|
41
|
-
|
42
|
-
link_to label, url_for_document(doc), document_link_params(doc, opts)
|
43
|
-
end
|
29
|
+
link_to label, search_state.url_for_document(doc), document_link_params(doc, opts)
|
44
30
|
end
|
45
31
|
|
46
32
|
# @private
|
@@ -49,47 +35,19 @@ module Blacklight::UrlHelperBehavior
|
|
49
35
|
end
|
50
36
|
private :document_link_params
|
51
37
|
|
52
|
-
##
|
53
|
-
# Link to the previous document in the current search context
|
54
|
-
# @deprecated
|
55
|
-
def link_to_previous_document(previous_document, classes: 'previous', **addl_link_opts)
|
56
|
-
link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class: classes, rel: 'prev').merge(addl_link_opts)
|
57
|
-
link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
|
58
|
-
tag.span raw(t('views.pagination.previous')), class: 'previous'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
deprecation_deprecate link_to_previous_document: 'Moving to Blacklight::SearchContextComponent'
|
62
|
-
|
63
|
-
##
|
64
|
-
# Link to the next document in the current search context
|
65
|
-
# @deprecated
|
66
|
-
def link_to_next_document(next_document, classes: 'next', **addl_link_opts)
|
67
|
-
link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class: classes, rel: 'next').merge(addl_link_opts)
|
68
|
-
link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
|
69
|
-
tag.span raw(t('views.pagination.next')), class: 'next'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
deprecation_deprecate link_to_previous_document: 'Moving to Blacklight::SearchContextComponent'
|
73
|
-
|
74
38
|
##
|
75
39
|
# Attributes for a link that gives a URL we can use to track clicks for the current search session
|
76
|
-
# We disable turbo prefetch (InstantClick), because since we replace the link with a form, it's just wasted.
|
77
|
-
# @private
|
78
40
|
# @param [SolrDocument] document
|
79
41
|
# @param [Integer] counter
|
80
42
|
# @example
|
81
43
|
# session_tracking_params(SolrDocument.new(id: 123), 7)
|
82
44
|
# => { data: { context_href: '/catalog/123/track?counter=7&search_id=999' } }
|
83
|
-
def session_tracking_params document, counter
|
84
|
-
path = session_tracking_path(document, per_page: params.fetch(:per_page,
|
85
|
-
|
86
|
-
if path.nil?
|
87
|
-
return {}
|
88
|
-
end
|
45
|
+
def session_tracking_params document, counter, per_page: search_session['per_page'], search_id: current_search_session&.id
|
46
|
+
path = session_tracking_path(document, per_page: params.fetch(:per_page, per_page), counter: counter, search_id: search_id, document_id: document&.id)
|
47
|
+
return {} if path.nil?
|
89
48
|
|
90
|
-
{ data: { context_href: path
|
49
|
+
{ data: { context_href: path } }
|
91
50
|
end
|
92
|
-
private :session_tracking_params
|
93
51
|
|
94
52
|
##
|
95
53
|
# Get the URL for tracking search sessions across pages using polymorphic routing
|
@@ -101,7 +59,7 @@ module Blacklight::UrlHelperBehavior
|
|
101
59
|
end
|
102
60
|
|
103
61
|
raise "Unable to find #{controller_tracking_method} route helper. " \
|
104
|
-
|
62
|
+
"Did you add `concerns :searchable` routing mixin to your `config/routes.rb`?"
|
105
63
|
end
|
106
64
|
|
107
65
|
def controller_tracking_method
|
@@ -112,28 +70,6 @@ module Blacklight::UrlHelperBehavior
|
|
112
70
|
# link based helpers ->
|
113
71
|
#
|
114
72
|
|
115
|
-
# create link to query (e.g. spelling suggestion)
|
116
|
-
# @deprecated
|
117
|
-
def link_to_query(query)
|
118
|
-
p = search_state.to_h.except(:page, :action)
|
119
|
-
p[:q] = query
|
120
|
-
link_to(query, search_action_path(p))
|
121
|
-
end
|
122
|
-
deprecation_deprecate link_to_query: 'Removed without replacement'
|
123
|
-
|
124
|
-
##
|
125
|
-
# Get the path to the search action with any parameters (e.g. view type)
|
126
|
-
# that should be persisted across search sessions.
|
127
|
-
# @deprecated
|
128
|
-
def start_over_path query_params = params
|
129
|
-
h = {}
|
130
|
-
current_index_view_type = document_index_view_type(query_params)
|
131
|
-
h[:view] = current_index_view_type unless current_index_view_type == default_document_index_view_type
|
132
|
-
|
133
|
-
search_action_path(h)
|
134
|
-
end
|
135
|
-
deprecation_deprecate start_over_path: 'Removed without replacement'
|
136
|
-
|
137
73
|
# Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
|
138
74
|
# @example
|
139
75
|
# link_back_to_catalog(label: 'Back to Search')
|
@@ -166,30 +102,9 @@ module Blacklight::UrlHelperBehavior
|
|
166
102
|
link_to label, link_url, opts
|
167
103
|
end
|
168
104
|
|
169
|
-
#
|
105
|
+
# Use in e.g. the search history display, where we want something more like text instead of the normal constraints
|
170
106
|
def link_to_previous_search(params)
|
171
|
-
|
172
|
-
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
# Get url parameters to a search within a grouped result set
|
177
|
-
#
|
178
|
-
# @deprecated
|
179
|
-
# @param [Blacklight::Solr::Response::Group] group
|
180
|
-
# @return [Hash]
|
181
|
-
def add_group_facet_params_and_redirect group
|
182
|
-
search_state.add_facet_params_and_redirect(group.field, group.key)
|
183
|
-
end
|
184
|
-
deprecation_deprecate add_group_facet_params_and_redirect: 'Removed without replacement'
|
185
|
-
|
186
|
-
# A URL to refworks export, with an embedded callback URL to this app.
|
187
|
-
# the callback URL is to bookmarks#export, which delivers a list of
|
188
|
-
# user's bookmarks in 'refworks marc txt' format -- we tell refworks
|
189
|
-
# to expect that format.
|
190
|
-
# @deprecated
|
191
|
-
def bookmarks_export_url(format, params = {})
|
192
|
-
bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id)))
|
107
|
+
search_state = controller.search_state_class.new(params, blacklight_config, self)
|
108
|
+
link_to(render(Blacklight::ConstraintsComponent.for_search_history(search_state: search_state)), search_action_path(params))
|
193
109
|
end
|
194
|
-
deprecation_deprecate bookmarks_export_url: 'Removed without replacement'
|
195
110
|
end
|