blacklight-spotlight 0.32.0 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/assets/images/spotlight/default_browse_thumbnail.jpg +0 -0
  4. data/app/assets/javascripts/spotlight/application.js +6 -1
  5. data/app/assets/javascripts/spotlight/blocks/pages_block.js +1 -1
  6. data/app/assets/javascripts/spotlight/blocks/resources_block.js +7 -4
  7. data/app/assets/javascripts/spotlight/blocks/solr_documents_base_block.js +108 -0
  8. data/app/assets/javascripts/spotlight/blocks/solr_documents_block.js +12 -56
  9. data/app/assets/javascripts/spotlight/blocks/solr_documents_carousel_block.js +3 -3
  10. data/app/assets/javascripts/spotlight/blocks/solr_documents_embed_block.js +3 -3
  11. data/app/assets/javascripts/spotlight/blocks/solr_documents_features_block.js +3 -3
  12. data/app/assets/javascripts/spotlight/blocks/solr_documents_grid_block.js +3 -3
  13. data/app/assets/javascripts/spotlight/crop.es6 +205 -0
  14. data/app/assets/javascripts/spotlight/croppable.js +7 -104
  15. data/app/assets/javascripts/spotlight/iiif.es6 +54 -0
  16. data/app/assets/javascripts/spotlight/multi_image_selector.js +34 -16
  17. data/app/assets/javascripts/spotlight/pages.js.erb +1 -1
  18. data/app/assets/javascripts/spotlight/reindex_monitor.js +5 -1
  19. data/app/assets/javascripts/spotlight/search_typeahead.js +33 -47
  20. data/app/assets/javascripts/spotlight/sir-trevor/locales.js +5 -2
  21. data/app/assets/javascripts/spotlight/zpr_links.js.erb +30 -0
  22. data/app/assets/stylesheets/spotlight/_croppable.scss +8 -13
  23. data/app/assets/stylesheets/spotlight/_multi_image_selector.scss +1 -1
  24. data/app/assets/stylesheets/spotlight/_pages.scss +5 -0
  25. data/app/assets/stylesheets/spotlight/typeahead.css +0 -1
  26. data/app/controllers/concerns/spotlight/base.rb +3 -5
  27. data/app/controllers/spotlight/appearances_controller.rb +6 -4
  28. data/app/controllers/spotlight/catalog_controller.rb +10 -0
  29. data/app/controllers/spotlight/contacts_controller.rb +2 -6
  30. data/app/controllers/spotlight/featured_images_controller.rb +26 -0
  31. data/app/controllers/spotlight/pages_controller.rb +3 -2
  32. data/app/controllers/spotlight/resources/iiif_harvester_controller.rb +10 -0
  33. data/app/controllers/spotlight/resources/upload_controller.rb +4 -3
  34. data/app/controllers/spotlight/searches_controller.rb +20 -6
  35. data/app/controllers/spotlight/sites_controller.rb +2 -5
  36. data/app/helpers/spotlight/application_helper.rb +14 -1
  37. data/app/helpers/spotlight/crop_helper.rb +37 -0
  38. data/app/helpers/spotlight/main_app_helpers.rb +13 -0
  39. data/app/helpers/spotlight/meta_helper.rb +10 -20
  40. data/app/models/concerns/spotlight/solr_document.rb +1 -2
  41. data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +1 -23
  42. data/app/models/sir_trevor_rails/blocks/browse_block.rb +10 -0
  43. data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +10 -0
  44. data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +5 -0
  45. data/app/models/spotlight/analytics/ga.rb +1 -1
  46. data/app/models/spotlight/blacklight_configuration.rb +16 -8
  47. data/app/models/spotlight/contact.rb +2 -13
  48. data/app/models/spotlight/contact_image.rb +11 -0
  49. data/app/models/spotlight/exhibit.rb +11 -8
  50. data/app/models/spotlight/exhibit_thumbnail.rb +12 -0
  51. data/app/models/spotlight/feature_page.rb +3 -5
  52. data/app/models/spotlight/featured_image.rb +28 -9
  53. data/app/models/spotlight/home_page.rb +2 -0
  54. data/app/models/spotlight/masthead.rb +5 -11
  55. data/app/models/spotlight/page.rb +5 -0
  56. data/app/models/spotlight/reindex_progress.rb +10 -18
  57. data/app/models/spotlight/reindexing_log_entry.rb +1 -0
  58. data/app/models/spotlight/resources/iiif_harvester.rb +33 -0
  59. data/app/models/spotlight/resources/iiif_manifest.rb +211 -0
  60. data/app/models/spotlight/resources/iiif_service.rb +93 -0
  61. data/app/models/spotlight/resources/upload.rb +1 -2
  62. data/app/models/spotlight/search.rb +5 -34
  63. data/app/presenters/spotlight/iiif_manifest_presenter.rb +79 -0
  64. data/app/serializers/spotlight/exhibit_export_serializer.rb +9 -41
  65. data/app/services/spotlight/carrierwave_file_resolver.rb +3 -1
  66. data/app/services/spotlight/iiif_resource_resolver.rb +73 -0
  67. data/app/services/spotlight/resources/iiif_builder.rb +17 -0
  68. data/app/services/spotlight/upload_solr_document_builder.rb +23 -23
  69. data/app/uploaders/spotlight/attachment_uploader.rb +0 -48
  70. data/app/uploaders/spotlight/featured_image_uploader.rb +2 -16
  71. data/app/views/_user_util_links.html.erb +8 -5
  72. data/app/views/catalog/_save_search.html.erb +4 -2
  73. data/app/views/layouts/spotlight/spotlight.html.erb +5 -1
  74. data/app/views/shared/_masthead.html.erb +1 -1
  75. data/app/views/spotlight/about_pages/_contact_properties.html.erb +1 -1
  76. data/app/views/spotlight/appearances/edit.html.erb +26 -6
  77. data/app/views/spotlight/browse/_search.html.erb +1 -1
  78. data/app/views/spotlight/contacts/_form.html.erb +12 -7
  79. data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +1 -1
  80. data/app/views/spotlight/exhibits/_exhibit_card_front.html.erb +2 -2
  81. data/app/views/spotlight/featured_images/_form.html.erb +12 -15
  82. data/app/views/spotlight/featured_images/_upload_form.html.erb +6 -12
  83. data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +3 -3
  84. data/app/views/spotlight/pages/_form.html.erb +3 -3
  85. data/app/views/spotlight/pages/edit.html.erb +4 -2
  86. data/app/views/spotlight/resources/iiif/_form.html.erb +9 -0
  87. data/app/views/spotlight/searches/_form.html.erb +3 -3
  88. data/app/views/spotlight/searches/_search.html.erb +4 -2
  89. data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +2 -2
  90. data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +1 -1
  91. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -2
  92. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +4 -2
  93. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +4 -2
  94. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +4 -2
  95. data/app/views/spotlight/sites/edit.html.erb +1 -1
  96. data/config/locales/spotlight.en.yml +31 -6
  97. data/config/routes.rb +9 -0
  98. data/db/migrate/20160714144125_add_iiif_urls_to_featured_image.rb +9 -0
  99. data/db/migrate/20160718194010_add_iiif_url_to_contact.rb +6 -0
  100. data/db/migrate/20160805143841_add_upload_id_to_resources.rb +6 -0
  101. data/db/migrate/20170204091234_add_theme_to_spotlight_exhibits.rb +5 -0
  102. data/lib/generators/spotlight/install_generator.rb +5 -2
  103. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +0 -1
  104. data/lib/generators/spotlight/templates/spotlight.scss +3 -2
  105. data/lib/migration/iiif.rb +82 -0
  106. data/lib/spotlight/engine.rb +22 -10
  107. data/lib/spotlight/version.rb +1 -1
  108. data/lib/tasks/spotlight_tasks.rake +10 -0
  109. data/spec/controllers/spotlight/about_pages_controller_spec.rb +1 -1
  110. data/spec/controllers/spotlight/appearances_controller_spec.rb +31 -18
  111. data/spec/controllers/spotlight/catalog_controller_spec.rb +40 -0
  112. data/spec/controllers/spotlight/contacts_controller_spec.rb +20 -1
  113. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +2 -6
  114. data/spec/controllers/spotlight/featured_images_controller_spec.rb +74 -0
  115. data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
  116. data/spec/controllers/spotlight/searches_controller_spec.rb +3 -1
  117. data/spec/controllers/spotlight/sites_controller_spec.rb +6 -1
  118. data/spec/examples.txt +1118 -1059
  119. data/spec/factories/contact_images.rb +6 -0
  120. data/spec/factories/contacts.rb +4 -1
  121. data/spec/factories/exhibit_thumbnails.rb +6 -0
  122. data/spec/factories/exhibits.rb +4 -0
  123. data/spec/factories/featured_images.rb +1 -0
  124. data/spec/factories/resources.rb +2 -1
  125. data/spec/features/add_contacts_spec.rb +5 -5
  126. data/spec/features/add_iiif_manifest_spec.rb +41 -0
  127. data/spec/features/add_items_spec.rb +2 -2
  128. data/spec/features/autocomplete_typeahead_spec.rb +86 -0
  129. data/spec/features/browse_category_admin_spec.rb +27 -6
  130. data/spec/features/browse_category_spec.rb +2 -2
  131. data/spec/features/create_exhibit_spec.rb +3 -3
  132. data/spec/features/exhibit_masthead_spec.rb +20 -9
  133. data/spec/features/exhibit_themes_spec.rb +25 -0
  134. data/spec/features/home_page_spec.rb +1 -1
  135. data/spec/features/javascript/blocks/solr_documents_block_spec.rb +42 -0
  136. data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +5 -3
  137. data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
  138. data/spec/features/javascript/multi_image_select_spec.rb +5 -6
  139. data/spec/features/javascript/search_config_admin_spec.rb +1 -1
  140. data/spec/features/site_masthead_spec.rb +14 -4
  141. data/spec/fixtures/gk446cj2442-manifest.json +58 -0
  142. data/spec/fixtures/iiif_responses.rb +274 -0
  143. data/spec/fixtures/sample_solr_documents.yml +106 -0
  144. data/spec/helpers/spotlight/crop_helper_spec.rb +9 -0
  145. data/spec/helpers/spotlight/main_app_helpers_spec.rb +45 -0
  146. data/spec/helpers/spotlight/meta_helper_spec.rb +2 -15
  147. data/spec/lib/migration/iiif_spec.rb +70 -0
  148. data/spec/models/spotlight/blacklight_configuration_spec.rb +17 -5
  149. data/spec/models/spotlight/contact_image_spec.rb +9 -0
  150. data/spec/models/spotlight/exhibit_spec.rb +17 -20
  151. data/spec/models/spotlight/exhibit_thumbnail_spec.rb +8 -0
  152. data/spec/models/spotlight/featured_image_spec.rb +59 -10
  153. data/spec/models/spotlight/masthead_spec.rb +33 -17
  154. data/spec/models/spotlight/page_spec.rb +14 -0
  155. data/spec/models/spotlight/reindex_progress_spec.rb +22 -73
  156. data/spec/models/spotlight/resources/iiif_harvester_spec.rb +30 -0
  157. data/spec/models/spotlight/resources/iiif_manifest_spec.rb +107 -0
  158. data/spec/models/spotlight/resources/iiif_service_spec.rb +52 -0
  159. data/spec/models/spotlight/resources/upload_spec.rb +7 -3
  160. data/spec/models/spotlight/search_spec.rb +0 -45
  161. data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +11 -29
  162. data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +123 -0
  163. data/spec/routing/spotlight/exhibit_catalog_spec.rb +4 -0
  164. data/spec/routing/spotlight/featured_images_spec.rb +21 -0
  165. data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +15 -18
  166. data/spec/services/spotlight/iiif_resource_resolver_spec.rb +90 -0
  167. data/spec/spec_helper.rb +3 -0
  168. data/spec/support/features/test_features_helpers.rb +3 -2
  169. data/spec/support/stub_iiif_response.rb +24 -0
  170. data/spec/support/views/test_view_helpers.rb +1 -0
  171. data/spec/test_app_templates/Gemfile.extra +0 -1
  172. data/spec/uploaders/spotlight/attachment_uploader_spec.rb +24 -0
  173. data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +30 -0
  174. data/spec/views/_user_util_links.html.erb_spec.rb +9 -5
  175. data/spec/views/shared/_masthead.html.erb_spec.rb +5 -2
  176. data/spec/views/spotlight/browse/_search.html.erb_spec.rb +2 -2
  177. data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +4 -7
  178. data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +7 -2
  179. data/spec/views/spotlight/pages/edit.html.erb_spec.rb +3 -1
  180. data/spec/views/spotlight/pages/new.html.erb_spec.rb +3 -1
  181. data/spec/views/spotlight/searches/_search.html.erb_spec.rb +3 -2
  182. data/spec/views/spotlight/searches/edit.html.erb_spec.rb +3 -2
  183. data/vendor/assets/javascripts/leaflet-areaselect.js +184 -0
  184. data/vendor/assets/javascripts/leaflet-iiif.js +230 -0
  185. data/vendor/assets/javascripts/leaflet.js +9 -0
  186. data/vendor/assets/javascripts/polyfill.min.js +4 -0
  187. data/vendor/assets/stylesheets/leaflet-areaselect.css +15 -0
  188. data/vendor/assets/stylesheets/leaflet.css +624 -0
  189. metadata +136 -62
  190. data/app/assets/javascripts/spotlight/jcrop.js +0 -1696
  191. data/app/helpers/spotlight/jcrop_helper.rb +0 -37
  192. data/app/models/concerns/spotlight/default_thumbnailable.rb +0 -25
  193. data/app/models/concerns/spotlight/image_derivatives.rb +0 -58
  194. data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +0 -55
  195. data/app/uploaders/spotlight/avatar_uploader.rb +0 -24
  196. data/app/uploaders/spotlight/item_uploader.rb +0 -25
  197. data/app/uploaders/spotlight/masthead_uploader.rb +0 -22
  198. data/spec/helpers/spotlight/jcrop_helper_spec.rb +0 -33
  199. data/spec/models/spotlight/default_thumbnailable_concern_spec.rb +0 -16
  200. data/spec/models/spotlight/image_derivatives_spec.rb +0 -15
  201. data/spec/models/spotlight/solr_document/spotlight_images_spec.rb +0 -42
  202. data/spec/uploaders/spotlight/item_uploader_spec.rb +0 -67
