blacklight 7.32.0 → 8.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (390) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -2
  3. data/.github/workflows/ruby.yml +32 -107
  4. data/.rubocop.yml +243 -2
  5. data/.rubocop_todo.yml +214 -270
  6. data/Gemfile +7 -6
  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 +351 -496
  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/_controls.scss +5 -12
  18. data/app/assets/stylesheets/blacklight/_facets.scss +96 -44
  19. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  20. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  21. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  22. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  23. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  24. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  25. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  26. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  27. data/app/builders/blacklight/action_builder.rb +18 -9
  28. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  29. data/app/components/blacklight/advanced_search_form_component.rb +4 -6
  30. data/app/components/blacklight/constraints_component.rb +27 -37
  31. data/app/components/blacklight/document/action_component.html.erb +2 -9
  32. data/app/components/blacklight/document/action_component.rb +26 -8
  33. data/app/components/blacklight/document/actions_component.rb +1 -1
  34. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  35. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  36. data/app/components/blacklight/document/citation_component.rb +5 -3
  37. data/app/components/blacklight/document/group_component.rb +7 -3
  38. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  39. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  40. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  41. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  42. data/app/components/blacklight/document_component.html.erb +4 -0
  43. data/app/components/blacklight/document_component.rb +7 -23
  44. data/app/components/blacklight/document_metadata_component.rb +5 -6
  45. data/app/components/blacklight/document_title_component.rb +4 -1
  46. data/app/components/blacklight/facet_component.rb +1 -1
  47. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
  48. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  49. data/app/components/blacklight/facet_field_component.html.erb +5 -5
  50. data/app/components/blacklight/facet_field_component.rb +9 -2
  51. data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
  52. data/app/components/blacklight/facet_field_list_component.rb +37 -5
  53. data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
  54. data/app/components/blacklight/facet_item_component.rb +1 -43
  55. data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
  56. data/app/components/blacklight/header_component.html.erb +2 -0
  57. data/app/components/blacklight/header_component.rb +26 -0
  58. data/app/components/blacklight/hidden_search_state_component.rb +1 -2
  59. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  60. data/app/components/blacklight/icons/list_component.rb +16 -0
  61. data/app/components/blacklight/icons/search_component.rb +16 -0
  62. data/app/components/blacklight/metadata_field_component.rb +24 -8
  63. data/app/components/blacklight/metadata_field_layout_component.rb +0 -18
  64. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  65. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  66. data/app/components/blacklight/response/sort_component.rb +1 -1
  67. data/app/components/blacklight/response/spellcheck_component.rb +17 -6
  68. data/app/components/blacklight/response/view_type_button_component.rb +2 -6
  69. data/app/components/blacklight/response/view_type_component.rb +2 -4
  70. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  71. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  72. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  73. data/app/components/blacklight/search_bar_component.rb +2 -16
  74. data/app/components/blacklight/search_button_component.rb +3 -3
  75. data/app/components/blacklight/search_context_component.rb +43 -9
  76. data/app/components/blacklight/search_header_component.html.erb +2 -0
  77. data/app/components/blacklight/search_header_component.rb +6 -0
  78. data/app/components/blacklight/search_navbar_component.html.erb +5 -0
  79. data/app/components/blacklight/search_navbar_component.rb +34 -0
  80. data/app/components/blacklight/start_over_button_component.rb +5 -3
  81. data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
  82. data/app/components/blacklight/system/flash_message_component.rb +10 -1
  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 +12 -0
  86. data/app/components/blacklight/top_navbar_component.rb +13 -0
  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 +13 -10
  90. data/app/controllers/concerns/blacklight/catalog.rb +21 -72
  91. data/app/controllers/concerns/blacklight/controller.rb +6 -43
  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 +10 -308
  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 -30
  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 -0
  121. data/app/models/concerns/blacklight/document/attributes.rb +50 -0
  122. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  123. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  124. data/app/models/concerns/blacklight/document/email.rb +1 -0
  125. data/app/models/concerns/blacklight/document/export.rb +2 -1
  126. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  127. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  128. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  129. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  130. data/app/models/concerns/blacklight/document.rb +12 -20
  131. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  132. data/app/models/concerns/blacklight/user.rb +17 -8
  133. data/app/models/record_mailer.rb +13 -12
  134. data/app/models/search.rb +0 -1
  135. data/app/models/solr_document.rb +1 -0
  136. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  137. data/app/presenters/blacklight/document_presenter.rb +13 -21
  138. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  139. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  140. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  141. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  142. data/app/presenters/blacklight/field_presenter.rb +1 -0
  143. data/app/presenters/blacklight/index_presenter.rb +2 -40
  144. data/app/presenters/blacklight/json_presenter.rb +7 -5
  145. data/app/presenters/blacklight/rendering/join.rb +1 -1
  146. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  147. data/app/presenters/blacklight/show_presenter.rb +1 -9
  148. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  149. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  150. data/app/services/blacklight/field_retriever.rb +1 -8
  151. data/app/services/blacklight/search_service.rb +8 -7
  152. data/app/values/blacklight/types.rb +95 -11
  153. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  154. data/app/views/bookmarks/_tools.html.erb +7 -12
  155. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  156. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  157. data/app/views/catalog/_constraints.html.erb +1 -14
  158. data/app/views/catalog/_document.atom.builder +12 -14
  159. data/app/views/catalog/_document.html.erb +5 -3
  160. data/app/views/catalog/_document.rss.builder +2 -4
  161. data/app/views/catalog/_facets.html.erb +5 -4
  162. data/app/views/catalog/_home_text.html.erb +2 -14
  163. data/app/views/catalog/_search_form.html.erb +3 -3
  164. data/app/views/catalog/_search_header.html.erb +1 -2
  165. data/app/views/catalog/_search_results.html.erb +2 -2
  166. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  167. data/app/views/catalog/_show_main_content.html.erb +10 -15
  168. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  169. data/app/views/catalog/_show_tools.html.erb +7 -12
  170. data/app/views/catalog/_view_type_group.html.erb +1 -1
  171. data/app/views/catalog/email_success.html.erb +5 -6
  172. data/app/views/catalog/facet.html.erb +4 -2
  173. data/app/views/catalog/index.atom.builder +12 -14
  174. data/app/views/catalog/index.html.erb +4 -1
  175. data/app/views/catalog/index.json.jbuilder +21 -19
  176. data/app/views/catalog/index.rss.builder +1 -1
  177. data/app/views/catalog/opensearch.xml.builder +1 -1
  178. data/app/views/catalog/show.json.jbuilder +2 -0
  179. data/app/views/catalog/sms_success.html.erb +5 -6
  180. data/app/views/catalog/suggest.html.erb +3 -0
  181. data/app/views/layouts/blacklight/base.html.erb +23 -9
  182. data/app/views/search_history/index.html.erb +6 -2
  183. data/app/views/shared/_header_navbar.html.erb +1 -22
  184. data/app/views/shared/_modal.html.erb +3 -3
  185. data/blacklight.gemspec +6 -8
  186. data/config/importmap.rb +3 -0
  187. data/config/locales/blacklight.ar.yml +0 -1
  188. data/config/locales/blacklight.ca.yml +0 -1
  189. data/config/locales/blacklight.de.yml +0 -1
  190. data/config/locales/blacklight.en.yml +0 -1
  191. data/config/locales/blacklight.es.yml +0 -1
  192. data/config/locales/blacklight.fr.yml +0 -1
  193. data/config/locales/blacklight.hu.yml +0 -1
  194. data/config/locales/blacklight.it.yml +0 -1
  195. data/config/locales/blacklight.nl.yml +0 -1
  196. data/config/locales/blacklight.pt-BR.yml +0 -1
  197. data/config/locales/blacklight.sq.yml +0 -1
  198. data/config/locales/blacklight.zh.yml +0 -1
  199. data/config/routes.rb +3 -2
  200. data/db/migrate/20140202020201_create_searches.rb +1 -0
  201. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  202. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  203. data/lib/blacklight/abstract_repository.rb +1 -0
  204. data/lib/blacklight/configuration/context.rb +4 -4
  205. data/lib/blacklight/configuration/display_field.rb +7 -9
  206. data/lib/blacklight/configuration/facet_field.rb +17 -11
  207. data/lib/blacklight/configuration/field.rb +1 -0
  208. data/lib/blacklight/configuration/fields.rb +12 -15
  209. data/lib/blacklight/configuration/index_field.rb +1 -0
  210. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  211. data/lib/blacklight/configuration/search_field.rb +1 -0
  212. data/lib/blacklight/configuration/show_field.rb +1 -0
  213. data/lib/blacklight/configuration/sort_field.rb +1 -0
  214. data/lib/blacklight/configuration/tool_config.rb +1 -0
  215. data/lib/blacklight/configuration/view_config.rb +16 -6
  216. data/lib/blacklight/configuration.rb +318 -341
  217. data/lib/blacklight/engine.rb +10 -11
  218. data/lib/blacklight/exceptions.rb +2 -2
  219. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  220. data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
  221. data/lib/blacklight/parameters.rb +7 -21
  222. data/lib/blacklight/routes/exportable.rb +1 -0
  223. data/lib/blacklight/routes/searchable.rb +2 -1
  224. data/lib/blacklight/routes.rb +1 -0
  225. data/lib/blacklight/search_builder.rb +10 -10
  226. data/lib/blacklight/search_state/filter_field.rb +8 -25
  227. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  228. data/lib/blacklight/search_state.rb +23 -79
  229. data/lib/blacklight/solr/document.rb +1 -0
  230. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  231. data/lib/blacklight/solr/repository.rb +1 -0
  232. data/lib/blacklight/solr/request.rb +3 -0
  233. data/lib/blacklight/solr/response/facets.rb +21 -5
  234. data/lib/blacklight/solr/response/group.rb +1 -0
  235. data/lib/blacklight/solr/response/group_response.rb +1 -0
  236. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  237. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  238. data/lib/blacklight/solr/response/params.rb +5 -4
  239. data/lib/blacklight/solr/response/response.rb +1 -0
  240. data/lib/blacklight/solr/response/spelling.rb +1 -0
  241. data/lib/blacklight/solr/response.rb +4 -3
  242. data/lib/blacklight/solr/search_builder_behavior.rb +16 -32
  243. data/lib/blacklight/solr.rb +1 -0
  244. data/lib/blacklight/version.rb +1 -0
  245. data/lib/blacklight.rb +8 -11
  246. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  247. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  248. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  249. data/lib/generators/blacklight/assets_generator.rb +13 -89
  250. data/lib/generators/blacklight/controller_generator.rb +3 -2
  251. data/lib/generators/blacklight/document_generator.rb +1 -0
  252. data/lib/generators/blacklight/install_generator.rb +5 -4
  253. data/lib/generators/blacklight/models_generator.rb +1 -0
  254. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  255. data/lib/generators/blacklight/solr_generator.rb +1 -1
  256. data/lib/generators/blacklight/templates/catalog_controller.rb +37 -7
  257. data/lib/generators/blacklight/templates/solr_document.rb +1 -1
  258. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  259. data/lib/generators/blacklight/user_generator.rb +7 -9
  260. data/lib/railties/blacklight.rake +2 -3
  261. data/package.json +9 -12
  262. data/rollup.config.js +27 -0
  263. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  264. data/spec/components/blacklight/document_component_spec.rb +12 -22
  265. data/spec/components/blacklight/facet_component_spec.rb +2 -7
  266. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  267. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  268. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +9 -7
  269. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  270. data/spec/components/blacklight/search_context_component_spec.rb +40 -0
  271. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  272. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  273. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  274. data/spec/controllers/catalog_controller_spec.rb +15 -129
  275. data/spec/features/autocomplete_spec.rb +1 -1
  276. data/spec/features/axe_spec.rb +1 -1
  277. data/spec/features/bookmarks_spec.rb +9 -0
  278. data/spec/features/facets_spec.rb +1 -1
  279. data/spec/features/search_context_spec.rb +4 -10
  280. data/spec/features/search_results_spec.rb +0 -33
  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 +3 -242
  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 +39 -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/response/facets_spec.rb +27 -27
  305. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  306. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  307. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  308. data/spec/models/blacklight/solr/search_builder_spec.rb +32 -23
  309. data/spec/models/blacklight/user_spec.rb +22 -0
  310. data/spec/models/solr_document_spec.rb +21 -3
  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 +10 -25
  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 +3 -2
  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/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  331. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  332. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  333. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  334. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  335. data/spec/views/catalog/_show_tools.html.erb_spec.rb +7 -54
  336. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  337. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  338. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  339. data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
  340. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  341. data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -19
  342. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  343. data/spec/views/catalog/show.json.jbuilder_spec.rb +2 -9
  344. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  345. data/tasks/blacklight.rake +6 -4
  346. metadata +66 -112
  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 -7
  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/controllers/blacklight/facet_spec.rb +0 -33
  376. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  377. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  378. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  379. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -108
  380. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  381. data/spec/lib/blacklight/engine_spec.rb +0 -41
  382. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  383. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  384. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  385. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  386. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  387. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  388. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  389. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  390. 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
