blacklight-spotlight 3.0.0.rc3 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/blacklight/close.svg +1 -0
  3. data/app/assets/images/blacklight/zoom_in.svg +1 -0
  4. data/app/assets/images/blacklight/zoom_out.svg +1 -0
  5. data/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +8 -1
  6. data/app/assets/javascripts/spotlight/admin/catalog_edit.js +13 -47
  7. data/app/assets/javascripts/spotlight/admin/exhibit_tag_autocomplete.js +37 -0
  8. data/app/assets/javascripts/spotlight/admin/{reindex_monitor.js → progress_monitor.js} +26 -4
  9. data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +1 -1
  10. data/app/assets/javascripts/spotlight/user/zpr_links.js.erb +29 -14
  11. data/app/assets/stylesheets/spotlight/_browse.scss +8 -0
  12. data/app/assets/stylesheets/spotlight/_catalog.scss +30 -4
  13. data/app/assets/stylesheets/spotlight/_exhibit_admin.scss +9 -0
  14. data/app/assets/stylesheets/spotlight/_modals.scss +3 -0
  15. data/app/assets/stylesheets/spotlight/_nestable.scss +8 -0
  16. data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -0
  17. data/app/assets/stylesheets/spotlight/_view_larger.scss +22 -0
  18. data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +23 -0
  19. data/app/assets/stylesheets/spotlight/typeahead.css +23 -23
  20. data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +4 -2
  21. data/app/controllers/concerns/spotlight/base.rb +1 -1
  22. data/app/controllers/concerns/spotlight/catalog.rb +7 -1
  23. data/app/controllers/spotlight/browse_controller.rb +9 -15
  24. data/app/controllers/spotlight/bulk_actions_controller.rb +62 -0
  25. data/app/controllers/spotlight/bulk_updates_controller.rb +67 -0
  26. data/app/controllers/spotlight/catalog_controller.rb +16 -13
  27. data/app/controllers/spotlight/dashboards_controller.rb +5 -4
  28. data/app/controllers/spotlight/exhibits_controller.rb +1 -1
  29. data/app/controllers/spotlight/featured_images_controller.rb +1 -1
  30. data/app/controllers/spotlight/job_trackers_controller.rb +17 -0
  31. data/app/controllers/spotlight/pages_controller.rb +6 -7
  32. data/app/controllers/spotlight/tags_controller.rb +39 -5
  33. data/app/helpers/spotlight/application_helper.rb +20 -1
  34. data/app/helpers/spotlight/job_trackers_helper.rb +31 -0
  35. data/app/helpers/spotlight/main_app_helpers.rb +3 -4
  36. data/app/helpers/spotlight/meta_helper.rb +2 -2
  37. data/app/helpers/spotlight/pages_helper.rb +1 -8
  38. data/app/helpers/spotlight/roles_helper.rb +1 -1
  39. data/app/helpers/spotlight/searches_helper.rb +1 -1
  40. data/app/jobs/concerns/spotlight/gather_documents.rb +35 -0
  41. data/app/jobs/concerns/spotlight/job_tracking.rb +64 -0
  42. data/app/jobs/concerns/spotlight/limit_concurrency.rb +33 -0
  43. data/app/jobs/spotlight/add_tags_job.rb +31 -0
  44. data/app/jobs/spotlight/add_uploads_from_csv.rb +4 -3
  45. data/app/jobs/spotlight/application_job.rb +8 -0
  46. data/app/jobs/spotlight/change_visibility_job.rb +33 -0
  47. data/app/jobs/spotlight/cleanup_job_trackers_job.rb +13 -0
  48. data/app/jobs/spotlight/default_thumbnail_job.rb +1 -3
  49. data/app/jobs/spotlight/process_bulk_updates_csv_job.rb +82 -0
  50. data/app/jobs/spotlight/reindex_exhibit_job.rb +39 -0
  51. data/app/jobs/spotlight/reindex_job.rb +64 -44
  52. data/app/jobs/spotlight/remove_tags_job.rb +31 -0
  53. data/app/jobs/spotlight/rename_sidecar_field_job.rb +3 -2
  54. data/app/jobs/spotlight/rename_tags_job.rb +33 -0
  55. data/app/jobs/spotlight/update_job_trackers_job.rb +20 -0
  56. data/app/models/concerns/spotlight/browse_category_search_builder.rb +59 -0
  57. data/app/models/concerns/spotlight/exhibit_analytics.rb +2 -6
  58. data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
  59. data/app/models/concerns/spotlight/resources/web.rb +1 -1
  60. data/app/models/concerns/spotlight/search_builder.rb +11 -0
  61. data/app/models/concerns/spotlight/solr_document.rb +1 -1
  62. data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +2 -2
  63. data/app/models/concerns/spotlight/user.rb +7 -2
  64. data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +9 -0
  65. data/app/models/sir_trevor_rails/blocks/uploaded_items_block.rb +4 -0
  66. data/app/models/spotlight/ability.rb +6 -2
  67. data/app/models/spotlight/attachment.rb +1 -1
  68. data/app/models/spotlight/background_job_progress.rb +96 -0
  69. data/app/models/spotlight/blacklight_configuration.rb +26 -6
  70. data/app/models/spotlight/bulk_update.rb +8 -0
  71. data/app/models/spotlight/event.rb +13 -0
  72. data/app/models/spotlight/exhibit.rb +5 -14
  73. data/app/models/spotlight/feature_page.rb +0 -2
  74. data/app/models/spotlight/featured_image.rb +40 -1
  75. data/app/models/spotlight/field_metadata.rb +4 -8
  76. data/app/models/spotlight/job_tracker.rb +114 -0
  77. data/app/models/spotlight/page.rb +1 -3
  78. data/app/models/spotlight/page_configurations.rb +10 -9
  79. data/app/models/spotlight/resource.rb +28 -62
  80. data/app/models/spotlight/resources/iiif_harvester.rb +12 -3
  81. data/app/models/spotlight/resources/iiif_manifest.rb +3 -1
  82. data/app/models/spotlight/resources/iiif_service.rb +9 -2
  83. data/app/models/spotlight/resources/json_upload.rb +12 -0
  84. data/app/models/spotlight/resources/upload.rb +25 -2
  85. data/app/models/spotlight/role.rb +1 -2
  86. data/app/models/spotlight/solr_document_sidecar.rb +2 -1
  87. data/app/presenters/spotlight/iiif_manifest_presenter.rb +2 -2
  88. data/app/services/spotlight/bulk_updates_csv_template_service.rb +93 -0
  89. data/app/services/spotlight/etl.rb +7 -0
  90. data/app/services/spotlight/etl/context.rb +52 -0
  91. data/app/services/spotlight/etl/executor.rb +192 -0
  92. data/app/services/spotlight/etl/loaders.rb +12 -0
  93. data/app/services/spotlight/etl/pipeline.rb +81 -0
  94. data/app/services/spotlight/etl/solr_loader.rb +96 -0
  95. data/app/services/spotlight/etl/sources.rb +25 -0
  96. data/app/services/spotlight/etl/step.rb +82 -0
  97. data/app/services/spotlight/etl/transforms.rb +64 -0
  98. data/app/services/spotlight/iiif_resource_resolver.rb +1 -1
  99. data/app/services/spotlight/validity_checker.rb +5 -5
  100. data/app/uploaders/spotlight/bulk_updates_uploader.rb +7 -0
  101. data/app/uploaders/spotlight/featured_image_uploader.rb +1 -1
  102. data/app/views/catalog/_add_tags.html.erb +28 -0
  103. data/app/views/catalog/_bulk_actions.html.erb +12 -0
  104. data/app/views/catalog/_change_visibility.html.erb +35 -0
  105. data/app/views/catalog/_curator_actions.html.erb +3 -0
  106. data/app/views/catalog/_remove_tags.html.erb +37 -0
  107. data/app/views/catalog/_save_search.html.erb +1 -1
  108. data/app/views/spotlight/about_pages/_sidebar.html.erb +2 -2
  109. data/app/views/spotlight/browse/_search.html.erb +3 -3
  110. data/app/views/spotlight/browse/_search_box.html.erb +9 -9
  111. data/app/views/spotlight/browse/_search_title.html.erb +1 -1
  112. data/app/views/spotlight/bulk_updates/_download.html.erb +23 -0
  113. data/app/views/spotlight/bulk_updates/_overview.html.erb +1 -0
  114. data/app/views/spotlight/bulk_updates/_progress_panel.html.erb +19 -0
  115. data/app/views/spotlight/bulk_updates/_upload.html.erb +12 -0
  116. data/app/views/spotlight/bulk_updates/edit.html.erb +37 -0
  117. data/app/views/spotlight/catalog/_admin_header.html.erb +1 -1
  118. data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +1 -1
  119. data/app/views/spotlight/catalog/_admin_thumbnail_default.html.erb +3 -2
  120. data/app/views/spotlight/catalog/_edit_default.html.erb +2 -2
  121. data/app/views/spotlight/catalog/_reindex_progress_panel.html.erb +1 -1
  122. data/app/views/spotlight/catalog/index.iiif_json.jbuilder +1 -1
  123. data/app/views/spotlight/custom_fields/_form.html.erb +1 -1
  124. data/app/views/spotlight/custom_search_fields/_form.html.erb +1 -1
  125. data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +6 -6
  126. data/app/views/spotlight/exhibits/_exhibit_card.html.erb +1 -1
  127. data/app/views/spotlight/feature_pages/_sidebar.html.erb +1 -1
  128. data/app/views/spotlight/featured_images/_form.html.erb +1 -1
  129. data/app/views/spotlight/job_trackers/show.html.erb +79 -0
  130. data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +2 -2
  131. data/app/views/spotlight/pages/_form.html.erb +2 -2
  132. data/app/views/spotlight/pages/_order_pages.html.erb +2 -2
  133. data/app/views/spotlight/pages/_view_type_group.html.erb +3 -3
  134. data/app/views/spotlight/pages/show.html.erb +1 -1
  135. data/app/views/spotlight/resources/_form.html.erb +1 -1
  136. data/app/views/spotlight/resources/csv_upload/_form.html.erb +1 -1
  137. data/app/views/spotlight/resources/iiif/_form.html.erb +1 -1
  138. data/app/views/spotlight/resources/json_upload/_form.html.erb +2 -2
  139. data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
  140. data/app/views/spotlight/search_configurations/_document_index_view_types.html.erb +2 -2
  141. data/app/views/spotlight/searches/_form.html.erb +2 -2
  142. data/app/views/spotlight/shared/_curation_sidebar.html.erb +3 -0
  143. data/app/views/spotlight/shared/_locale_picker.html.erb +1 -1
  144. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +7 -6
  145. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -1
  146. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +8 -8
  147. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +7 -7
  148. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +9 -7
  149. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +5 -5
  150. data/app/views/spotlight/sir_trevor/blocks/_uploaded_items_block.html.erb +4 -0
  151. data/app/views/spotlight/tags/_tag.html.erb +24 -0
  152. data/app/views/spotlight/tags/index.html.erb +12 -16
  153. data/app/views/spotlight/translations/show.yaml.yamlbuilder +6 -0
  154. data/config/i18n-tasks.yml +1 -0
  155. data/config/locales/spotlight.ar.yml +11 -1
  156. data/config/locales/spotlight.en.yml +170 -10
  157. data/config/routes.rb +29 -1
  158. data/db/migrate/20210122082032_create_job_trackers.rb +22 -0
  159. data/db/migrate/20210126123041_create_events.rb +15 -0
  160. data/db/migrate/20210305070001_remove_class_from_sirtrevor_image_blocks.rb +20 -0
  161. data/db/migrate/20210305171150_create_bulk_updates.rb +9 -0
  162. data/db/migrate/20210308090000_migrate_caption_values_for_title_key.rb +29 -0
  163. data/db/migrate/20210506070809_add_indexes_for_featured_images.rb +9 -0
  164. data/lib/generators/spotlight/install_generator.rb +2 -2
  165. data/lib/generators/spotlight/scaffold_resource_generator.rb +5 -13
  166. data/lib/generators/spotlight/templates/config/initializers/riiif.rb +7 -5
  167. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +1 -1
  168. data/lib/generators/spotlight/templates/solr/config/schema.xml +1 -1
  169. data/lib/migration/iiif.rb +3 -3
  170. data/lib/spotlight/engine.rb +22 -1
  171. data/lib/spotlight/version.rb +1 -1
  172. data/spec/controllers/spotlight/browse_controller_spec.rb +0 -6
  173. data/spec/controllers/spotlight/bulk_actions_controller_spec.rb +124 -0
  174. data/spec/controllers/spotlight/bulk_updates_controller_spec.rb +77 -0
  175. data/spec/controllers/spotlight/catalog_controller_spec.rb +15 -13
  176. data/spec/controllers/spotlight/featured_images_controller_spec.rb +3 -3
  177. data/spec/controllers/spotlight/job_trackers_controller_spec.rb +37 -0
  178. data/spec/controllers/spotlight/tags_controller_spec.rb +5 -1
  179. data/spec/examples.txt +1502 -1437
  180. data/spec/factories/bulk_updates.rb +15 -0
  181. data/spec/factories/exhibits.rb +4 -0
  182. data/spec/factories/job_trackers.rb +11 -0
  183. data/spec/factories/users.rb +27 -8
  184. data/spec/features/add_items_spec.rb +10 -5
  185. data/spec/features/bulk_actions_spec.rb +72 -0
  186. data/spec/features/catalog_spec.rb +1 -0
  187. data/spec/features/import_exhibit_spec.rb +5 -1
  188. data/spec/features/javascript/blocks/solr_documents_block_spec.rb +4 -4
  189. data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +27 -1
  190. data/spec/features/javascript/reindex_monitor_spec.rb +1 -1
  191. data/spec/features/site_users_management_spec.rb +5 -5
  192. data/spec/fixtures/bulk-update-template.csv +57 -0
  193. data/spec/fixtures/updated-bulk-update-template-w-tags.csv +4 -0
  194. data/spec/fixtures/updated-bulk-update-template.csv +4 -0
  195. data/spec/helpers/spotlight/application_helper_spec.rb +5 -6
  196. data/spec/helpers/spotlight/pages_helper_spec.rb +8 -15
  197. data/spec/helpers/spotlight/roles_helper_spec.rb +1 -1
  198. data/spec/i18n_spec.rb +1 -0
  199. data/spec/jobs/spotlight/add_tags_job_spec.rb +34 -0
  200. data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +4 -1
  201. data/spec/jobs/spotlight/change_visibility_job_spec.rb +30 -0
  202. data/spec/jobs/spotlight/process_bulk_updates_csv_job_spec.rb +78 -0
  203. data/spec/jobs/spotlight/reindex_exhibit_job_spec.rb +43 -0
  204. data/spec/jobs/spotlight/reindex_job_spec.rb +34 -60
  205. data/spec/jobs/spotlight/remove_tags_job_spec.rb +39 -0
  206. data/spec/lib/migration/iiif_spec.rb +1 -1
  207. data/spec/models/spotlight/ability_spec.rb +27 -0
  208. data/spec/models/spotlight/background_job_progress_spec.rb +137 -0
  209. data/spec/models/spotlight/blacklight_configuration_spec.rb +22 -17
  210. data/spec/models/spotlight/browse_category_search_builder_spec.rb +49 -0
  211. data/spec/models/spotlight/exhibit_spec.rb +4 -58
  212. data/spec/models/spotlight/featured_image_spec.rb +13 -1
  213. data/spec/models/spotlight/resource_spec.rb +89 -87
  214. data/spec/models/spotlight/resources/iiif_harvester_spec.rb +9 -10
  215. data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +10 -0
  216. data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -0
  217. data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +1 -1
  218. data/spec/services/spotlight/bulk_updates_csv_template_service_spec.rb +26 -0
  219. data/spec/services/spotlight/etl/context_spec.rb +66 -0
  220. data/spec/services/spotlight/etl/executor_spec.rb +149 -0
  221. data/spec/services/spotlight/etl/pipeline_spec.rb +22 -0
  222. data/spec/services/spotlight/etl/solr_loader_spec.rb +76 -0
  223. data/spec/services/spotlight/etl/step_spec.rb +70 -0
  224. data/spec/spec_helper.rb +2 -5
  225. data/spec/test_app_templates/Gemfile.extra +1 -0
  226. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  227. data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +2 -2
  228. data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +1 -1
  229. data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +24 -19
  230. data/spec/views/spotlight/job_trackers/show.html.erb_spec.rb +65 -0
  231. data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -4
  232. data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +1 -1
  233. data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +1 -1
  234. data/spec/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb_spec.rb +1 -1
  235. data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +1 -1
  236. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +8 -4
  237. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +7 -2
  238. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +8 -5
  239. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +3 -2
  240. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +9 -4
  241. data/spec/views/spotlight/tags/index.html.erb_spec.rb +5 -2
  242. metadata +143 -34
  243. data/app/assets/images/blacklight/add_circle.svg +0 -1
  244. data/app/assets/images/blacklight/custom_fullscreen.svg +0 -1
  245. data/app/assets/images/blacklight/remove_circle.svg +0 -1
  246. data/app/assets/images/blacklight/resize_small.svg +0 -1
  247. data/app/models/concerns/spotlight/resources/open_graph.rb +0 -36
  248. data/app/models/spotlight/reindex_progress.rb +0 -78
  249. data/app/models/spotlight/reindexing_log_entry.rb +0 -42
  250. data/app/services/spotlight/resources/iiif_builder.rb +0 -19
  251. data/app/services/spotlight/solr_document_builder.rb +0 -77
  252. data/app/services/spotlight/upload_solr_document_builder.rb +0 -57
  253. data/spec/factories/reindexing_log_entries.rb +0 -54
  254. data/spec/models/spotlight/reindex_progress_spec.rb +0 -122
  255. data/spec/models/spotlight/reindexing_log_entry_spec.rb +0 -129
  256. data/spec/models/spotlight/resources/open_graph_spec.rb +0 -65
  257. data/spec/services/spotlight/solr_document_builder_spec.rb +0 -66
