blacklight 7.40.0 → 8.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (417) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -3
  3. data/.github/workflows/ruby.yml +36 -114
  4. data/.rubocop.yml +243 -14
  5. data/.rubocop_todo.yml +137 -429
  6. data/Gemfile +11 -6
  7. data/README.md +11 -3
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +374 -493
  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/_constraints.scss +4 -4
  18. data/app/assets/stylesheets/blacklight/_facets.scss +72 -44
  19. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  20. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  21. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  22. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  23. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  24. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  25. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  26. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  27. data/app/builders/blacklight/action_builder.rb +18 -9
  28. data/app/components/blacklight/advanced_search_form_component.html.erb +3 -3
  29. data/app/components/blacklight/advanced_search_form_component.rb +8 -10
  30. data/app/components/blacklight/constraints_component.rb +27 -37
  31. data/app/components/blacklight/document/action_component.rb +9 -9
  32. data/app/components/blacklight/document/actions_component.rb +2 -2
  33. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  34. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  35. data/app/components/blacklight/document/citation_component.rb +5 -3
  36. data/app/components/blacklight/document/group_component.rb +7 -3
  37. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  38. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  39. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  40. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  41. data/app/components/blacklight/document_component.html.erb +1 -1
  42. data/app/components/blacklight/document_component.rb +16 -78
  43. data/app/components/blacklight/document_metadata_component.html.erb +2 -4
  44. data/app/components/blacklight/document_metadata_component.rb +5 -10
  45. data/app/components/blacklight/facet_component.rb +3 -3
  46. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +4 -4
  47. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  48. data/app/components/blacklight/facet_field_component.html.erb +4 -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/icon_component.rb +4 -9
  58. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  59. data/app/components/blacklight/icons/list_component.rb +16 -0
  60. data/app/components/blacklight/icons/search_component.rb +16 -0
  61. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  62. data/app/components/blacklight/metadata_field_component.rb +24 -8
  63. data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
  64. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  65. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  66. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  67. data/app/components/blacklight/response/pagination_component.rb +2 -11
  68. data/app/components/blacklight/response/sort_component.html.erb +6 -1
  69. data/app/components/blacklight/response/sort_component.rb +1 -16
  70. data/app/components/blacklight/response/spellcheck_component.rb +18 -7
  71. data/app/components/blacklight/response/view_type_button_component.rb +3 -7
  72. data/app/components/blacklight/response/view_type_component.rb +4 -6
  73. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  74. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  75. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  76. data/app/components/blacklight/search_bar_component.rb +2 -16
  77. data/app/components/blacklight/search_button_component.rb +3 -3
  78. data/app/components/blacklight/search_context_component.rb +43 -9
  79. data/app/components/blacklight/search_header_component.html.erb +2 -0
  80. data/app/components/blacklight/search_header_component.rb +6 -0
  81. data/app/components/blacklight/start_over_button_component.rb +5 -3
  82. data/app/components/blacklight/system/dropdown_component.rb +8 -5
  83. data/app/components/blacklight/system/flash_message_component.html.erb +4 -2
  84. data/app/components/blacklight/system/flash_message_component.rb +12 -3
  85. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  86. data/app/components/blacklight/system/modal_component.rb +1 -3
  87. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  88. data/app/components/blacklight/top_navbar_component.rb +0 -4
  89. data/app/controllers/bookmarks_controller.rb +1 -0
  90. data/app/controllers/catalog_controller.rb +1 -0
  91. data/app/controllers/concerns/blacklight/bookmarks.rb +10 -9
  92. data/app/controllers/concerns/blacklight/catalog.rb +21 -83
  93. data/app/controllers/concerns/blacklight/controller.rb +3 -41
  94. data/app/controllers/concerns/blacklight/search_context.rb +25 -7
  95. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  96. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  97. data/app/controllers/concerns/blacklight/token_based_user.rb +13 -1
  98. data/app/controllers/search_history_controller.rb +1 -0
  99. data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
  100. data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -139
  101. data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
  102. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -119
  103. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  104. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -7
  105. data/app/helpers/blacklight/layout_helper_behavior.rb +4 -3
  106. data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
  107. data/app/helpers/blacklight/url_helper_behavior.rb +12 -97
  108. data/app/helpers/blacklight_helper.rb +1 -0
  109. data/app/helpers/catalog_helper.rb +1 -0
  110. data/app/javascript/blacklight/bookmark_toggle.js +13 -19
  111. data/app/javascript/blacklight/button_focus.js +12 -10
  112. data/app/javascript/blacklight/checkbox_submit.js +68 -123
  113. data/app/javascript/blacklight/core.js +5 -7
  114. data/app/javascript/blacklight/index.js +13 -0
  115. data/app/javascript/blacklight/modal.js +99 -164
  116. data/app/javascript/blacklight/modalForm.js +60 -0
  117. data/app/javascript/blacklight/search_context.js +46 -54
  118. data/app/models/blacklight/facet_paginator.rb +3 -2
  119. data/app/models/blacklight/icon.rb +4 -2
  120. data/app/models/bookmark.rb +0 -2
  121. data/app/models/concerns/blacklight/configurable.rb +5 -4
  122. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -10
  123. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  124. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  125. data/app/models/concerns/blacklight/document/email.rb +1 -0
  126. data/app/models/concerns/blacklight/document/export.rb +2 -1
  127. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  128. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  129. data/app/models/concerns/blacklight/document/semantic_fields.rb +2 -1
  130. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  131. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  132. data/app/models/concerns/blacklight/user.rb +17 -8
  133. data/app/models/record_mailer.rb +13 -12
  134. data/app/models/search.rb +1 -7
  135. data/app/models/solr_document.rb +1 -0
  136. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  137. data/app/presenters/blacklight/document_presenter.rb +23 -50
  138. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  139. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  140. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  141. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  142. data/app/presenters/blacklight/field_presenter.rb +1 -0
  143. data/app/presenters/blacklight/index_presenter.rb +2 -40
  144. data/app/presenters/blacklight/json_presenter.rb +7 -5
  145. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  146. data/app/presenters/blacklight/show_presenter.rb +1 -9
  147. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  148. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  149. data/app/services/blacklight/field_retriever.rb +12 -21
  150. data/app/services/blacklight/search_service.rb +10 -17
  151. data/app/values/blacklight/types.rb +0 -18
  152. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  153. data/app/views/bookmarks/_tools.html.erb +7 -12
  154. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  155. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  156. data/app/views/catalog/_citation.html.erb +1 -1
  157. data/app/views/catalog/_constraints.html.erb +1 -14
  158. data/app/views/catalog/_document.atom.builder +12 -14
  159. data/app/views/catalog/_document.html.erb +5 -3
  160. data/app/views/catalog/_document.rss.builder +2 -4
  161. data/app/views/catalog/_facet_layout.html.erb +2 -2
  162. data/app/views/catalog/_facets.html.erb +5 -4
  163. data/app/views/catalog/_home_text.html.erb +2 -14
  164. data/app/views/catalog/_per_page_widget.html.erb +10 -1
  165. data/app/views/catalog/_search_form.html.erb +2 -2
  166. data/app/views/catalog/_search_header.html.erb +1 -2
  167. data/app/views/catalog/_search_results.html.erb +2 -2
  168. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  169. data/app/views/catalog/_show_main_content.html.erb +11 -16
  170. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  171. data/app/views/catalog/_show_tools.html.erb +8 -14
  172. data/app/views/catalog/_view_type_group.html.erb +1 -1
  173. data/app/views/catalog/email.html.erb +2 -2
  174. data/app/views/catalog/email_success.html.erb +5 -6
  175. data/app/views/catalog/facet.html.erb +7 -5
  176. data/app/views/catalog/index.atom.builder +12 -14
  177. data/app/views/catalog/index.html.erb +4 -1
  178. data/app/views/catalog/index.json.jbuilder +19 -19
  179. data/app/views/catalog/index.rss.builder +1 -1
  180. data/app/views/catalog/opensearch.xml.builder +1 -1
  181. data/app/views/catalog/sms.html.erb +2 -2
  182. data/app/views/catalog/sms_success.html.erb +5 -6
  183. data/app/views/catalog/suggest.html.erb +3 -0
  184. data/app/views/kaminari/blacklight/_page.html.erb +2 -1
  185. data/app/views/layouts/blacklight/base.html.erb +13 -2
  186. data/app/views/search_history/index.html.erb +6 -2
  187. data/app/views/shared/_flash_messages.html.erb +1 -1
  188. data/app/views/shared/_modal.html.erb +3 -3
  189. data/blacklight.gemspec +7 -11
  190. data/config/importmap.rb +3 -0
  191. data/config/locales/blacklight.ar.yml +0 -1
  192. data/config/locales/blacklight.ca.yml +0 -1
  193. data/config/locales/blacklight.de.yml +0 -1
  194. data/config/locales/blacklight.en.yml +0 -2
  195. data/config/locales/blacklight.es.yml +0 -1
  196. data/config/locales/blacklight.fr.yml +0 -1
  197. data/config/locales/blacklight.hu.yml +0 -1
  198. data/config/locales/blacklight.it.yml +0 -1
  199. data/config/locales/blacklight.nl.yml +0 -1
  200. data/config/locales/blacklight.pt-BR.yml +0 -1
  201. data/config/locales/blacklight.sq.yml +0 -1
  202. data/config/locales/blacklight.zh.yml +0 -1
  203. data/config/routes.rb +3 -2
  204. data/db/migrate/20140202020201_create_searches.rb +1 -0
  205. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  206. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  207. data/docker-compose.yml +3 -2
  208. data/lib/blacklight/abstract_repository.rb +1 -6
  209. data/lib/blacklight/component.rb +47 -10
  210. data/lib/blacklight/configuration/context.rb +4 -4
  211. data/lib/blacklight/configuration/display_field.rb +7 -9
  212. data/lib/blacklight/configuration/facet_field.rb +17 -11
  213. data/lib/blacklight/configuration/field.rb +1 -0
  214. data/lib/blacklight/configuration/fields.rb +12 -15
  215. data/lib/blacklight/configuration/index_field.rb +1 -0
  216. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  217. data/lib/blacklight/configuration/search_field.rb +1 -0
  218. data/lib/blacklight/configuration/show_field.rb +1 -0
  219. data/lib/blacklight/configuration/sort_field.rb +1 -0
  220. data/lib/blacklight/configuration/tool_config.rb +1 -0
  221. data/lib/blacklight/configuration/view_config.rb +14 -10
  222. data/lib/blacklight/configuration.rb +310 -365
  223. data/lib/blacklight/engine.rb +8 -24
  224. data/lib/blacklight/exceptions.rb +2 -2
  225. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  226. data/lib/blacklight/open_struct_with_hash_access.rb +23 -6
  227. data/lib/blacklight/parameters.rb +7 -21
  228. data/lib/blacklight/routes/exportable.rb +1 -0
  229. data/lib/blacklight/routes/searchable.rb +2 -1
  230. data/lib/blacklight/routes.rb +1 -0
  231. data/lib/blacklight/search_builder.rb +10 -10
  232. data/lib/blacklight/search_state/filter_field.rb +8 -25
  233. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  234. data/lib/blacklight/search_state.rb +23 -79
  235. data/lib/blacklight/solr/document.rb +1 -0
  236. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  237. data/lib/blacklight/solr/repository.rb +4 -24
  238. data/lib/blacklight/solr/request.rb +1 -0
  239. data/lib/blacklight/solr/response/facets.rb +21 -5
  240. data/lib/blacklight/solr/response/group.rb +1 -0
  241. data/lib/blacklight/solr/response/group_response.rb +1 -0
  242. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  243. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  244. data/lib/blacklight/solr/response/params.rb +5 -4
  245. data/lib/blacklight/solr/response/response.rb +1 -0
  246. data/lib/blacklight/solr/response/spelling.rb +1 -0
  247. data/lib/blacklight/solr/response.rb +16 -3
  248. data/lib/blacklight/solr/search_builder_behavior.rb +16 -35
  249. data/lib/blacklight/solr.rb +7 -0
  250. data/lib/blacklight/version.rb +1 -0
  251. data/lib/blacklight.rb +26 -14
  252. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  253. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  254. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  255. data/lib/generators/blacklight/assets_generator.rb +13 -86
  256. data/lib/generators/blacklight/controller_generator.rb +3 -2
  257. data/lib/generators/blacklight/document_generator.rb +1 -0
  258. data/lib/generators/blacklight/install_generator.rb +4 -3
  259. data/lib/generators/blacklight/models_generator.rb +1 -0
  260. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  261. data/lib/generators/blacklight/solr_generator.rb +1 -1
  262. data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
  263. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
  264. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  265. data/lib/generators/blacklight/user_generator.rb +7 -9
  266. data/lib/railties/blacklight.rake +6 -7
  267. data/package.json +10 -13
  268. data/rollup.config.js +27 -0
  269. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  270. data/spec/components/blacklight/document/action_component_spec.rb +6 -1
  271. data/spec/components/blacklight/document_component_spec.rb +22 -131
  272. data/spec/components/blacklight/facet_component_spec.rb +3 -18
  273. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  274. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  275. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
  276. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  277. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  278. data/spec/components/blacklight/search_context_component_spec.rb +40 -0
  279. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  280. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  281. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  282. data/spec/controllers/catalog_controller_spec.rb +13 -135
  283. data/spec/features/advanced_search_spec.rb +0 -56
  284. data/spec/features/autocomplete_spec.rb +1 -1
  285. data/spec/features/axe_spec.rb +1 -6
  286. data/spec/features/bookmarks_spec.rb +1 -1
  287. data/spec/features/facets_spec.rb +1 -1
  288. data/spec/features/search_context_spec.rb +4 -10
  289. data/spec/features/search_results_spec.rb +0 -33
  290. data/spec/features/sitelinks_search_box.rb +13 -0
  291. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  292. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  293. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  294. data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +3 -20
  295. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  296. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
  297. data/spec/helpers/blacklight_helper_spec.rb +8 -252
  298. data/spec/helpers/catalog_helper_spec.rb +7 -118
  299. data/spec/i18n_spec.rb +1 -0
  300. data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
  301. data/spec/lib/blacklight/component_spec.rb +27 -32
  302. data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
  303. data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
  304. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  305. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
  306. data/spec/lib/blacklight/parameters_spec.rb +1 -4
  307. data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
  308. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
  309. data/spec/lib/blacklight/search_state_spec.rb +80 -198
  310. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  311. data/spec/models/blacklight/configuration_spec.rb +17 -51
  312. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  313. data/spec/models/blacklight/icon_spec.rb +31 -15
  314. data/spec/models/blacklight/search_builder_spec.rb +9 -9
  315. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  316. data/spec/models/blacklight/solr/repository_spec.rb +0 -45
  317. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  318. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  319. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  320. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  321. data/spec/models/blacklight/solr/search_builder_spec.rb +24 -44
  322. data/spec/models/blacklight/user_spec.rb +22 -0
  323. data/spec/models/solr_document_spec.rb +2 -6
  324. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  325. data/spec/presenters/blacklight/document_presenter_spec.rb +2 -3
  326. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  327. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  328. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  329. data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
  330. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -5
  331. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  332. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  333. data/spec/presenters/blacklight/show_presenter_spec.rb +20 -30
  334. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  335. data/spec/requests/load_suggestions_spec.rb +16 -0
  336. data/spec/routing/catalog_routing_spec.rb +2 -1
  337. data/spec/services/blacklight/search_service_spec.rb +39 -76
  338. data/spec/spec_helper.rb +6 -4
  339. data/spec/support/controller_level_helpers.rb +1 -2
  340. data/spec/support/features/search_helpers.rb +39 -0
  341. data/spec/support/features/session_helpers.rb +1 -0
  342. data/spec/support/features.rb +3 -0
  343. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  344. data/spec/test_app_templates/Gemfile.extra +1 -0
  345. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  346. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  347. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  348. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -2
  349. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  350. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  351. data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
  352. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  353. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  354. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  355. data/spec/views/catalog/index.atom.builder_spec.rb +17 -11
  356. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  357. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  358. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  359. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  360. data/tasks/blacklight.rake +11 -9
  361. data/template.demo.rb +7 -7
  362. metadata +78 -180
  363. data/.babelrc +0 -11
  364. data/app/assets/images/blacklight/list.svg +0 -1
  365. data/app/assets/images/blacklight/search.svg +0 -1
  366. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  367. data/app/components/blacklight/content_areas_shim.rb +0 -13
  368. data/app/components/blacklight/search/per_page_component.html.erb +0 -2
  369. data/app/components/blacklight/search/per_page_component.rb +0 -50
  370. data/app/components/blacklight/system/dropdown_button_component.rb +0 -18
  371. data/app/controllers/concerns/blacklight/base.rb +0 -12
  372. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  373. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  374. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  375. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  376. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  377. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  378. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  379. data/app/javascript/blacklight/autocomplete.js +0 -36
  380. data/app/javascript/blacklight/facet_load.js +0 -22
  381. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  382. data/app/views/catalog/_constraints_element.html.erb +0 -14
  383. data/app/views/catalog/_document_action.html.erb +0 -5
  384. data/app/views/catalog/_facet_group.html.erb +0 -5
  385. data/app/views/catalog/_facet_limit.html.erb +0 -3
  386. data/app/views/catalog/_index.html.erb +0 -1
  387. data/app/views/catalog/_index_header.html.erb +0 -22
  388. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  389. data/app/views/catalog/_show.html.erb +0 -6
  390. data/app/views/catalog/_show_header.html.erb +0 -2
  391. data/app/views/catalog/_thumbnail.html.erb +0 -1
  392. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  393. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  394. data/spec/components/blacklight/header_component_spec.rb +0 -20
  395. data/spec/components/blacklight/icons/icon_component_spec.rb +0 -42
  396. data/spec/components/blacklight/response/pagination_component_spec.rb +0 -53
  397. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  398. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  399. data/spec/features/citation_spec.rb +0 -10
  400. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  401. data/spec/features/sms_spec.rb +0 -12
  402. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  403. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  404. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
  405. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  406. data/spec/lib/blacklight/engine_spec.rb +0 -41
  407. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  408. data/spec/services/blacklight/field_retriever_spec.rb +0 -17
  409. data/spec/support/view_component_test_helpers.rb +0 -35
  410. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  411. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  412. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  413. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  414. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  415. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  416. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  417. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Filters added to this controller apply to all controllers in the hosting application