@@ -20,297 +22,301 @@ module Blacklight
20
22
  autoload :ShowField
21
23
  end
22
24
 
25
+ class_attribute :default_values, default: {}
26
+
23
27
  # Set up Blacklight::Configuration.default_values to contain the basic, required Blacklight fields
24
28
  class << self
25
29
  def property(key, default: nil)
26
30
  default_values[key] = default
27
31
  end
28
32
 
29
- def default_values
30
- @default_values ||= {}
31
- end
32
- end
33
- # === Search request configuration
34
-
35
- # @!attribute http_method
36
- # @since v5.0.0
37
- # @return [:get, :post] HTTP method used for search
38
- property :http_method, default: :get
39
- # @!attribute solr_path
40
- # @return [String] The path to send requests to solr.
41
- property :solr_path, default: 'select'
42
- # @!attribute default_solr_params
43
- # @return [Hash] Default values of parameters to send with every search request
44
- property :default_solr_params, default: {}
45
-
46
- # === Single document request configuration
47
-
48
- # @!attribute document_solr_request_handler
49
- # @return [String] The solr request handler to use when requesting only a single document
50
- property :document_solr_request_handler, default: nil
51
- # @!attribute document_solr_path
52
- # @since v5.2.0
53
- # @return [String] The url path (relative to the solr base url) to use when requesting only a single document
54
- property :document_solr_path, default: 'get'
55
- # @!attribute document_unique_id_param
56
- # @since v5.2.0
57
- # @return [Symbol] The solr query parameter used for sending the unique identifiers for one or more documents
58
- property :document_unique_id_param, default: :ids
59
- # @!attribute default_document_solr_params
60
- # @return [Hash] Default values of parameters to send with every single-document request
61
- property :default_document_solr_params, default: {}
62
- # @!attribute fetch_many_document_params
63
- # @since v7.0.0
64
- # @return [Hash] Default values of parameters to send with every multi-document request
65
- property :fetch_many_document_params, default: {}
66
- # @!attribute document_pagination_params
67
- # @return [Hash] Default values of parameters to send when getting the previous + next documents
68
- property :document_pagination_params, default: {}
69
-
70
- ##
71
- # == Response models
72
-
73
- # @!attribute repository_class
74
- # @return [Class] Class for sending and receiving requests from a search index
75
- property :repository_class, default: nil
76
- def repository_class
77
- super || Blacklight::Solr::Repository
78
- end
79
-
80
- # @!attribute search_builder_class
81
- # @return [Class] class for converting Blacklight parameters to request parameters for the repository_class
82
- property :search_builder_class, default: nil
83
- def search_builder_class
84
- super || locate_search_builder_class
85
- end
33
+ def default_configuration(&block)
34
+ @default_configurations ||= []
86
35
 
