blacklight 7.35.0 → 8.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (394) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -3
  3. data/.github/workflows/ruby.yml +32 -127
  4. data/.rubocop.yml +241 -2
  5. data/.rubocop_todo.yml +214 -270
  6. data/Gemfile +7 -10
  7. data/README.md +11 -3
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +374 -489
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
  13. data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
  14. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
  15. data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
  16. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
  17. data/app/assets/stylesheets/blacklight/_facets.scss +72 -44
  18. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  19. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  20. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  21. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  22. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  23. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  24. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  25. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  26. data/app/builders/blacklight/action_builder.rb +18 -9
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +2 -2
  28. data/app/components/blacklight/advanced_search_form_component.rb +8 -10
  29. data/app/components/blacklight/constraints_component.rb +27 -37
  30. data/app/components/blacklight/document/action_component.rb +9 -9
  31. data/app/components/blacklight/document/actions_component.rb +2 -2
  32. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  33. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  34. data/app/components/blacklight/document/citation_component.rb +5 -3
  35. data/app/components/blacklight/document/group_component.rb +7 -3
  36. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  37. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  38. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  39. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  40. data/app/components/blacklight/document_component.html.erb +4 -0
  41. data/app/components/blacklight/document_component.rb +14 -53
  42. data/app/components/blacklight/document_metadata_component.html.erb +2 -4
  43. data/app/components/blacklight/document_metadata_component.rb +5 -10
  44. data/app/components/blacklight/document_title_component.rb +4 -1
  45. data/app/components/blacklight/facet_component.rb +1 -1
  46. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
  47. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  48. data/app/components/blacklight/facet_field_component.html.erb +5 -5
  49. data/app/components/blacklight/facet_field_component.rb +9 -2
  50. data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
  51. data/app/components/blacklight/facet_field_list_component.rb +37 -5
  52. data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
  53. data/app/components/blacklight/facet_item_component.rb +1 -43
  54. data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
  55. data/app/components/blacklight/header_component.rb +1 -1
  56. data/app/components/blacklight/hidden_search_state_component.rb +1 -2
  57. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  58. data/app/components/blacklight/icons/list_component.rb +16 -0
  59. data/app/components/blacklight/icons/search_component.rb +16 -0
  60. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  61. data/app/components/blacklight/metadata_field_component.rb +24 -8
  62. data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
  63. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  64. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  65. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  66. data/app/components/blacklight/response/pagination_component.rb +1 -5
  67. data/app/components/blacklight/response/sort_component.rb +1 -1
  68. data/app/components/blacklight/response/spellcheck_component.rb +17 -6
  69. data/app/components/blacklight/response/view_type_button_component.rb +2 -6
  70. data/app/components/blacklight/response/view_type_component.rb +3 -5
  71. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  72. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  73. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  74. data/app/components/blacklight/search_bar_component.rb +2 -16
  75. data/app/components/blacklight/search_button_component.rb +3 -3
  76. data/app/components/blacklight/search_context_component.rb +43 -9
  77. data/app/components/blacklight/search_header_component.html.erb +2 -0
  78. data/app/components/blacklight/search_header_component.rb +6 -0
  79. data/app/components/blacklight/start_over_button_component.rb +5 -3
  80. data/app/components/blacklight/system/dropdown_component.rb +2 -2
  81. data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
  82. data/app/components/blacklight/system/flash_message_component.rb +11 -2
  83. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  84. data/app/components/blacklight/system/modal_component.rb +0 -2
  85. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  86. data/app/components/blacklight/top_navbar_component.rb +0 -4
  87. data/app/controllers/bookmarks_controller.rb +1 -0
  88. data/app/controllers/catalog_controller.rb +1 -0
  89. data/app/controllers/concerns/blacklight/bookmarks.rb +10 -9
  90. data/app/controllers/concerns/blacklight/catalog.rb +21 -83
  91. data/app/controllers/concerns/blacklight/controller.rb +3 -41
  92. data/app/controllers/concerns/blacklight/search_context.rb +25 -7
  93. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  94. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  95. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  96. data/app/controllers/search_history_controller.rb +1 -0
  97. data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
  98. data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -137
  99. data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
  100. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
  101. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  102. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
  103. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  104. data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
  105. data/app/helpers/blacklight/url_helper_behavior.rb +13 -97
  106. data/app/helpers/blacklight_helper.rb +1 -0
  107. data/app/helpers/catalog_helper.rb +1 -0
  108. data/app/javascript/blacklight/bookmark_toggle.js +13 -19
  109. data/app/javascript/blacklight/button_focus.js +12 -10
  110. data/app/javascript/blacklight/checkbox_submit.js +68 -122
  111. data/app/javascript/blacklight/core.js +6 -5
  112. data/app/javascript/blacklight/index.js +13 -0
  113. data/app/javascript/blacklight/modal.js +99 -164
  114. data/app/javascript/blacklight/modalForm.js +60 -0
  115. data/app/javascript/blacklight/search_context.js +45 -55
  116. data/app/models/blacklight/facet_paginator.rb +3 -2
  117. data/app/models/blacklight/icon.rb +4 -2
  118. data/app/models/bookmark.rb +0 -2
  119. data/app/models/concerns/blacklight/configurable.rb +5 -4
  120. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -10
  121. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  122. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  123. data/app/models/concerns/blacklight/document/email.rb +1 -0
  124. data/app/models/concerns/blacklight/document/export.rb +2 -1
  125. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  126. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  127. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  128. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  129. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  130. data/app/models/concerns/blacklight/user.rb +17 -8
  131. data/app/models/record_mailer.rb +13 -12
  132. data/app/models/search.rb +1 -7
  133. data/app/models/solr_document.rb +1 -0
  134. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  135. data/app/presenters/blacklight/document_presenter.rb +13 -21
  136. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  137. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  138. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  139. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  140. data/app/presenters/blacklight/field_presenter.rb +1 -0
  141. data/app/presenters/blacklight/index_presenter.rb +2 -40
  142. data/app/presenters/blacklight/json_presenter.rb +7 -5
  143. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  144. data/app/presenters/blacklight/show_presenter.rb +1 -9
  145. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  146. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  147. data/app/services/blacklight/field_retriever.rb +12 -21
  148. data/app/services/blacklight/search_service.rb +8 -7
  149. data/app/values/blacklight/types.rb +0 -4
  150. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  151. data/app/views/bookmarks/_tools.html.erb +7 -12
  152. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  153. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  154. data/app/views/catalog/_constraints.html.erb +1 -14
  155. data/app/views/catalog/_document.atom.builder +12 -14
  156. data/app/views/catalog/_document.html.erb +5 -3
  157. data/app/views/catalog/_document.rss.builder +2 -4
  158. data/app/views/catalog/_facet_layout.html.erb +2 -2
  159. data/app/views/catalog/_facets.html.erb +5 -4
  160. data/app/views/catalog/_home_text.html.erb +2 -14
  161. data/app/views/catalog/_search_form.html.erb +2 -2
  162. data/app/views/catalog/_search_header.html.erb +1 -2
  163. data/app/views/catalog/_search_results.html.erb +2 -2
  164. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  165. data/app/views/catalog/_show_main_content.html.erb +11 -16
  166. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  167. data/app/views/catalog/_show_tools.html.erb +8 -14
  168. data/app/views/catalog/_view_type_group.html.erb +1 -1
  169. data/app/views/catalog/email_success.html.erb +5 -6
  170. data/app/views/catalog/facet.html.erb +7 -5
  171. data/app/views/catalog/index.atom.builder +12 -14
  172. data/app/views/catalog/index.html.erb +4 -1
  173. data/app/views/catalog/index.json.jbuilder +19 -19
  174. data/app/views/catalog/index.rss.builder +1 -1
  175. data/app/views/catalog/opensearch.xml.builder +1 -1
  176. data/app/views/catalog/sms_success.html.erb +5 -6
  177. data/app/views/catalog/suggest.html.erb +3 -0
  178. data/app/views/layouts/blacklight/base.html.erb +13 -2
  179. data/app/views/search_history/index.html.erb +6 -2
  180. data/app/views/shared/_modal.html.erb +3 -3
  181. data/blacklight.gemspec +8 -9
  182. data/config/importmap.rb +3 -0
  183. data/config/locales/blacklight.ar.yml +0 -1
  184. data/config/locales/blacklight.ca.yml +0 -1
  185. data/config/locales/blacklight.de.yml +0 -1
  186. data/config/locales/blacklight.en.yml +0 -2
  187. data/config/locales/blacklight.es.yml +0 -1
  188. data/config/locales/blacklight.fr.yml +0 -1
  189. data/config/locales/blacklight.hu.yml +0 -1
  190. data/config/locales/blacklight.it.yml +0 -1
  191. data/config/locales/blacklight.nl.yml +0 -1
  192. data/config/locales/blacklight.pt-BR.yml +0 -1
  193. data/config/locales/blacklight.sq.yml +0 -1
  194. data/config/locales/blacklight.zh.yml +0 -1
  195. data/config/routes.rb +3 -2
  196. data/db/migrate/20140202020201_create_searches.rb +1 -0
  197. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  198. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  199. data/docker-compose.yml +0 -1
  200. data/lib/blacklight/abstract_repository.rb +1 -0
  201. data/lib/blacklight/configuration/context.rb +4 -4
  202. data/lib/blacklight/configuration/display_field.rb +7 -9
  203. data/lib/blacklight/configuration/facet_field.rb +17 -11
  204. data/lib/blacklight/configuration/field.rb +1 -0
  205. data/lib/blacklight/configuration/fields.rb +12 -15
  206. data/lib/blacklight/configuration/index_field.rb +1 -0
  207. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  208. data/lib/blacklight/configuration/search_field.rb +1 -0
  209. data/lib/blacklight/configuration/show_field.rb +1 -0
  210. data/lib/blacklight/configuration/sort_field.rb +1 -0
  211. data/lib/blacklight/configuration/tool_config.rb +1 -0
  212. data/lib/blacklight/configuration/view_config.rb +16 -6
  213. data/lib/blacklight/configuration.rb +294 -358
  214. data/lib/blacklight/engine.rb +8 -24
  215. data/lib/blacklight/exceptions.rb +2 -2
  216. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  217. data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
  218. data/lib/blacklight/parameters.rb +7 -21
  219. data/lib/blacklight/routes/exportable.rb +1 -0
  220. data/lib/blacklight/routes/searchable.rb +2 -1
  221. data/lib/blacklight/routes.rb +1 -0
  222. data/lib/blacklight/search_builder.rb +10 -10
  223. data/lib/blacklight/search_state/filter_field.rb +8 -25
  224. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  225. data/lib/blacklight/search_state.rb +23 -79
  226. data/lib/blacklight/solr/document.rb +1 -0
  227. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  228. data/lib/blacklight/solr/repository.rb +3 -14
  229. data/lib/blacklight/solr/request.rb +1 -0
  230. data/lib/blacklight/solr/response/facets.rb +21 -5
  231. data/lib/blacklight/solr/response/group.rb +1 -0
  232. data/lib/blacklight/solr/response/group_response.rb +1 -0
  233. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  234. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  235. data/lib/blacklight/solr/response/params.rb +5 -4
  236. data/lib/blacklight/solr/response/response.rb +1 -0
  237. data/lib/blacklight/solr/response/spelling.rb +1 -0
  238. data/lib/blacklight/solr/response.rb +4 -3
  239. data/lib/blacklight/solr/search_builder_behavior.rb +17 -34
  240. data/lib/blacklight/solr.rb +1 -0
  241. data/lib/blacklight/version.rb +1 -0
  242. data/lib/blacklight.rb +7 -10
  243. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  244. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  245. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  246. data/lib/generators/blacklight/assets_generator.rb +13 -89
  247. data/lib/generators/blacklight/controller_generator.rb +3 -2
  248. data/lib/generators/blacklight/document_generator.rb +1 -0
  249. data/lib/generators/blacklight/install_generator.rb +4 -3
  250. data/lib/generators/blacklight/models_generator.rb +1 -0
  251. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  252. data/lib/generators/blacklight/solr_generator.rb +1 -1
  253. data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
  254. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
  255. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  256. data/lib/generators/blacklight/user_generator.rb +7 -9
  257. data/lib/railties/blacklight.rake +6 -7
  258. data/package.json +10 -13
  259. data/rollup.config.js +27 -0
  260. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  261. data/spec/components/blacklight/document_component_spec.rb +23 -82
  262. data/spec/components/blacklight/facet_component_spec.rb +3 -18
  263. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  264. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  265. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
  266. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  267. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  268. data/spec/components/blacklight/search_context_component_spec.rb +40 -0
  269. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  270. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  271. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  272. data/spec/controllers/catalog_controller_spec.rb +13 -135
  273. data/spec/features/advanced_search_spec.rb +0 -56
  274. data/spec/features/autocomplete_spec.rb +1 -1
  275. data/spec/features/axe_spec.rb +1 -6
  276. data/spec/features/bookmarks_spec.rb +1 -1
  277. data/spec/features/facets_spec.rb +1 -1
  278. data/spec/features/search_context_spec.rb +4 -10
  279. data/spec/features/search_results_spec.rb +0 -33
  280. data/spec/features/sitelinks_search_box.rb +13 -0
  281. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  282. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  283. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  284. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  285. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
  286. data/spec/helpers/blacklight_helper_spec.rb +8 -252
  287. data/spec/helpers/catalog_helper_spec.rb +7 -118
  288. data/spec/i18n_spec.rb +1 -0
  289. data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
  290. data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
  291. data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
  292. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  293. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
  294. data/spec/lib/blacklight/parameters_spec.rb +1 -4
  295. data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
  296. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
  297. data/spec/lib/blacklight/search_state_spec.rb +80 -198
  298. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  299. data/spec/models/blacklight/configuration_spec.rb +17 -51
  300. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  301. data/spec/models/blacklight/icon_spec.rb +31 -15
  302. data/spec/models/blacklight/search_builder_spec.rb +9 -9
  303. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  304. data/spec/models/blacklight/solr/repository_spec.rb +0 -27
  305. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  306. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  307. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  308. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  309. data/spec/models/blacklight/solr/search_builder_spec.rb +24 -31
  310. data/spec/models/blacklight/user_spec.rb +22 -0
  311. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  312. data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
  313. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  314. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  315. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  316. data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
  317. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -4
  318. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  319. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  320. data/spec/presenters/blacklight/show_presenter_spec.rb +20 -29
  321. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  322. data/spec/requests/load_suggestions_spec.rb +16 -0
  323. data/spec/routing/catalog_routing_spec.rb +2 -1
  324. data/spec/services/blacklight/search_service_spec.rb +31 -68
  325. data/spec/spec_helper.rb +6 -32
  326. data/spec/support/controller_level_helpers.rb +1 -2
  327. data/spec/support/features/search_helpers.rb +39 -0
  328. data/spec/support/features/session_helpers.rb +1 -0
  329. data/spec/support/features.rb +3 -0
  330. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  331. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  332. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  333. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  334. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  335. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  336. data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
  337. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  338. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  339. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  340. data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
  341. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  342. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  343. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  344. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  345. data/tasks/blacklight.rake +6 -4
  346. metadata +81 -130
  347. data/.babelrc +0 -11
  348. data/app/assets/images/blacklight/list.svg +0 -1
  349. data/app/assets/images/blacklight/search.svg +0 -1
  350. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  351. data/app/components/blacklight/content_areas_shim.rb +0 -13
  352. data/app/controllers/concerns/blacklight/base.rb +0 -12
  353. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  354. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  355. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  356. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  357. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  358. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  359. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  360. data/app/javascript/blacklight/autocomplete.js +0 -36
  361. data/app/javascript/blacklight/facet_load.js +0 -22
  362. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  363. data/app/views/catalog/_constraints_element.html.erb +0 -14
  364. data/app/views/catalog/_document_action.html.erb +0 -5
  365. data/app/views/catalog/_facet_group.html.erb +0 -5
  366. data/app/views/catalog/_facet_limit.html.erb +0 -3
  367. data/app/views/catalog/_index.html.erb +0 -1
  368. data/app/views/catalog/_index_header.html.erb +0 -22
  369. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  370. data/app/views/catalog/_show.html.erb +0 -6
  371. data/app/views/catalog/_show_header.html.erb +0 -2
  372. data/app/views/catalog/_thumbnail.html.erb +0 -1
  373. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  374. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  375. data/spec/components/blacklight/header_component_spec.rb +0 -20
  376. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  377. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  378. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  379. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  380. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  381. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
  382. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  383. data/spec/lib/blacklight/engine_spec.rb +0 -41
  384. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  385. data/spec/services/blacklight/field_retriever_spec.rb +0 -17
  386. data/spec/support/view_component_test_helpers.rb +0 -35
  387. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  388. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  389. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  390. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  391. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  392. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  393. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  394. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Blacklight
