blacklight 7.34.0 → 8.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (393) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -3
  3. data/.github/workflows/ruby.yml +32 -127
  4. data/.rubocop.yml +241 -2
  5. data/.rubocop_todo.yml +214 -270
  6. data/Gemfile +7 -10
  7. data/README.md +11 -3
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +374 -489
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
  13. data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
  14. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
  15. data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
  16. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
  17. data/app/assets/stylesheets/blacklight/_facets.scss +72 -44
  18. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  19. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  20. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  21. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  22. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  23. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  24. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  25. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  26. data/app/builders/blacklight/action_builder.rb +18 -9
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +2 -2
  28. data/app/components/blacklight/advanced_search_form_component.rb +8 -10
  29. data/app/components/blacklight/constraints_component.rb +27 -37
  30. data/app/components/blacklight/document/action_component.rb +9 -9
  31. data/app/components/blacklight/document/actions_component.rb +2 -2
  32. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  33. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  34. data/app/components/blacklight/document/citation_component.rb +5 -3
  35. data/app/components/blacklight/document/group_component.rb +7 -3
  36. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  37. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  38. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  39. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  40. data/app/components/blacklight/document_component.html.erb +4 -0
  41. data/app/components/blacklight/document_component.rb +14 -53
  42. data/app/components/blacklight/document_metadata_component.html.erb +2 -4
  43. data/app/components/blacklight/document_metadata_component.rb +5 -10
  44. data/app/components/blacklight/document_title_component.rb +4 -1
  45. data/app/components/blacklight/facet_component.rb +1 -1
  46. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
  47. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  48. data/app/components/blacklight/facet_field_component.html.erb +5 -5
  49. data/app/components/blacklight/facet_field_component.rb +9 -2
  50. data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
  51. data/app/components/blacklight/facet_field_list_component.rb +37 -5
  52. data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
  53. data/app/components/blacklight/facet_item_component.rb +1 -43
  54. data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
  55. data/app/components/blacklight/header_component.rb +1 -1
  56. data/app/components/blacklight/hidden_search_state_component.rb +1 -2
  57. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  58. data/app/components/blacklight/icons/list_component.rb +16 -0
  59. data/app/components/blacklight/icons/search_component.rb +16 -0
  60. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  61. data/app/components/blacklight/metadata_field_component.rb +24 -8
  62. data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
  63. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  64. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  65. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  66. data/app/components/blacklight/response/pagination_component.rb +1 -5
  67. data/app/components/blacklight/response/sort_component.rb +1 -1
  68. data/app/components/blacklight/response/spellcheck_component.rb +17 -6
  69. data/app/components/blacklight/response/view_type_button_component.rb +2 -6
  70. data/app/components/blacklight/response/view_type_component.rb +3 -5
  71. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  72. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  73. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  74. data/app/components/blacklight/search_bar_component.rb +2 -16
  75. data/app/components/blacklight/search_button_component.rb +3 -3
  76. data/app/components/blacklight/search_context_component.rb +43 -9
  77. data/app/components/blacklight/search_header_component.html.erb +2 -0
  78. data/app/components/blacklight/search_header_component.rb +6 -0
  79. data/app/components/blacklight/start_over_button_component.rb +5 -3
  80. data/app/components/blacklight/system/dropdown_component.rb +2 -2
  81. data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
  82. data/app/components/blacklight/system/flash_message_component.rb +11 -2
  83. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  84. data/app/components/blacklight/system/modal_component.rb +0 -2
  85. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  86. data/app/components/blacklight/top_navbar_component.rb +0 -4
  87. data/app/controllers/bookmarks_controller.rb +1 -0
  88. data/app/controllers/catalog_controller.rb +1 -0
  89. data/app/controllers/concerns/blacklight/bookmarks.rb +10 -5
  90. data/app/controllers/concerns/blacklight/catalog.rb +21 -75
  91. data/app/controllers/concerns/blacklight/controller.rb +3 -41
  92. data/app/controllers/concerns/blacklight/search_context.rb +25 -7
  93. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  94. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  95. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  96. data/app/controllers/search_history_controller.rb +1 -0
  97. data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
  98. data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -137
  99. data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
  100. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
  101. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  102. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
  103. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  104. data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
  105. data/app/helpers/blacklight/url_helper_behavior.rb +13 -97
  106. data/app/helpers/blacklight_helper.rb +1 -0
  107. data/app/helpers/catalog_helper.rb +1 -0
  108. data/app/javascript/blacklight/bookmark_toggle.js +13 -19
  109. data/app/javascript/blacklight/button_focus.js +12 -10
  110. data/app/javascript/blacklight/checkbox_submit.js +68 -122
  111. data/app/javascript/blacklight/core.js +6 -5
  112. data/app/javascript/blacklight/index.js +13 -0
  113. data/app/javascript/blacklight/modal.js +99 -164
  114. data/app/javascript/blacklight/modalForm.js +60 -0
  115. data/app/javascript/blacklight/search_context.js +45 -55
  116. data/app/models/blacklight/facet_paginator.rb +3 -2
  117. data/app/models/blacklight/icon.rb +4 -2
  118. data/app/models/bookmark.rb +0 -2
  119. data/app/models/concerns/blacklight/configurable.rb +5 -4
  120. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
  121. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  122. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  123. data/app/models/concerns/blacklight/document/email.rb +1 -0
  124. data/app/models/concerns/blacklight/document/export.rb +2 -1
  125. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  126. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  127. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  128. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  129. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  130. data/app/models/concerns/blacklight/user.rb +17 -8
  131. data/app/models/record_mailer.rb +13 -12
  132. data/app/models/search.rb +0 -1
  133. data/app/models/solr_document.rb +1 -0
  134. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  135. data/app/presenters/blacklight/document_presenter.rb +13 -21
  136. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  137. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  138. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  139. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  140. data/app/presenters/blacklight/field_presenter.rb +1 -0
  141. data/app/presenters/blacklight/index_presenter.rb +2 -40
  142. data/app/presenters/blacklight/json_presenter.rb +7 -5
  143. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  144. data/app/presenters/blacklight/show_presenter.rb +1 -9
  145. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  146. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  147. data/app/services/blacklight/field_retriever.rb +1 -8
  148. data/app/services/blacklight/search_service.rb +8 -7
  149. data/app/values/blacklight/types.rb +0 -4
  150. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  151. data/app/views/bookmarks/_tools.html.erb +7 -12
  152. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  153. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  154. data/app/views/catalog/_constraints.html.erb +1 -14
  155. data/app/views/catalog/_document.atom.builder +12 -14
  156. data/app/views/catalog/_document.html.erb +5 -3
  157. data/app/views/catalog/_document.rss.builder +2 -4
  158. data/app/views/catalog/_facet_layout.html.erb +2 -2
  159. data/app/views/catalog/_facets.html.erb +5 -4
  160. data/app/views/catalog/_home_text.html.erb +2 -14
  161. data/app/views/catalog/_search_form.html.erb +2 -2
  162. data/app/views/catalog/_search_header.html.erb +1 -2
  163. data/app/views/catalog/_search_results.html.erb +2 -2
  164. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  165. data/app/views/catalog/_show_main_content.html.erb +11 -16
  166. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  167. data/app/views/catalog/_show_tools.html.erb +8 -14
  168. data/app/views/catalog/_view_type_group.html.erb +1 -1
  169. data/app/views/catalog/email_success.html.erb +5 -6
  170. data/app/views/catalog/facet.html.erb +7 -5
  171. data/app/views/catalog/index.atom.builder +12 -14
  172. data/app/views/catalog/index.html.erb +4 -1
  173. data/app/views/catalog/index.json.jbuilder +19 -19
  174. data/app/views/catalog/index.rss.builder +1 -1
  175. data/app/views/catalog/opensearch.xml.builder +1 -1
  176. data/app/views/catalog/sms_success.html.erb +5 -6
  177. data/app/views/catalog/suggest.html.erb +3 -0
  178. data/app/views/layouts/blacklight/base.html.erb +13 -2
  179. data/app/views/search_history/index.html.erb +6 -2
  180. data/app/views/shared/_modal.html.erb +3 -3
  181. data/blacklight.gemspec +8 -9
  182. data/config/importmap.rb +3 -0
  183. data/config/locales/blacklight.ar.yml +0 -1
  184. data/config/locales/blacklight.ca.yml +0 -1
  185. data/config/locales/blacklight.de.yml +0 -1
  186. data/config/locales/blacklight.en.yml +0 -2
  187. data/config/locales/blacklight.es.yml +0 -1
  188. data/config/locales/blacklight.fr.yml +0 -1
  189. data/config/locales/blacklight.hu.yml +0 -1
  190. data/config/locales/blacklight.it.yml +0 -1
  191. data/config/locales/blacklight.nl.yml +0 -1
  192. data/config/locales/blacklight.pt-BR.yml +0 -1
  193. data/config/locales/blacklight.sq.yml +0 -1
  194. data/config/locales/blacklight.zh.yml +0 -1
  195. data/config/routes.rb +3 -2
  196. data/db/migrate/20140202020201_create_searches.rb +1 -0
  197. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  198. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  199. data/docker-compose.yml +0 -1
  200. data/lib/blacklight/abstract_repository.rb +1 -0
  201. data/lib/blacklight/configuration/context.rb +4 -4
  202. data/lib/blacklight/configuration/display_field.rb +7 -9
  203. data/lib/blacklight/configuration/facet_field.rb +17 -11
  204. data/lib/blacklight/configuration/field.rb +1 -0
  205. data/lib/blacklight/configuration/fields.rb +12 -15
  206. data/lib/blacklight/configuration/index_field.rb +1 -0
  207. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  208. data/lib/blacklight/configuration/search_field.rb +1 -0
  209. data/lib/blacklight/configuration/show_field.rb +1 -0
  210. data/lib/blacklight/configuration/sort_field.rb +1 -0
  211. data/lib/blacklight/configuration/tool_config.rb +1 -0
  212. data/lib/blacklight/configuration/view_config.rb +16 -6
  213. data/lib/blacklight/configuration.rb +294 -358
  214. data/lib/blacklight/engine.rb +8 -13
  215. data/lib/blacklight/exceptions.rb +2 -2
  216. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  217. data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
  218. data/lib/blacklight/parameters.rb +7 -21
  219. data/lib/blacklight/routes/exportable.rb +1 -0
  220. data/lib/blacklight/routes/searchable.rb +2 -1
  221. data/lib/blacklight/routes.rb +1 -0
  222. data/lib/blacklight/search_builder.rb +10 -10
  223. data/lib/blacklight/search_state/filter_field.rb +8 -25
  224. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  225. data/lib/blacklight/search_state.rb +23 -79
  226. data/lib/blacklight/solr/document.rb +1 -0
  227. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  228. data/lib/blacklight/solr/repository.rb +3 -14
  229. data/lib/blacklight/solr/request.rb +1 -0
  230. data/lib/blacklight/solr/response/facets.rb +21 -5
  231. data/lib/blacklight/solr/response/group.rb +1 -0
  232. data/lib/blacklight/solr/response/group_response.rb +1 -0
  233. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  234. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  235. data/lib/blacklight/solr/response/params.rb +5 -4
  236. data/lib/blacklight/solr/response/response.rb +1 -0
  237. data/lib/blacklight/solr/response/spelling.rb +1 -0
  238. data/lib/blacklight/solr/response.rb +4 -3
  239. data/lib/blacklight/solr/search_builder_behavior.rb +17 -34
  240. data/lib/blacklight/solr.rb +1 -0
  241. data/lib/blacklight/version.rb +1 -0
  242. data/lib/blacklight.rb +7 -10
  243. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  244. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  245. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  246. data/lib/generators/blacklight/assets_generator.rb +13 -89
  247. data/lib/generators/blacklight/controller_generator.rb +3 -2
  248. data/lib/generators/blacklight/document_generator.rb +1 -0
  249. data/lib/generators/blacklight/install_generator.rb +4 -3
  250. data/lib/generators/blacklight/models_generator.rb +1 -0
  251. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  252. data/lib/generators/blacklight/solr_generator.rb +1 -1
  253. data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
  254. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
  255. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  256. data/lib/generators/blacklight/user_generator.rb +7 -9
  257. data/lib/railties/blacklight.rake +6 -7
  258. data/package.json +10 -13
  259. data/rollup.config.js +27 -0
  260. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  261. data/spec/components/blacklight/document_component_spec.rb +23 -82
  262. data/spec/components/blacklight/facet_component_spec.rb +2 -7
  263. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  264. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  265. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
  266. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  267. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  268. data/spec/components/blacklight/search_context_component_spec.rb +40 -0
  269. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  270. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  271. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  272. data/spec/controllers/catalog_controller_spec.rb +13 -135
  273. data/spec/features/advanced_search_spec.rb +0 -56
  274. data/spec/features/autocomplete_spec.rb +1 -1
  275. data/spec/features/axe_spec.rb +1 -6
  276. data/spec/features/bookmarks_spec.rb +1 -1
  277. data/spec/features/facets_spec.rb +1 -1
  278. data/spec/features/search_context_spec.rb +4 -10
  279. data/spec/features/search_results_spec.rb +0 -33
  280. data/spec/features/sitelinks_search_box.rb +13 -0
  281. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  282. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  283. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  284. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  285. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
  286. data/spec/helpers/blacklight_helper_spec.rb +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 +17 -51
  300. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  301. data/spec/models/blacklight/icon_spec.rb +31 -15
  302. data/spec/models/blacklight/search_builder_spec.rb +9 -9
  303. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  304. data/spec/models/blacklight/solr/repository_spec.rb +0 -27
  305. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  306. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  307. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  308. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  309. data/spec/models/blacklight/solr/search_builder_spec.rb +24 -31
  310. data/spec/models/blacklight/user_spec.rb +22 -0
  311. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  312. data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
  313. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  314. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  315. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  316. data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
  317. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -4
  318. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  319. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  320. data/spec/presenters/blacklight/show_presenter_spec.rb +20 -29
  321. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  322. data/spec/requests/load_suggestions_spec.rb +16 -0
  323. data/spec/routing/catalog_routing_spec.rb +2 -1
  324. data/spec/services/blacklight/search_service_spec.rb +31 -68
  325. data/spec/spec_helper.rb +6 -4
  326. data/spec/support/controller_level_helpers.rb +1 -2
  327. data/spec/support/features/search_helpers.rb +39 -0
  328. data/spec/support/features/session_helpers.rb +1 -0
  329. data/spec/support/features.rb +3 -0
  330. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  331. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  332. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  333. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  334. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  335. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  336. data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
  337. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  338. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  339. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  340. data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
  341. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  342. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  343. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  344. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  345. data/tasks/blacklight.rake +6 -4
  346. metadata +79 -126
  347. data/.babelrc +0 -11
  348. data/app/assets/images/blacklight/list.svg +0 -1
  349. data/app/assets/images/blacklight/search.svg +0 -1
  350. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  351. data/app/components/blacklight/content_areas_shim.rb +0 -13
  352. data/app/controllers/concerns/blacklight/base.rb +0 -12
  353. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  354. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  355. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  356. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  357. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  358. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  359. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  360. data/app/javascript/blacklight/autocomplete.js +0 -36
  361. data/app/javascript/blacklight/facet_load.js +0 -22
  362. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  363. data/app/views/catalog/_constraints_element.html.erb +0 -14
  364. data/app/views/catalog/_document_action.html.erb +0 -5
  365. data/app/views/catalog/_facet_group.html.erb +0 -5
  366. data/app/views/catalog/_facet_limit.html.erb +0 -3
  367. data/app/views/catalog/_index.html.erb +0 -1
  368. data/app/views/catalog/_index_header.html.erb +0 -22
  369. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  370. data/app/views/catalog/_show.html.erb +0 -6
  371. data/app/views/catalog/_show_header.html.erb +0 -2
  372. data/app/views/catalog/_thumbnail.html.erb +0 -1
  373. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  374. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  375. data/spec/components/blacklight/header_component_spec.rb +0 -20
  376. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  377. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  378. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  379. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  380. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  381. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
  382. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  383. data/spec/lib/blacklight/engine_spec.rb +0 -41
  384. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  385. data/spec/support/view_component_test_helpers.rb +0 -35
  386. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  387. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  388. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  389. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  390. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  391. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  392. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  393. 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::SearchContext