87
- def locate_search_builder_class
88
- ::SearchBuilder
89
- end
90
-
91
- # @!attribute response_model
92
- # model that maps index responses to the blacklight response model
93
- # @return [Class]
94
- property :response_model, default: nil
95
- def response_model
96
- super || Blacklight::Solr::Response
97
- end
98
-
99
- def response_model=(*args)
100
- super
101
- end
102
-
103
- # @!attribute document_factory
104
- # the factory that builds document
105
- # @return [Class]
106
- property :document_factory, default: nil
107
- # A class that builds documents
108
- def document_factory
109
- super || Blacklight::DocumentFactory
110
- end
111
- # @!attribute document_model
112
- # the model to use for each response document
113
- # @return [Class]
114
- property :document_model, default: nil
115
- def document_model
116
- super || ::SolrDocument
117
- end
36
+ if block
37
+ @default_configurations << block
118
38
 
119
- # only here to support alias_method
120
- def document_model=(*args)
121
- super
122
- end
123
-
124
- # @!attribute facet_paginator_class
125
- # Class for paginating long lists of facet fields
126
- # @return [Class]
127
- property :facet_paginator_class, default: nil
128
- def facet_paginator_class
129
- super || Blacklight::Solr::FacetPaginator
130
- end
131
-
132
- # @!attribute connection_config
133
- # repository connection configuration
134
- # @since v5.13.0
135
- # @return [Class]
136
- property :connection_config, default: nil
137
- def connection_config
138
- super || Blacklight.connection_config
139
- end
140
-
141
- ##
142
- # == Blacklight view configuration
143
-
144
- # @!attribute navbar
145
- # @since v5.8.0
146
- # @return [#partials]
147
- property :navbar, default: OpenStructWithHashAccess.new(partials: {})
148
-
149
- # @!attribute index
150
- # General configuration for all views
151
- # @return [Blacklight::Configuration::ViewConfig::Index]
152
- property :index, default: ViewConfig::Index.new(
153
- # document presenter class used by helpers and views
154
- document_presenter_class: nil,
155
- # component class used to render a document
156
- document_component: nil,
157
- # solr field to use to render a document title
158
- title_field: nil,
159
- # solr field to use to render format-specific partials
160
- display_type_field: nil,
161
- # partials to render for each document(see #render_document_partials)
162
- partials: [:index_header, :thumbnail, :index],
163
- document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
164
- collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
165
- # what field, if any, to use to render grouped results
166
- group: false,
167
- # additional response formats for search results
168
- respond_to: OpenStructWithHashAccess.new,
169
- # component class used to render the facet grouping
170
- facet_group_component: nil,
171
- # component class used to render search constraints
172
- constraints_component: nil,
173
- # component class used to render the search bar
174
- search_bar_component: nil
175
- )
176
-
177
- # @!attribute show
178
- # Additional configuration when displaying a single document
179
- # @return [Blacklight::Configuration::ViewConfig::Show]
180
- property :show, default: ViewConfig::Show.new(
181
- # document presenter class used by helpers and views
182
- document_presenter_class: nil,
183
- document_component: nil,
184
- display_type_field: nil,
185
- # Default route parameters for 'show' requests.
186
- # Set this to a hash with additional arguments to merge into the route,
187
- # or set `controller: :current` to route to the current controller.
188
- route: nil,
189
- # partials to render for each document(see #render_document_partials)
190
- partials: [:show_header, :show],
191
- document_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
192
- )
193
-
194
- # @!attribute action_mapping
195
- # @since v7.16.0
196
- # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
197
- property :action_mapping, default: NestedOpenStructWithHashAccess.new(
198
- ViewConfig,
199
- default: { top_level_config: :index },
200
- show: { top_level_config: :show },
201
- citation: { parent_config: :show }
202
- )
203
-
204
- # @!attribute sms
205
- # @since v7.21.0
206
- # @return [Blacklight::Configuration::ViewConfig]
207
- property :sms, default: ViewConfig.new
208
-
209
- # @!attribute email
210
- # @since v7.21.0
211
- # @return [Blacklight::Configuration::ViewConfig]
212
- property :email, default: ViewConfig.new
213
-
214
- # @!attribute
215
- # Configurations for specific types of index views
216
- # @return [Hash{Symbol => Blacklight::Configuration::ViewConfig}]
217
- property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig,
218
- list: {},
219
- atom: {
220
- if: false, # by default, atom should not show up as an alternative view
221
- partials: [:document],
222
- summary_partials: [:index]
223
- },
224
- rss: {
225
- if: false, # by default, rss should not show up as an alternative view
226
- partials: [:document]
227
- })
39
+ block.call if @default_configuration_initialized
40
+ end
228
41
 
