blacklight-spotlight 3.0.0.rc2 → 3.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/images/blacklight/arrow-alt-circle-left.svg +1 -0
  4. data/app/assets/images/blacklight/arrow-alt-circle-right.svg +1 -0
  5. data/app/assets/javascripts/spotlight/admin/{add_new_page_button.js → add_new_button.js} +7 -0
  6. data/app/assets/javascripts/spotlight/admin/block_mixins/autocompleteable.js +4 -4
  7. data/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
  8. data/app/assets/javascripts/spotlight/admin/blocks/pages_block.js +1 -1
  9. data/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js +1 -1
  10. data/app/assets/javascripts/spotlight/admin/croppable.js +1 -1
  11. data/app/assets/javascripts/spotlight/admin/index.js +0 -2
  12. data/app/assets/javascripts/spotlight/admin/search_typeahead.js +2 -2
  13. data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +7 -0
  14. data/app/assets/javascripts/spotlight/user/browse_group_categories.js +59 -0
  15. data/app/assets/javascripts/spotlight/user/index.js +1 -0
  16. data/app/assets/stylesheets/spotlight/_breadcrumbs.scss +8 -0
  17. data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +34 -1
  18. data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -0
  19. data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +69 -0
  20. data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +1 -2
  21. data/app/controllers/concerns/spotlight/search_helper.rb +2 -8
  22. data/app/controllers/spotlight/appearances_controller.rb +0 -13
  23. data/app/controllers/spotlight/browse_controller.rb +7 -3
  24. data/app/controllers/spotlight/catalog_controller.rb +1 -1
  25. data/app/controllers/spotlight/concerns/application_controller.rb +13 -2
  26. data/app/controllers/spotlight/groups_controller.rb +80 -0
  27. data/app/controllers/spotlight/pages_controller.rb +5 -8
  28. data/app/controllers/spotlight/searches_controller.rb +4 -17
  29. data/app/helpers/spotlight/application_helper.rb +1 -1
  30. data/app/helpers/spotlight/crud_link_helpers.rb +1 -1
  31. data/app/helpers/spotlight/main_app_helpers.rb +1 -1
  32. data/app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb +25 -0
  33. data/app/models/spotlight/ability.rb +2 -0
  34. data/app/models/spotlight/about_page.rb +1 -1
  35. data/app/models/spotlight/blacklight_configuration.rb +2 -1
  36. data/app/models/spotlight/exhibit.rb +14 -2
  37. data/app/models/spotlight/feature_page.rb +1 -1
  38. data/app/models/spotlight/featured_image.rb +1 -1
  39. data/app/models/spotlight/group.rb +22 -0
  40. data/app/models/spotlight/group_member.rb +11 -0
  41. data/app/models/spotlight/home_page.rb +1 -1
  42. data/app/models/spotlight/page.rb +2 -2
  43. data/app/models/spotlight/page_configurations.rb +5 -0
  44. data/app/models/spotlight/resources/iiif_manifest.rb +6 -6
  45. data/app/models/spotlight/search.rb +5 -0
  46. data/app/services/spotlight/exhibit_import_export_service.rb +50 -22
  47. data/app/views/spotlight/browse/_search.html.erb +2 -1
  48. data/app/views/spotlight/browse/index.html.erb +13 -0
  49. data/app/views/spotlight/catalog/_document.html.erb +2 -4
  50. data/app/views/spotlight/catalog/index.iiif_json.jbuilder +22 -0
  51. data/app/views/spotlight/searches/_form.html.erb +12 -0
  52. data/app/views/spotlight/searches/_group.html.erb +27 -0
  53. data/app/views/spotlight/searches/index.html.erb +58 -17
  54. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +44 -0
  55. data/app/views/spotlight/translations/_groups.html.erb +34 -0
  56. data/app/views/spotlight/translations/edit.html.erb +6 -0
  57. data/config/i18n-tasks.yml +5 -0
  58. data/config/locales/spotlight.en.yml +37 -1
  59. data/config/routes.rb +10 -0
  60. data/db/migrate/20210113092223_create_spotlight_groups.rb +23 -0
  61. data/lib/generators/spotlight/install_generator.rb +3 -3
  62. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +1 -1
  63. data/lib/spotlight/engine.rb +4 -3
  64. data/lib/spotlight/version.rb +1 -1
  65. data/spec/controllers/spotlight/browse_controller_spec.rb +23 -0
  66. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +11 -0
  67. data/spec/controllers/spotlight/groups_controller_spec.rb +103 -0
  68. data/spec/controllers/spotlight/searches_controller_spec.rb +10 -3
  69. data/spec/controllers/spotlight/view_configurations_controller_spec.rb +1 -1
  70. data/spec/examples.txt +1437 -136
  71. data/spec/factories/group.rb +17 -0
  72. data/spec/factories/searches.rb +10 -0
  73. data/spec/features/browse_category_admin_spec.rb +36 -4
  74. data/spec/features/browse_category_navigation_spec.rb +44 -0
  75. data/spec/features/browse_category_spec.rb +2 -2
  76. data/spec/features/exhibits/translation_editing_spec.rb +49 -0
  77. data/spec/features/home_page_spec.rb +4 -4
  78. data/spec/features/javascript/about_page_admin_spec.rb +1 -1
  79. data/spec/features/javascript/block_controls_spec.rb +1 -1
  80. data/spec/features/javascript/blocks/browse_group_categories_block_spec.rb +64 -0
  81. data/spec/features/javascript/browse_group_admin_spec.rb +45 -0
  82. data/spec/features/javascript/edit_in_place_spec.rb +2 -2
  83. data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
  84. data/spec/helpers/spotlight/crud_link_helpers_spec.rb +3 -3
  85. data/spec/models/sir_trevor_rails/blocks/browse_group_categories_block_spec.rb +41 -0
  86. data/spec/models/spotlight/exhibit_spec.rb +8 -0
  87. data/spec/models/spotlight/group_spec.rb +19 -0
  88. data/spec/models/spotlight/role_spec.rb +1 -1
  89. data/spec/models/spotlight/search_spec.rb +30 -3
  90. data/spec/services/spotlight/exhibit_import_export_service_spec.rb +48 -1
  91. data/spec/services/spotlight/solr_document_builder_spec.rb +1 -1
  92. data/spec/spec_helper.rb +1 -1
  93. data/spec/support/features/test_features_helpers.rb +15 -0
  94. data/spec/test_app_templates/Gemfile.extra +1 -0
  95. data/spec/test_app_templates/catalog_controller.rb +6 -3
  96. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  97. data/spec/views/spotlight/browse/index.html.erb_spec.rb +2 -0
  98. data/spec/views/spotlight/pages/show.html.erb_spec.rb +1 -0
  99. data/vendor/assets/javascripts/tiny-slider.js +3218 -0
  100. data/vendor/assets/stylesheets/tiny-slider.css +1 -0
  101. metadata +339 -263
  102. data/vendor/assets/javascripts/handlebars-v1.3.0.js +0 -2746