3
4
  extend ActiveSupport::Concern
4
5
 
@@ -17,6 +18,16 @@ module Blacklight::SearchContext
17
18
  end
18
19
  end
19
20
 
21
+ # The current search session
22
+ def current_search_session
23
+ @current_search_session ||= find_search_session
24
+ end
25
+
26
+ # Returns a list of Searches from the ids in the user's history.
27
+ def searches_from_history
28
+ session[:history].blank? ? ::Search.none : ::Search.where(id: session[:history]).order("updated_at desc")
29
+ end
30
+
20
31
  private
21
32
 
22
33
  # sets up the session[:search] hash if it doesn't already exist
@@ -27,11 +38,6 @@ module Blacklight::SearchContext
27
38
  session[:search]
28
39
  end
29
40
 
30
- # The current search session
31
- def current_search_session
32
- @current_search_session ||= find_search_session
33
- end
34
-
35
41
  # Persist the current search session id to the user's session
36
42
  def set_current_search_session
37
43
  search_session['id'] = current_search_session.id if current_search_session
@@ -79,7 +85,7 @@ module Blacklight::SearchContext
79
85
  end
80
86
 
81
87
  def find_or_initialize_search_session_from_params params
82
- params_copy = params.reject { |k, v| blacklisted_search_session_params.include?(k.to_sym) || v.blank? }
88
+ params_copy = params.reject { |k, v| nonpersisted_search_session_params.include?(k.to_sym) || v.blank? }
83
89
 
