blacklight-spotlight 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (367) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -8
  3. data/Rakefile +40 -39
  4. data/app/assets/javascripts/spotlight/blacklight_configuration.js +16 -0
  5. data/app/assets/javascripts/spotlight/blocks/resources_block.js +3 -1
  6. data/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +2 -2
  7. data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +24 -0
  8. data/app/assets/stylesheets/spotlight/_header.scss +150 -47
  9. data/app/assets/stylesheets/spotlight/_pages.scss +62 -11
  10. data/app/assets/stylesheets/spotlight/_report_a_problem.scss +1 -0
  11. data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -0
  12. data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +28 -21
  13. data/app/controllers/spotlight/about_pages_controller.rb +25 -14
  14. data/app/controllers/spotlight/appearances_controller.rb +34 -30
  15. data/app/controllers/spotlight/application_controller.rb +2 -1
  16. data/app/controllers/spotlight/attachments_controller.rb +9 -7
  17. data/app/controllers/spotlight/browse_controller.rb +13 -9
  18. data/app/controllers/spotlight/catalog_controller.rb +179 -161
  19. data/app/controllers/spotlight/concerns/application_controller.rb +22 -20
  20. data/app/controllers/spotlight/concerns/catalog_search_context.rb +44 -0
  21. data/app/controllers/spotlight/confirmations_controller.rb +5 -2
  22. data/app/controllers/spotlight/contact_forms_controller.rb +13 -7
  23. data/app/controllers/spotlight/contacts_controller.rb +13 -4
  24. data/app/controllers/spotlight/custom_fields_controller.rb +48 -40
  25. data/app/controllers/spotlight/dashboards_controller.rb +17 -8
  26. data/app/controllers/spotlight/default_controller.rb +3 -1
  27. data/app/controllers/spotlight/exhibits_controller.rb +69 -62
  28. data/app/controllers/spotlight/feature_pages_controller.rb +21 -11
  29. data/app/controllers/spotlight/home_pages_controller.rb +6 -5
  30. data/app/controllers/spotlight/lock_controller.rb +3 -1
  31. data/app/controllers/spotlight/metadata_configurations_controller.rb +49 -0
  32. data/app/controllers/spotlight/pages_controller.rb +28 -18
  33. data/app/controllers/spotlight/resources/upload_controller.rb +53 -46
  34. data/app/controllers/spotlight/resources_controller.rb +9 -5
  35. data/app/controllers/spotlight/roles_controller.rb +26 -22
  36. data/app/controllers/spotlight/search_configurations_controller.rb +66 -0
  37. data/app/controllers/spotlight/searches_controller.rb +91 -82
  38. data/app/controllers/spotlight/solr_controller.rb +20 -13
  39. data/app/controllers/spotlight/tags_controller.rb +5 -3
  40. data/app/controllers/spotlight/versions_controller.rb +15 -12
  41. data/app/controllers/spotlight/view_configurations_controller.rb +17 -0
  42. data/app/helpers/spotlight/application_helper.rb +44 -32
  43. data/app/helpers/spotlight/browse_helper.rb +13 -1
  44. data/app/helpers/spotlight/crud_link_helpers.rb +22 -14
  45. data/app/helpers/spotlight/jcrop_helper.rb +4 -2
  46. data/app/helpers/spotlight/main_app_helpers.rb +45 -41
  47. data/app/helpers/spotlight/navbar_helper.rb +6 -0
  48. data/app/helpers/spotlight/pages_helper.rb +23 -15
  49. data/app/helpers/spotlight/roles_helper.rb +10 -4
  50. data/app/helpers/spotlight/search_configurations_helper.rb +22 -0
  51. data/app/helpers/spotlight/title_helper.rb +16 -13
  52. data/app/jobs/spotlight/add_uploads_from_csv.rb +13 -9
  53. data/app/jobs/spotlight/reindex_job.rb +9 -9
  54. data/app/jobs/spotlight/rename_sidecar_field_job.rb +3 -0
  55. data/app/mailers/spotlight/confirmation_mailer.rb +2 -0
  56. data/app/mailers/spotlight/indexing_complete_mailer.rb +4 -2
  57. data/app/models/ability.rb +3 -0
  58. data/app/models/concerns/spotlight/ar_light.rb +49 -25
  59. data/app/models/concerns/spotlight/blacklight_configuration_defaults.rb +25 -10
  60. data/app/models/concerns/spotlight/exhibit_analytics.rb +28 -0
  61. data/app/models/concerns/spotlight/image_derivatives.rb +25 -26
  62. data/app/models/concerns/spotlight/resources/open_graph.rb +23 -19
  63. data/app/models/concerns/spotlight/resources/web.rb +25 -24
  64. data/app/models/concerns/spotlight/solr_document.rb +40 -34
  65. data/app/models/concerns/spotlight/solr_document/active_model_concern.rb +29 -40
  66. data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +22 -18
  67. data/app/models/concerns/spotlight/solr_document/finder.rb +23 -18
  68. data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +43 -39
  69. data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +41 -29
  70. data/app/models/concerns/spotlight/user.rb +25 -19
  71. data/app/models/sir_trevor_rails/blocks/browse_block.rb +36 -30
  72. data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +24 -18
  73. data/app/models/sir_trevor_rails/blocks/oembed_block.rb +8 -4
  74. data/app/models/sir_trevor_rails/blocks/search_results_block.rb +29 -23
  75. data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +43 -42
  76. data/app/models/sir_trevor_rails/blocks/solr_documents_carousel_block.rb +16 -12
  77. data/app/models/sir_trevor_rails/blocks/solr_documents_embed_block.rb +7 -3
  78. data/app/models/sir_trevor_rails/blocks/solr_documents_features_block.rb +7 -3
  79. data/app/models/sir_trevor_rails/blocks/solr_documents_grid_block.rb +7 -3
  80. data/app/models/sir_trevor_rails/blocks/textable.rb +18 -18
  81. data/app/models/spotlight/ability.rb +32 -33
  82. data/app/models/spotlight/about_page.rb +3 -1
  83. data/app/models/spotlight/analytics/ga.rb +46 -27
  84. data/app/models/spotlight/attachment.rb +3 -1
  85. data/app/models/spotlight/blacklight_configuration.rb +146 -68
  86. data/app/models/spotlight/contact.rb +35 -30
  87. data/app/models/spotlight/contact_email.rb +6 -3
  88. data/app/models/spotlight/contact_form.rb +4 -3
  89. data/app/models/spotlight/custom_field.rb +41 -33
  90. data/app/models/spotlight/exhibit.rb +104 -130
  91. data/app/models/spotlight/feature_page.rb +9 -7
  92. data/app/models/spotlight/featured_image.rb +10 -10
  93. data/app/models/spotlight/field_metadata.rb +46 -0
  94. data/app/models/spotlight/home_page.rb +8 -5
  95. data/app/models/spotlight/lock.rb +4 -3
  96. data/app/models/spotlight/main_navigation.rb +9 -3
  97. data/app/models/spotlight/masthead.rb +17 -16
  98. data/app/models/spotlight/page.rb +16 -16
  99. data/app/models/spotlight/resource.rb +69 -22
  100. data/app/models/spotlight/resources/csv_upload.rb +8 -4
  101. data/app/models/spotlight/resources/upload.rb +68 -57
  102. data/app/models/spotlight/role.rb +30 -34
  103. data/app/models/spotlight/search.rb +74 -63
  104. data/app/models/spotlight/solr_document_sidecar.rb +17 -15
  105. data/app/serializers/spotlight/exhibit_export_serializer.rb +65 -29
  106. data/app/serializers/spotlight/page_representer.rb +10 -6
  107. data/app/uploaders/spotlight/attachment_uploader.rb +4 -6
  108. data/app/uploaders/spotlight/avatar_uploader.rb +4 -3
  109. data/app/uploaders/spotlight/featured_image_uploader.rb +15 -14
  110. data/app/uploaders/spotlight/item_uploader.rb +3 -1
  111. data/app/uploaders/spotlight/masthead_uploader.rb +4 -2
  112. data/app/views/catalog/_search_form.html.erb +24 -0
  113. data/app/views/shared/_browse_navbar.html.erb +1 -1
  114. data/app/views/shared/_exhibit_navbar.html.erb +1 -1
  115. data/app/views/spotlight/appearances/edit.html.erb +13 -45
  116. data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
  117. data/app/views/spotlight/custom_fields/_form.html.erb +1 -1
  118. data/app/views/spotlight/exhibits/edit.html.erb +4 -4
  119. data/app/views/spotlight/home_pages/_empty.html.erb +1 -3
  120. data/app/views/spotlight/home_pages/_page_options.html.erb +1 -1
  121. data/app/views/spotlight/{blacklight_configurations → metadata_configurations}/_metadata_field.html.erb +0 -0
  122. data/app/views/spotlight/{blacklight_configurations/edit_metadata_fields.html.erb → metadata_configurations/edit.html.erb} +1 -1
  123. data/app/views/spotlight/pages/show.html.erb +2 -2
  124. data/app/views/spotlight/search_configurations/_default_per_page.html.erb +5 -0
  125. data/app/views/spotlight/search_configurations/_document_index_view_types.html.erb +7 -0
  126. data/app/views/spotlight/search_configurations/_facets.html.erb +38 -0
  127. data/app/views/spotlight/search_configurations/_search_fields.html.erb +58 -0
  128. data/app/views/spotlight/search_configurations/_sort.html.erb +53 -0
  129. data/app/views/spotlight/search_configurations/edit.html.erb +46 -0
  130. data/app/views/spotlight/searches/_search.html.erb +1 -1
  131. data/app/views/spotlight/shared/_admin_sidebar.html.erb +0 -2
  132. data/app/views/spotlight/shared/_curation_sidebar.html.erb +2 -3
  133. data/app/views/spotlight/shared/_report_a_problem.html.erb +2 -2
  134. data/app/views/spotlight/sir_trevor/blocks/_oembed_block.html.erb +5 -1
  135. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -5
  136. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +2 -2
  137. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb +7 -5
  138. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +2 -2
  139. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +14 -9
  140. data/config/locales/spotlight.en.yml +94 -49
  141. data/config/routes.rb +11 -20
  142. data/db/migrate/20150410180014_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  143. data/db/migrate/20150410180015_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  144. data/db/migrate/20150410180016_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
  145. data/db/migrate/20150713160101_change_spotlight_searches_to_published.rb +5 -0
  146. data/db/migrate/20151016092343_remove_searchable_from_exhibit.rb +20 -0
  147. data/lib/blacklight/spotlight.rb +1 -1
  148. data/lib/generators/spotlight/install_generator.rb +27 -25
  149. data/lib/generators/spotlight/templates/catalog_controller.rb +7 -5
  150. data/lib/generators/spotlight/templates/jetty.rake +8 -2
  151. data/lib/generators/spotlight/templates/spotlight_helper.rb +3 -1
  152. data/lib/spotlight.rb +4 -2
  153. data/lib/spotlight/base.rb +21 -14
  154. data/lib/spotlight/catalog.rb +10 -9
  155. data/lib/spotlight/catalog/access_controls_enforcement.rb +30 -15
  156. data/lib/spotlight/config.rb +4 -2
  157. data/lib/spotlight/controller.rb +12 -11
  158. data/lib/spotlight/engine.rb +30 -22
  159. data/lib/spotlight/rails/routes.rb +7 -4
  160. data/lib/spotlight/version.rb +2 -1
  161. data/lib/tasks/spotlight_tasks.rake +56 -50
  162. data/spec/controllers/application_controller_spec.rb +13 -13
  163. data/spec/controllers/spotlight/about_pages_controller_spec.rb +63 -59
  164. data/spec/controllers/spotlight/appearances_controller_spec.rb +29 -24
  165. data/spec/controllers/spotlight/application_controller_spec.rb +3 -3
  166. data/spec/controllers/spotlight/attachments_controller_spec.rb +10 -10
  167. data/spec/controllers/spotlight/browse_controller_spec.rb +23 -25
  168. data/spec/controllers/spotlight/catalog_controller_spec.rb +82 -87
  169. data/spec/controllers/spotlight/confirmations_controller_spec.rb +13 -11
  170. data/spec/controllers/spotlight/contact_forms_controller_spec.rb +17 -12
  171. data/spec/controllers/spotlight/contacts_controller_spec.rb +36 -36
  172. data/spec/controllers/spotlight/custom_fields_controller_spec.rb +26 -26
  173. data/spec/controllers/spotlight/dashboards_controller_spec.rb +14 -14
  174. data/spec/controllers/spotlight/exhibits_controller_spec.rb +59 -54
  175. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +59 -59
  176. data/spec/controllers/spotlight/home_pages_controller_spec.rb +28 -29
  177. data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +84 -0
  178. data/spec/controllers/spotlight/resources/upload_controller_spec.rb +42 -33
  179. data/spec/controllers/spotlight/resources_controller_spec.rb +25 -29
  180. data/spec/controllers/spotlight/roles_controller_spec.rb +37 -19
  181. data/spec/controllers/spotlight/search_configurations_controller_spec.rb +125 -0
  182. data/spec/controllers/spotlight/searches_controller_spec.rb +84 -63
  183. data/spec/controllers/spotlight/solr_controller_spec.rb +13 -14
  184. data/spec/controllers/spotlight/tags_controller_spec.rb +16 -16
  185. data/spec/controllers/spotlight/versions_controller_spec.rb +15 -18
  186. data/spec/controllers/spotlight/view_configurations_controller_spec.rb +31 -0
  187. data/spec/factories/contacts.rb +1 -3
  188. data/spec/factories/custom_fields.rb +2 -4
  189. data/spec/factories/exhibits.rb +4 -2
  190. data/spec/factories/pages.rb +8 -11
  191. data/spec/factories/resources.rb +4 -4
  192. data/spec/factories/searches.rb +10 -13
  193. data/spec/factories/tags.rb +0 -3
  194. data/spec/factories/users.rb +2 -4
  195. data/spec/features/about_page_spec.rb +19 -19
  196. data/spec/features/add_contacts_spec.rb +34 -34
  197. data/spec/features/add_custom_field_metadata_spec.rb +24 -26
  198. data/spec/features/add_item_bookmarklet_spec.rb +12 -12
  199. data/spec/features/browse_category_admin_spec.rb +39 -39
  200. data/spec/features/catalog_spec.rb +9 -10
  201. data/spec/features/confirm_email_spec.rb +10 -10
  202. data/spec/features/create_exhibit_spec.rb +18 -15
  203. data/spec/features/create_page_spec.rb +8 -8
  204. data/spec/features/curator_items.rb +3 -3
  205. data/spec/features/dashboard_spec.rb +15 -16
  206. data/spec/features/edit_contact_spec.rb +8 -10
  207. data/spec/features/edit_search_fields_spec.rb +79 -0
  208. data/spec/features/exhibits/add_tags_spec.rb +15 -16
  209. data/spec/features/exhibits/administration_spec.rb +25 -25
  210. data/spec/features/exhibits/custom_metadata_fields_spec.rb +41 -43
  211. data/spec/features/exhibits/edit_metadata_fields_spec.rb +19 -19
  212. data/spec/features/feature_page_spec.rb +49 -48
  213. data/spec/features/home_page_spec.rb +38 -38
  214. data/spec/features/import_exhibit_spec.rb +23 -20
  215. data/spec/features/item_admin_spec.rb +28 -29
  216. data/spec/features/javascript/about_page_admin_spec.rb +9 -9
  217. data/spec/features/javascript/block_controls_spec.rb +16 -18
  218. data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +11 -12
  219. data/spec/features/javascript/blocks/featured_pages_block_spec.rb +12 -13
  220. data/spec/features/javascript/blocks/search_result_block_spec.rb +17 -17
  221. data/spec/features/javascript/blocks/solr_documents_block_spec.rb +67 -65
  222. data/spec/features/javascript/edit_in_place_spec.rb +30 -56
  223. data/spec/features/javascript/feature_page_admin_spec.rb +73 -59
  224. data/spec/features/javascript/home_page_edit_spec.rb +6 -6
  225. data/spec/features/javascript/metadata_admin_spec.rb +15 -15
  226. data/spec/features/javascript/multi_image_select_spec.rb +17 -18
  227. data/spec/features/javascript/preview_block_spec.rb +11 -12
  228. data/spec/features/javascript/rule_block_spec.rb +7 -7
  229. data/spec/features/javascript/search_config_admin_spec.rb +144 -0
  230. data/spec/features/javascript/search_context_spec.rb +41 -42
  231. data/spec/features/main_navigation_spec.rb +22 -22
  232. data/spec/features/metadata_admin_spec.rb +8 -8
  233. data/spec/features/multiple_exhibits_spec.rb +15 -17
  234. data/spec/features/report_a_problem_spec.rb +23 -17
  235. data/spec/features/site_masthead_spec.rb +46 -46
  236. data/spec/features/slideshow_spec.rb +8 -9
  237. data/spec/features/tags_admin_spec.rb +11 -11
  238. data/spec/features/upload_non_repository_item_spec.rb +32 -32
  239. data/spec/features/user_admin_spec.rb +7 -7
  240. data/spec/helpers/spotlight/application_helper_spec.rb +63 -56
  241. data/spec/helpers/spotlight/browse_helper_spec.rb +6 -6
  242. data/spec/helpers/spotlight/crud_link_helpers_spec.rb +58 -52
  243. data/spec/helpers/spotlight/main_app_helpers_spec.rb +44 -24
  244. data/spec/helpers/spotlight/navbar_helper_spec.rb +4 -4
  245. data/spec/helpers/spotlight/pages_helper_spec.rb +56 -37
  246. data/spec/helpers/spotlight/roles_helper_spec.rb +3 -3
  247. data/spec/helpers/spotlight/search_configurations_helper_spec.rb +24 -0
  248. data/spec/helpers/spotlight/title_helper_spec.rb +33 -35
  249. data/spec/jobs/spotlight/reindex_job_spec.rb +6 -6
  250. data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +7 -7
  251. data/spec/lib/spotlight/catalog/access_controls_enforcement_spec.rb +41 -26
  252. data/spec/lib/spotlight/controller_spec.rb +10 -10
  253. data/spec/lib/spotlight/routes_spec.rb +4 -4
  254. data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +13 -13
  255. data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +8 -8
  256. data/spec/models/{spotlight/sir_trevor_blocks → sir_trevor_rails/blocks}/textable_spec.rb +7 -8
  257. data/spec/models/solr_document_spec.rb +49 -50
  258. data/spec/models/spotlight/ability_spec.rb +17 -20
  259. data/spec/models/spotlight/about_page_spec.rb +6 -6
  260. data/spec/models/spotlight/analytics/ga_spec.rb +2 -2
  261. data/spec/models/spotlight/blacklight_configuration_spec.rb +196 -133
  262. data/spec/models/spotlight/contact_email_spec.rb +28 -24
  263. data/spec/models/spotlight/contact_spec.rb +6 -7
  264. data/spec/models/spotlight/custom_field_spec.rb +51 -52
  265. data/spec/models/spotlight/exhibit_spec.rb +102 -60
  266. data/spec/models/spotlight/feature_page_spec.rb +32 -32
  267. data/spec/models/spotlight/featured_image_spec.rb +5 -5
  268. data/spec/models/spotlight/field_metadata_spec.rb +78 -0
  269. data/spec/models/spotlight/home_page_spec.rb +11 -20
  270. data/spec/models/spotlight/{spotlight_image_derivatives_spec.rb → image_derivatives_spec.rb} +2 -2
  271. data/spec/models/spotlight/main_navigation_spec.rb +7 -9
  272. data/spec/models/spotlight/masthead_spec.rb +6 -6
  273. data/spec/models/spotlight/page_spec.rb +26 -29
  274. data/spec/models/spotlight/resource_spec.rb +56 -26
  275. data/spec/models/spotlight/resources/open_graph_spec.rb +16 -18
  276. data/spec/models/spotlight/resources/upload_spec.rb +32 -35
  277. data/spec/models/spotlight/resources/web_spec.rb +9 -11
  278. data/spec/models/spotlight/role_spec.rb +20 -20
  279. data/spec/models/spotlight/search_spec.rb +32 -15
  280. data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +34 -0
  281. data/spec/models/spotlight/{solr_document_images_spec.rb → solr_document/spotlight_images_spec.rb} +18 -10
  282. data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +52 -0
  283. data/spec/models/spotlight/solr_document_sidecar_spec.rb +3 -4
  284. data/spec/routing/spotlight/exhibit_catalog_spec.rb +5 -5
  285. data/spec/routing/spotlight/pages_routing_spec.rb +24 -25
  286. data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +88 -68
  287. data/spec/spec_helper.rb +13 -22
  288. data/spec/support/features/test_features_helpers.rb +50 -46
  289. data/spec/support/views/test_view_helpers.rb +1 -1
  290. data/spec/test_app_templates/Gemfile.extra +0 -1
  291. data/spec/test_app_templates/carrierwave.rb +2 -2
  292. data/spec/test_app_templates/catalog_controller.rb +42 -42
  293. data/spec/test_app_templates/lib/generators/test_app_generator.rb +20 -11
  294. data/spec/test_app_templates/spotlight_test.rake +3 -3
  295. data/spec/uploaders/spotlight/item_uploader_spec.rb +68 -0
  296. data/spec/views/_user_util_links.html.erb_spec.rb +14 -14
  297. data/spec/views/shared/_analytics.html.erb_spec.rb +4 -6
  298. data/spec/views/shared/_exhibit_masthead.html.erb_spec.rb +19 -20
  299. data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +129 -131
  300. data/spec/views/shared/_footer.html.erb_spec.rb +6 -7
  301. data/spec/views/shared/_header_navbar.html.erb_spec.rb +5 -5
  302. data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +4 -4
  303. data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +9 -11
  304. data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +31 -28
  305. data/spec/views/spotlight/browse/_search.html.erb_spec.rb +6 -6
  306. data/spec/views/spotlight/browse/_sort_and_per_page.html.erb_spec.rb +10 -12
  307. data/spec/views/spotlight/browse/index.html.erb_spec.rb +6 -6
  308. data/spec/views/spotlight/browse/show.html.erb_spec.rb +19 -20
  309. data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +7 -7
  310. data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +7 -7
  311. data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +3 -6
  312. data/spec/views/spotlight/catalog/new.html.erb_spec.rb +8 -10
  313. data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +8 -8
  314. data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +22 -22
  315. data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +7 -8
  316. data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +5 -5
  317. data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +24 -26
  318. data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +13 -9
  319. data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +6 -6
  320. data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +26 -0
  321. data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +22 -0
  322. data/spec/views/spotlight/pages/edit.html.erb_spec.rb +16 -16
  323. data/spec/views/spotlight/pages/index.html.erb_spec.rb +19 -17
  324. data/spec/views/spotlight/pages/new.html.erb_spec.rb +6 -6
  325. data/spec/views/spotlight/pages/show.html.erb_spec.rb +27 -28
  326. data/spec/views/spotlight/roles/index.html.erb_spec.rb +6 -6
  327. data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +54 -0
  328. data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +28 -0
  329. data/spec/views/spotlight/searches/_search.html.erb_spec.rb +20 -10
  330. data/spec/views/spotlight/searches/edit.html.erb_spec.rb +12 -11
  331. data/spec/views/spotlight/searches/index.html.erb_spec.rb +12 -7
  332. data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +7 -8
  333. data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +4 -4
  334. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +38 -0
  335. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +7 -8
  336. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +18 -13
  337. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +14 -12
  338. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +11 -12
  339. data/spec/views/spotlight/tags/index.html.erb_spec.rb +9 -9
  340. metadata +167 -83
  341. data/app/controllers/spotlight/blacklight_configurations_controller.rb +0 -101
  342. data/app/controllers/spotlight/resources/csv_controller.rb +0 -23
  343. data/app/forms/spotlight/appearance.rb +0 -86
  344. data/app/helpers/spotlight/attachments_helper.rb +0 -4
  345. data/app/helpers/spotlight/blacklight_configurations_helper.rb +0 -15
  346. data/app/jobs/spotlight/set_default_thumbnail_job.rb +0 -16
  347. data/app/models/spotlight/resources/csv.rb +0 -80
  348. data/app/uploaders/spotlight/csv_uploader.rb +0 -15
  349. data/app/views/spotlight/blacklight_configurations/edit_facet_fields.html.erb +0 -47
  350. data/app/views/spotlight/blacklight_configurations/edit_sort_fields.html.erb +0 -65
  351. data/app/views/spotlight/resources/csv/_form.html.erb +0 -17
  352. data/app/views/spotlight/resources/csv/new.html.erb +0 -3
  353. data/spec/controllers/spotlight/blacklight_configurations_controller_spec.rb +0 -167
  354. data/spec/features/edit_sort_fields_spec.rb +0 -42
  355. data/spec/features/exhibits/edit_facet_fields_spec.rb +0 -37
  356. data/spec/features/javascript/facet_admin_spec.rb +0 -36
  357. data/spec/features/search_facets_admin_spec.rb +0 -19
  358. data/spec/features/update_appearance_spec.rb +0 -58
  359. data/spec/helpers/spotlight/blacklight_configurations_helper_spec.rb +0 -12
  360. data/spec/models/spotlight/appearance_spec.rb +0 -33
  361. data/spec/models/spotlight/resources/csv_spec.rb +0 -101
  362. data/spec/models/spotlight/solr_document_atomic_updates_spec.rb +0 -29
  363. data/spec/models/spotlight/solr_document_uploaded_resource_spec.rb +0 -45
  364. data/spec/uploaders/item_uploader_spec.rb +0 -62
  365. data/spec/views/spotlight/blacklight_configuration/_metadata_field.html.erb_spec.rb +0 -27
  366. data/spec/views/spotlight/blacklight_configuration/edit_metadata_fields.html.erb_spec.rb +0 -23
  367. data/spec/views/spotlight/blacklight_configuration/edit_sort_fields.html.erb_spec.rb +0 -19