3
4
  ##
4
5
  # Blacklight::Configuration holds the configuration for a Blacklight::Controller, including
@@ -12,6 +13,7 @@ module Blacklight
12
13
  autoload :Fields
13
14
  autoload :Field
14
15
  autoload :NullField
16
+ autoload :NullDisplayField
15
17
  autoload :SearchField
16
18
  autoload :FacetField
17
19
  autoload :SortField
@@ -50,297 +52,271 @@ module Blacklight
50
52
  end
51
53
  end
52
54
 
53
- property :logo_link
54
- property :header_component, default: nil
55
- def header_component
56
- super || Blacklight::HeaderComponent
57
- end
58
-
59
- # === Search request configuration
60
-
61
- # @!attribute http_method
62
- # @since v5.0.0
63
- # @return [:get, :post] HTTP method used for search
64
- property :http_method, default: :get
65
- # @!attribute solr_path
66
- # @return [String] The path to send requests to solr.
67
- property :solr_path, default: 'select'
68
- # @!attribute default_solr_params
69
- # @return [Hash] Default values of parameters to send with every search request
70
- property :default_solr_params, default: {}
71
-
72
- # === Single document request configuration
73
-
74
- # @!attribute document_solr_request_handler
75
- # @return [String] The solr request handler to use when requesting only a single document
76
- property :document_solr_request_handler, default: nil
77
- # @!attribute document_solr_path
78
- # @since v5.2.0
79
- # @return [String] The url path (relative to the solr base url) to use when requesting only a single document
80
- property :document_solr_path, default: 'get'
81
- # @!attribute json_solr_path
82
- # @since v7.34.0
83
- # @return [String] The url path (relative to the solr base url) to use when using Solr's JSON Query DSL (as with the advanced search)
84
- property :json_solr_path, default: nil
85
- # @!attribute document_unique_id_param
86
- # @since v5.2.0
87
- # @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
88
- property :document_unique_id_param, default: :ids
89
- # @!attribute default_document_solr_params
90
- # @return [Hash] Default values of parameters to send with every single-document request
91
- property :default_document_solr_params, default: {}
92
- # @!attribute fetch_many_document_params
93
- # @since v7.0.0
94
- # @return [Hash] Default values of parameters to send with every multi-document request
95
- property :fetch_many_document_params, default: {}
96
- # @!attribute document_pagination_params
97
- # @return [Hash] Default values of parameters to send when getting the previous + next documents
98
- property :document_pagination_params, default: {}
99
-
100
- ##
101
- # == Response models
102
-
103
- # @!attribute repository_class
104
- # @return [Class] Class for sending and receiving requests from a search index
105
- property :repository_class, default: nil
106
- def repository_class
107
- super || Blacklight::Solr::Repository
108
- end
109
-
110
- # @!attribute search_builder_class
111
- # @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
112
- property :search_builder_class, default: nil
113
- def search_builder_class
114
- super || locate_search_builder_class
115
- end
116
-
117
- def locate_search_builder_class
118
- ::SearchBuilder
119
- end
120
-
121
- # @!attribute response_model
122
- # model that maps index responses to the blacklight response model
123
- # @return [Class]
124
- property :response_model, default: nil
125
- def response_model
126
- super || Blacklight::Solr::Response
127
- end
128
-
129
- def response_model=(*args)
130
- super
131
- end
132
-
133
- # @!attribute document_factory
134
- # the factory that builds document
135
- # @return [Class]
136
- property :document_factory, default: nil
137
- # A class that builds documents
138
- def document_factory
139
- super || Blacklight::DocumentFactory
140
- end
141
- # @!attribute document_model
142
- # the model to use for each response document
143
- # @return [Class]
144
- property :document_model, default: nil
145
- def document_model
146
- super || ::SolrDocument
147
- end
148
-
149
- # only here to support alias_method
150
- def document_model=(*args)
151
- super
152
- end
153
-
154
- # @!attribute facet_paginator_class
155
- # Class for paginating long lists of facet fields
156
- # @return [Class]
157
- property :facet_paginator_class, default: nil
158
- def facet_paginator_class
159
- super || Blacklight::Solr::FacetPaginator
160
- end
161
-
162
- # @!attribute connection_config
163
- # repository connection configuration
164
- # @since v5.13.0
165
- # @return [Class]
166
- property :connection_config, default: nil
167
- def connection_config
168
- super || Blacklight.connection_config
169
- end
170
-
171
- ##
172
- # == Blacklight view configuration
173
-
174
- # @!attribute navbar
175
- # @since v5.8.0
176
- # @return [#partials]
177
- property :navbar, default: OpenStructWithHashAccess.new(partials: {})
178
-
179
- # @!attribute index
180
- # General configuration for all views
181
- # @return [Blacklight::Configuration::ViewConfig::Index]
182
- property :index, default: ViewConfig::Index.new(
183
- # document presenter class used by helpers and views
184
- document_presenter_class: nil,
185
- # component class used to render a document
186
- document_component: nil,
187
- # solr field to use to render a document title
188
- title_field: nil,
189
- # solr field to use to render format-specific partials
190
- display_type_field: nil,
191
- # partials to render for each document(see #render_document_partials)
192
- partials: [:index_header, :thumbnail, :index],
193
- document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
194
- collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
195
- # what field, if any, to use to render grouped results
196
- group: false,
197
- # additional response formats for search results
198
- respond_to: OpenStructWithHashAccess.new,
199
- # component class used to render the facet grouping
200
- facet_group_component: nil,
201
- # component class used to render search constraints
202
- constraints_component: nil,
203
- # component class used to render the search bar
204
- search_bar_component: nil
205
- )
206
-
207
- # @!attribute show
208
- # Additional configuration when displaying a single document
209
- # @return [Blacklight::Configuration::ViewConfig::Show]
210
- property :show, default: ViewConfig::Show.new(
211
- # document presenter class used by helpers and views
212
- document_presenter_class: nil,
213
- document_component: nil,
214
- display_type_field: nil,
215
- # Default route parameters for 'show' requests.
216
- # Set this to a hash with additional arguments to merge into the route,
217
- # or set `controller: :current` to route to the current controller.
218
- route: nil,
219
- # partials to render for each document(see #render_document_partials)
220
- partials: [:show_header, :show],
221
- document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
222
- )
223
-
224
- # @!attribute action_mapping
225
- # @since v7.16.0
226
- # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
227
- property :action_mapping, default: NestedOpenStructWithHashAccess.new(
228
- ViewConfig,
229
- default: { top_level_config: :index },
230
- show: { top_level_config: :show },
231
- citation: { parent_config: :show }
232
- )
233
-
234
- # @!attribute sms
235
- # @since v7.21.0
236
- # @return [Blacklight::Configuration::ViewConfig]
237
- property :sms, default: ViewConfig.new
238
-
239
- # @!attribute email
240
- # @since v7.21.0
241
- # @return [Blacklight::Configuration::ViewConfig]
242
- property :email, default: ViewConfig.new
243
-
244
- # @!attribute
245
- # Configurations for specific types of index views
246
- # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
247
- property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
248
- list: {},
249
- atom: {
250
- if: false, # by default, atom should not show up as an alternative view
251
- partials: [:document],
252
- summary_partials: [:index]
253
- },
254
- rss: {
255
- if: false, # by default, rss should not show up as an alternative view
256
- partials: [:document]
257
- })
258
-
259
- ##
260
- # === Blacklight behavior configuration
261
-
262
- # @!attribute spell_max
263
- # Maxiumum number of spelling suggestions to offer
264
- # @return [Integer]
265
- property :spell_max, default: 5
266
-
267
- # @!attribute max_per_page
268
- # Maximum number of results to show per page
269
- # @return [Integer]
270
- property :max_per_page, default: 100
271
- # @!attribute per_page
272
- # Options for the user for number of results to show per page
273
- # @return [Array<Integer>]
274
- property :per_page, default: [10, 20, 50, 100]
275
- # @!attribute default_per_page
276
- # @return [Integer]
277
- property :default_per_page, default: nil
278
- # @return [Integer]
279
- def default_per_page
280
- super || per_page.first
281
- end
282
-
283
- # @!attribute search_history_window
284
- # how many searches to save in session history
285
- # @return [Integer]
286
- property :search_history_window, default: 100
287
- # @!attribute default_facet_limit
288
- # @since v5.10.0
289
- # @return [Integer]
290
- property :default_facet_limit, default: 10
291
- # @!attribute default_more_limit
292
- # @since v7.0.0
293
- # @return [Integer]
294
- property :default_more_limit, default: 20
295
-
296
- # @!attribute crawler_detector
297
- # proc for determining whether the session is a crawler/bot
298
- # ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
299
- # @since v7.0.0
300
- # @return [<nil, Proc>]
301
- property :crawler_detector, default: nil
302
-
303
- # @!attribute autocomplete_suggester
304
- # @since v7.0.0
305
- # @return [String]
306
- property :autocomplete_suggester, default: 'mySuggester'
307
-
308
- # @!attribute raw_endpoint
309
- # @since v7.0.0
310
- # @return [#enabled]
311
- property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
312
-
313
- # @!attribute track_search_session
314
- # @since v7.1.0
315
- # @return [Boolean]
316
- property :track_search_session, default: true
317
-
318
- # @!attribute advanced_search
319
- # @since v7.15.0
320
- # @return [#enabled]
321
- property :advanced_search, default: OpenStruct.new(enabled: false)
322
-
323
- # @!attribute enable_search_bar_autofocus
324
- # @since v7.2.0
325
- # @return [Boolean]
326
- property :enable_search_bar_autofocus, default: false
327
-
328
55
  BASIC_SEARCH_PARAMETERS = [:q, :qt, :page, :per_page, :search_field, :sort, :controller, :action, :'facet.page', :'facet.prefix', :'facet.sort', :rows, :format, :view].freeze