84
90
  return if params_copy.reject { |k, _v| [:action, :controller].include? k.to_sym }.blank?
85
91
 
@@ -102,10 +108,22 @@ module Blacklight::SearchContext
102
108
  end
103
109
 
104
110
  # A list of query parameters that should not be persisted for a search
105
- def blacklisted_search_session_params
111
+ def nonpersisted_search_session_params
112
+ unless method(:blacklisted_search_session_params).source_location.first.end_with?('deprecation/method_wrappers.rb')
113
+ # The blacklisted_search_session_params was overridden, so call it.
114
+ Blacklight.deprecation.warn(self, "blacklisted_search_session_params was overriden in your app, " \
115
+ "but that method should be renamed to `nonpersisted_search_session_params'. " \
116
+ "The original behavior will be removed in the next major release.")
117
+ return blacklisted_search_session_params
118
+ end
106
119
  [:commit, :counter, :total, :search_id, :page, :per_page]
107
120
  end
108
121
 
122
+ def blacklisted_search_session_params
123
+ nonpersisted_search_session_params
124
+ end
125
+ Blacklight.deprecation.deprecate_methods(self, blacklisted_search_session_params: 'use nonpersisted_search_session_params instead')
126
+
109
127
  # calls setup_previous_document then setup_next_document.