3
4
  # as this module is mixed-in to the application controller in the hosting app on installation.
4
5
  module Blacklight::Controller
5
6
  extend ActiveSupport::Concern
6
- extend Deprecation
7
7
 
8
8
  included do
9
- include Blacklight::SearchFields
10
- helper Blacklight::SearchFields if respond_to? :helper
11
-
12
9
  include ActiveSupport::Callbacks
13
10
 
14
11
  # now in application.rb file under config.filter_parameters
@@ -16,6 +13,7 @@ module Blacklight::Controller
16
13
 
17
14
  # handle basic authorization exception with #access_denied
18
15
  rescue_from Blacklight::Exceptions::AccessDenied, with: :access_denied
16
+ helper BlacklightHelper
19
17
 
20
18
  if respond_to? :helper_method
21
19
  helper_method :current_user_session, :current_user, :current_or_guest_user
@@ -24,7 +22,6 @@ module Blacklight::Controller
24
22
  helper_method :has_user_authentication_provider?
25
23
  helper_method :blacklight_config, :blacklight_configuration_context # move to Catalog
26
24
  helper_method :search_action_url, :search_action_path
27
- helper_method :search_facet_path # move to catalog? deprecate?
28
25
  helper_method :search_state
29
26
  end
30
27
 
@@ -33,12 +30,6 @@ module Blacklight::Controller
33
30
  # TODO: move to Searchable