@@ -0,0 +1,9 @@
1
+ class AddIiifUrlsToFeaturedImage < ActiveRecord::Migration
2
+ def change
3
+ add_column :spotlight_featured_images, :iiif_region, :string
4
+ add_column :spotlight_featured_images, :iiif_manifest_url, :string
5
+ add_column :spotlight_featured_images, :iiif_canvas_id, :string
6
+ add_column :spotlight_featured_images, :iiif_image_id, :string
7
+ add_column :spotlight_featured_images, :iiif_tilesource, :string
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ class AddIiifUrlToContact < ActiveRecord::Migration
2
+ def change
3
+ add_column :spotlight_contacts, :avatar_id, :integer
4
+ add_index :spotlight_contacts, :avatar_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddUploadIdToResources < ActiveRecord::Migration
2
+ def change
3
+ add_column :spotlight_resources, :upload_id, :integer
4
+ add_index :spotlight_resources, :upload_id
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddThemeToSpotlightExhibits < ActiveRecord::Migration
2
+ def change
3
+ add_column :spotlight_exhibits, :theme, :string
4
+ end
5
+ end
@@ -17,14 +17,14 @@ module Spotlight
17
17
  end
18
18
 
19
19
  def friendly_id
20
- gem 'friendly_id', github: 'norman/friendly_id'
20
+ gem 'friendly_id'
21
21
  # we need to immediately run `bundle install` while pointing at github.