229
- ##
230
- # === Blacklight behavior configuration
42
+ @default_configurations
43
+ end
231
44
 
232
- # @!attribute spell_max
233
- # Maxiumum number of spelling suggestions to offer
234
- # @return [Integer]
235
- property :spell_max, default: 5
45
+ def initialize_default_configuration
46
+ @default_configurations&.map(&:call)
47
+ @default_configuration_initialized = true
48
+ end
236
49
 
237
- # @!attribute max_per_page
238
- # Maximum number of results to show per page
239
- # @return [Integer]
240
- property :max_per_page, default: 100
241
- # @!attribute per_page
242
- # Options for the user for number of results to show per page
243
- # @return [Array<Integer>]
244
- property :per_page, default: [10, 20, 50, 100]
245
- # @!attribute default_per_page
246
- # @return [Integer]
247
- property :default_per_page, default: nil
248
- # @return [Integer]
249
- def default_per_page
250
- super || per_page.first
50
+ def initialized_default_configuration?
51
+ @default_configuration_initialized
52
+ end
251
53
  end
252
54
 
253
- # @!attribute search_history_window
254
- # how many searches to save in session history
255
- # @return [Integer]
256
- property :search_history_window, default: 100
257
- # @!attribute default_facet_limit
258
- # @since v5.10.0
259
- # @return [Integer]
260
- property :default_facet_limit, default: 10
261
- # @!attribute default_more_limit
262
- # @since v7.0.0
263
- # @return [Integer]
264
- property :default_more_limit, default: 20
265
-
266
- # @!attribute crawler_detector
267
- # proc for determining whether the session is a crawler/bot
268
- # ex.: crawler_detector: lambda { |req| req.env['HTTP_USER_AGENT'] =~ /bot/ }
269
- # @since v7.0.0
270
- # @return [<nil, Proc>]
271
- property :crawler_detector, default: nil
272
-
273
- # @!attribute autocomplete_suggester
274
- # @since v7.0.0
275
- # @return [String]
276
- property :autocomplete_suggester, default: 'mySuggester'
277
-
278
- # @!attribute raw_endpoint
279
- # @since v7.0.0
280
- # @return [#enabled]
281
- property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false)
282
-
283
- # @!attribute track_search_session
284
- # @since v7.1.0
285
- # @return [Boolean]
286
- property :track_search_session, default: true
287
-
288
- # @!attribute advanced_search
289
- # @since v7.15.0
290
- # @return [#enabled]
291
- property :advanced_search, default: OpenStruct.new(enabled: false)
292
-
293
- # @!attribute enable_search_bar_autofocus
294
- # @since v7.2.0
295
- # @return [Boolean]
296
- property :enable_search_bar_autofocus, default: false
297
-
298
55
  BASIC_SEARCH_PARAMETERS = [:q, :qt, :page, :per_page, :search_field, :sort, :controller, :action, :'facet.page', :'facet.prefix', :'facet.sort', :rows, :format, :view].freeze