329
56
  ADVANCED_SEARCH_PARAMETERS = [{ clause: {} }, :op].freeze
330
- # List the request parameters that compose the SearchState.
331
- # If you use a plugin that adds to the search state, then you can add the parameters
332
- # by modifiying this field.
333
- # @!attribute search_state_fields
334
- # @since v8.0.0
335
- # @return [Array<Symbol>]
336
- property :search_state_fields, default: BASIC_SEARCH_PARAMETERS + ADVANCED_SEARCH_PARAMETERS
337
-
338
- # Have SearchState filter out unknown request parameters
339
- #
340
- # @!attribute filter_search_state_fields
341
- # @since v8.0.0
342
- # @return [Boolean]
343
- property :filter_search_state_fields, default: false
57
+
58
+ # rubocop:disable Metrics/BlockLength
59
+ default_configuration do
60
+ property :logo_link, default: nil
61
+ property :header_component, default: Blacklight::HeaderComponent
62
+
63
+ # bootstrap_version may be set to 4 or 5
64
+ bootstrap_version = ENV['BOOTSTRAP_VERSION'].presence || "5"
65
+ property :bootstrap_version, default: /(\d)(?:\.\d){0,2}/.match(bootstrap_version)[1].to_i
66
+
67
+ # === Search request configuration
68
+
69
+ # @!attribute http_method
70
+ # @since v5.0.0
71
+ # @return [:get, :post] HTTP method used for search
72
+ property :http_method, default: :get
73
+ # @!attribute solr_path
74
+ # @return [String] The path to send requests to solr.
75
+ property :solr_path, default: 'select'
76
+ # @!attribute default_solr_params
77
+ # @return [Hash] Default values of parameters to send with every search request
78
+ property :default_solr_params, default: {}
79
+
80
+ # === Single document request configuration
81
+
82
+ # @!attribute document_solr_request_handler
83
+ # @return [String] The solr request handler to use when requesting only a single document
84
+ property :document_solr_request_handler, default: nil
85
+ # @!attribute document_solr_path
86
+ # @since v5.2.0
87
+ # @return [String] The url path (relative to the solr base url) to use when requesting only a single document
88
+ property :document_solr_path, default: 'get'
89
+ # @!attribute document_unique_id_param
90
+ # @since v5.2.0
91
+ # @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
92
+ property :document_unique_id_param, default: :ids
93
+ # @!attribute default_document_solr_params
94
+ # @return [Hash] Default values of parameters to send with every single-document request
95
+ property :default_document_solr_params, default: {}
96
+ # @!attribute fetch_many_document_params
97
+ # @since v7.0.0
98
+ # @return [Hash] Default values of parameters to send with every multi-document request
99
+ property :fetch_many_document_params, default: {}
100
+ # @!attribute document_pagination_params
101
+ # @return [Hash] Default values of parameters to send when getting the previous + next documents
102
+ property :document_pagination_params, default: {}
103
+
104
+ ##
105
+ # == Response models
106
+
107
+ # @!attribute repository_class
108
+ # @return [Class] Class for sending and receiving requests from a search index
109
+ property :repository_class, default: Blacklight::Solr::Repository
110
+ # @!attribute search_builder_class
111
+ # @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
112
+ property :search_builder_class, default: ::SearchBuilder
113
+ # @!attribute response_model
114
+ # model that maps index responses to the blacklight response model
115
+ # @return [Class]
116
+ property :response_model, default: Blacklight::Solr::Response
117
+ # @!attribute document_model
118
+ # the model to use for each response document
119
+ # @return [Class]
120
+ property :document_model, default: ::SolrDocument
121
+ # @!attribute document_factory
122
+ # the factory that builds document
123
+ # @return [Class]
124
+ property :document_factory, default: Blacklight::DocumentFactory
125
+ # @!attribute facet_paginator_class
126
+ # Class for paginating long lists of facet fields
127
+ # @return [Class]
128
+ property :facet_paginator_class, default: Blacklight::Solr::FacetPaginator
129
+ # @!attribute connection_config
130
+ # repository connection configuration
131
+ # @since v5.13.0
132
+ # @return [Class]
133
+ property :connection_config, default: Blacklight.connection_config
134
+
135
+ ##
136
+ # == Blacklight view configuration
137
+
138
+ # @!attribute navbar
139
+ # @since v5.8.0
140
+ # @return [#partials]
141
+ property :navbar, default: OpenStructWithHashAccess.new(partials: {})
142
+
143
+ # @!attribute index
144
+ # General configuration for all views
145
+ # @return [Blacklight::Configuration::ViewConfig::Index]
146
+ property :index, default: ViewConfig::Index.new(
147
+ # document presenter class used by helpers and views
148
+ document_presenter_class: nil,
149
+ # component class used to render a document
150
+ document_component: Blacklight::DocumentComponent,
151
+ sidebar_component: Blacklight::Search::SidebarComponent,
152
+ # solr field to use to render a document title
153
+ title_field: nil,
154
+ # solr field to use to render format-specific partials
155
+ display_type_field: nil,
156
+ # the "field access" key to use to look up the document display fields
157
+ document_fields_key: :index_fields,
158
+ # partials to render for each document(see #render_document_partials)
159
+ partials: [],
160
+ document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
161
+ collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
162
+ # what field, if any, to use to render grouped results
163
+ group: false,
164
+ # additional response formats for search results
165
+ respond_to: OpenStructWithHashAccess.new,
166
+ # component class used to render the facet grouping
167
+ facet_group_component: nil,
168
+ # component class used to render search constraints
169
+ constraints_component: nil,
170
+ # component class used to render the search bar
171
+ search_bar_component: nil,
172
+ # component class used to render the header above the documents
173
+ search_header_component: Blacklight::SearchHeaderComponent
174
+ )
175
+
176
+ # @!attribute show
177
+ # Additional configuration when displaying a single document
178
+ # @return [Blacklight::Configuration::ViewConfig::Show]
179
+ property :show, default: ViewConfig::Show.new(
180
+ # document presenter class used by helpers and views
181
+ document_presenter_class: nil,
182
+ document_component: Blacklight::DocumentComponent,
183
+ sidebar_component: Blacklight::Document::SidebarComponent,
184
+ display_type_field: nil,
185
+ # the "field access" key to use to look up the document display fields
186
+ document_fields_key: :show_fields,
187
+ # Default route parameters for 'show' requests.
188
+ # Set this to a hash with additional arguments to merge into the route,
189
+ # or set `controller: :current` to route to the current controller.
190
+ route: nil,
191
+ # partials to render for each document(see #render_document_partials)
192
+ partials: [],
193
+ document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
194
+ )
195
+
196
+ # @!attribute action_mapping
197
+ # @since v7.16.0
198
+ # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
199
+ property :action_mapping, default: NestedOpenStructWithHashAccess.new(
200
+ ViewConfig,
201
+ default: { top_level_config: :index },
202
+ show: { top_level_config: :show },
203
+ citation: { parent_config: :show }
204
+ )
205
+
206
+ # @!attribute sms
207
+ # @since v7.21.0
208
+ # @return [Blacklight::Configuration::ViewConfig]
209
+ property :sms, default: ViewConfig.new
210
+
211
+ # @!attribute email
212
+ # @since v7.21.0
213
+ # @return [Blacklight::Configuration::ViewConfig]
214
+ property :email, default: ViewConfig.new
215
+
216
+ # @!attribute
217
+ # Configurations for specific types of index views
218
+ # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
219
+ property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
220
+ list: {},
221
+ atom: {
222
+ if: false, # by default, atom should not show up as an alternative view
223
+ partials: [:document],
224
+ summary_component: Blacklight::DocumentComponent
225
+ },
226
+ rss: {
227
+ if: false, # by default, rss should not show up as an alternative view
228
+ partials: [:document]
229
+ })
230
+
231
+ ##
232
+ # === Blacklight behavior configuration
233
+
234
+ # @!attribute spell_max
235
+ # Maxiumum number of spelling suggestions to offer
236
+ # @return [Integer]
237
+ property :spell_max, default: 5
238
+
239
+ # @!attribute max_per_page
240
+ # Maximum number of results to show per page
241
+ # @return [Integer]
242
+ property :max_per_page, default: 100
243
+ # @!attribute per_page
244
+ # Options for the user for number of results to show per page
245
+ # @return [Array<Integer>]
246
+ property :per_page, default: [10, 20, 50, 100]
247
+ # @!attribute default_per_page
248
+ # @return [Integer]
249
+ property :default_per_page, default: nil
250
+
251
+ # @!attribute search_history_window
252
+ # how many searches to save in session history
253
+ # @return [Integer]
254
+ property :search_history_window, default: 100
255
+ # @!attribute default_facet_limit
256
+ # @since v5.10.0
257
+ # @return [Integer]
258
+ property :default_facet_limit, default: 10
259
+ # @!attribute default_more_limit
260
+ # @since v7.0.0
261
+ # @return [Integer]
262
+ property :default_more_limit, default: 20
263
+
264
+ # @!attribute crawler_detector
265
+ # proc for determining whether the session is a crawler/bot
266
+ # ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
267
+ # @since v7.0.0
268
+ # @return [<nil, Proc>]
269
+ property :crawler_detector, default: nil
270
+
271
+ # @!attribute autocomplete_suggester
272
+ # @since v7.0.0
273
+ # @return [String]
274
+ property :autocomplete_suggester, default: 'mySuggester'
275
+
276
+ # @!attribute raw_endpoint
277
+ # @since v7.0.0
278
+ # @return [#enabled]
279
+ property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
280
+
281
+ # @!attribute track_search_session
282
+ # @since v7.1.0
283
+ # @return [Boolean]
284
+ property :track_search_session, default: true
285
+
286
+ # @!attribute advanced_search
287
+ # @since v7.15.0
288
+ # @return [#enabled]
289
+ property :advanced_search, default: OpenStruct.new(enabled: false)
290
+
291
+ # @!attribute enable_search_bar_autofocus
292
+ # @since v7.2.0
293
+ # @return [Boolean]
294
+ property :enable_search_bar_autofocus, default: false
295
+
296
+ # List the request parameters that compose the SearchState.
297
+ # If you use a plugin that adds to the search state, then you can add the parameters
298
+ # by modifiying this field.
299
+ # @!attribute search_state_fields
300
+ # @since v8.0.0
301
+ # @return [Array<Symbol>]
302
+ property :search_state_fields, default: BASIC_SEARCH_PARAMETERS + ADVANCED_SEARCH_PARAMETERS
303
+
304
+ # Have SearchState filter out unknown request parameters
305
+ #
306
+ # @!attribute filter_search_state_fields
307
+ # @since v8.0.0
308
+ # @return [Boolean]
309
+ property :filter_search_state_fields, default: true
310
+
311
+ # Additional Blacklight configuration setting for document-type specific
312
+ # configuration.
313
+ # @!attribute fields_for_type
314
+ # @since v8.0.0
315
+ # @return [Hash{Symbol => Blacklight::Configuration}]
316
+ # @see [#for_display_type]
317
+ property :fields_for_type, default: {}.with_indifferent_access
318
+ end
319
+ # rubocop:enable Metrics/BlockLength
344
320
 