22
22
  Bundler.with_clean_env { run 'bundle install' }
23
23
  generate 'friendly_id'
24
24
  end
25
25
 
26
26
  def riiif
27
- gem 'riiif', '~> 0.4.0'
27
+ gem 'riiif', '~> 1.0'
28
28
  route "mount Riiif::Engine => '/images', as: 'riiif'"
29
29
  copy_file 'config/initializers/riiif.rb'
30
30
  end
@@ -35,6 +35,9 @@ module Spotlight
35
35
 
36
36
  def sitemaps
37
37
  gem 'sitemap_generator'
38
+
39
+ Bundler.with_clean_env { run 'bundle install' }
40
+
38
41
  copy_file 'config/sitemap.rb', 'config/sitemap.rb'
39
42
 
40
43
  say <<-EOS.strip_heredoc, :red
@@ -34,7 +34,6 @@
34
34
  # Spotlight::Engine.config.resource_global_id_field = :"#{config.solr_fields.prefix}spotlight_resource_id#{config.solr_fields.string_suffix}"
35
35
  # Spotlight::Engine.config.full_image_field = :full_image_url_ssm
36
36
  # Spotlight::Engine.config.thumbnail_field = :thumbnail_url_ssm
37
- # Spotlight::Engine.config.square_image_field = :thumbnail_square_url_ssm
38
37
 