299
56
  ADVANCED_SEARCH_PARAMETERS = [{ clause: {} }, :op].freeze
300
- # List the request parameters that compose the SearchState.
301
- # If you use a plugin that adds to the search state, then you can add the parameters
302
- # by modifiying this field.
303
- # @!attribute search_state_fields
304
- # @since v8.0.0
305
- # @return [Array<Symbol>]
306
- property :search_state_fields, default: BASIC_SEARCH_PARAMETERS + ADVANCED_SEARCH_PARAMETERS
307
-
308
- # Have SearchState filter out unknown request parameters
309
- #
310
- # @!attribute filter_search_state_fields
311
- # @since v8.0.0
312
- # @return [Boolean]
313
- property :filter_search_state_fields, default: 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
314
320
 
315
321
  ##
316
322
  # Create collections of solr field configurations.
@@ -357,7 +363,9 @@ module Blacklight
357
363
  define_field_access :email_field, Blacklight::Configuration::DisplayField
358
364
 
359
365
  def initialize(hash = {})
360
- super(self.class.default_values.deep_dup.merge(hash))
366
+ self.class.initialize_default_configuration unless self.class.initialized_default_configuration?
367
+
368
+ super(self.class.default_values.deep_transform_values(&method(:_deep_copy)).merge(hash))
361
369
  yield(self) if block_given?