345
321
  ##
346
322
  # Create collections of solr field configurations.
@@ -389,7 +365,7 @@ module Blacklight
389
365
  def initialize(hash = {})
390
366
  self.class.initialize_default_configuration unless self.class.initialized_default_configuration?
391
367
 
392
- super(self.class.default_values.deep_dup.merge(hash))
368
+ super(self.class.default_values.deep_transform_values(&method(:_deep_copy)).merge(hash))
393
369
  yield(self) if block_given?
394
370
 
395
371
  @view_config ||= {}
@@ -405,6 +381,11 @@ module Blacklight
405
381
  super || Rails.application.routes.url_helpers.root_path
406
382
  end
407
383
 
384
+ # @return [Integer]
385
+ def default_per_page
386
+ super || per_page.first
387
+ end
388
+
408
389
  # DSL helper
409
390
  # @yield [config]
410
391
  # @yieldparam [Blacklight::Configuration]
@@ -418,8 +399,7 @@ module Blacklight
418
399
  # if not set, defaults to first defined search field
419
400
  # @return [Blacklight::Configuration::SearchField]
420
401
  def default_search_field
421
- field = super || search_fields.values.find { |f| f.default == true }
422
- field || search_fields.values.first
402
+ @default_search_field ||= super || search_fields.values.find { |f| f.default == true } || search_fields.values.first
423
403
  end