data/config/routes.rb CHANGED
@@ -99,6 +99,7 @@ Spotlight::Engine.routes.draw do
99
99
  get :autocomplete
100
100
  end
101
101
  end
102
+ get 'browse/:browse_category_id', to: 'catalog#index', constraints: ->(req) { req.format != :html }
102
103
  resources :browse, only: %i[index show]
103
104
  get 'browse/group/:group_id', to: 'browse#index', as: 'browse_groups'
104
105
  get 'browse/group/:group_id/:id', to: 'browse#show', as: 'browse_group'
@@ -109,7 +110,15 @@ Spotlight::Engine.routes.draw do
109
110
  end
110
111
  end
111
112
 
112
- resources :tags, only: %i[index destroy]
113
+ resources :tags, only: %i[index destroy] do
114
+ collection do
115
+ patch :update_all
116
+ end
117
+
118
+ member do
119
+ post :rename
120
+ end
121
+ end
113
122
 
114
123
  resources :contacts, only: %i[edit update destroy]
115
124
 
@@ -141,10 +150,29 @@ Spotlight::Engine.routes.draw do
141
150
  get :clone
142
151
  end
143
152
  end
153
+ resource :bulk_actions, only: [] do
154
+ member do
155
+ post :change_visibility
156
+ post :add_tags
157
+ post :remove_tags
158
+ end
159
+ end
160
+
161
+ resource :bulk_updates, only: %i[edit update] do
162
+ collection do
163
+ get :monitor
164
+ end
165
+
166
+ member do
167
+ post :download_template
168
+ end
169
+ end
170
+
144
171
  post '/pages/:id/preview' => 'pages#preview', as: :preview_block