@@ -6,7 +6,7 @@ module Spotlight
6
6
  class FeaturePage < Spotlight::Page
7
7
  extend FriendlyId
8
8
  friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale] do |config|
9
- config.reserved_words.concat(%w[update_all])
9
+ config.reserved_words&.concat(%w[update_all])
10
10
  end
11
11
 
12
12
  has_many :child_pages, class_name: 'Spotlight::FeaturePage', inverse_of: :parent_page, foreign_key: 'parent_page_id'
@@ -12,7 +12,7 @@ module Spotlight
12
12
  # copy the image from the temp upload
13
13
  temp_image = Spotlight::TemporaryImage.find(upload_id)
14
14
  self.image = CarrierWave::SanitizedFile.new tempfile: StringIO.new(temp_image.image.read),
15
- filename: temp_image.image.identifier,
15
+ filename: temp_image.image.filename || temp_image.image.identifier,
16
16
  content_type: temp_image.image.content_type
17
17
 
18
18
  # Unset the incoming iiif_tilesource, which points at the temp image
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spotlight
4
+ ##
5
+ # Exhibit saved searches
6
+ class Group < ActiveRecord::Base
7
+ include Spotlight::Translatables
8
+
9
+ extend FriendlyId
10
+ friendly_id :title, use: %i[slugged scoped finders history], scope: [:exhibit]
11
+ translates :title
12
+
13
+ self.table_name = 'spotlight_groups'
14
+ belongs_to :exhibit
15
+ has_many :group_members
16
+ has_many :searches, through: :group_members, source: :member, source_type: 'Spotlight::Search'
17
+ default_scope { order('weight ASC') }
18
+ scope :published, -> { where(published: true) }
19
+ accepts_nested_attributes_for :group_members
20
+ accepts_nested_attributes_for :searches
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spotlight
4
+ ##
5
+ # Exhibit saved searches
6
+ class GroupMember < ActiveRecord::Base
7
+ self.table_name = 'spotlight_groups_members'
8
+ belongs_to :group
9
+ belongs_to :member, polymorphic: true
10
+ end
11
+ end
@@ -6,7 +6,7 @@ module Spotlight
6
6
  class HomePage < Spotlight::Page