424
404
 
425
405
  # Returns default sort field, used for simpler display in history, etc.
@@ -497,7 +477,7 @@ module Blacklight
497
477
  # Note: Rails provides `#deep_dup`, but it aggressively `#dup`'s class names too, turning them
498
478
  # into anonymous class instances.
499
479
  def deep_copy
500
- deep_transform_values_in_object(self, &method(:_deep_copy))
480
+ deep_transform_values(&method(:_deep_copy))
501
481
  end
502
482
 
503
483
  # builds a copy for the provided controller class
@@ -529,14 +509,12 @@ module Blacklight
529
509
  view_type = nil
530
510
  end
531
511
 
532
- @view_config[[view_type, action_name]] ||= begin
533
- if view_type.nil?
534
- action_config(action_name)
535
- else
536
- base_config = action_config(action_name)
537
- base_config.merge(view.fetch(view_type, {}))
538
- end
539
- end
512
+ @view_config[[view_type, action_name]] ||= if view_type.nil?
513
+ action_config(action_name)
514
+ else
515
+ base_config = action_config(action_name)
516
+ base_config.merge(view.fetch(view_type, {}))
517
+ end
540
518
  end
541
519
 
542
520
  # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
@@ -546,10 +524,13 @@ module Blacklight
546
524
  # @!macro partial_if_unless