@@ -103,14 +103,23 @@
103
103
  }
104
104
 
105
105
  .contact-photo {
106
- border: 1px solid #CCC;
107
- float: left;
108
- margin-right: 15px;
106
+ border: 1px solid #ccc;
107
+ border-radius: $border-radius-base;
108
+ float: left;
109
+ margin-right: 15px;
110
+ margin-top: 3px;
111
+ }
112
+
113
+ // Indent contact fields so they align evenly, only when there is a contact photo
114
+ .sidenav.contacts .contact-photo + div[itemprop] ~ div[itemprop] {
115
+ margin-left: 87px;
109
116
  }
110
117
 
111
118
  .item-grid-block {
112
119
  h3 {margin-top: 0;}
113
120
  .items-col {
121
+ margin-bottom: 1em;
122
+ z-index: 1;
114
123
  display: flex;
115
124
  flex-flow: row wrap;
116
125
  justify-content: space-between;
@@ -143,7 +152,11 @@
143
152
  min-width: 25%;
144
153
  height: 120px;
145
154
  @media (min-width: $screen-lg-min) {
146
- height: 135px;
155
+ height: 170px; // default: no sidebar, no text column
156
+ // reduce height if on a page with a sidebar or text column, because will be less wide
157
+ .col-md-9 & {
158
+ height: 135px;
159
+ }
147
160
  }
148
161
  padding: 5px;
149
162
  }
@@ -159,15 +172,20 @@
159
172
  .item-0, .item-1, .item-2 {
160
173
  height: 220px;
161
174
  order: 0;
162
-
163
175
  @media (min-width: $screen-lg-min) {
164
- height: 240px;
176
+ height: 280px; // default: no sidebar, no text column
177
+ // reduce height if on a page with a sidebar or text column, because will be less wide
178
+ .col-md-9 & {
179
+ height: 240px;
180
+ }
165
181
  }
166
182
  }
167
-
168
183
  }