362
370
 
363
371
  @view_config ||= {}
@@ -368,6 +376,16 @@ module Blacklight
368
376
  repository_class.new(self)
369
377
  end
370
378
 
379
+ # @return [String] The destination for the link around the logo in the header
380
+ def logo_link
381
+ super || Rails.application.routes.url_helpers.root_path
382
+ end
383
+
384
+ # @return [Integer]
385
+ def default_per_page
386
+ super || per_page.first
387
+ end
388
+
371
389
  # DSL helper
372
390
  # @yield [config]
373
391
  # @yieldparam [Blacklight::Configuration]
@@ -381,8 +399,7 @@ module Blacklight
381
399
  # if not set, defaults to first defined search field
382
400
  # @return [Blacklight::Configuration::SearchField]
383
401
  def default_search_field
384
- field = super || search_fields.values.find { |f| f.default == true }
385
- field || search_fields.values.first
402
+ @default_search_field ||= super || search_fields.values.find { |f| f.default == true } || search_fields.values.first
386
403
  end
387
404
 
388
405
  # Returns default sort field, used for simpler display in history, etc.
@@ -460,7 +477,7 @@ module Blacklight
460
477
  # Note: Rails provides `#deep_dup`, but it aggressively `#dup`'s class names too, turning them
461
478
  # into anonymous class instances.