547
525
  # @param name [String] the name of the document partial
548
526
  # @param opts [Hash]
527
+ # @option opts [Class] :component draw a component
528
+ # @option opts [String] :partial partial to draw if component is false
549
529
  # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true. The proc will receive the action configuration and the document or documents for the action.
550
530
  # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true. The proc will receive the action configuration and the document or documents for the action.
551
531
  def add_show_tools_partial(name, opts = {})
552
532
  opts[:partial] ||= 'document_action'
533
+
553
534
  add_action(show.document_actions, name, opts)
554
535
  klass && ActionBuilder.new(klass, name, opts).build
555
536
  end
@@ -576,9 +557,9 @@ module Blacklight
576
557
  ##
577
558
  # Add a section of config that only applies to documents with a matching display type
578
559
  def for_display_type display_type, &_block
579
- self.fields_for_type ||= {}
560
+ fields_for_type[display_type] ||= self.class.new
580
561
 
581
- (fields_for_type[display_type] ||= self.class.new).tap do |conf|
562
+ fields_for_type[display_type].tap do |conf|
582
563
  yield(conf) if block_given?
583
564
  end
584
565
  end
@@ -586,45 +567,21 @@ module Blacklight
586
567
  ##
587
568
  # Return a list of fields for the index display that should be used for the