7
7
  extend FriendlyId
8
8
  friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale] do |config|
9
- config.reserved_words.concat(%w[update_all])
9
+ config.reserved_words&.concat(%w[update_all])
10
10
  end
11
11
 
12
12
  before_save :publish
@@ -9,8 +9,8 @@ module Spotlight
9
9
  extend FriendlyId
10
10
  # Note: This configuration also needs to be duplicated on the
11
11
  # STI models ({Spotlight::AboutPage}, {Spotlight::FeaturePage}, {Spotlight::HomePage})
12
- friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale] do |config|
13
- config.reserved_words.concat(%w[update_all])
12
+ friendly_id :title, use: %i[slugged scoped finders history], scope: %i[exhibit locale], treat_reserved_as_conflict: true do |config|
13
+ config.reserved_words&.concat(%w[update_all contacts])
14
14
  end
15
15
 
16
16
  belongs_to :exhibit, touch: true
@@ -40,6 +40,7 @@ module Spotlight
40
40
  'attachment-endpoint': attachment_endpoint,
41
41
  'autocomplete-exhibit-catalog-path': exhibit_autocomplete_endpoint,
42
42
  'autocomplete-exhibit-pages-path': page_autocomplete_endpoint,
43
+ 'autocomplete-exhibit-browse-groups-path': browse_groups_autocomplete_endpoint,
43
44
  'autocomplete-exhibit-searches-path': search_autocomplete_endpoint,
44
45
  'preview-url': page_preview_url
45
46
  }.merge(downstream_parameters)
@@ -62,6 +63,10 @@ module Spotlight
62
63
  spotlight.exhibit_attachments_path(current_exhibit)
63
64
  end
64
65
 
66
+ def browse_groups_autocomplete_endpoint
67
+ spotlight.exhibit_groups_path(current_exhibit)
68
+ end
69
+
65
70
  def exhibit_autocomplete_endpoint
66
71
  spotlight.autocomplete_exhibit_catalog_path(current_exhibit, q: '%QUERY', format: 'json')
67
72
  end
@@ -69,7 +69,7 @@ module Spotlight
69
69
  end
70
70
 
71
71
  def add_label
72
- return unless title_fields.present? && manifest.try(:label)
72
+ return unless title_fields.present? && manifest&.label
73
73
 
74
74
  Array.wrap(title_fields).each do |field|
75
75
  solr_hash[field] = metadata_class.new(manifest).label
@@ -144,7 +144,7 @@ module Spotlight
144
144
  end
145
145
 
146
146
  def thumbnail_field
147
- blacklight_config.index.try(:thumbnail_field)
147
+ blacklight_config.index.thumbnail_field
148
148
  end
149
149
 
150
150
  def full_image_field
@@ -152,11 +152,11 @@ module Spotlight
152
152
  end
153
153
 
154
154
  def tile_source_field
155
- blacklight_config.show.try(:tile_source_field)
155
+ blacklight_config.show.tile_source_field
156
156
  end
157
157
 
158
158
  def title_fields
159
- Spotlight::Engine.config.iiif_title_fields || blacklight_config.index.try(:title_field)
159
+ Spotlight::Engine.config.iiif_title_fields || blacklight_config.index&.title_field
160
160
  end
161
161
 
162
162
  def sidecar
@@ -187,7 +187,7 @@ module Spotlight
187
187
  end
188
188
 
189
189
  def label
190
- return unless manifest.try(:label)
190
+ return unless manifest&.label
191
191
 