169
184
  @media (max-width: $screen-sm-max) {
170
- .items-col {margin-bottom: $line-height-computed;}
185
+ &.items-block .items-col {margin-bottom: $line-height-computed;}
186
+ }
187
+ @media (min-width: $screen-md-min) and (max-width: $screen-md-max) {
188
+ &.items-block .items-col .box {min-width: 128px;}
171
189
  }
172
190
  }
173
191
 
@@ -205,9 +223,42 @@
205
223
  }
206
224
  }
207
225
 
208
- .items-block .content-block {
209
- @media (max-width: $screen-sm-max) {
210
- margin-bottom: 0;
226
+ .items-block {
227
+
228
+ .text-col {
229
+ float: none;
230
+ width: auto;
231
+ }
232
+ .items-col {
233
+ z-index: 1;
234
+
235
+ @media (max-width: $screen-sm-max) {
236
+ margin-bottom: 0;
237
+ }
238
+
239
+ .box {
240
+ min-width: 150px;
241
+ }
242
+
243
+ /* two items */
244
+ .box:first-child:nth-last-child(2),
245
+ .box:first-child:nth-last-child(2) ~ .box {
246
+ min-width: 250px;
247
+ }
248
+
249
+ /* only images, no text */
250
+ &:last-child {
251
+ .box {
252
+ padding: 0.25em;
253
+ img {
254
+ height: 250px;
255
+ object-fit: cover;
256
+ @media (max-width: $screen-sm-max) {
257
+ height: 175px;
258
+ }
259
+ }
260
+ }
261
+ }
211
262
  }
212
263
  }
213
264
 
@@ -1,4 +1,5 @@
1
1
  #report-problem-form {
2
2
  display: none;
3
3
  background-color: #e7e7e7;
4
+ border-bottom: 1px dotted $gray-light;
4
5
  }
@@ -24,6 +24,7 @@
24
24
  @import "spotlight/blacklight_configuration";
25
25
  @import "spotlight/typeahead";
26
26
  @import "spotlight/bootstrap_overrides";
27
+ @import "spotlight/blacklight_overrides";
27
28
  @import "spotlight/report_a_problem";
28
29
 
29
30
 
@@ -1,28 +1,35 @@
1
- # The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
2
- # It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
3
- #
4
- # BootstrapBreadcrumbsBuilder accepts a limited set of options:
5
- #
6
- # You can use it with the :builder option on render_breadcrumbs:
7
- # <%= render_breadcrumbs :builder => Spotlight::BootstrapBreadcrumbsBuilder %>
8
- #
9
- class Spotlight::BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
10
- include ActionView::Helpers::OutputSafetyHelper
11
- def render
12
- if @elements.blank?
13
- return ""
1
+ module Spotlight
2
+ # The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
3
+ # It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
4
+ #
5
+ # BootstrapBreadcrumbsBuilder accepts a limited set of options:
6
+ #
7
+ # You can use it with the :builder option on render_breadcrumbs:
8
+ # <%= render_breadcrumbs :builder => Spotlight::BootstrapBreadcrumbsBuilder %>
9
+ #
10
+ class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
11
+ include ActionView::Helpers::OutputSafetyHelper
12
+
13
+ def render
14
+ return '' if @elements.blank?
15
+
16
+ @context.content_tag(:ul, class: 'breadcrumb') do
17
+ safe_join(@elements.uniq.map { |e| render_element(e) })
18
+ end
14
19
  end
15
20
 
16
- @context.content_tag(:ul, class: 'breadcrumb') do
17
- safe_join(@elements.uniq.collect {|e| render_element(e)})
18
- end
19
- end
21
+ def render_element(element)
22
+ html_class = 'active' if @context.current_page?(compute_path(element))
23
+
24
+ @context.content_tag(:li, class: html_class) do
25
+ @context.link_to_unless_current(element_label(element), compute_path(element), element.options)
26
+ end
27
+ end
20
28
 
21
- def render_element(element)
22
- html_class = 'active' if @context.current_page?(compute_path(element))
29
+ private
23
30
 
24
- @context.content_tag(:li, :class => html_class) do
25
- @context.link_to_unless_current(@context.truncate(compute_name(element), length: 30, separator: ' '), compute_path(element), element.options)
31
+ def element_label(element)
32
+ @context.truncate(compute_name(element), length: 30, separator: ' ')
26
33
  end
27
34
  end
28
35
  end
@@ -1,8 +1,9 @@
1
1
  module Spotlight
2
+ ##
3
+ # CRUD actions for about pages and contacts
2
4
  class AboutPagesController < PagesController
3
5
  load_and_authorize_resource through: :exhibit, instance_name: 'page'
4
- before_filter :attach_breadcrumbs, except: [:update_contacts]
5
-
6
+ before_action :attach_breadcrumbs, except: [:update_contacts]
6
7
 
7
8
  def update_contacts
8
9
  if @exhibit.update(contact_params)
@@ -17,32 +18,42 @@ module Spotlight
17
18
  def attach_breadcrumbs
18
19
  super
19
20
  if @page
20
- if action_name == 'edit'
21
- add_breadcrumb t(:'spotlight.pages.index.about_pages.header'), exhibit_about_pages_path(@exhibit)
22
- else
23
- add_breadcrumb (@exhibit.main_navigations.about.label_or_default), [@exhibit, @exhibit.main_about_page]
24
- end
25
-
26
- unless @page == @exhibit.main_about_page
27
- add_breadcrumb @page.title, action_name == 'edit' ? [:edit, @page.exhibit, @page] : [@page.exhibit, @page]
28
- end
21
+ attach_section_breadcrumbs
22
+ attach_page_breadcrumbs
29
23
  elsif action_name == 'index'
30
24
  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
31
25
  add_breadcrumb t(:'spotlight.pages.index.about_pages.header'), exhibit_about_pages_path(@exhibit)
32
26
  end
33
27
  end
34
28
 
29
+ def attach_page_breadcrumbs
30
+ return if @page == @exhibit.main_about_page
31
+
32
+ if action_name == 'edit'
33
+ add_breadcrumb @page.title, [:edit, @page.exhibit, @page]
34
+ else
35
+ add_breadcrumb @page.title, [@page.exhibit, @page]
36
+ end
37
+ end
38
+
39
+ def attach_section_breadcrumbs
40
+ if action_name == 'edit'
41
+ add_breadcrumb t(:'spotlight.pages.index.about_pages.header'), exhibit_about_pages_path(@exhibit)
42
+ else
43
+ add_breadcrumb((@exhibit.main_navigations.about.label_or_default), [@exhibit, @exhibit.main_about_page])
44
+ end
45
+ end
46
+
35
47
  def contact_params
36
- params.require(:exhibit).permit("contacts_attributes" => [:id, :show_in_sidebar, :weight])
48
+ params.require(:exhibit).permit('contacts_attributes' => [:id, :show_in_sidebar, :weight])
37
49
  end
38
50
 
39
51
  def update_all_page_params
40
- params.require(:exhibit).permit( "about_pages_attributes" => page_attributes)
52
+ params.require(:exhibit).permit('about_pages_attributes' => page_attributes)
41
53
  end
42
54
 
43
55
  def allowed_page_params
44
56
  super.concat [:published]
45
57
  end
46
-
47
58
  end
48
59
  end
@@ -1,38 +1,42 @@
1
- class Spotlight::AppearancesController < Spotlight::ApplicationController
2
- before_filter :authenticate_user!
3
- load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
4
- before_filter :load_and_authorize_appearance
1
+ module Spotlight
2
+ ##
3
+ # Edit and update an exhibit's appearance
4
+ class AppearancesController < Spotlight::ApplicationController
5
+ before_action :authenticate_user!
6
+ load_and_authorize_resource id_param: :exhibit_id, instance_name: 'exhibit', class: 'Spotlight::Exhibit', parent: false
5
7
 
6
- def update
7
- if @appearance.update(appearance_params)
8
- redirect_to edit_exhibit_appearance_path(@exhibit), notice: t(:'helpers.submit.spotlight_default.updated', model: @appearance.class.model_name.human.downcase)
9
- else
10
- render 'edit'
8
+ def update
9
+ if @exhibit.update(exhibit_params)
10
+ notice = t(:'helpers.submit.spotlight_default.updated', model: @exhibit.class.model_name.human.downcase)
11
+ redirect_to edit_exhibit_appearance_path(@exhibit), notice: notice
12
+ else
13
+ render 'edit'
14
+ end
11
15
  end
12
- end
13
-
14
- def edit
15
- add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
16
- add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit)
17
- add_breadcrumb t(:'spotlight.administration.sidebar.appearance'), edit_exhibit_appearance_path(@exhibit)
18
- end
19
16
 