588
569
  # provided document. This respects any configuration made using for_display_type
589
- def index_fields_for(document_or_display_types)
590
- display_types = if document_or_display_types.is_a? Blacklight::Document
591
- Deprecation.warn self, "Calling index_fields_for with a #{document_or_display_types.class} is deprecated and will be removed in Blacklight 8. Pass the display type instead."
592
- document_or_display_types[index.display_type_field || 'format']
593
- else
594
- document_or_display_types
595
- end
596
-
597
- fields = {}.with_indifferent_access
598
-
599
- Array.wrap(display_types).each do |display_type|
600
- fields = fields.merge(for_display_type(display_type).index_fields)
570
+ # @deprecated
571
+ def index_fields_for(display_types)
572
+ Array(display_types).inject(index_fields) do |fields, display_type|
573
+ fields.merge(for_display_type(display_type).index_fields)
601
574
  end
602
-
603
- fields.merge(index_fields)
604
575
  end
605
576
 
606
577
  ##
607
578
  # Return a list of fields for the show page that should be used for the
608
579
  # provided document. This respects any configuration made using for_display_type
609
- def show_fields_for(document_or_display_types)
610
- display_types = if document_or_display_types.is_a? Blacklight::Document
611
- Deprecation.warn self, "Calling show_fields_for with a #{document_or_display_types.class} is deprecated and will be removed in Blacklight 8. Pass the display type instead."
612
- document_or_display_types[show.display_type_field || 'format']
613
- else
614
- document_or_display_types
615
- end
616
-
617
- unless display_types.respond_to?(:each)
618
- Deprecation.warn self, "Calling show_fields_for with a scalar value is deprecated. It must receive an Enumerable."
619
- display_types = Array.wrap(display_types)
620
- end
621
- fields = {}.with_indifferent_access
622
-
623
- display_types.each do |display_type|
624
- fields = fields.merge(for_display_type(display_type).show_fields)
580
+ # @deprecated
581
+ def show_fields_for(display_types)
582
+ Array(display_types).inject(show_fields) do |fields, display_type|
583
+ fields.merge(for_display_type(display_type).show_fields)
625
584
  end