192
192
  Array(json_ld_value(manifest.label)).map { |v| html_sanitize(v) }.first
193
193
  end
@@ -197,7 +197,7 @@ module Spotlight
197
197
  attr_reader :manifest
198
198
 
199
199
  def metadata
200
- manifest.try(:metadata) || []
200
+ manifest&.metadata || []
201
201
  end
202
202
 
203
203
  def metadata_hash
@@ -12,9 +12,14 @@ module Spotlight
12
12
 
13
13
  self.table_name = 'spotlight_searches'
14
14
  belongs_to :exhibit
15
+ has_many :group_memberships, class_name: 'Spotlight::GroupMember', as: :member, dependent: :delete_all
16
+ has_many :groups, through: :group_memberships
17
+ accepts_nested_attributes_for :group_memberships
18
+ accepts_nested_attributes_for :groups
15
19
  serialize :query_params, Hash
16
20
  default_scope { order('weight ASC') }
17
21
  scope :published, -> { where(published: true) }
22
+ scope :unpublished, -> { where(published: [nil, false]) }
18
23
  validates :title, presence: true
19
24
 
20
25
  translates :title, :subtitle, :long_description
@@ -11,6 +11,7 @@ module Spotlight
11
11
  class_attribute :serialization_pipeline, default: %i[
12
12
  raw_json
13
13
  add_feature_page_hierarchy
14
+ add_browse_group_hierarchy
14
15
  add_page_content
15
16
  attach_featured_images
16
17
  attach_attachments
@@ -37,34 +38,43 @@ module Spotlight
37
38
  attachments: {},
38
39
  languages: {},
39
40
  translations: {},
40
- owned_taggings: {}
41
+ owned_taggings: {},
42
+ groups: {}
41
43
  )
42
44
 
43
45
  exhibit_attributes = hash.reject { |_k, v| v.is_a?(Array) || v.is_a?(Hash) }
44
- exhibit.update_attributes(exhibit_attributes.except(:theme))
46
+ exhibit.update(exhibit_attributes.except(:theme))
45
47
  exhibit.theme = exhibit_attributes[:theme] if exhibit.themes.include? exhibit_attributes[:theme]
46
48
 
47
49
  deserialize_featured_image(exhibit, :masthead, hash[:masthead]) if hash[:masthead]
48
50
  deserialize_featured_image(exhibit, :thumbnail, hash[:thumbnail]) if hash[:thumbnail]
49
51
 
50
- exhibit.blacklight_configuration.update_attributes hash[:blacklight_configuration].deep_stringify_keys if hash[:blacklight_configuration]
52
+ exhibit.blacklight_configuration.update hash[:blacklight_configuration].deep_stringify_keys if hash[:blacklight_configuration]
51
53
 
52
54
  hash[:main_navigations].each do |attr|
53
55
  ar = exhibit.main_navigations.find_or_initialize_by(nav_type: attr[:nav_type])
54
- ar.update_attributes(attr)
56
+ ar.update(attr)
55
57
  end
56
58
 
57
59
  hash[:contact_emails].each do |attr|
58
60
  ar = exhibit.contact_emails.find_or_initialize_by(email: attr[:email])
59
- ar.update_attributes(attr)
61
+ ar.update(attr)
62
+ end
63
+
64
+ hash[:groups].each do |attr|
65
+ gr = exhibit.groups.find_or_initialize_by(slug: attr[:slug])
66
+ gr.update(attr)
60
67
  end
61
68
 
62
69
  hash[:searches].each do |attr|
70
+ group_slugs = attr.delete(:group_slugs) || []
63
71
  masthead = attr.delete(:masthead)
64
72
  thumbnail = attr.delete(:thumbnail)
65
73
 
66
74
  ar = exhibit.searches.find_or_initialize_by(slug: attr[:slug])
67
- ar.update_attributes(attr)
75
+ ar.update(attr)
76
+
77
+ ar.update(groups: exhibit.groups.select { |x| group_slugs.include? x.slug })
68
78
 
69
79
  deserialize_featured_image(ar, :masthead, masthead) if masthead
70
80
  deserialize_featured_image(ar, :thumbnail, thumbnail) if thumbnail