145
172
  get '/pages' => 'pages#index', constraints: { format: 'json' }
146
173
 
147
174
  resources :lock, only: [:destroy]
175
+ resources :job_trackers, only: [:show]
148
176
 
149
177
  resources :roles, path: 'users', only: %i[index create destroy] do
150
178
  collection do
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateJobTrackers < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :spotlight_job_trackers do |t|
6
+ t.references :on, null: false, polymorphic: true, index: true
7
+ t.references :resource, null: false, polymorphic: true, index: true
8
+ t.string :job_id
9
+ t.string :job_class
10
+ t.string :parent_job_id
11
+ t.string :parent_job_class
12
+ t.string :status
13
+ t.references :user
14
+ t.text :log
15
+ t.text :data
16
+
17
+ t.timestamps
18
+ end
19
+
20
+ add_index :spotlight_job_trackers, :job_id
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateEvents < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :spotlight_events do |t|
6
+ t.references :exhibit, null: true
7
+ t.references :resource, null: false, polymorphic: true, index: true
8
+ t.string :type
9
+ t.string :collation_key
10
+ t.text :data
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Remove the class field from the block; ostruct 0.3 helpfully allows it to override
4
+ # this field and that confuses sir trevor..
5
+ class RemoveClassFromSirtrevorImageBlocks < ActiveRecord::Migration[5.2]
6
+ def up
7
+ Spotlight::Page.reset_column_information
8
+ image = SirTrevorRails::Block.block_class('image')
9
+
10
+ Spotlight::Page.find_each do |page|
11
+ next unless page.content.any? { |block| block.is_a? image }
12
+ page.content.select { |block| block.is_a?(image) && block.respond_to?(:class=) }.each do |block|
13
+ block.delete_field(:class)
14
+ block.attachment = Spotlight::Attachment.find(block.id).to_global_id rescue nil
15
+ end
16
+
17
+ page.update(content: page.content)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ class CreateBulkUpdates < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :spotlight_bulk_updates do |t|
4
+ t.string :file, null: false
5
+ t.references :exhibit
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Migrate caption fields for the document title (pointing at the solr field name) to use the
4
+ # new `Spotlight::PageConfigurations::DOCUMENT_TITLE_KEY` for run-time lookups instead.
5
+ class MigrateCaptionValuesForTitleKey < ActiveRecord::Migration[5.2]
6
+ def up
7
+ Spotlight::Page.reset_column_information
8
+ change_caption_field_of(Spotlight::Page, from: CatalogController.blacklight_config.index.title_field, to: Spotlight::PageConfigurations::DOCUMENT_TITLE_KEY)
9
+ end
10
+
11
+ def down
12
+ Spotlight::Page.reset_column_information
13
+ change_caption_field_of(Spotlight::Page, from: Spotlight::PageConfigurations::DOCUMENT_TITLE_KEY, to: CatalogController.blacklight_config.index.title_field)
14
+ end
15
+
16
+ def change_caption_field_of(scope, from:, to:)
17
+ scope.find_each do |page|
18
+ changed = false
19
+
20
+ page.content.select { |block| block['primary-caption-field'] == from || block['secondary-caption-field'] == from }.each do |block|
21
+ changed = true
22
+ block['primary-caption-field'] = to if block['primary-caption-field'] == from
23
+ block['secondary-caption-field'] = to if block['secondary-caption-field'] == from
24
+ end
25
+
26
+ page.update(content: page.content) if changed
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ class AddIndexesForFeaturedImages < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_index(:spotlight_searches, [:thumbnail_id])
4
+ add_index(:spotlight_searches, [:masthead_id])
5
+ add_index(:spotlight_exhibits, [:thumbnail_id])
6
+ add_index(:spotlight_exhibits, [:masthead_id])
7
+ add_index(:spotlight_pages, [:thumbnail_id])
8
+ end
9
+ end
@@ -113,10 +113,10 @@ module Spotlight
113
113
  def add_search_builder_mixin