34
31
  class_attribute :search_state_class
35
32
  self.search_state_class = Blacklight::SearchState
36
-
37
- # Which class to use for the search service. You can subclass SearchService if you
38
- # want to override any of the methods (e.g. SearchService#fetch)
39
- # TODO: move to Searchable
40
- class_attribute :search_service_class
41
- self.search_service_class = Blacklight::SearchService
42
33
  end
43
34
 
44
35
  # @private
@@ -76,7 +67,7 @@ module Blacklight::Controller
76
67
  # which action the search form should use
77
68
  def search_action_url options = {}
78
69
  # Rails 4.2 deprecated url helpers accepting string keys for 'controller' or 'action'
79
- search_catalog_url(options.except(:controller, :action))
70
+ search_catalog_url(options.to_h.except(:controller, :action))
80
71
  end
81
72
 
82
73
  def search_action_path *args
@@ -87,22 +78,6 @@ module Blacklight::Controller
87
78
  search_action_url(*args)
88
79
  end
89
80
 
90
- # TODO: move to catalog? deprecate?
91
- def search_facet_path(options = {})
92
- opts = search_state
93
- .to_h
94
- .merge(action: "facet", only_path: true)
95
- .merge(options)
96
- .except(:page)
97
- url_for opts
98
- end
99
-
100
- # Returns a list of Searches from the ids in the user's history.
101
- # TODO: move to catalog? SearchHistory?
102
- def searches_from_history
103
- session[:history].blank? ? ::Search.none : ::Search.where(id: session[:history]).order("updated_at desc")
104
- end
105
-
106
81
  # Should be provided by authentication provider