462
479
  def deep_copy
463
- deep_transform_values_in_object(self, &method(:_deep_copy))
480
+ deep_transform_values(&method(:_deep_copy))
464
481
  end
465
482
 
466
483
  # builds a copy for the provided controller class
@@ -492,14 +509,12 @@ module Blacklight
492
509
  view_type = nil
493
510
  end
494
511
 
495
- @view_config[[view_type, action_name]] ||= begin
496
- if view_type.nil?
497
- action_config(action_name)
498
- else
499
- base_config = action_config(action_name)
500
- base_config.merge(view.fetch(view_type, {}))
501
- end
502
- 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
503
518
  end
504
519
 
505
520
  # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
@@ -509,10 +524,13 @@ module Blacklight
509
524
  # @!macro partial_if_unless
510
525
  # @param name [String] the name of the document partial
511
526
  # @param opts [Hash]
527
+ # @option opts [Class] :component draw a component
528
+ # @option opts [String] :partial partial to draw if component is false
512
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.
513
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.
514
531
  def add_show_tools_partial(name, opts = {})
515
532
  opts[:partial] ||= 'document_action'
533
+
516
534
  add_action(show.document_actions, name, opts)
517
535
  klass && ActionBuilder.new(klass, name, opts).build
518
536
  end
@@ -539,9 +557,9 @@ module Blacklight
539
557
  ##