110
128
  # used in the show action for single view pagination.
111
129
  def setup_next_and_previous_documents
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Blacklight
3
4
  module SearchHistory
4
5
  extend ActiveSupport::Concern
5
6
  include Blacklight::Configurable
7
+ include Blacklight::SearchContext
6
8
 
7
9
  included do
8
10
  copy_blacklight_config_from(CatalogController)
@@ -5,17 +5,28 @@
5
5
  # would be provided by Blacklight::Controller
6
6
  # 1. search_state
7
7
  # 2. blacklight_config
8
- # 3. search_service_class
9
8
  #
10
9
  # Additionally, the including class may override the search_service_context method to provide
11
10
  # further context to the SearchService. For example you could override this to provide the
12
11
  # currently signed in user.
13
12
  module Blacklight::Searchable
13
+ extend ActiveSupport::Concern
14
+
15
+ included do
16
+ # Which class to use for the search service. You can subclass SearchService if you
17
+ # want to override any of the methods (e.g. SearchService#fetch)
18
+ class_attribute :search_service_class
19
+ self.search_service_class = Blacklight::SearchService
20
+ end
21
+
14
22
  # @return [Blacklight::SearchService]
15
23
  def search_service
16
24
  search_service_class.new(config: blacklight_config, search_state: search_state, user_params: search_state.to_h, **search_service_context)