@@ -76,7 +86,7 @@ module Spotlight
76
86
  translated_pages = attr.delete(:translated_pages) || []
77
87
 
78
88
  ar = exhibit.about_pages.find_or_initialize_by(slug: attr[:slug])
79
- ar.update_attributes(attr)
89
+ ar.update(attr)
80
90
 
81
91
  deserialize_featured_image(ar, :masthead, masthead) if masthead
82
92
  deserialize_featured_image(ar, :thumbnail, thumbnail) if thumbnail
@@ -86,7 +96,7 @@ module Spotlight
86
96
  thumbnail = tattr.delete(:thumbnail)
87
97
 
88
98
  tar = ar.translated_page_for(tattr[:locale]) || ar.clone_for_locale(tattr[:locale])
89
- tar.update_attributes(tattr)
99
+ tar.update(tattr)
90
100
 
91
101
  deserialize_featured_image(ar, :masthead, masthead) if masthead
92
102
  deserialize_featured_image(ar, :thumbnail, thumbnail) if thumbnail
@@ -98,7 +108,7 @@ module Spotlight
98
108
  thumbnail = attr.delete(:thumbnail)
99
109
 
100
110
  ar = exhibit.feature_pages.find_or_initialize_by(slug: attr[:slug])
101
- ar.update_attributes(attr.except(:parent_page_slug, :translated_pages))
111
+ ar.update(attr.except(:parent_page_slug, :translated_pages))
102
112
 
103
113
  deserialize_featured_image(ar, :masthead, masthead) if masthead
104
114
  deserialize_featured_image(ar, :thumbnail, thumbnail) if thumbnail
@@ -119,7 +129,7 @@ module Spotlight
119
129
  thumbnail = tattr.delete(:thumbnail)
120
130
 
121
131
  tar = ar.translated_page_for(tattr[:locale]) || ar.clone_for_locale(tattr[:locale])
122
- tar.update_attributes(tattr)
132
+ tar.update(tattr)
123
133
 
124
134
  deserialize_featured_image(ar, :masthead, masthead) if masthead
125
135
  deserialize_featured_image(ar, :thumbnail, thumbnail) if thumbnail
@@ -128,7 +138,7 @@ module Spotlight
128
138
 
129
139
  if hash[:home_page]
130
140
  translated_pages = hash[:home_page].delete(:translated_pages) || []
131
- exhibit.home_page.update_attributes(hash[:home_page].except(:thumbnail))
141
+ exhibit.home_page.update(hash[:home_page].except(:thumbnail))
132
142
  deserialize_featured_image(exhibit.home_page, :thumbnail, hash[:home_page][:thumbnail]) if hash[:home_page][:thumbnail]
133
143
 
134
144
  translated_pages.each do |tattr|
@@ -136,7 +146,7 @@ module Spotlight
136
146
  thumbnail = tattr.delete(:thumbnail)
137
147
 
138
148
  tar = exhibit.home_page.translated_page_for(tattr[:locale]) || exhibit.home_page.clone_for_locale(tattr[:locale])
139
- tar.update_attributes(tattr)
149
+ tar.update(tattr)
140
150
 
141
151
  deserialize_featured_image(ar, :masthead, masthead) if masthead
142
152
  deserialize_featured_image(ar, :thumbnail, thumbnail) if thumbnail
@@ -147,26 +157,26 @@ module Spotlight
147
157
  avatar = attr.delete(:avatar)
148
158
 
149
159
  ar = exhibit.contacts.find_or_initialize_by(slug: attr[:slug])
150
- ar.update_attributes(attr)
160
+ ar.update(attr)
151
161
 
152
162
  deserialize_featured_image(ar, :avatar, avatar) if avatar
153
163
  end
154
164
 
155
165
  hash[:custom_fields].each do |attr|
156
166
  ar = exhibit.custom_fields.find_or_initialize_by(slug: attr[:slug])
157
- ar.update_attributes(attr)
167
+ ar.update(attr)
158
168
  end
159
169
 
160
170
  hash[:solr_document_sidecars].each do |attr|
161
171
  ar = exhibit.solr_document_sidecars.find_or_initialize_by(document_id: attr[:document_id])
162
- ar.update_attributes(attr)
172
+ ar.update(attr)
163
173
  end
164
174
 