114
114
  if File.exist? 'app/models/search_builder.rb'
115
115
  inject_into_file 'app/models/search_builder.rb', after: "include Blacklight::Solr::SearchBuilderBehavior\n" do
116
- "\n include Spotlight::AccessControlsEnforcementSearchBuilder\n"
116
+ "\n include Spotlight::SearchBuilder\n"
117
117
  end
118
118
  else
119
- say 'Unable to find SearchBuilder class; add `include Spotlight::AccessControlsEnforcementSearchBuilder` to the class manually.'
119
+ say 'Unable to find SearchBuilder class; add `include Spotlight::SearchBuilder` to the class manually.'
120
120
  end
121
121
  end
122
122
 
@@ -7,23 +7,15 @@ module Spotlight
7
7
  # spotlight:scaffold_resource generator
8
8
  class ScaffoldResource < Rails::Generators::NamedBase
9
9
  source_root File.expand_path('templates', __dir__)
10
- def create_document_builder
11
- create_file "app/services/#{file_name}_builder.rb", <<-FILE.strip_heredoc
12
- class #{class_name}Builder < Spotlight::SolrDocumentBuilder
13
- def to_solr
14
- return to_enum(:to_solr) unless block_given?
15
-
16
- # TODO: your implementation here
17
- # yield { id: resource.id }
18
- end
19
- end
20
- FILE
21
- end
22
10
 