20
- protected
17
+ def edit
18
+ add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
19
+ add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit)
20
+ add_breadcrumb t(:'spotlight.administration.sidebar.appearance'), edit_exhibit_appearance_path(@exhibit)
21
+ end
21
22
 
22
- def load_and_authorize_appearance
23
- @appearance = @exhibit.appearance
24
- authorize! action_name.to_sym, @appearance
25
- end
23
+ protected
26
24
 
27
- def appearance_params
28
- params.require(:appearance).permit(:default_per_page, :searchable,
29
- document_index_view_types: @appearance.view_type_options,
30
- main_navigations: [:id, :display, :label, :weight],
31
- masthead: featured_image_params,
32
- thumbnail: featured_image_params)
33
- end
25
+ def exhibit_params
26
+ params.require(:exhibit).permit(main_navigations_attributes: [:id, :display, :label, :weight],
27
+ masthead_attributes: featured_image_params,
28
+ thumbnail_attributes: featured_image_params)
29
+ end
34
30
 
35
- def featured_image_params
36
- [:display, :source, :image, :remote_image_url, :document_global_id, :image_crop_x, :image_crop_y, :image_crop_w, :image_crop_h]
31
+ def featured_image_params
32
+ [
33
+ :display,
34
+ :source,
35
+ :image,
36
+ :remote_image_url,
37
+ :document_global_id,
38
+ :image_crop_x, :image_crop_y, :image_crop_w, :image_crop_h
39
+ ]
40
+ end
37
41
  end