626
-
627
- fields.merge(show_fields)
628
585
  end
629
586
 
630
587
  # @!visibility private
@@ -647,34 +604,13 @@ module Blacklight
647
604
  def _deep_copy(value)
648
605
  case value
649
606
  when Module then value
650
- when NestedOpenStructWithHashAccess then value.class.new(value.nested_class, deep_transform_values_in_object(value.to_h, &method(:_deep_copy)))
651
- when OpenStruct then value.class.new(deep_transform_values_in_object(value.to_h, &method(:_deep_copy)))
607
+ when NestedOpenStructWithHashAccess then value.class.new(value.nested_class, value.to_h.deep_transform_values(&method(:_deep_copy)))
608
+ when OpenStruct then value.class.new(value.to_h.deep_transform_values(&method(:_deep_copy)))
652
609
  else
653
610
  value.dup
654
611
  end
655
612
  end
656
613
 
657
- # This is a little shim to support Rails 6 (which has Hash#deep_transform_values) and
658
- # earlier versions (which use our backport). Once we drop support for Rails 6, this
659
- # can go away.
660
- def deep_transform_values_in_object(object, &block)
661
- return object.deep_transform_values(&block) if object.respond_to?(:deep_transform_values)
662
-
663
- _deep_transform_values_in_object(object, &block)
664
- end
665
-
666
- # Ported from Rails 6
667
- def _deep_transform_values_in_object(object, &block)
668
- case object
669
- when Hash
670
- object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
671
- when Array
672
- object.map { |e| _deep_transform_values_in_object(e, &block) }
673
- else
674
- yield(object)
675
- end
676
- end
677
-
678
614
  def action_config(action, default: :index)
679
615
  action_config = action_mapping[action]
680
616
  action_config ||= action_mapping[:default]