39
38
  # ==> Uploaded item configuration
40
39
  # Spotlight::Engine.config.upload_fields = [
@@ -1,9 +1,10 @@
1
1
  /*
2
2
  *= require bootstrap-tagsinput
3
- *= require jquery.jcrop
4
3
  */
5
4
  @import 'spotlight/variables_bootstrap';
6
5
  @import 'bootstrap-sprockets';
7
6
  @import 'bootstrap';
8
7
  @import 'sir-trevor/main';
9
- @import 'spotlight/spotlight';
8
+ @import 'leaflet';
9
+ @import 'leaflet-areaselect';
10
+ @import 'spotlight/spotlight';
@@ -0,0 +1,82 @@
1
+ module Migration
2
+ # This migrates FeaturedImages with crop coordinates into IIIF urls which
3
+ # are stored in the `iiif_url' field.
4
+ class IIIF
5
+ def self.run(hostname)
6
+ new(hostname).run
7
+ end
8
+
9
+ def initialize(hostname)
10
+ @hostname = hostname
11
+ end
12
+
13
+ def run
14
+ migrate_featured_images
15
+ migrate_contact_avatars
16
+ end
17
+
18
+ attr_reader :hostname
19
+
20
+ private
21
+
22
+ def riiif
23
+ Riiif::Engine.routes.url_helpers
24
+ end
25
+
26
+ def migrate_featured_images
27
+ Spotlight::FeaturedImage.all.each do |image|
28
+ update_iiif_url(image)
29
+ copy_exhibit_thumbnail_from_featured_image(image)
30
+ end
31
+ end
32
+
33
+ def migrate_contact_avatars
34
+ Spotlight::Contact.all.each do |contact|
35
+ avatar = copy_contact_image_to_avatar(contact)
36
+ contact.update(avatar: avatar) if avatar
37
+ end
38
+ end
39
+
40
+ # Checks if the image was associated as a thumbnail.
41
+ # If so, this will update the STI type column of the FeaturedImage as well
42
+ # as copy the file over to the correct directory given the new class name
43
+ def copy_exhibit_thumbnail_from_featured_image(image)
44
+ return unless Spotlight::Exhibit.where(thumbnail_id: image.id).any?
45
+ filename = image.read_attribute_before_type_cast('image')
46
+ old_file = "public/#{image.image.store_dir}/#{filename}"
47
+ image.becomes!(Spotlight::ExhibitThumbnail)
48
+ image.save
49
+ # AR + STI seems to require that we re-query for this
50
+ # otherwise we get an association miss-match
51
+ reloaded_image = Spotlight::ExhibitThumbnail.find(image.id)
52
+ reloaded_image.image.store!(File.new(old_file))
53
+ end
54
+
55
+ # Looks for a file at the old uploader location and copies it to a FeaturedImage
56
+ def copy_contact_image_to_avatar(contact)
57
+ filename = contact.read_attribute_before_type_cast('avatar')
58
+ filepath = "public/uploads/spotlight/contact/avatar/#{contact.id}/#{filename}"
59
+ old_file = File.new(filepath)
60
+ image = contact.create_avatar { |i| i.image.store!(old_file) }
61
+ iiif_tilesource = riiif.info_path(image.id)
62
+ image.update(iiif_tilesource: iiif_tilesource, iiif_region: avatar_coordinates(contact))
63
+ image
64
+ end
65
+
66
+ def update_iiif_url(image)
67
+ image.update(
68
+ iiif_tilesource: riiif.info_url(image.id, host: hostname),
69
+ iiif_region: coordinates(image)
70
+ )
71
+ end
72
+
73
+ def coordinates(image)
74
+ return unless image.image_crop_x.present?
75
+ [image.image_crop_x, image.image_crop_y, image.image_crop_w, image.image_crop_h].join(',')
76
+ end
77
+
78
+ def avatar_coordinates(contact)
79
+ [contact.avatar_crop_x, contact.avatar_crop_y, contact.avatar_crop_w, contact.avatar_crop_h].join(',')
80
+ end
81
+ end
82
+ end
@@ -29,11 +29,12 @@ module Spotlight
29
29
  end
