blacklight 7.33.0 → 8.0.0

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