17
25
  end
18
26
 
27
+ # Override this method on the class that includes Blacklight::Searchable to provide more context to the search service if necessary.
28
+ # For example, if your search builder needs to be aware of the current user, override this method to return a hash including the current user.
29
+ # Then the search builder could use some property about the current user to construct a constraint on the search.
19
30
  # @return [Hash] a hash of context information to pass through to the search service
20
31
  def search_service_context
21
32
  {}
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Blacklight::TokenBasedUser
3
4
  extend ActiveSupport::Concern
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class SearchHistoryController < ApplicationController
3
4
  include Blacklight::SearchHistory
4
5
  end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Methods added to this helper will be available to all templates in the hosting application
3
4
  module Blacklight::BlacklightHelperBehavior
4
- extend Deprecation
5
-
6
5
  include Blacklight::UrlHelperBehavior
7
- include Blacklight::HashAsHiddenFieldsHelperBehavior
8
6
  include Blacklight::LayoutHelperBehavior
9
7
  include Blacklight::IconHelperBehavior
10
8
 
@@ -51,15 +49,6 @@ module Blacklight::BlacklightHelperBehavior
51
49
  document_presenter(document).link_rel_alternates(options)
52
50
  end
53
51
 
54
- ##
55
- # Render OpenSearch headers for this search
56
- # @deprecated
57
- # @return [String]
58
- def render_opensearch_response_metadata
59
- render partial: 'catalog/opensearch_response_metadata', locals: { response: @response }
60
- end
61
- deprecation_deprecate render_opensearch_response_metadata: 'Use `render "catalog/opensearch_response_metadata"\' instead'
62
-
63
52
  ##
64
53
  # Render classes for the <body> element
65
54
  # @return [String]
@@ -72,207 +61,17 @@ module Blacklight::BlacklightHelperBehavior
72
61
  # @see render_body_class