23
11
  def create_model
24
12
  create_file "app/models/#{file_name}_resource.rb", <<-FILE.strip_heredoc
25
13
  class #{class_name}Resource < Spotlight::Resource
26
- self.document_builder_class = #{class_name}Builder
14
+ def self.indexing_pipeline
15
+ @indexing_pipeline ||= super.dup.tap do |pipeline|
16
+ # your pipeline here...
17
+ end
18
+ end
27
19
  end
28
20
  FILE
29
21
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Riiif::Image.file_resolver = Spotlight::CarrierwaveFileResolver.new
3
+ ActiveSupport::Reloader.to_prepare do
4
+ Riiif::Image.file_resolver = Spotlight::CarrierwaveFileResolver.new
4
5
 
5
- # Riiif::Image.authorization_service = IIIFAuthorizationService
6
+ # Riiif::Image.authorization_service = IIIFAuthorizationService
6
7
 
7
- # Riiif.not_found_image = 'app/assets/images/us_404.svg'
8
- #
9
- Riiif::Engine.config.cache_duration = 365.days
8
+ # Riiif.not_found_image = 'app/assets/images/us_404.svg'
9
+ #
10
+ Riiif::Engine.config.cache_duration = 365.days
11
+ end
@@ -73,7 +73,7 @@
73
73
  # These are set by default by Spotlight's configuration,