38
42
  end
@@ -1,12 +1,13 @@
1
1
  require 'spotlight'
2
2
 
3
3
  module Spotlight
4
+ ##
4
5
  # Inherit from the host app's ApplicationController
5
6
  # This will configure e.g. the layout used by the host
6
7
  class ApplicationController < ::ApplicationController
7
8
  include Spotlight::Concerns::ApplicationController
8
9
 
9
- before_filter do
10
+ before_action do
10
11
  flash.now[:notice] = flash[:notice].html_safe if flash[:html_safe] && flash[:notice]
11
12
  end
12
13
  end
@@ -1,14 +1,16 @@
1
1
  module Spotlight
2
+ ##
3
+ # Create image attachments for the sir-trevor image widget
2
4
  class AttachmentsController < ApplicationController
3
- before_filter :authenticate_user!
4
- load_and_authorize_resource :exhibit, class: "Spotlight::Exhibit"
5
+ before_action :authenticate_user!
6
+ load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
5
7
  load_and_authorize_resource through: :exhibit
6
8
 
7
9
  # POST /attachments
8
10
  def create
9
11
  @attachment.attributes = attachment_params
10
12
  if @attachment.save
11
- render :json => @attachment
13
+ render json: @attachment
12
14
  else
13
15
  render action: 'new'