73
62
  # @return [Array<String>]
74
63
  def extra_body_classes
75
- @extra_body_classes ||= ['blacklight-' + controller.controller_name, 'blacklight-' + [controller.controller_name, controller.action_name].join('-')]
76
- end
77
-
78
- ##
79
- # Render the search navbar
80
- # @return [String]
81
- def render_search_bar
82
- if search_bar_presenter_class == Blacklight::SearchBarPresenter && partial_from_blacklight?(Blacklight::SearchBarPresenter.partial)
83
- component_class = blacklight_config&.view_config(document_index_view_type)&.search_bar_component || Blacklight::SearchBarComponent
84
- render component_class.new(
85
- url: search_action_url,
86
- advanced_search_url: search_action_url(action: 'advanced_search'),
87
- params: search_state.params_for_search.except(:qt),
88
- search_fields: Deprecation.silence(Blacklight::ConfigurationHelperBehavior) { search_fields },
89
- autocomplete_path: search_action_path(action: :suggest)
90
- )
91
- else
92
- search_bar_presenter.render
93
- end
94
- end
95
- deprecation_deprecate render_search_bar: "Call `render Blacklight::SearchBarComponent.new' instead"
96
-
97
- # @!group Presenter extension helpers
98
- ##
99
- # @return [Blacklight::SearchBarPresenter]
100
- def search_bar_presenter
101
- @search_bar ||= search_bar_presenter_class.new(controller, blacklight_config)
102
- end
103
- deprecation_deprecate :search_bar_presenter
104
-
105
- # @!group Document helpers
106
- ##
107
- # Determine whether to render a given field in the index view.
108
- #
109
- # @deprecated
110
- # @param [SolrDocument] document
111
- # @param [Blacklight::Configuration::Field] field_config
112
- # @return [Boolean]
113
- def should_render_index_field? document, field_config
114
- Deprecation.warn self, "should_render_index_field? is deprecated and will be removed in Blacklight 8. Use IndexPresenter#render_field? instead."
115
- should_render_field?(field_config, document) && document_has_value?(document, field_config)
116
- end
117
-
118
- ##
119
- # Determine whether to render a given field in the show view
120
- #
121
- # @deprecated
122
- # @param [SolrDocument] document
123
- # @param [Blacklight::Configuration::Field] field_config
124
- # @return [Boolean]
125
- def should_render_show_field? document, field_config
126
- Deprecation.warn self, "should_render_show_field? is deprecated and will be removed in Blacklight 8. Use ShowPresenter#render_field? instead."
127
- should_render_field?(field_config, document) && document_has_value?(document, field_config)
128
- end
129
-
130
- ##
131
- # Check if a document has (or, might have, in the case of accessor methods) a value for
132
- # the given solr
133
- # @deprecated
134
- # @param [SolrDocument] document
135
- # @param [Blacklight::Configuration::Field] field_config
136
- # @return [Boolean]
137
- def document_has_value? document, field_config
138
- Deprecation.warn self, "document_has_value? is deprecated and will be removed in Blacklight 8. Use DocumentPresenter#has_value? instead."
139
- document.has?(field_config.field) ||
140
- (document.has_highlight_field? field_config.field if field_config.highlight) ||
141
- field_config.accessor
142
- end
143
-
144
- # @!group Search result helpers
145
- ##
146
- # Determine whether to display spellcheck suggestions
147
- #
148
- # @deprecated
149
- # @param [Blacklight::Solr::Response] response
150
- # @return [Boolean]
151
- def should_show_spellcheck_suggestions? response
152
- Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
153
- # The spelling response field may be missing from non solr repositories.
154
- response.total <= spell_check_max &&
155
- (response.spelling&.words&.any? || response.spelling&.collation&.present? || false)
156
- end
157
- end
158
- deprecation_deprecate should_show_spellcheck_suggestions?: 'moving into a private method of Blacklight::Response::SpellcheckComponent'
159
-
160
- # @!group Document helpers
161
- ##
162
- # Render the index field label for a document
163
- #
164
- # Translations for index field labels should go under blacklight.search.fields
165
- # They are picked up from there by a value "%{label}" in blacklight.search.index.label
166
- #
167
- # @deprecated
168
- # @overload render_index_field_label(options)
169
- # Use the default, document-agnostic configuration
170
- # @param [Hash] opts
171
- # @option opts [String] :field
172
- # @overload render_index_field_label(document, options)
173
- # Allow an extention point where information in the document
174
- # may drive the value of the field
175
- # @param [SolrDocument] doc
176
- # @param [Hash] opts
177
- # @option opts [String] :field
178
- # @return [String]
179
- def render_index_field_label *args
180
- options = args.extract_options!
181
- document = args.first
182
-
183
- field = options[:field]
184
- label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
185
- options[:label] || index_field_label(document, field)
186
- end
187
- html_escape t(:"blacklight.search.index.#{document_index_view_type}.label", default: :'blacklight.search.index.label', label: label)
188
- end
189
- deprecation_deprecate render_index_field_label: 'Use Blacklight::MetadataFieldComponent instead'
190
-
191
- ##
192
- # Render the show field label for a document
193
- #
194
- # @deprecated
195
- # @overload render_document_show_field_label(options)
196
- # Use the default, document-agnostic configuration
197
- # @param [Hash] opts
198
- # @option opts [String] :field
199
- # @overload render_document_show_field_label(document, options)
200
- # Allow an extention point where information in the document
201
- # may drive the value of the field
202
- # @param [SolrDocument] doc
203
- # @param [Hash] opts
204
- # @option opts [String] :field
205
- # @return [String]
206
- def render_document_show_field_label *args
207
- options = args.extract_options!
208
- document = args.first
209
-
210
- field = options[:field]
211
- label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
212
- options[:label] || document_show_field_label(document, field)
213
- end
214
-
215
- t(:'blacklight.search.show.label', label: label)
64
+ @extra_body_classes ||= ["blacklight-#{controller.controller_name}", "blacklight-#{[controller.controller_name, controller.action_name].join('-')}"]
216
65
  end