165
175
  hash[:resources].each do |attr|
166
176
  upload = attr.delete(:upload)
167
177
 
168
178
  ar = exhibit.resources.find_or_initialize_by(type: attr[:type], url: attr[:url])
169
- ar.update_attributes(attr)
179
+ ar.update(attr)
170
180
 
171
181
  deserialize_featured_image(ar, :upload, upload) if upload
172
182
  end
@@ -183,12 +193,12 @@ module Spotlight
183
193
 
184
194
  hash[:languages].each do |attr|
185
195
  ar = exhibit.languages.find_or_initialize_by(locale: attr[:locale])
186
- ar.update_attributes(attr)
196
+ ar.update(attr)
187
197
  end
188
198
 
189
199
  hash[:translations].each do |attr|
190
200
  ar = exhibit.translations.find_or_initialize_by(locale: attr[:locale], key: attr[:key])
191
- ar.update_attributes(attr)
201
+ ar.update(attr)
192
202
  end
193
203
 
194
204
  hash[:owned_taggings].each do |attr|
@@ -200,18 +210,21 @@ module Spotlight
200
210
  def deserialize_featured_image(obj, method, data)
201
211
  file = data.delete(:image)
202
212
  image = obj.public_send("build_#{method}")
203
- image.update_attributes(data)
213
+ image.update(data)
204
214
  if file
205
215
  image.image = CarrierWave::SanitizedFile.new tempfile: StringIO.new(Base64.decode64(file[:content])),
206
216
  filename: file[:filename],
207
217
  content_type: file[:content_type]
218
+ # Unset the iiif_tilesource field as the new image should be different, because
219
+ # the source has been reloaded
220
+ image.iiif_tilesource = nil
208
221
  end
209
222
  image.save!
210
223
  obj.update(method => image)
211
224
  end
212
225
 
213
- def as_json(**args)
214
- self.class.serialization_pipeline.inject(args) do |memo, step|
226
+ def as_json(*_args)
227
+ self.class.serialization_pipeline.inject({}) do |memo, step|
215
228
  method(step).call(memo)
216
229
  end
217
230
  end
@@ -292,7 +305,7 @@ module Spotlight
292
305
  if file
293
306
  img = {
294
307
  image: {
295
- filename: file.identifier, content_type: file.content_type, content: Base64.encode64(file.read)
308
+ filename: file.filename, content_type: file.content_type, content: Base64.encode64(file.read)
296
309
  }
297
310
  }
298
311
  end
@@ -335,6 +348,18 @@ module Spotlight
335
348
  json
336
349
  end
337
350
 
351
+ def add_browse_group_hierarchy(json)
352
+ return json unless json[:groups] && json[:searches]
353
+
354
+ json[:searches].each do |attr|
355
+ search = exhibit.searches.find_by(slug: attr[:slug])
356
+
357
+ attr[:group_slugs] = search.groups.pluck(:slug)
358
+ end
359
+
360
+ json
361
+ end
362
+
338
363
  def add_page_content(json)
339
364
  (json[:feature_pages] || []).each do |page|
340
365
  p = exhibit.feature_pages.find_by(slug: page[:slug])
@@ -382,6 +407,9 @@ module Spotlight
382
407
  searches: { # thumbnail
383
408
  except: %i[id scope exhibit_id]
384
409
  },