74
74
  # but you can customize them here, or in the SirTrevorRails::Block#custom_block_types method
75
75
  # Spotlight::Engine.config.sir_trevor_widgets = %w(
76
- # Heading Text List Quote Iframe Video Oembed Rule UploadedItems Browse BrowseGroupCategories
76
+ # Heading Text List Quote Iframe Video Oembed Rule UploadedItems Browse BrowseGroupCategories LinkToSearch
77
77
  # FeaturedPages SolrDocuments SolrDocumentsCarousel SolrDocumentsEmbed
78
78
  # SolrDocumentsFeatures SolrDocumentsGrid SearchResults
79
79
  # )
@@ -306,7 +306,7 @@
306
306
  <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="15" />
307
307
  </analyzer>
308
308
 
309
- <analyzer type="index">
309
+ <analyzer type="query">
310
310
  <tokenizer class="solr.ICUTokenizerFactory"/>
311
311
  <filter class="solr.ICUFoldingFilterFactory"/> <!-- NFKC, case folding, diacritics removed -->
312
312
  <filter class="solr.EnglishPossessiveFilterFactory"/>
@@ -73,7 +73,7 @@ module Migration
73
73
 
74
74
  old_file = File.new(filepath)
75
75
  image = contact.create_avatar { |i| i.image.store!(old_file) }
76
- iiif_tilesource = riiif.info_path(image.id)
76
+ iiif_tilesource = riiif.info_path(image)
77
77
  image.update(iiif_tilesource: iiif_tilesource, iiif_region: avatar_coordinates(contact))
78
78
  image
79
79
  end
@@ -87,7 +87,7 @@ module Migration
87
87
 
88
88
  old_file = File.new(filepath)
89
89
  image = upload.create_upload { |i| i.image.store!(old_file) }
90
- iiif_tilesource = riiif.info_path(image.id)
90
+ iiif_tilesource = riiif.info_path(image)
91
91
  image.update(iiif_tilesource: iiif_tilesource)