217
- deprecation_deprecate render_document_show_field_label: 'Use Blacklight::MetadataFieldComponent instead'
218
-
219
- ##
220
- # Get the value of the document's "title" field, or a placeholder
221
- # value (if empty)
222
- #
223
- # @deprecated
224
- # @param [SolrDocument] document
225
- # @return [String]
226
- def document_heading document = nil
227
- document ||= @document
228
- document_presenter(document).heading
229
- end
230
- deprecation_deprecate document_heading: 'Use Blacklight::DocumentPresenter#heading instead'
231
-
232
- ##
233
- # Get the document's "title" to display in the <title> element.
234
- # (by default, use the #document_heading)
235
- #
236
- # @deprecated
237
- # @see #document_heading
238
- # @param [SolrDocument] document
239
- # @return [String]
240
- def document_show_html_title document = nil
241
- document ||= @document
242
-
243
- document_presenter(document).html_title
244
- end
245
- deprecation_deprecate document_show_html_title: 'Use Blacklight::DocumentPresenter#html_title instead'
246
-
247
- ##
248
- # Render the document "heading" (title) in a content tag
249
- # @deprecated
250
- # @overload render_document_heading(document, options)
251
- # @param [SolrDocument] document
252
- # @param [Hash] options
253
- # @option options [Symbol] :tag
254
- # @overload render_document_heading(options)
255
- # @param [Hash] options
256
- # @option options [Symbol] :tag
257
- # @return [String]
258
- def render_document_heading(*args)
259
- options = args.extract_options!
260
- document = args.first
261
- tag = options.fetch(:tag, :h4)
262
- document ||= @document
263
-
264
- content_tag(tag, document_presenter(document).heading, itemprop: "name")
265
- end
266
- deprecation_deprecate render_document_heading: 'Removed without replacement'
267
66
 
268
67
  ##
269
68
  # Get the current "view type" (and ensure it is a valid type)
270
69
  #
271
70
  # @param [Hash] query_params the query parameters to check
272
71
  # @return [Symbol]
273
- def document_index_view_type query_params = params || {}
72
+ def document_index_view_type query_params = params
274
73
  view_param = query_params[:view]
275
- view_param ||= session[:preferred_view] if respond_to?(:session)
74
+ view_param ||= session[:preferred_view]
276
75
  if view_param && document_index_views.key?(view_param.to_sym)
277
76
  view_param.to_sym
278
77
  else
@@ -309,101 +108,24 @@ module Blacklight::BlacklightHelperBehavior
309
108
  response&.grouped?
310
109
  end
311
110
 