14
16
  end
@@ -16,9 +18,9 @@ module Spotlight
16
18
 
17
19
  private
18
20
 
19
- # Only allow a trusted parameter "white list" through.
20
- def attachment_params
21
- params.require(:attachment).permit(:name, :file, :uid)
22
- end
21
+ # Only allow a trusted parameter "white list" through.
22
+ def attachment_params
23
+ params.require(:attachment).permit(:name, :file, :uid)
24
+ end
23
25
  end
24
26
  end
@@ -1,15 +1,18 @@
1
1
  module Spotlight
2
+ ##
3
+ # Index and read actions for browse (see {Spotlight::SearchesController}
4
+ # for the curator's create-update-delete actions)
2
5
  class BrowseController < Spotlight::ApplicationController
3
- load_and_authorize_resource :exhibit, class: "Spotlight::Exhibit"
6
+ load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
4
7
  include Spotlight::Base
5
8
  include Spotlight::Catalog::AccessControlsEnforcement
6
9
 
7
10
  load_and_authorize_resource :search, except: :index, through: :exhibit, parent: false
8
- before_filter :attach_breadcrumbs
11
+ before_action :attach_breadcrumbs
9
12
  record_search_parameters only: :show
10
13
 
11
- before_filter :set_masthead, only: :show
12
-
14
+ before_action :set_masthead, only: :show
15
+
13
16
  def index
14
17
  @searches = @exhibit.searches.published
15
18
  end
@@ -18,10 +21,11 @@ module Spotlight
18
21
  blacklight_config.index.document_actions = blacklight_config.browse.document_actions
19
22
 
20
23
  add_breadcrumb @search.title, exhibit_browse_path(@exhibit, @search)
21
- (@response, @document_list) = get_search_results @search.query_params.with_indifferent_access.merge(params)
24
+ (@response, @document_list) = search_results(@search.query_params.with_indifferent_access.merge(params), search_params_logic)
22
25
  end
23
-
26
+
24
27
  protected
28
+
25
29
  ##
26
30
  # Browsing an exhibit should start a new search session
27
31
  def start_new_search_session?
@@ -31,12 +35,12 @@ module Spotlight
31
35
  # WARNING: Blacklight::Catalog::SearchContext sets @searches in history_session in a before_filter
32
36
  # See https://github.com/projectblacklight/blacklight/pull/780
33
37
  def history_session
34
- #nop
38
+ # nop
35
39
  end
36
40
 
37
41
  def attach_breadcrumbs
38
42
  add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
39
- add_breadcrumb (@exhibit.main_navigations.browse.label_or_default), exhibit_browse_index_path(@exhibit)
43
+ add_breadcrumb((@exhibit.main_navigations.browse.label_or_default), exhibit_browse_index_path(@exhibit))
40
44
  end
41
45
 
42
46
  def _prefixes
@@ -44,7 +48,7 @@ module Spotlight
44
48
  end
45
49
 
46
50
  def set_masthead
47
- self.current_masthead = @search.masthead if @search.masthead and @search.masthead.display?
51
+ self.current_masthead = @search.masthead if @search.masthead && @search.masthead.display?
48
52
  end
49
53
  end
50
54
  end
@@ -1,213 +1,231 @@
1
- class Spotlight::CatalogController < ::CatalogController
2
- include Spotlight::Concerns::ApplicationController
3
- load_and_authorize_resource :exhibit, class: Spotlight::Exhibit, prepend: true
4
- include Spotlight::Catalog
5
- before_filter :authenticate_user!, only: [:admin, :edit, :make_public, :make_private]
6
- before_filter :check_authorization, only: [:admin, :edit, :make_public, :make_private]
7
- before_filter :redirect_to_exhibit_home_without_search_params, only: :index
8
- before_filter :add_breadcrumb_with_search_params, only: :index
9
-
10
- before_filter :attach_breadcrumbs
11
-
12
-
13
- def new
14
- add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
15
- add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
16
- add_breadcrumb t(:'spotlight.catalog.new.header'), new_exhibit_catalog_path(@exhibit)
17
- @resource = @exhibit.resources.build
18
- end
1
+ module Spotlight
2
+ ##
3
+ # Spotlight's catalog controller. Note that this subclasses
4
+ # the host application's CatalogController to get its configuration,
5
+ # partial overrides, etc
6
+ # rubocop:disable Metrics/ClassLength
7
+ class CatalogController < ::CatalogController
8
+ include Spotlight::Concerns::ApplicationController
9
+ load_and_authorize_resource :exhibit, class: Spotlight::Exhibit, prepend: true
10
+ include Spotlight::Catalog
11
+ include Spotlight::Concerns::CatalogSearchContext
12
+
13
+ before_action :authenticate_user!, only: [:admin, :edit, :make_public, :make_private]
14
+ before_action :check_authorization, only: [:admin, :edit, :make_public, :make_private]
15
+ before_action :redirect_to_exhibit_home_without_search_params!, only: :index
16
+ before_action :add_breadcrumb_with_search_params, only: :index
17
+
18
+ before_action :attach_breadcrumbs
19
+
20
+ before_action only: :show do
21
+ blacklight_config.show.partials.unshift 'curation_mode_toggle'
22
+ end
23
+
24
+ before_action only: :admin do
25
+ blacklight_config.view.select! { |k, _v| k == :admin_table }
26
+ blacklight_config.view.admin_table.partials = [:index_compact]
27
+ blacklight_config.view.admin_table.document_actions = []
19
28
 