92
92
  upload.upload_id = image.id
93
93
  upload.save_and_index
@@ -95,7 +95,7 @@ module Migration
95
95
 
96
96
  def update_iiif_url(image)
97
97
  image.update(
98
- iiif_tilesource: riiif.info_url(image.id, host: hostname),
98
+ iiif_tilesource: riiif.info_url(image, host: hostname),
99
99
  iiif_region: coordinates(image)
100
100
  )
101
101
  end
@@ -6,6 +6,7 @@
6
6
  require 'devise'
7
7
  require 'devise_invitable'
8
8
 
9
+ require 'activejob-status'
9
10
  require 'blacklight'
10
11
  require 'autoprefixer-rails'
11
12
  require 'friendly_id'
@@ -16,6 +17,8 @@ require 'leaflet-rails'
16
17
  require 'i18n/active_record'
17
18
  require 'spotlight/upload_field_config'
18
19
  require 'riiif'
20
+ require 'faraday'
21
+ require 'faraday_middleware'
19
22
 
20
23
  module Spotlight
21
24
  ##
@@ -100,7 +103,7 @@ module Spotlight
100
103
  config.external_resources_partials = []
101
104
  config.solr_batch_size = 20
102
105
 
103
- Spotlight::Engine.config.reindex_progress_window = 10
106
+ Spotlight::Engine.config.reindex_progress_window = 1.hour
104
107
 
105
108
  # Filter resources by exhibit by default
106
109
  config.filter_resources_by_exhibit = true
@@ -125,6 +128,7 @@ module Spotlight
125
128
  }
126
129
 
127
130
  config.resource_global_id_field = :"#{config.solr_fields.prefix}spotlight_resource_id#{config.solr_fields.string_suffix}"
131
+ config.job_tracker_id_field = :"#{config.solr_fields.prefix}spotlight_job_tracker_id#{config.solr_fields.string_suffix}"
128
132
 
129
133
  # Set to nil if you don't want to pull thumbnails from the index
130
134
  config.full_image_field = :full_image_url_ssm
@@ -285,5 +289,22 @@ module Spotlight
285
289
  pages: true,
286
290
  resources: true
287
291
  }
292
+
293
+ config.reindexing_batch_size = nil
294
+ config.reindexing_batch_count = nil
295
+ config.hidden_job_classes = %w[Spotlight::ReindexJob]
296
+
297
+ config.bulk_actions_batch_size = 1000
298
+
299
+ config.bulk_updates = OpenStruct.new
300
+ config.bulk_updates.csv_id = 'Item ID'
301
+ config.bulk_updates.csv_title = 'Item Title'
302
+ config.bulk_updates.csv_visibility = 'Visibility'
303
+ config.bulk_updates.csv_tags_prefix = 'Tag:'
304
+ config.bulk_updates.csv_tags = 'Tag: %s'
305
+
306
+ config.assign_default_roles_to_first_user = true
307
+
308
+ config.exhibit_roles = %w[admin curator viewer]
288
309
  end
289
310
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spotlight
4
- VERSION = '3.0.0.rc3'
4
+ VERSION = '3.0.1'
5
5
  end
@@ -128,12 +128,6 @@ describe Spotlight::BrowseController, type: :controller do
128
128
  get :show, params: { id: search, exhibit_id: exhibit }
129
129
  expect(controller.blacklight_config.index.document_actions).to match_array %i[a b c]
130
130
  end
131
-
132
- it 'has a json response' do
133
- get :show, params: { id: search, exhibit_id: exhibit, format: :json }
134
- expect(assigns[:presenter]).to be_a Blacklight::JsonPresenter
135
- expect(response).to render_template 'catalog/index'
136
- end
137
131
  end
138
132
  end
139
133
  end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Spotlight::BulkActionsController, type: :controller do