540
558
  # Add a section of config that only applies to documents with a matching display type
541
559
  def for_display_type display_type, &_block
542
- self.fields_for_type ||= {}
560
+ fields_for_type[display_type] ||= self.class.new
543
561
 
544
- (fields_for_type[display_type] ||= self.class.new).tap do |conf|
562
+ fields_for_type[display_type].tap do |conf|
545
563
  yield(conf) if block_given?
546
564
  end
547
565
  end
@@ -549,41 +567,21 @@ module Blacklight
549
567
  ##
550
568
  # Return a list of fields for the index display that should be used for the
551
569
  # provided document. This respects any configuration made using for_display_type
552
- def index_fields_for(document_or_display_types)
553
- display_types = if document_or_display_types.is_a? Blacklight::Document
554
- 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."
555
- document_or_display_types[index.display_type_field || 'format']
556
- else
557
- document_or_display_types
558
- end
559
-
560
- fields = {}.with_indifferent_access
561
-
562
- Array.wrap(display_types).each do |display_type|
563
- fields = fields.merge(for_display_type(display_type).index_fields)
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)
564
574
  end
565
-
566
- fields.merge(index_fields)
567
575
  end
568
576
 
569
577
  ##
570
578
  # Return a list of fields for the show page that should be used for the
571
579
  # provided document. This respects any configuration made using for_display_type
572
- def show_fields_for(document_or_display_types)
573
- display_types = if document_or_display_types.is_a? Blacklight::Document
574
- 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."
575
- document_or_display_types[show.display_type_field || 'format']
576
- else
577
- document_or_display_types
578
- end
579
-
580
- fields = {}.with_indifferent_access
581
-
582
- Array.wrap(display_types).each do |display_type|
583
- fields = fields.merge(for_display_type(display_type).show_fields)
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)
584
584
  end
585
-
586
- fields.merge(show_fields)
587
585
  end
588
586
 
589
587
  # @!visibility private
@@ -606,34 +604,13 @@ module Blacklight
606
604
  def _deep_copy(value)
607
605
  case value
608
606
  when Module then value
609
- when NestedOpenStructWithHashAccess then value.class.new(value.nested_class, deep_transform_values_in_object(value.to_h, &method(:_deep_copy)))
610
- 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)))
611
609
  else
612
610
  value.dup
613
611
  end
614
612
  end
615
613
 
616
- # This is a little shim to support Rails 6 (which has Hash#deep_transform_values) and
617
- # earlier versions (which use our backport). Once we drop support for Rails 6, this
618
- # can go away.
619
- def deep_transform_values_in_object(object, &block)
620
- return object.deep_transform_values(&block) if object.respond_to?(:deep_transform_values)
621
-
622
- _deep_transform_values_in_object(object, &block)
623
- end
624
-
625
- # Ported from Rails 6
626
- def _deep_transform_values_in_object(object, &block)
627
- case object
628
- when Hash
629
- object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
630
- when Array
631
- object.map { |e| _deep_transform_values_in_object(e, &block) }
632
- else
633
- yield(object)
634
- end
635
- end
636
-
637
614
  def action_config(action, default: :index)
638
615
  action_config = action_mapping[action]
639
616
  action_config ||= action_mapping[:default]