20
- def show
21
- blacklight_config.show.partials.unshift "curation_mode_toggle"
22
- super
29
+ unless blacklight_config.sort_fields.key? :timestamp
30
+ blacklight_config.add_sort_field :timestamp, sort: "#{blacklight_config.index.timestamp_field} desc"
31
+ end
32
+ end
23
33
 
24
- if @document.private? current_exhibit
25
- authenticate_user!
26
- authorize! :curate, current_exhibit
34
+ before_action only: :edit do
35
+ blacklight_config.view.edit.partials = blacklight_config.view_config(:show).partials.dup
36
+ blacklight_config.view.edit.partials.insert(2, :edit)
27
37
  end
28
38
 
29
- if current_browse_category
30
- add_breadcrumb current_browse_category.exhibit.main_navigations.browse.label_or_default, exhibit_browse_index_path(current_browse_category.exhibit)
31
- add_breadcrumb current_browse_category.title, exhibit_browse_path(current_browse_category.exhibit, current_browse_category)
32
- elsif current_page_context
33
- add_breadcrumb current_page_context.title, [current_page_context.exhibit, current_page_context] if current_page_context.title.present? and !current_page_context.is_a?(Spotlight::HomePage)
34
- else
35
- add_breadcrumb t(:'spotlight.catalog.breadcrumb.index'), search_action_url(current_search_session[:query_params]) if current_search_session
39
+ def new
40
+ add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
41
+ add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
42
+ add_breadcrumb t(:'spotlight.catalog.new.header'), new_exhibit_catalog_path(@exhibit)
43
+ @resource = @exhibit.resources.build
36
44
  end
37
- add_breadcrumb Array(@document[blacklight_config.view_config(:show).title_field]).join(', '), exhibit_catalog_path(@exhibit, @document)
38
- end
39
45
 
40
- # "id_ng" and "full_title_ng" should be defined in the Solr core's schema.xml.
41
- # It's expected that these fields will be set up to have EdgeNGram filter
42
- # setup within their index analyzer. This will ensure that this method returns
43
- # results when a partial match is passed in the "q" parameter.
44
- def autocomplete
45
- (_, @document_list) = get_search_results(params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field), facet: false, "facet.field" => [], fq: ["-#{Spotlight::SolrDocument.visibility_field(current_exhibit)}:false"])
46
+ def show
47
+ super
46
48
 
47
- respond_to do |format|
48
- format.json do
49
- render json: { docs: autocomplete_json_response(@document_list) }
49
+ if @document.private? current_exhibit
50
+ authenticate_user! && authorize!(:curate, current_exhibit)
50
51
  end
51
- end
52
- end
53
52
 
54
- def admin
55
- self.blacklight_config.view.select! { |k,v| k == :admin_table }
56
- self.blacklight_config.view.admin_table.partials = [:index_compact]
57
- self.blacklight_config.view.admin_table.document_actions = []
53
+ add_document_breadcrumbs(@document)
54
+ end
58
55
 
59
- unless self.blacklight_config.sort_fields.has_key? :timestamp
60
- self.blacklight_config.add_sort_field :timestamp, sort: "#{blacklight_config.index.timestamp_field} desc"
56
+ # "id_ng" and "full_title_ng" should be defined in the Solr core's schema.xml.
57
+ # It's expected that these fields will be set up to have EdgeNGram filter
58
+ # setup within their index analyzer. This will ensure that this method returns
59
+ # results when a partial match is passed in the "q" parameter.
60
+ def autocomplete
61
+ search_params = params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field)
62
+ (_, @document_list) = search_results(search_params.merge(public: true), search_params_logic)
63
+
64
+ respond_to do |format|
65
+ format.json do
66
+ render json: { docs: autocomplete_json_response(@document_list) }
67
+ end
68
+ end
61
69
  end
62
70
 
63
- add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
64
- add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
65
- (@response, @document_list) = get_search_results
66
- @filters = params[:f] || []
67
-
68
- respond_to do |format|
69
- format.html
71
+ def admin
72
+ add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
73
+ add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
74
+ (@response, @document_list) = search_results(params, search_params_logic)
75
+ @filters = params[:f] || []
76
+
77
+ respond_to do |format|
78
+ format.html
79
+ end
70
80
  end
71
- end
72
81
 
73
- def update
74
- @response, @document = fetch params[:id]
75
- @document.update(current_exhibit, solr_document_params)
76
- @document.save
77
- repository.connection.commit rescue nil
78
- redirect_to exhibit_catalog_path(current_exhibit, @document)
79
- end
82
+ def update
83
+ @response, @document = fetch params[:id]
84
+ @document.update(current_exhibit, solr_document_params)
85
+ @document.save
80
86
 
81
- def edit
82
- @response, @document = fetch params[:id]
83
- blacklight_config.view.edit.partials = blacklight_config.view_config(:show).partials.dup
84
- blacklight_config.view.edit.partials.insert(2, :edit)
85
- end
87
+ try_solr_commit!
86
88
 
87
- def make_private
88
- @response, @document = fetch params[:catalog_id]
89
- @document.make_private!(current_exhibit)
90
- @document.save
89
+ redirect_to exhibit_catalog_path(current_exhibit, @document)
90
+ end
91
91
 
92
- respond_to do |format|
93
- format.html { redirect_to :back }
94
- format.json { render json: true }
92
+ def edit
93
+ @response, @document = fetch params[:id]
95
94
  end
96
- end
97
95
 
98
- def make_public
99
- @response, @document = fetch params[:catalog_id]
100
- @document.make_public!(current_exhibit)
101
- @document.save
96
+ def make_private
97
+ @response, @document = fetch params[:catalog_id]
98
+ @document.make_private!(current_exhibit)
99
+ @document.save
102
100
 
103
- respond_to do |format|
104
- format.html { redirect_to :back }
105
- format.json { render json: true }
101
+ respond_to do |format|
102
+ format.html { redirect_to :back }
103
+ format.json { render json: true }
104
+ end
106
105
  end
107
- end
108
106
 
109
- protected
107
+ def make_public
108
+ @response, @document = fetch params[:catalog_id]
109
+ @document.make_public!(current_exhibit)
110
+ @document.save
110
111
 
111
- # TODO move this out of app/helpers/blacklight/catalog_helper_behavior.rb and into blacklight/catalog.rb
112
- def has_search_parameters?
113
- !params[:q].blank? or !params[:f].blank? or !params[:search_field].blank?
114
- end
112
+ respond_to do |format|
113
+ format.html { redirect_to :back }
114
+ format.json { render json: true }
115
+ end
116
+ end
115
117
 