107
82
  # def current_user
108
83
  # end
@@ -126,21 +101,9 @@ module Blacklight::Controller
126
101
  respond_to? :current_user
127
102
  end
128
103
 
129
- def require_user_authentication_provider
130
- raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
131
- end
132
- deprecation_deprecate require_user_authentication_provider: 'removed without replacement'
133
-
134
104
  ##
135
105
  # When a user logs in, transfer any saved searches or bookmarks to the current_user
136
106
  def transfer_guest_to_user
137
- Deprecation.silence(Blacklight::Controller) do
138
- transfer_guest_user_actions_to_current_user
139
- end
140
- end
141
-
142
- # @deprecated use canonical `transfer_guest_to_user` method instead
143
- def transfer_guest_user_actions_to_current_user
144
107
  return unless respond_to?(:current_user) && respond_to?(:guest_user) && current_user && guest_user
145
108
 
146
109
  current_user_searches = current_user.searches.pluck(:query_params)
@@ -159,7 +122,6 @@ module Blacklight::Controller
159
122
  # let guest_user know we've moved some bookmarks from under it
160
123
  guest_user.reload if guest_user.persisted?
161
124
  end
162
- deprecation_deprecate :transfer_guest_user_actions_to_current_user
163
125
 
164
126
  ##
165
127
  # To handle failed authorization attempts, redirect the user to the
@@ -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
 
@@ -48,7 +49,18 @@ module Blacklight::TokenBasedUser
48
49
  end
49
50
 
50
51
  def secret_key_generator
51
- @secret_key_generator ||= ActiveSupport::KeyGenerator.new(Rails.application.secret_key_base)
52
+ @secret_key_generator ||= begin
53
+ app = Rails.application
54
+
55
+ secret_key_base = if app.respond_to?(:credentials)
56
+ # Rails 5.2+
57
+ app.credentials.secret_key_base
58
+ else
59
+ # Rails <= 5.1
60
+ app.secrets.secret_key_base
61
+ end
62
+ ActiveSupport::KeyGenerator.new(secret_key_base)
63
+ end
52
64
  end
53
65
 
54
66
  def message_encryptor
@@ -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