410
+ groups: {
411
+ except: %i[id exhibit_id]
412
+ },
385
413
  about_pages: { # thumbnail
386
414
  except: %i[id scope exhibit_id parent_page_id content],
387
415
  include: {
@@ -1,6 +1,7 @@
1
1
  <%= cache [@exhibit, search, I18n.locale] do %>
2
+ <% group ||= @group %>
2
3
  <div class="col-md-4 col-12 category">
3
- <%= link_to spotlight.exhibit_browse_path(@exhibit, search) do %>
4
+ <%= link_to group.present? ? spotlight.exhibit_browse_group_path(@exhibit, group, search) : spotlight.exhibit_browse_path(@exhibit, search) do %>
4
5
  <div class="image-overlay">
5
6
  <%= image_tag(search.thumbnail_image_url || 'spotlight/default_browse_thumbnail.jpg', class: 'img-responsive', alt: '') %>
6
7
  <div class="text-overlay">
@@ -2,6 +2,19 @@
2
2
  <% set_html_page_title(title) %>
3
3
  <h1 class="sr-only"><%= title %></h1>
4
4
 
5
+ <% if @groups.any? # active %>
6
+ <ul class="browse-group-navigation nav nav-pills justify-content-center">
7
+ <li class="nav-item">
8
+ <%= link_to t('spotlight.exhibits.groups.all'), exhibit_browse_index_path(current_exhibit), class: "nav-link #{'active' if @group.blank?}" %>
9
+ </li>
10
+ <% @groups.each do |group| %>
11
+ <li class="nav-item">
12
+ <%= link_to group.title, exhibit_browse_groups_path(current_exhibit, group), class: "nav-link #{'active' if @group.present? && @group.id == group.id}" %>
13
+ </li>
14
+ <% end %>
15
+ </ul>
16
+ <% end %>
17
+
5
18
  <div class="browse-landing row">
6
19
  <%= render collection: @searches, partial: 'spotlight/browse/search' %>
7
20
  </div>
@@ -1,4 +1,2 @@
1
- <% # copied from blacklight; rails tries to render spotlight/catalog/document explicitly.. -%>
2
- <div class="document <%= render_document_class document %>" itemscope itemtype="<%= document.itemtype %>">
3
- <%= render_document_partials document, blacklight_config.view_config(document_index_view_type).partials, :document_counter => document_counter %>
4
- </div>
1
+ <% # try to render the blacklight provided catalog/document partial; rails tries to render spotlight/catalog/document explicitly.. -%>
2
+ <%= render 'catalog/document', local_assigns %>
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ json.set! :@context, 'http://iiif.io/api/presentation/2/context.json'
4
+ json.set! :@id, exhibit_iiif_collection_url(page: params[:page]&.to_i)
5
+ json.set! :@type, 'sc:Collection'
6
+ json.label current_exhibit.title
7
+ json.viewingHint 'top'
8
+ json.description current_exhibit.description if current_exhibit.description
9
+ json.manifests do
10
+ json.array!(@response.documents) do |doc|
11
+ next unless doc.first(Spotlight::Engine.config.iiif_manifest_field)
12
+
13
+ json.set! :@id, doc.first(Spotlight::Engine.config.iiif_manifest_field)
14
+ json.set! :@type, 'sc:manifest'
15
+ json.label presenter(doc).label(document_show_link_field(doc)).to_str
16
+ end
17
+ end
18
+
19
+ json.total @response.total
20
+ json.first exhibit_iiif_collection_url(page: nil)
21
+
22
+ json.next exhibit_iiif_collection_url(page: @response.next_page) unless @response.last_page? || @response.out_of_range?
@@ -16,6 +16,10 @@
16
16
  <a href="#search-description" aria-controls="search-description" role="tab" data-toggle="tab" class="nav-link active"><%= t(:'.search_description') %></a>
17
17
  </li>
18
18
 
19
+ <li role="presentation" class="nav-item">
20
+ <a href="#search-group" aria-controls="search-group" role="tab" data-toggle="tab" class="nav-link"><%= t(:'.search_group') %></a>
21
+ </li>
22
+
19
23
  <li role="presentation" class="nav-item">
20
24
  <a href="#search-masthead" aria-controls="search-masthead" role="tab" data-toggle="tab" class="nav-link"><%= t(:'.search_masthead') %></a>
21
25
  </li>
@@ -50,6 +54,14 @@
50
54
  </div>
51
55
  <% end %>
52
56
  </div>
57
+ <div role="tabpanel" class="tab-pane" id="search-group">
58
+ <% if @groups.present? %>
59
+ <p class="instructions"><%= t(:'.group.help') %></p>
60
+ <%= f.collection_check_boxes(:group_ids, @groups, :id, :title, hide_label: true) %>
61
+ <% else %>
62
+ <p class="instructions"><%= t(:'.group.help_no_groups') %></p>
63
+ <% end %>
64
+ </div>
53
65
  <div role="tabpanel" class="tab-pane" id="search-masthead">
54
66
  <%= f.fields_for :masthead, (@search.masthead || @search.build_masthead) do |m| %>
55
67
  <p class="instructions"><%= t(:'.masthead.help') %></p>