116
- def attach_breadcrumbs
117
- # The "q: ''" is necessary so that the breadcrumb builder recognizes that a path like this:
118
- # /exhibits/1?f%5Bgenre_sim%5D%5B%5D=map&q= is not the same as /exhibits/1
119
- # Otherwise the exhibit breadcrumb won't be a link.
120
- # see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-current_page-3F
121
- add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit, q: '')
122
- end
118
+ protected
119
+
120
+ # TODO: move this out of app/helpers/blacklight/catalog_helper_behavior.rb and into blacklight/catalog.rb
121
+ # rubocop:disable Style/PredicateName
122
+ def has_search_parameters?
123
+ !params[:q].blank? || !params[:f].blank? || !params[:search_field].blank?
124
+ end
125
+ # rubocop:enable Style/PredicateName
126
+
127
+ def attach_breadcrumbs
128
+ # The "q: ''" is necessary so that the breadcrumb builder recognizes that a path like this:
129
+ # /exhibits/1?f%5Bgenre_sim%5D%5B%5D=map&q= is not the same as /exhibits/1
130
+ # Otherwise the exhibit breadcrumb won't be a link.
131
+ # see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-current_page-3F
132
+ add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit, q: '')
133
+ end
134
+
135
+ ##
136
+ # Override Blacklight's #setup_next_and_previous_documents to handle
137
+ # browse categories too
138
+ def setup_next_and_previous_documents
139
+ if current_browse_category
140
+ setup_next_and_previous_documents_from_browse_category
141
+ elsif current_page_context
142
+ # TODO: figure out how to construct previous/next documents
143
+ else
144
+ super
145
+ end
146
+ end
123
147
 
124
- ##
125
- # Override Blacklight's #setup_next_and_previous_documents to handle
126
- # browse categories too
127
- def setup_next_and_previous_documents
128
- if current_browse_category
148
+ def setup_next_and_previous_documents_from_browse_category
129
149
  index = search_session['counter'].to_i - 1
130
150
  response, documents = get_previous_and_next_documents_for_search index, current_browse_category.query_params.with_indifferent_access
131
151
  search_session['total'] = response.total
132
- @search_context_response = response
133
152
  @previous_document = documents.first
134
153
  @next_document = documents.last
135
- elsif current_page_context
136
- # TODO: figure out how to construct previous/next documents
137
- else
138
- super
139
154
  end
140
- end
141
155
 
142
- def _prefixes
143
- @_prefixes ||= super + ['catalog']
144
- end
145
-
146
- ##
147
- # Admin catalog controller should not create a new search
148
- # session in the blacklight context
149
- def start_new_search_session?
150
- super || params[:action] == 'admin'
151
- end
156
+ def _prefixes
157
+ @_prefixes ||= super + ['catalog']
158
+ end
152
159
 
153
- def solr_document_params
154
- params.require(:solr_document).permit(:exhibit_tag_list, uploaded_resource: [:url], sidecar: [:public, data: [editable_solr_document_params] ])
155
- end
160
+ ##
161
+ # Admin catalog controller should not create a new search
162
+ # session in the blacklight context
163
+ def start_new_search_session?
164
+ super || params[:action] == 'admin'
165
+ end
156
166
 
157
- def editable_solr_document_params
158
- custom_field_params + uploaded_resource_params
159
- end
167
+ def solr_document_params
168
+ params.require(:solr_document).permit(:exhibit_tag_list,
169
+ uploaded_resource: [:url],
170
+ sidecar: [:public, data: [editable_solr_document_params]])
171
+ end
160
172
 
161
- def uploaded_resource_params
162
- if @document.uploaded_resource?
163
- [{configured_fields: Spotlight::Resources::Upload.fields(current_exhibit).collect(&:field_name)}]
164
- else
165
- []
173
+ def editable_solr_document_params
174
+ custom_field_params + uploaded_resource_params
166
175
  end
167
- end
168
176
 
169
- def custom_field_params
170
- current_exhibit.custom_fields.pluck(:field)
171
- end
177
+ def uploaded_resource_params
178
+ if @document.uploaded_resource?
179
+ [{ configured_fields: Spotlight::Resources::Upload.fields(current_exhibit).map(&:field_name) }]
180
+ else
181
+ []
182
+ end
183
+ end
172
184
 
173
- def check_authorization
174
- authorize! :curate, @exhibit
175
- end
185
+ def custom_field_params
186
+ current_exhibit.custom_fields.pluck(:field)
187
+ end
176
188
 
177
- def current_browse_category
178
- @current_browse_category ||= if current_search_session and current_search_session.query_params["action"] == "show" and current_search_session.query_params["controller"] == "spotlight/browse"
179
- current_exhibit.searches.accessible_by(current_ability).find(current_search_session.query_params["id"]) if current_search_session.query_params["id"]
189
+ def check_authorization
190
+ authorize! :curate, @exhibit
180
191
  end
181
- end
182
192
 
183
- def redirect_to_exhibit_home_without_search_params
184
- unless has_search_parameters?
185
- redirect_to spotlight.exhibit_root_path(@exhibit)
193
+ def redirect_to_exhibit_home_without_search_params!
194
+ redirect_to spotlight.exhibit_root_path(@exhibit) unless has_search_parameters?
186
195
  end
187
- end
188
196
 
189
- def add_breadcrumb_with_search_params
190
- if has_search_parameters?
191
- add_breadcrumb t(:'spotlight.catalog.breadcrumb.index'), request.fullpath
197
+ def add_breadcrumb_with_search_params
198
+ add_breadcrumb t(:'spotlight.catalog.breadcrumb.index'), request.fullpath if has_search_parameters?
192
199
  end
193
- end
194
200
 
195
- def current_page_context
196
- @current_page_context ||= if current_search_session and current_search_session.query_params["action"] == "show" and current_search_session.query_params["controller"].ends_with? "_pages"
197
- if current_search_session.query_params["controller"] == "spotlight/home_pages"
198
- current_exhibit.home_page if can? :read, current_exhibit.home_page
199
- else
200
- current_exhibit.pages.accessible_by(current_ability).find(current_search_session.query_params["id"]) if current_search_session.query_params["id"]
201
+ # rubocop:disable Metrics/AbcSize
202
+ def add_document_breadcrumbs(document)
203
+ if current_browse_category
204
+ add_breadcrumb current_browse_category.exhibit.main_navigations.browse.label_or_default, exhibit_browse_index_path(current_browse_category.exhibit)
205
+ add_breadcrumb current_browse_category.title, exhibit_browse_path(current_browse_category.exhibit, current_browse_category)
206
+ elsif current_page_context && current_page_context.title.present? && !current_page_context.is_a?(Spotlight::HomePage)
207
+ add_breadcrumb current_page_context.title, [current_page_context.exhibit, current_page_context]
208
+ elsif current_search_session
209
+ add_breadcrumb t(:'spotlight.catalog.breadcrumb.index'), search_action_url(current_search_session[:query_params])
201
210
  end
211
+
212
+ add_breadcrumb Array(document[blacklight_config.view_config(:show).title_field]).join(', '), exhibit_catalog_path(current_exhibit, document)
202
213
  end
203
- end
214
+ # rubocop:enable Metrics/AbcSize
204
215
 
205
- def additional_export_formats document, format
206
- super
216
+ def additional_export_formats(document, format)
217
+ super
218
+
219
+ format.solr_json do
220
+ authorize! :update_solr, @exhibit
221
+ render json: document.to_solr.merge(@exhibit.solr_data)
222
+ end
223
+ end
207
224
 
208
- format.solr_json do
209
- authorize! :update_solr, @exhibit
210
- render json: document.to_solr.merge(@exhibit.solr_data)
225
+ def try_solr_commit!
226
+ repository.connection.commit
227
+ rescue => e
228
+ Rails.logger.info "Failed to commit document updates: #{e}"
211
229
  end
212
230
  end
213
231
  end