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,15 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
# Methods added to this helper will be available to all templates in the hosting application
|
|
3
4
|
module Blacklight::BlacklightHelperBehavior
|
|
4
|
-
extend Deprecation
|
|
5
|
-
|
|
6
5
|
include Blacklight::UrlHelperBehavior
|
|
7
|
-
include Blacklight::HashAsHiddenFieldsHelperBehavior
|
|
8
6
|
include Blacklight::LayoutHelperBehavior
|
|
9
7
|
include Blacklight::IconHelperBehavior
|
|
10
8
|
|
|
11
|
-
# @!group Layout helpers
|
|
12
|
-
|
|
13
9
|
##
|
|
14
10
|
# Get the name of this application from an i18n string
|
|
15
11
|
# key: blacklight.application_name
|
|
@@ -25,262 +21,6 @@ module Blacklight::BlacklightHelperBehavior
|
|
|
25
21
|
end
|
|
26
22
|
end
|
|
27
23
|
|
|
28
|
-
##
|
|
29
|
-
# Get the page's HTML title
|
|
30
|
-
#
|
|
31
|
-
# @return [String]
|
|
32
|
-
def render_page_title
|
|
33
|
-
(content_for(:page_title) if content_for?(:page_title)) || @page_title || application_name
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
##
|
|
37
|
-
# Create <link rel="alternate"> links from a documents dynamically
|
|
38
|
-
# provided export formats.
|
|
39
|
-
#
|
|
40
|
-
# Returns empty string if no links available.
|
|
41
|
-
#
|
|
42
|
-
# @param [SolrDocument] document
|
|
43
|
-
# @param [Hash] options
|
|
44
|
-
# @option options [Boolean] :unique ensures only one link is output for every
|
|
45
|
-
# content type, e.g. as required by atom
|
|
46
|
-
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
|
|
47
|
-
# @return [String]
|
|
48
|
-
def render_link_rel_alternates(document = @document, options = {})
|
|
49
|
-
return if document.nil?
|
|
50
|
-
|
|
51
|
-
document_presenter(document).link_rel_alternates(options)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
##
|
|
55
|
-
# Render OpenSearch headers for this search
|
|
56
|
-
# @deprecated
|
|
57
|
-
# @return [String]
|
|
58
|
-
def render_opensearch_response_metadata
|
|
59
|
-
render partial: 'catalog/opensearch_response_metadata', locals: { response: @response }
|
|
60
|
-
end
|
|
61
|
-
deprecation_deprecate render_opensearch_response_metadata: 'Use `render "catalog/opensearch_response_metadata"\' instead'
|
|
62
|
-
|
|
63
|
-
##
|
|
64
|
-
# Render classes for the <body> element
|
|
65
|
-
# @return [String]
|
|
66
|
-
def render_body_class
|
|
67
|
-
extra_body_classes.join " "
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
##
|
|
71
|
-
# List of classes to be applied to the <body> element
|
|
72
|
-
# @see render_body_class
|
|
73
|
-
# @return [Array<String>]
|
|
74
|
-
def extra_body_classes
|
|
75
|
-
@extra_body_classes ||= ['blacklight-' + controller.controller_name, 'blacklight-' + [controller.controller_name, controller.action_name].join('-')]
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
##
|
|
79
|
-
# Render the search navbar
|
|
80
|
-
# @return [String]
|
|
81
|
-
def render_search_bar
|
|
82
|
-
if search_bar_presenter_class == Blacklight::SearchBarPresenter && partial_from_blacklight?(Blacklight::SearchBarPresenter.partial)
|
|
83
|
-
component_class = blacklight_config&.view_config(document_index_view_type)&.search_bar_component || Blacklight::SearchBarComponent
|
|
84
|
-
render component_class.new(
|
|
85
|
-
url: search_action_url,
|
|
86
|
-
advanced_search_url: search_action_url(action: 'advanced_search'),
|
|
87
|
-
params: search_state.params_for_search.except(:qt),
|
|
88
|
-
search_fields: Deprecation.silence(Blacklight::ConfigurationHelperBehavior) { search_fields },
|
|
89
|
-
autocomplete_path: search_action_path(action: :suggest)
|
|
90
|
-
)
|
|
91
|
-
else
|
|
92
|
-
search_bar_presenter.render
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
deprecation_deprecate render_search_bar: "Call `render Blacklight::SearchBarComponent.new' instead"
|
|
96
|
-
|
|
97
|
-
# @!group Presenter extension helpers
|
|
98
|
-
##
|
|
99
|
-
# @return [Blacklight::SearchBarPresenter]
|
|
100
|
-
def search_bar_presenter
|
|
101
|
-
@search_bar ||= search_bar_presenter_class.new(controller, blacklight_config)
|
|
102
|
-
end
|
|
103
|
-
deprecation_deprecate :search_bar_presenter
|
|
104
|
-
|
|
105
|
-
# @!group Document helpers
|
|
106
|
-
##
|
|
107
|
-
# Determine whether to render a given field in the index view.
|
|
108
|
-
#
|
|
109
|
-
# @deprecated
|
|
110
|
-
# @param [SolrDocument] document
|
|
111
|
-
# @param [Blacklight::Configuration::Field] field_config
|
|
112
|
-
# @return [Boolean]
|
|
113
|
-
def should_render_index_field? document, field_config
|
|
114
|
-
Deprecation.warn self, "should_render_index_field? is deprecated and will be removed in Blacklight 8. Use IndexPresenter#render_field? instead."
|
|
115
|
-
should_render_field?(field_config, document) && document_has_value?(document, field_config)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
##
|
|
119
|
-
# Determine whether to render a given field in the show view
|
|
120
|
-
#
|
|
121
|
-
# @deprecated
|
|
122
|
-
# @param [SolrDocument] document
|
|
123
|
-
# @param [Blacklight::Configuration::Field] field_config
|
|
124
|
-
# @return [Boolean]
|
|
125
|
-
def should_render_show_field? document, field_config
|
|
126
|
-
Deprecation.warn self, "should_render_show_field? is deprecated and will be removed in Blacklight 8. Use ShowPresenter#render_field? instead."
|
|
127
|
-
should_render_field?(field_config, document) && document_has_value?(document, field_config)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
##
|
|
131
|
-
# Check if a document has (or, might have, in the case of accessor methods) a value for
|
|
132
|
-
# the given solr
|
|
133
|
-
# @deprecated
|
|
134
|
-
# @param [SolrDocument] document
|
|
135
|
-
# @param [Blacklight::Configuration::Field] field_config
|
|
136
|
-
# @return [Boolean]
|
|
137
|
-
def document_has_value? document, field_config
|
|
138
|
-
Deprecation.warn self, "document_has_value? is deprecated and will be removed in Blacklight 8. Use DocumentPresenter#has_value? instead."
|
|
139
|
-
document.has?(field_config.field) ||
|
|
140
|
-
(document.has_highlight_field? field_config.field if field_config.highlight) ||
|
|
141
|
-
field_config.accessor
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# @!group Search result helpers
|
|
145
|
-
##
|
|
146
|
-
# Determine whether to display spellcheck suggestions
|
|
147
|
-
#
|
|
148
|
-
# @deprecated
|
|
149
|
-
# @param [Blacklight::Solr::Response] response
|
|
150
|
-
# @return [Boolean]
|
|
151
|
-
def should_show_spellcheck_suggestions? response
|
|
152
|
-
Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
|
|
153
|
-
# The spelling response field may be missing from non solr repositories.
|
|
154
|
-
response.total <= spell_check_max &&
|
|
155
|
-
(response.spelling&.words&.any? || response.spelling&.collation&.present? || false)
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
deprecation_deprecate should_show_spellcheck_suggestions?: 'moving into a private method of Blacklight::Response::SpellcheckComponent'
|
|
159
|
-
|
|
160
|
-
# @!group Document helpers
|
|
161
|
-
##
|
|
162
|
-
# Render the index field label for a document
|
|
163
|
-
#
|
|
164
|
-
# Translations for index field labels should go under blacklight.search.fields
|
|
165
|
-
# They are picked up from there by a value "%{label}" in blacklight.search.index.label
|
|
166
|
-
#
|
|
167
|
-
# @deprecated
|
|
168
|
-
# @overload render_index_field_label(options)
|
|
169
|
-
# Use the default, document-agnostic configuration
|
|
170
|
-
# @param [Hash] opts
|
|
171
|
-
# @option opts [String] :field
|
|
172
|
-
# @overload render_index_field_label(document, options)
|
|
173
|
-
# Allow an extention point where information in the document
|
|
174
|
-
# may drive the value of the field
|
|
175
|
-
# @param [SolrDocument] doc
|
|
176
|
-
# @param [Hash] opts
|
|
177
|
-
# @option opts [String] :field
|
|
178
|
-
# @return [String]
|
|
179
|
-
def render_index_field_label *args
|
|
180
|
-
options = args.extract_options!
|
|
181
|
-
document = args.first
|
|
182
|
-
|
|
183
|
-
field = options[:field]
|
|
184
|
-
label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
|
|
185
|
-
options[:label] || index_field_label(document, field)
|
|
186
|
-
end
|
|
187
|
-
html_escape t(:"blacklight.search.index.#{document_index_view_type}.label", default: :'blacklight.search.index.label', label: label)
|
|
188
|
-
end
|
|
189
|
-
deprecation_deprecate render_index_field_label: 'Use Blacklight::MetadataFieldComponent instead'
|
|
190
|
-
|
|
191
|
-
##
|
|
192
|
-
# Render the show field label for a document
|
|
193
|
-
#
|
|
194
|
-
# @deprecated
|
|
195
|
-
# @overload render_document_show_field_label(options)
|
|
196
|
-
# Use the default, document-agnostic configuration
|
|
197
|
-
# @param [Hash] opts
|
|
198
|
-
# @option opts [String] :field
|
|
199
|
-
# @overload render_document_show_field_label(document, options)
|
|
200
|
-
# Allow an extention point where information in the document
|
|
201
|
-
# may drive the value of the field
|
|
202
|
-
# @param [SolrDocument] doc
|
|
203
|
-
# @param [Hash] opts
|
|
204
|
-
# @option opts [String] :field
|
|
205
|
-
# @return [String]
|
|
206
|
-
def render_document_show_field_label *args
|
|
207
|
-
options = args.extract_options!
|
|
208
|
-
document = args.first
|
|
209
|
-
|
|
210
|
-
field = options[:field]
|
|
211
|
-
label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
|
|
212
|
-
options[:label] || document_show_field_label(document, field)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
t(:'blacklight.search.show.label', label: label)
|
|
216
|
-
end
|
|
217
|
-
deprecation_deprecate render_document_show_field_label: 'Use Blacklight::MetadataFieldComponent instead'
|
|
218
|
-
|
|
219
|
-
##
|
|
220
|
-
# Get the value of the document's "title" field, or a placeholder
|
|
221
|
-
# value (if empty)
|
|
222
|
-
#
|
|
223
|
-
# @deprecated
|
|
224
|
-
# @param [SolrDocument] document
|
|
225
|
-
# @return [String]
|
|
226
|
-
def document_heading document = nil
|
|
227
|
-
document ||= @document
|
|
228
|
-
document_presenter(document).heading
|
|
229
|
-
end
|
|
230
|
-
deprecation_deprecate document_heading: 'Use Blacklight::DocumentPresenter#heading instead'
|
|
231
|
-
|
|
232
|
-
##
|
|
233
|
-
# Get the document's "title" to display in the <title> element.
|
|
234
|
-
# (by default, use the #document_heading)
|
|
235
|
-
#
|
|
236
|
-
# @deprecated
|
|
237
|
-
# @see #document_heading
|
|
238
|
-
# @param [SolrDocument] document
|
|
239
|
-
# @return [String]
|
|
240
|
-
def document_show_html_title document = nil
|
|
241
|
-
document ||= @document
|
|
242
|
-
|
|
243
|
-
document_presenter(document).html_title
|
|
244
|
-
end
|
|
245
|
-
deprecation_deprecate document_show_html_title: 'Use Blacklight::DocumentPresenter#html_title instead'
|
|
246
|
-
|
|
247
|
-
##
|
|
248
|
-
# Render the document "heading" (title) in a content tag
|
|
249
|
-
# @deprecated
|
|
250
|
-
# @overload render_document_heading(document, options)
|
|
251
|
-
# @param [SolrDocument] document
|
|
252
|
-
# @param [Hash] options
|
|
253
|
-
# @option options [Symbol] :tag
|
|
254
|
-
# @overload render_document_heading(options)
|
|
255
|
-
# @param [Hash] options
|
|
256
|
-
# @option options [Symbol] :tag
|
|
257
|
-
# @return [String]
|
|
258
|
-
def render_document_heading(*args)
|
|
259
|
-
options = args.extract_options!
|
|
260
|
-
document = args.first
|
|
261
|
-
tag = options.fetch(:tag, :h4)
|
|
262
|
-
document ||= @document
|
|
263
|
-
|
|
264
|
-
content_tag(tag, document_presenter(document).heading, itemprop: "name")
|
|
265
|
-
end
|
|
266
|
-
deprecation_deprecate render_document_heading: 'Removed without replacement'
|
|
267
|
-
|
|
268
|
-
##
|
|
269
|
-
# Get the current "view type" (and ensure it is a valid type)
|
|
270
|
-
#
|
|
271
|
-
# @param [Hash] query_params the query parameters to check
|
|
272
|
-
# @return [Symbol]
|
|
273
|
-
def document_index_view_type query_params = params
|
|
274
|
-
view_param = query_params[:view]
|
|
275
|
-
view_param ||= session[:preferred_view]
|
|
276
|
-
if view_param && document_index_views.key?(view_param.to_sym)
|
|
277
|
-
view_param.to_sym
|
|
278
|
-
else
|
|
279
|
-
default_document_index_view_type
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
# @!group Search result helpers
|
|
284
24
|
##
|
|
285
25
|
# Render a partial of an arbitrary format inside a
|
|
286
26
|
# template of a different format. (e.g. render an HTML
|
|
@@ -297,143 +37,4 @@ module Blacklight::BlacklightHelperBehavior
|
|
|
297
37
|
self.formats = old_formats
|
|
298
38
|
nil
|
|
299
39
|
end
|
|
300
|
-
|
|
301
|
-
##
|
|
302
|
-
# Should we render a grouped response (because the response
|
|
303
|
-
# contains a grouped response instead of the normal response)
|
|
304
|
-
#
|
|
305
|
-
# Default to false if there's no response object available (sometimes the case
|
|
306
|
-
# for tests, but might happen in other circumstances too..)
|
|
307
|
-
# @return [Boolean]
|
|
308
|
-
def render_grouped_response? response = @response
|
|
309
|
-
response&.grouped?
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
# @!group Presenter extension helpers
|
|
313
|
-
##
|
|
314
|
-
# Returns a document presenter for the given document
|
|
315
|
-
# TODO: Move this to the controller. It can just pass a presenter or set of presenters.
|
|
316
|
-
# @deprecated
|
|
317
|
-
# @return [Blacklight::DocumentPresenter]
|
|
318
|
-
def presenter(document)
|
|
319
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#presenter is deprecated; use #document_presenter instead')
|
|
320
|
-
|
|
321
|
-
# As long as the presenter methods haven't been overridden, we can use the new behavior
|
|
322
|
-
if method(:show_presenter).owner == Blacklight::BlacklightHelperBehavior &&
|
|
323
|
-
method(:index_presenter).owner == Blacklight::BlacklightHelperBehavior
|
|
324
|
-
return document_presenter_class(document).new(document, self)
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter and/or #index_presenter have been overridden; please override #document_presenter instead')
|
|
328
|
-
|
|
329
|
-
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
|
330
|
-
case action_name
|
|
331
|
-
when 'show', 'citation'
|
|
332
|
-
show_presenter(document)
|
|
333
|
-
else
|
|
334
|
-
index_presenter(document)
|
|
335
|
-
end
|
|
336
|
-
end
|
|
337
|
-
end
|
|
338
|
-
|
|
339
|
-
##
|
|
340
|
-
# Returns a document presenter for the given document
|
|
341
|
-
def document_presenter(document)
|
|
342
|
-
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
|
343
|
-
presenter(document)
|
|
344
|
-
end
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
# @deprecated
|
|
348
|
-
# @return [Blacklight::ShowPresenter]
|
|
349
|
-
def show_presenter(document)
|
|
350
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter is deprecated; use #document_presenter instead')
|
|
351
|
-
|
|
352
|
-
if method(:show_presenter_class).owner != Blacklight::BlacklightHelperBehavior
|
|
353
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter_class has been overridden; please override #document_presenter_class instead')
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
|
357
|
-
show_presenter_class(document).new(document, self)
|
|
358
|
-
end
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
# @deprecated
|
|
362
|
-
# @return [Blacklight::IndexPresenter]
|
|
363
|
-
def index_presenter(document)
|
|
364
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter is deprecated; use #document_presenter instead')
|
|
365
|
-
|
|
366
|
-
if method(:index_presenter_class).owner != Blacklight::BlacklightHelperBehavior
|
|
367
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter_class has been overridden; please override #document_presenter_class instead')
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
|
371
|
-
index_presenter_class(document).new(document, self)
|
|
372
|
-
end
|
|
373
|
-
end
|
|
374
|
-
|
|
375
|
-
##
|
|
376
|
-
# Override this method if you want to use a differnet presenter for your documents
|
|
377
|
-
# @param [Blacklight::Document] document optional, here for extension + backwards compatibility only
|
|
378
|
-
def document_presenter_class(document = nil)
|
|
379
|
-
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
|
380
|
-
case action_name
|
|
381
|
-
when 'show', 'citation'
|
|
382
|
-
show_presenter_class(document)
|
|
383
|
-
else
|
|
384
|
-
index_presenter_class(document)
|
|
385
|
-
end
|
|
386
|
-
end
|
|
387
|
-
end
|
|
388
|
-
|
|
389
|
-
##
|
|
390
|
-
# Override this method if you want to use a different presenter class
|
|
391
|
-
# @deprecated
|
|
392
|
-
# @return [Class]
|
|
393
|
-
def show_presenter_class(_document)
|
|
394
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter_class is deprecated; use #document_presenter_class instead')
|
|
395
|
-
|
|
396
|
-
blacklight_config.view_config(:show, action_name: action_name).document_presenter_class
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
# @deprecated
|
|
400
|
-
# @return [Class]
|
|
401
|
-
def index_presenter_class(_document)
|
|
402
|
-
Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter_class is deprecated; use #document_presenter_class instead')
|
|
403
|
-
|
|
404
|
-
blacklight_config.view_config(document_index_view_type, action_name: action_name).document_presenter_class
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
# @return [Class]
|
|
408
|
-
def search_bar_presenter_class
|
|
409
|
-
blacklight_config.view_config(action_name: :index).search_bar_presenter_class
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
# @!group Layout helpers
|
|
413
|
-
##
|
|
414
|
-
# Open Search discovery tag for HTML <head> links
|
|
415
|
-
# @return [String]
|
|
416
|
-
def opensearch_description_tag title, href
|
|
417
|
-
tag :link, href: href, title: title, type: "application/opensearchdescription+xml", rel: "search"
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
# @private
|
|
421
|
-
|
|
422
|
-
def self.blacklight_path
|
|
423
|
-
@blacklight_path ||= Gem.loaded_specs["blacklight"].full_gem_path
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
def partial_from_blacklight?(partial)
|
|
427
|
-
path = if Rails::VERSION::MAJOR >= 6
|
|
428
|
-
name = partial.split('/').last
|
|
429
|
-
prefix = partial.split('/').first if partial.include?('/')
|
|
430
|
-
logger&.debug "Looking for document index partial #{partial}"
|
|
431
|
-
prefixes = lookup_context.prefixes + [prefix, ""].compact
|
|
432
|
-
lookup_context.find_all(name, prefixes, true).first&.identifier
|
|
433
|
-
else
|
|
434
|
-
lookup_context.find_all(partial, lookup_context.prefixes + [""], true).first&.identifier
|
|
435
|
-
end
|
|
436
|
-
|
|
437
|
-
path&.starts_with?(Blacklight::BlacklightHelperBehavior.blacklight_path)
|
|
438
|
-
end
|
|
439
40
|
end
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
# Helper methods for catalog-like controllers
|
|
3
4
|
module Blacklight::CatalogHelperBehavior
|
|
4
|
-
extend Deprecation
|
|
5
|
-
self.deprecation_horizon = 'blacklight 8.0'
|
|
6
|
-
|
|
7
5
|
include Blacklight::ConfigurationHelperBehavior
|
|
8
6
|
include Blacklight::ComponentHelperBehavior
|
|
7
|
+
include Blacklight::DocumentHelperBehavior
|
|
9
8
|
include Blacklight::FacetsHelperBehavior
|
|
10
|
-
include Blacklight::RenderConstraintsHelperBehavior
|
|
11
9
|
include Blacklight::RenderPartialsHelperBehavior
|
|
12
|
-
include Blacklight::SearchHistoryConstraintsHelperBehavior
|
|
13
|
-
include Blacklight::SuggestHelperBehavior
|
|
14
10
|
|
|
15
11
|
# @param [Hash] options
|
|
16
12
|
# @option options :route_set the route scope to use when constructing the link
|
|
@@ -64,18 +60,18 @@ module Blacklight::CatalogHelperBehavior
|
|
|
64
60
|
end
|
|
65
61
|
|
|
66
62
|
case collection.total_count
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
when 0
|
|
64
|
+
t('blacklight.search.pagination_info.no_items_found', entry_name: entry_name).html_safe
|
|
65
|
+
when 1
|
|
66
|
+
t('blacklight.search.pagination_info.single_item_found', entry_name: entry_name).html_safe
|
|
67
|
+
else
|
|
68
|
+
t('blacklight.search.pagination_info.pages', entry_name: entry_name,
|
|
69
|
+
current_page: collection.current_page,
|
|
70
|
+
num_pages: collection.total_pages,
|
|
71
|
+
start_num: number_with_delimiter(collection.offset_value + 1),
|
|
72
|
+
end_num: number_with_delimiter(end_num),
|
|
73
|
+
total_num: number_with_delimiter(collection.total_count),
|
|
74
|
+
count: collection.total_pages).html_safe
|
|
79
75
|
end
|
|
80
76
|
end
|
|
81
77
|
|
|
@@ -94,20 +90,6 @@ module Blacklight::CatalogHelperBehavior
|
|
|
94
90
|
end
|
|
95
91
|
end
|
|
96
92
|
|
|
97
|
-
##
|
|
98
|
-
# Like #page_entries_info above, but for an individual
|
|
99
|
-
# item show page. Displays "showing X of Y items" message.
|
|
100
|
-
#
|
|
101
|
-
# @deprecated
|
|
102
|
-
# @see #page_entries_info
|
|
103
|
-
# @return [String]
|
|
104
|
-
def item_page_entry_info
|
|
105
|
-
t('blacklight.search.entry_pagination_info.other', current: number_with_delimiter(search_session['counter']),
|
|
106
|
-
total: number_with_delimiter(search_session['total']),
|
|
107
|
-
count: search_session['total'].to_i).html_safe
|
|
108
|
-
end
|
|
109
|
-
deprecation_deprecate item_page_entry_info: 'Use Blacklight::SearchContextComponent methods instead'
|
|
110
|
-
|
|
111
93
|
##
|
|
112
94
|
# Look up search field user-displayable label
|
|
113
95
|
# based on params[:qt] and blacklight_configuration.
|
|
@@ -132,57 +114,6 @@ module Blacklight::CatalogHelperBehavior
|
|
|
132
114
|
(@response.rows if @response && @response.rows > 0) || params.fetch(:per_page, blacklight_config.default_per_page).to_i
|
|
133
115
|
end
|
|
134
116
|
|
|
135
|
-
##
|
|
136
|
-
# Get the classes to add to a document's div
|
|
137
|
-
#
|
|
138
|
-
# @param [Blacklight::Document] document
|
|
139
|
-
# @return [String]
|
|
140
|
-
def render_document_class(document = @document)
|
|
141
|
-
types = document_presenter(document).display_type
|
|
142
|
-
return if types.blank?
|
|
143
|
-
|
|
144
|
-
Array(types).compact.map do |t|
|
|
145
|
-
"#{document_class_prefix}#{t.try(:parameterize) || t}"
|
|
146
|
-
end.join(' ')
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
##
|
|
150
|
-
# Return a prefix for the document classes infered from the document
|
|
151
|
-
# @see #render_document_class
|
|
152
|
-
# @return [String]
|
|
153
|
-
def document_class_prefix
|
|
154
|
-
'blacklight-'
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
##
|
|
158
|
-
# Render the sidebar partial for a document
|
|
159
|
-
# This is used as an integration point by downstream apps to add to the
|
|
160
|
-
# default sidebar.
|
|
161
|
-
# See: https://github.com/geoblacklight/geoblacklight/blob/7d3c31c7af3362879b97e2c1351a2496c728c59c/app/helpers/blacklight_helper.rb#L7
|
|
162
|
-
#
|
|
163
|
-
# @param [SolrDocument] document
|
|
164
|
-
# @return [String]
|
|
165
|
-
def render_document_sidebar_partial(document = nil)
|
|
166
|
-
unless document
|
|
167
|
-
Deprecation.warn(self, 'render_document_sidebar_partial expects one argument ' \
|
|
168
|
-
'(@document) and you passed none. This behavior will be removed in version 8')
|
|
169
|
-
document = @document
|
|
170
|
-
end
|
|
171
|
-
render 'show_sidebar', document: document
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
##
|
|
175
|
-
# Render the main content partial for a document
|
|
176
|
-
# This is widely used as by downstream apps when they override their show view.
|
|
177
|
-
# See https://github.com/search?q=render_document_main_content_partial&type=Code
|
|
178
|
-
#
|
|
179
|
-
# @param [SolrDocument] _document
|
|
180
|
-
# @return [String]
|
|
181
|
-
def render_document_main_content_partial(_document = @document)
|
|
182
|
-
render partial: 'show_main_content'
|
|
183
|
-
end
|
|
184
|
-
deprecation_deprecate render_document_main_content_partial: "Use \"render 'show_main_content'\" instead"
|
|
185
|
-
|
|
186
117
|
##
|
|
187
118
|
# Should we display the sort and per page widget?
|
|
188
119
|
#
|
|
@@ -203,105 +134,6 @@ module Blacklight::CatalogHelperBehavior
|
|
|
203
134
|
response.limit_value > 0
|
|
204
135
|
end
|
|
205
136
|
|
|
206
|
-
##
|
|
207
|
-
# If no search parameters have been given, we should
|
|
208
|
-
# auto-focus the user's cursor into the searchbox
|
|
209
|
-
#
|
|
210
|
-
# @deprecated
|
|
211
|
-
# @return [Boolean]
|
|
212
|
-
def should_autofocus_on_search_box?
|
|
213
|
-
controller.is_a?(Blacklight::Catalog) &&
|
|
214
|
-
action_name == "index" &&
|
|
215
|
-
!has_search_parameters?
|
|
216
|
-
end
|
|
217
|
-
deprecation_deprecate should_autofocus_on_search_box?: "use SearchBarPresenter#autofocus?"
|
|
218
|
-
|
|
219
|
-
##
|
|
220
|
-
# Does the document have a thumbnail to render?
|
|
221
|
-
#
|
|
222
|
-
# @deprecated
|
|
223
|
-
# @param [SolrDocument] document
|
|
224
|
-
# @return [Boolean]
|
|
225
|
-
def has_thumbnail? document
|
|
226
|
-
document_presenter(document).thumbnail.exists?
|
|
227
|
-
end
|
|
228
|
-
deprecation_deprecate has_thumbnail?: "use IndexPresenter#thumbnail.exists?"
|
|
229
|
-
|
|
230
|
-
##
|
|
231
|
-
# Render the thumbnail, if available, for a document and
|
|
232
|
-
# link it to the document record.
|
|
233
|
-
#
|
|
234
|
-
# @deprecated
|
|
235
|
-
# @param [SolrDocument] document
|
|
236
|
-
# @param [Hash] image_options to pass to the image tag
|
|
237
|
-
# @param [Hash] url_options to pass to #link_to_document
|
|
238
|
-
# @return [String]
|
|
239
|
-
def render_thumbnail_tag document, image_options = {}, url_options = {}
|
|
240
|
-
document_presenter(document).thumbnail.thumbnail_tag(image_options, url_options)
|
|
241
|
-
end
|
|
242
|
-
deprecation_deprecate render_thumbnail_tag: "Use IndexPresenter#thumbnail.thumbnail_tag"
|
|
243
|
-
|
|
244
|
-
##
|
|
245
|
-
# Get the URL to a document's thumbnail image
|
|
246
|
-
#
|
|
247
|
-
# @deprecated
|
|
248
|
-
# @param [SolrDocument] document
|
|
249
|
-
# @return [String]
|
|
250
|
-
def thumbnail_url document
|
|
251
|
-
if document.has? blacklight_config.view_config(document_index_view_type).thumbnail_field
|
|
252
|
-
document.first(blacklight_config.view_config(document_index_view_type).thumbnail_field)
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
deprecation_deprecate thumbnail_url: "this method will be removed without replacement"
|
|
256
|
-
|
|
257
|
-
##
|
|
258
|
-
# Render the view type icon for the results view picker
|
|
259
|
-
#
|
|
260
|
-
# @deprecated
|
|
261
|
-
# @param [String] view
|
|
262
|
-
# @return [String]
|
|
263
|
-
def render_view_type_group_icon view
|
|
264
|
-
blacklight_icon(view)
|
|
265
|
-
end
|
|
266
|
-
deprecation_deprecate render_view_type_group_icon: 'call blacklight_icon instead'
|
|
267
|
-
|
|
268
|
-
##
|
|
269
|
-
# Get the default view type classes for a view in the results view picker
|
|
270
|
-
#
|
|
271
|
-
# @deprecated
|
|
272
|
-
# @param [String] view
|
|
273
|
-
# @return [String]
|
|
274
|
-
def default_view_type_group_icon_classes view
|
|
275
|
-
Deprecation.warn(Blacklight::CatalogHelperBehavior, 'This method has been deprecated, use blacklight_icons helper instead')
|
|
276
|
-
"glyphicon-#{view.to_s.parameterize} view-icon-#{view.to_s.parameterize}"
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
##
|
|
280
|
-
# return the Bookmarks on a set of documents
|
|
281
|
-
# @param [Enumerable<Blacklight::Document>] documents_or_response
|
|
282
|
-
# @return [Enumerable<Bookmark>]
|
|
283
|
-
def current_bookmarks documents_or_response = nil
|
|
284
|
-
documents = if documents_or_response.respond_to? :documents
|
|
285
|
-
Deprecation.warn(Blacklight::CatalogHelperBehavior, "Passing a response to #current_bookmarks is deprecated; pass response.documents instead")
|
|
286
|
-
documents_or_response.documents
|
|
287
|
-
else
|
|
288
|
-
documents_or_response
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
documents ||= [@document] if @document.present?
|
|
292
|
-
documents ||= @response.documents
|
|
293
|
-
|
|
294
|
-
@current_bookmarks ||= current_or_guest_user.bookmarks_for_documents(documents).to_a
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
##
|
|
298
|
-
# Check if the document is in the user's bookmarks
|
|
299
|
-
# @param [Blacklight::Document] document
|
|
300
|
-
# @return [Boolean]
|
|
301
|
-
def bookmarked? document
|
|
302
|
-
current_bookmarks.any? { |x| x.document_id == document.id && x.document_type == document.class }
|
|
303
|
-
end
|
|
304
|
-
|
|
305
137
|
# Render an html <title> appropriate string for a selected facet field and values
|
|
306
138
|
#
|
|
307
139
|
# @see #render_search_to_page_title
|
|
@@ -348,6 +180,32 @@ module Blacklight::CatalogHelperBehavior
|
|
|
348
180
|
constraints.join(' / ')
|
|
349
181
|
end
|
|
350
182
|
|
|
183
|
+
##
|
|
184
|
+
# Should we render a grouped response (because the response
|
|
185
|
+
# contains a grouped response instead of the normal response)
|
|
186
|
+
#
|
|
187
|
+
# Default to false if there's no response object available (sometimes the case
|
|
188
|
+
# for tests, but might happen in other circumstances too..)
|
|
189
|
+
# @return [Boolean]
|
|
190
|
+
def render_grouped_response? response = @response
|
|
191
|
+
response&.grouped?
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
##
|
|
195
|
+
# Get the current "view type" (and ensure it is a valid type)
|
|
196
|
+
#
|
|
197
|
+
# @param [Hash] query_params the query parameters to check
|
|
198
|
+
# @return [Symbol]
|
|
199
|
+
def document_index_view_type query_params = params || {}
|
|
200
|
+
view_param = query_params[:view]
|
|
201
|
+
view_param ||= session[:preferred_view] if respond_to?(:session)
|
|
202
|
+
if view_param && document_index_views.key?(view_param.to_sym)
|
|
203
|
+
view_param.to_sym
|
|
204
|
+
else
|
|
205
|
+
default_document_index_view_type
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
351
209
|
private
|
|
352
210
|
|
|
353
211
|
# @param [String] format
|