4
+ routes { Spotlight::Engine.routes }
5
+ let(:exhibit) { FactoryBot.create(:skinny_exhibit) }
6
+
7
+ # rubocop:disable RSpec/BeforeAfterAll
8
+ before(:all) do
9
+ ActiveJob::Base.queue_adapter = :test
10
+ end
11
+
12
+ after(:all) do
13
+ ActiveJob::Base.queue_adapter = :inline
14
+ end
15
+ # rubocop:enable RSpec/BeforeAfterAll
16
+
17
+ describe 'when the user is not authorized' do
18
+ before do
19
+ sign_in FactoryBot.create(:exhibit_visitor)
20
+ end
21
+
22
+ describe 'POST change_visibility' do
23
+ it 'denies access' do
24
+ post :change_visibility, params: { exhibit_id: exhibit }
25
+ expect(response).to redirect_to main_app.root_path
26
+ expect(flash[:alert]).to be_present
27
+ end
28
+ end
29
+
30
+ describe 'POST add_tags' do
31
+ it 'denies access' do
32
+ post :add_tags, params: { exhibit_id: exhibit }
33
+ expect(response).to redirect_to main_app.root_path
34
+ expect(flash[:alert]).to be_present
35
+ end
36
+ end
37
+
38
+ describe 'POST remove_tags' do
39
+ it 'denies access' do
40
+ post :remove_tags, params: { exhibit_id: exhibit }
41
+ expect(response).to redirect_to main_app.root_path
42
+ expect(flash[:alert]).to be_present
43
+ end
44
+ end
45
+ end
46
+
47
+ describe 'when the user is a curator' do
48
+ before do
49
+ sign_in FactoryBot.create(:exhibit_curator, exhibit: exhibit)
50
+ end
51
+
52
+ let(:search) { FactoryBot.create(:search, exhibit: exhibit) }
53
+ let(:search_session) { instance_double('Blacklight::Search', query_params: { q: 'map' }) }
54
+
55
+ describe 'POST change_visibility' do
56
+ it 'redirects and sets a notice' do
57
+ allow(controller).to receive(:current_search_session).and_return(search_session)
58
+ request.env['HTTP_REFERER'] = '/referring_url'
59
+ post :change_visibility, params: { 'visibility' => 'private', 'q' => 'map', exhibit_id: exhibit }
60
+ expect(response).to redirect_to '/referring_url'
61
+ expect(flash[:notice]).to eq 'Visibility of 55 items is being updated.'
62
+ end
63
+
64
+ # rubocop:disable Style/MultilineBlockChain
65
+ it 'enqueues the job' do
66
+ allow(controller).to receive(:current_search_session).and_return(search_session)
67
+ expect do
68
+ post :change_visibility, params: { 'visibility' => 'private', 'q' => 'map', exhibit_id: exhibit }
69
+ end.to have_enqueued_job(Spotlight::ChangeVisibilityJob).with do |solr_params, exhb, visibility|
70
+ expect(solr_params).to.not be_nil
71
+ expect(exhb).to eq exhibit
72
+ expect(visibility).to eq 'private'
73
+ end
74
+ end
75
+ # rubocop:enable Style/MultilineBlockChain
76
+ end
77
+
78
+ describe 'POST add_tags' do
79
+ it 'redirects and sets a notice' do
80
+ allow(controller).to receive(:current_search_session).and_return(search_session)
81
+ request.env['HTTP_REFERER'] = '/referring_url'
82
+ post :add_tags, params: { 'tags' => 'howdy,planet', 'q' => 'map', exhibit_id: exhibit }
83
+ expect(response).to redirect_to '/referring_url'
84
+ expect(flash[:notice]).to eq 'Tags are being added for 55 items.'
85
+ end
86
+
87
+ # rubocop:disable Style/MultilineBlockChain
88
+ it 'enqueues the job' do
89
+ allow(controller).to receive(:current_search_session).and_return(search_session)
90
+ expect do
91
+ post :add_tags, params: { 'tags' => 'howdy,planet', 'q' => 'map', exhibit_id: exhibit }
92
+ end.to have_enqueued_job(Spotlight::AddTagsJob).with do |solr_params, exhb, tags|
93
+ expect(solr_params).to.not be_nil
94
+ expect(exhb).to eq exhibit
95
+ expect(tags).to eq %w[howdy planet]
96
+ end
97
+ end
98
+ # rubocop:enable Style/MultilineBlockChain
99
+ end
100
+
101
+ describe 'POST remove_tags' do
102
+ it 'redirects and sets a notice' do
103
+ allow(controller).to receive(:current_search_session).and_return(search_session)
104
+ request.env['HTTP_REFERER'] = '/referring_url'
105
+ post :remove_tags, params: { 'tags' => 'hello,world', 'q' => 'map', exhibit_id: exhibit }
106
+ expect(response).to redirect_to '/referring_url'
107
+ expect(flash[:notice]).to eq 'Tags are being removed for 55 items.'
108
+ end
109
+
110
+ # rubocop:disable Style/MultilineBlockChain
111
+ it 'enqueues the job' do
112
+ allow(controller).to receive(:current_search_session).and_return(search_session)
113
+ expect do
114
+ post :remove_tags, params: { 'tags' => 'howdy,planet', 'q' => 'map', exhibit_id: exhibit }
115
+ end.to have_enqueued_job(Spotlight::RemoveTagsJob).with do |solr_params, exhb, tags|
116
+ expect(solr_params).to.not be_nil
117
+ expect(exhb).to eq exhibit
118
+ expect(tags).to eq %w[howdy planet]
119
+ end
120
+ end
121
+ # rubocop:enable Style/MultilineBlockChain
122
+ end
123
+ end
124
+ end