312
- # @!group Presenter extension helpers
313
- ##
314
- # Returns a document presenter for the given document
315
- # TODO: Move this to the controller. It can just pass a presenter or set of presenters.
316
- # @deprecated
317
- # @return [Blacklight::DocumentPresenter]
318
- def presenter(document)
319
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#presenter is deprecated; use #document_presenter instead')
320
-
321
- # As long as the presenter methods haven't been overridden, we can use the new behavior
322
- if method(:show_presenter).owner == Blacklight::BlacklightHelperBehavior &&
323
- method(:index_presenter).owner == Blacklight::BlacklightHelperBehavior
324
- return document_presenter_class(document).new(document, self)
325
- end
326
-
327
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter and/or #index_presenter have been overridden; please override #document_presenter instead')
328
-
329
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
330
- case action_name
331
- when 'show', 'citation'
332
- show_presenter(document)
333
- else
334
- index_presenter(document)
335
- end
336
- end
337
- end
338
-
339
111
  ##
340
112
  # Returns a document presenter for the given document
341
113
  def document_presenter(document)
342
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
343
- presenter(document)
344
- end
345
- end
346
-
347
- # @deprecated
348
- # @return [Blacklight::ShowPresenter]
349
- def show_presenter(document)
350
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter is deprecated; use #document_presenter instead')
351
-
352
- if method(:show_presenter_class).owner != Blacklight::BlacklightHelperBehavior
353
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter_class has been overridden; please override #document_presenter_class instead')
354
- end
355
-
356
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
357
- show_presenter_class(document).new(document, self)
358
- end
359
- end
360
-
361
- # @deprecated
362
- # @return [Blacklight::IndexPresenter]
363
- def index_presenter(document)
364
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter is deprecated; use #document_presenter instead')
365
-
366
- if method(:index_presenter_class).owner != Blacklight::BlacklightHelperBehavior
367
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter_class has been overridden; please override #document_presenter_class instead')
368
- end
369
-
370
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
371
- index_presenter_class(document).new(document, self)
372
- end
114
+ document_presenter_class(document).new(document, self)
373
115
  end
374
116
 
375
117
  ##
376
118
  # Override this method if you want to use a differnet presenter for your documents
377
- # @param [Blacklight::Document] document optional, here for extension + backwards compatibility only
378
- def document_presenter_class(document = nil)
379
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
380
- case action_name
381
- when 'show', 'citation'
382
- show_presenter_class(document)
383
- else
384
- index_presenter_class(document)
385
- end
119
+ # @param [Blacklight::Document] _document optional, here for extension + backwards compatibility only
120
+ def document_presenter_class(_document = nil)
121
+ case action_name
122
+ when 'show', 'citation'
123
+ blacklight_config.view_config(:show, action_name: action_name).document_presenter_class
124
+ else
125
+ blacklight_config.view_config(document_index_view_type, action_name: action_name).document_presenter_class
386
126
  end
387
127
  end
388
128
 
389
- ##
390
- # Override this method if you want to use a different presenter class
391
- # @deprecated
392
- # @return [Class]
393
- def show_presenter_class(_document)
394
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#show_presenter_class is deprecated; use #document_presenter_class instead')
395
-
396
- blacklight_config.view_config(:show, action_name: action_name).document_presenter_class
397
- end
398
-
399
- # @deprecated
400
- # @return [Class]
401
- def index_presenter_class(_document)
402
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, '#index_presenter_class is deprecated; use #document_presenter_class instead')
403
-
404
- blacklight_config.view_config(document_index_view_type, action_name: action_name).document_presenter_class
405
- end
406
-
407
129
  # @return [Class]
408
130
  def search_bar_presenter_class
409
131
  blacklight_config.view_config(action_name: :index).search_bar_presenter_class
@@ -416,24 +138,4 @@ module Blacklight::BlacklightHelperBehavior
416
138
  def opensearch_description_tag title, href
417
139
  tag :link, href: href, title: title, type: "application/opensearchdescription+xml", rel: "search"
418
140
  end
419
-
420
- # @private
421
-
422
- def self.blacklight_path
423
- @blacklight_path ||= Gem.loaded_specs["blacklight"].full_gem_path
424
- end
425
-
426
- def partial_from_blacklight?(partial)
427
- path = if Rails::VERSION::MAJOR >= 6
428
- name = partial.split('/').last
429
- prefix = partial.split('/').first if partial.include?('/')
430
- logger&.debug "Looking for document index partial #{partial}"
431
- prefixes = lookup_context.prefixes + [prefix, ""].compact
432
- lookup_context.find_all(name, prefixes, true).first&.identifier
433
- else
434
- lookup_context.find_all(partial, lookup_context.prefixes + [""], true).first&.identifier
435
- end
436
-
437
- path&.starts_with?(Blacklight::BlacklightHelperBehavior.blacklight_path)
438
- end
439
141
  end