30
30
 
31
31
  require 'carrierwave'
32
- require 'carrierwave/crop'
33
32
  require 'underscore-rails'
34
33
  require 'github/markup'
35
34
  require 'sir_trevor_rails'
36
35
  require 'openseadragon'
36
+ require 'sprockets/es6'
37
+ require 'almond-rails'
37
38
 
38
39
  config.assets.precompile += %w(spotlight/fallback/*.png)
39
40
 
@@ -61,7 +62,12 @@ module Spotlight
61
62
  end
62
63
 
63
64
  initializer 'spotlight.assets.precompile' do |app|
64
- app.config.assets.precompile += %w(spotlight/default_thumbnail.jpg)
65
+ app.config.assets.precompile += %w(spotlight/default_thumbnail.jpg spotlight/default_browse_thumbnail.jpg)
66
+
67
+ Sprockets::ES6.configuration = { 'modules' => 'amd', 'moduleIds' => true }
68
+ # When we upgrade to Sprockets 4, we can ditch sprockets-es6 and config AMD
69
+ # in this way:
70
+ # https://github.com/rails/sprockets/issues/73#issuecomment-139113466
65
71
  end
66
72
 
67
73
  def self.user_class
@@ -87,7 +93,8 @@ module Spotlight
87
93
  'spotlight/resources/external_resources_form',
88
94
  'spotlight/resources/upload/form',
89
95
  'spotlight/resources/csv_upload/form',
90
- 'spotlight/resources/json_upload/form'
96
+ 'spotlight/resources/json_upload/form',
97
+ 'spotlight/resources/iiif/form'
91
98
  ]
92
99
  config.external_resources_partials = []
93
100
  config.solr_batch_size = 20
@@ -112,29 +119,32 @@ module Spotlight
112
119
 
113
120
  config.resource_global_id_field = :"#{config.solr_fields.prefix}spotlight_resource_id#{config.solr_fields.string_suffix}"
114
121
 
115
- # The solr field that original (largest) images will be stored.
116
122
  # Set to nil if you don't want to pull thumbnails from the index
117
123
  config.full_image_field = :full_image_url_ssm
118
124
  config.thumbnail_field = :thumbnail_url_ssm
119
- config.square_image_field = :thumbnail_square_url_ssm
120
125
 
121
126
  # Defaults to the blacklight_config.index.title_field:
122
127
  config.upload_title_field = nil # OpenStruct.new(...)
128
+ config.upload_description_field = :spotlight_upload_description_tesim
123
129
 
124
130
  config.upload_fields = [
125
- OpenStruct.new(field_name: :spotlight_upload_description_tesim, label: 'Description', form_field_type: :text_area),
131
+ OpenStruct.new(field_name: config.upload_description_field, label: 'Description', form_field_type: :text_area),
126
132
  OpenStruct.new(field_name: :spotlight_upload_attribution_tesim, label: 'Attribution'),
127
133
  OpenStruct.new(field_name: :spotlight_upload_date_tesim, label: 'Date')
128
134
  ]
129
135
 
136
+ config.iiif_manifest_field = :iiif_manifest_url_ssi
137
+ config.iiif_metadata_class = -> { Spotlight::Resources::IiifManifest::Metadata }
138
+ config.iiif_collection_id_field = :collection_id_ssim
139
+
140
+ config.masthead_initial_crop_selection = [1200, 120]
141
+ config.thumbnail_initial_crop_selection = [120, 120]
142
+
130
143
  # Configure the CarrierWave file storage mechanism
131
144
  config.uploader_storage = :file
132
145
  config.featured_image_thumb_size = [400, 300]
133
146
  config.featured_image_square_size = [400, 400]
134
-
135
- initializer 'spotlight-assets.initialize' do
136
- Rails.application.config.assets.precompile += %w(Jcrop.gif)
137
- end
147
+ config.contact_square_size = [70, 70]
138
148
 
139
149
  # To present curators with analytics reports on the exhibit dashboard, you need to configure
140
150
  # an Analytics provider. Google Analytics support is provided out-of-the-box.
@@ -185,5 +195,7 @@ module Spotlight
185
195
 
186
196
  # make blacklight configuration play nice with bootstrap_form
187
197
  Blacklight::OpenStructWithHashAccess.send(:extend, ActiveModel::Translation)
198
+
199
+ config.exhibit_themes = ['default']
188
200
  end
189
201
  end
@@ -1,3 +1,3 @@
1
1
  module Spotlight
2
- VERSION = '0.32.0'.freeze
2
+ VERSION = '0.33.0'.freeze
3
3
  end
@@ -59,6 +59,16 @@ namespace :spotlight do
59
59
  puts Spotlight::ExhibitExportSerializer.new(exhibit).to_json
60
60
  end
61
61
 
62
+ desc 'Migrate to IIIF'
63
+ task :migrate_to_iiif, [:hostname] => :environment do |_, args|
64
+ if args[:hostname]
65
+ require 'migration/iiif'
66
+ Migration::IIIF.run args[:hostname]
67
+ else
68
+ STDERR.puts "\nUsage: rake spotlight:migrate_to_iiif[hostname]\n\n Example: rake spotlight:migrate_to_iiif[https://exhibits.stanford.edu]\n\n"
69
+ end
70
+ end
71
+
62
72
  def prompt_to_create_user
63
73
  Spotlight::Engine.user_class.find_or_create_by!(email: prompt_for_email) do |u|
64
74
  puts 'User not found. Enter a password to create the user.'
@@ -1,6 +1,6 @@
1
1
  describe Spotlight::AboutPagesController, type: :controller do
2
2
  routes { Spotlight::Engine.routes }
3
- let(:valid_attributes) { { 'title' => 'MyString' } }
3
+ let(:valid_attributes) { { 'title' => 'MyString', thumbnail: { iiif_url: '' } } }
4
4
 
5
5
  describe 'when not logged in' do
6
6
  describe 'POST update_all' do
@@ -43,34 +43,47 @@ describe Spotlight::AppearancesController, type: :controller do
43
43
  describe 'PATCH update' do
44
44
  let(:first_nav) { exhibit.main_navigations.first }
45
45
  let(:last_nav) { exhibit.main_navigations.last }
46
- it 'updates the navigation' do
46
+ let(:submitted) do
47
+ {
48
+ exhibit_id: exhibit,
49
+ exhibit: {
50
+ masthead_attributes: {
51
+ iiif_tilesource: 'http://test.host/1/foo',
52
+ iiif_region: '0,0,2000,200'
53
+ },
54
+ thumbnail_attributes: {
55
+ iiif_tilesource: 'http://test.host/2/foo',
56
+ iiif_region: '0,0,600,600'
57
+ },
58
+ main_navigations_attributes: main_navigation_attributes
59
+ }
60
+ }
61
+ end
62
+ let(:main_navigation_attributes) do
47
63
  if Rails::VERSION::MAJOR >= 5
48
- patch :update, params: {
49
- exhibit_id: exhibit,
50
- exhibit: {
51
- main_navigations_attributes: {
52
- 0 => { id: first_nav.id, label: 'Some Label', weight: 500 },
53
- 1 => { id: last_nav.id, display: false }
54
- }
55
- }
64
+ {
65
+ 0 => { id: first_nav.id, label: 'Some Label', weight: 500 },
66
+ 1 => { id: last_nav.id, display: false }
56
67
  }
57
68
  else
58
- patch :update, params: {
59
- exhibit_id: exhibit,
60
- exhibit: {
61
- main_navigations_attributes: [
62
- { id: first_nav.id, label: 'Some Label', weight: 500 },
63
- { id: last_nav.id, display: false }
64
- ]
65
- }
66
- }
69
+ [
70
+ { id: first_nav.id, label: 'Some Label', weight: 500 },
71
+ { id: last_nav.id, display: false }
72
+ ]
67
73
  end
74
+ end
75
+ it 'updates the navigation' do
76
+ patch :update, params: submitted
68
77
  expect(flash[:notice]).to eq 'The exhibit was successfully updated.'
69
78
  expect(response).to redirect_to edit_exhibit_appearance_path(exhibit)
70
79
  assigns[:exhibit].tap do |saved|
71
80
  expect(saved.main_navigations.find(first_nav.id).label).to eq 'Some Label'
72
81
  expect(saved.main_navigations.find(first_nav.id).weight).to eq 500
73
82
  expect(saved.main_navigations.find(last_nav.id)).not_to be_displayable
83
+ expect(saved.masthead.iiif_tilesource).to eq 'http://test.host/1/foo'
84
+ expect(saved.thumbnail.iiif_region).to eq '0,0,600,600'
85
+ expect(saved.masthead.iiif_url).to eq 'http://test.host/1/foo/0,0,2000,200/1800,180/0/default.jpg'
86
+ expect(saved.thumbnail.iiif_url).to eq 'http://test.host/2/foo/0,0,600,600/400,400/0/default.jpg'
74
87
  end
75
88
  end
76
89
  end
@@ -111,6 +111,46 @@ describe Spotlight::CatalogController, type: :controller do
111
111
  expect(json['docs'].first['title']).to eq 'KAART der REYZE van drie Schepen naar het ZUYDLAND in de Jaaren 1721 en 1722'
112
112
  end
113
113
  end
114
+
115
+ describe 'GET manifest' do
116
+ context 'document is an uploaded resource' do
117
+ it 'returns the json manifest produced by Spotlight::IiifManifestPresenter, based on the retrieved document and the controller' do
118
+ uploaded_resource = FactoryGirl.create(:uploaded_resource)
119
+ compound_id = uploaded_resource.compound_id
120
+ slug = uploaded_resource.exhibit.slug
121
+
122
+ uploaded_resource.save_and_index
123
+
124
+ get :manifest, params: { exhibit_id: uploaded_resource.exhibit, id: compound_id }
125
+
126
+ expect(response).to be_successful
127
+
128
+ json = JSON.parse(response.body)
129
+ expect(json['@context']).to eq 'http://iiif.io/api/presentation/2/context.json'
130
+ expect(json['@id']).to eq "http://test.host/spotlight/#{slug}/catalog/#{compound_id}/manifest"
131
+ expect(json['@type']).to eq 'sc:Manifest'
132
+
133
+ canvas = json['sequences'].first['canvases'].first
134
+ expect(canvas['@id']).to eq "http://test.host/spotlight/#{slug}/catalog/#{compound_id}/manifest/canvas/#{compound_id}"
135
+ expect(canvas['@type']).to eq 'sc:Canvas'
136
+
137
+ image = canvas['images'].first
138
+ expect(image['resource']['@id']).to eq compound_id
139
+ expect(image['resource']['format']).to eq 'image/jpeg'
140
+
141
+ # clean up solr document created by save_and_index above
142
+ Blacklight.default_index.connection.delete_by_id uploaded_resource.compound_id
143
+ Blacklight.default_index.connection.commit
144
+ end
145
+ end
146
+ context 'document is not an uploaded resource' do
147
+ it 'returns a 404 when called on something other than an uploaded resource' do
148
+ get :manifest, params: { exhibit_id: exhibit, id: 'dx157dh4345' }
149
+ expect(response).not_to be_successful
150
+ expect(response.status).to eq(404)
151
+ end
152
+ end
153
+ end
114
154
  end
115
155
 
116
156
  describe 'when the user is not authorized' do
@@ -32,6 +32,24 @@ describe Spotlight::ContactsController, type: :controller do
32
32
  expect(response).to redirect_to exhibit_about_pages_path(exhibit)
33
33
  expect(contact.reload.name).to eq 'Chester'
34
34
  end
35
+
36
+ it 'allows thumbnails to be updated' do
37
+ contact = FactoryGirl.create(:contact, exhibit: exhibit, name: 'Andrew Carnegie')
38
+ patch :update, params: {
39
+ id: contact,
40
+ contact: {
41
+ avatar_attributes: {
42
+ iiif_tilesource: 'https://example.com/iiif',
43
+ iiif_region: '0,0,200,200'
44
+ }
45
+ },
46
+ exhibit_id: contact.exhibit
47
+ }
48
+
49
+ expect(response).to redirect_to exhibit_about_pages_path(exhibit)
50
+ expect(contact.reload.avatar.iiif_url).to eq 'https://example.com/iiif/0,0,200,200/70,70/0/default.jpg'
51
+ end
52
+
35
53
  it 'fails by rendering edit' do
36
54
  expect_any_instance_of(Spotlight::Contact).to receive(:update).and_return(false)
37
55
  patch :update, params: { id: contact, contact: { name: 'Chester' }, exhibit_id: contact.exhibit }
@@ -65,10 +83,11 @@ describe Spotlight::ContactsController, type: :controller do
65
83
  end
66
84
  it 'is successful' do
67
85
  expect do
68
- post :create, params: { exhibit_id: exhibit, contact: { name: 'Chester' } }
86
+ post :create, params: { exhibit_id: exhibit, contact: { name: 'Chester', avatar_attributes: { iiif_tilesource: 'someurl' } } }
69
87
  end.to change { Spotlight::Contact.count }.by(1)
70
88
  expect(response).to redirect_to exhibit_about_pages_path(exhibit)
71
89
  expect(Spotlight::Contact.last.show_in_sidebar).to be_truthy
90
+ expect(Spotlight::Contact.last.avatar.iiif_url).to be_present
72
91
  end
73
92
  end
74
93
  end
@@ -4,7 +4,7 @@ describe Spotlight::FeaturePagesController, type: :controller do
4
4
  # This should return the minimal set of attributes required to create a valid
5
5
  # Page. As you add validations to Page, be sure to
6
6
  # adjust the attributes here as well.
7
- let(:valid_attributes) { { 'title' => 'MyString' } }
7
+ let(:valid_attributes) { { 'title' => 'MyString', thumbnail_attributes: { iiif_url: '' } } }
8
8
  describe 'when signed in as a curator' do
9
9
  let(:exhibit) { FactoryGirl.create(:exhibit) }
10
10
  let(:user) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
@@ -104,11 +104,7 @@ describe Spotlight::FeaturePagesController, type: :controller do
104
104
  let(:page) { FactoryGirl.create(:feature_page, exhibit: exhibit) }
105
105
  describe 'with valid params' do
106
106
  it 'updates the requested page' do
107
- # Assuming there are no other pages in the database, this
108
- # specifies that the Page created on the previous line
109
- # receives the :update_attributes message with whatever params are
110
- # submitted in the request.
111
- expect_any_instance_of(Spotlight::FeaturePage).to receive(:update).with(hash_including(valid_attributes))
107
+ expect_any_instance_of(Spotlight::FeaturePage).to receive(:update)
112
108
  put :update, params: { id: page, exhibit_id: page.exhibit.id, feature_page: valid_attributes }
113
109
  end
114
110