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.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/assets/images/spotlight/default_browse_thumbnail.jpg +0 -0
- data/app/assets/javascripts/spotlight/application.js +6 -1
- data/app/assets/javascripts/spotlight/blocks/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/blocks/resources_block.js +7 -4
- data/app/assets/javascripts/spotlight/blocks/solr_documents_base_block.js +108 -0
- data/app/assets/javascripts/spotlight/blocks/solr_documents_block.js +12 -56
- data/app/assets/javascripts/spotlight/blocks/solr_documents_carousel_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_embed_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_features_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_grid_block.js +3 -3
- data/app/assets/javascripts/spotlight/crop.es6 +205 -0
- data/app/assets/javascripts/spotlight/croppable.js +7 -104
- data/app/assets/javascripts/spotlight/iiif.es6 +54 -0
- data/app/assets/javascripts/spotlight/multi_image_selector.js +34 -16
- data/app/assets/javascripts/spotlight/pages.js.erb +1 -1
- data/app/assets/javascripts/spotlight/reindex_monitor.js +5 -1
- data/app/assets/javascripts/spotlight/search_typeahead.js +33 -47
- data/app/assets/javascripts/spotlight/sir-trevor/locales.js +5 -2
- data/app/assets/javascripts/spotlight/zpr_links.js.erb +30 -0
- data/app/assets/stylesheets/spotlight/_croppable.scss +8 -13
- data/app/assets/stylesheets/spotlight/_multi_image_selector.scss +1 -1
- data/app/assets/stylesheets/spotlight/_pages.scss +5 -0
- data/app/assets/stylesheets/spotlight/typeahead.css +0 -1
- data/app/controllers/concerns/spotlight/base.rb +3 -5
- data/app/controllers/spotlight/appearances_controller.rb +6 -4
- data/app/controllers/spotlight/catalog_controller.rb +10 -0
- data/app/controllers/spotlight/contacts_controller.rb +2 -6
- data/app/controllers/spotlight/featured_images_controller.rb +26 -0
- data/app/controllers/spotlight/pages_controller.rb +3 -2
- data/app/controllers/spotlight/resources/iiif_harvester_controller.rb +10 -0
- data/app/controllers/spotlight/resources/upload_controller.rb +4 -3
- data/app/controllers/spotlight/searches_controller.rb +20 -6
- data/app/controllers/spotlight/sites_controller.rb +2 -5
- data/app/helpers/spotlight/application_helper.rb +14 -1
- data/app/helpers/spotlight/crop_helper.rb +37 -0
- data/app/helpers/spotlight/main_app_helpers.rb +13 -0
- data/app/helpers/spotlight/meta_helper.rb +10 -20
- data/app/models/concerns/spotlight/solr_document.rb +1 -2
- data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +1 -23
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +10 -0
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +10 -0
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +5 -0
- data/app/models/spotlight/analytics/ga.rb +1 -1
- data/app/models/spotlight/blacklight_configuration.rb +16 -8
- data/app/models/spotlight/contact.rb +2 -13
- data/app/models/spotlight/contact_image.rb +11 -0
- data/app/models/spotlight/exhibit.rb +11 -8
- data/app/models/spotlight/exhibit_thumbnail.rb +12 -0
- data/app/models/spotlight/feature_page.rb +3 -5
- data/app/models/spotlight/featured_image.rb +28 -9
- data/app/models/spotlight/home_page.rb +2 -0
- data/app/models/spotlight/masthead.rb +5 -11
- data/app/models/spotlight/page.rb +5 -0
- data/app/models/spotlight/reindex_progress.rb +10 -18
- data/app/models/spotlight/reindexing_log_entry.rb +1 -0
- data/app/models/spotlight/resources/iiif_harvester.rb +33 -0
- data/app/models/spotlight/resources/iiif_manifest.rb +211 -0
- data/app/models/spotlight/resources/iiif_service.rb +93 -0
- data/app/models/spotlight/resources/upload.rb +1 -2
- data/app/models/spotlight/search.rb +5 -34
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +79 -0
- data/app/serializers/spotlight/exhibit_export_serializer.rb +9 -41
- data/app/services/spotlight/carrierwave_file_resolver.rb +3 -1
- data/app/services/spotlight/iiif_resource_resolver.rb +73 -0
- data/app/services/spotlight/resources/iiif_builder.rb +17 -0
- data/app/services/spotlight/upload_solr_document_builder.rb +23 -23
- data/app/uploaders/spotlight/attachment_uploader.rb +0 -48
- data/app/uploaders/spotlight/featured_image_uploader.rb +2 -16
- data/app/views/_user_util_links.html.erb +8 -5
- data/app/views/catalog/_save_search.html.erb +4 -2
- data/app/views/layouts/spotlight/spotlight.html.erb +5 -1
- data/app/views/shared/_masthead.html.erb +1 -1
- data/app/views/spotlight/about_pages/_contact_properties.html.erb +1 -1
- data/app/views/spotlight/appearances/edit.html.erb +26 -6
- data/app/views/spotlight/browse/_search.html.erb +1 -1
- data/app/views/spotlight/contacts/_form.html.erb +12 -7
- data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +1 -1
- data/app/views/spotlight/exhibits/_exhibit_card_front.html.erb +2 -2
- data/app/views/spotlight/featured_images/_form.html.erb +12 -15
- data/app/views/spotlight/featured_images/_upload_form.html.erb +6 -12
- data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +3 -3
- data/app/views/spotlight/pages/_form.html.erb +3 -3
- data/app/views/spotlight/pages/edit.html.erb +4 -2
- data/app/views/spotlight/resources/iiif/_form.html.erb +9 -0
- data/app/views/spotlight/searches/_form.html.erb +3 -3
- data/app/views/spotlight/searches/_search.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +4 -2
- data/app/views/spotlight/sites/edit.html.erb +1 -1
- data/config/locales/spotlight.en.yml +31 -6
- data/config/routes.rb +9 -0
- data/db/migrate/20160714144125_add_iiif_urls_to_featured_image.rb +9 -0
- data/db/migrate/20160718194010_add_iiif_url_to_contact.rb +6 -0
- data/db/migrate/20160805143841_add_upload_id_to_resources.rb +6 -0
- data/db/migrate/20170204091234_add_theme_to_spotlight_exhibits.rb +5 -0
- data/lib/generators/spotlight/install_generator.rb +5 -2
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +0 -1
- data/lib/generators/spotlight/templates/spotlight.scss +3 -2
- data/lib/migration/iiif.rb +82 -0
- data/lib/spotlight/engine.rb +22 -10
- data/lib/spotlight/version.rb +1 -1
- data/lib/tasks/spotlight_tasks.rake +10 -0
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/appearances_controller_spec.rb +31 -18
- data/spec/controllers/spotlight/catalog_controller_spec.rb +40 -0
- data/spec/controllers/spotlight/contacts_controller_spec.rb +20 -1
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +2 -6
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +74 -0
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/searches_controller_spec.rb +3 -1
- data/spec/controllers/spotlight/sites_controller_spec.rb +6 -1
- data/spec/examples.txt +1118 -1059
- data/spec/factories/contact_images.rb +6 -0
- data/spec/factories/contacts.rb +4 -1
- data/spec/factories/exhibit_thumbnails.rb +6 -0
- data/spec/factories/exhibits.rb +4 -0
- data/spec/factories/featured_images.rb +1 -0
- data/spec/factories/resources.rb +2 -1
- data/spec/features/add_contacts_spec.rb +5 -5
- data/spec/features/add_iiif_manifest_spec.rb +41 -0
- data/spec/features/add_items_spec.rb +2 -2
- data/spec/features/autocomplete_typeahead_spec.rb +86 -0
- data/spec/features/browse_category_admin_spec.rb +27 -6
- data/spec/features/browse_category_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +3 -3
- data/spec/features/exhibit_masthead_spec.rb +20 -9
- data/spec/features/exhibit_themes_spec.rb +25 -0
- data/spec/features/home_page_spec.rb +1 -1
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +42 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +5 -3
- data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
- data/spec/features/javascript/multi_image_select_spec.rb +5 -6
- data/spec/features/javascript/search_config_admin_spec.rb +1 -1
- data/spec/features/site_masthead_spec.rb +14 -4
- data/spec/fixtures/gk446cj2442-manifest.json +58 -0
- data/spec/fixtures/iiif_responses.rb +274 -0
- data/spec/fixtures/sample_solr_documents.yml +106 -0
- data/spec/helpers/spotlight/crop_helper_spec.rb +9 -0
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +45 -0
- data/spec/helpers/spotlight/meta_helper_spec.rb +2 -15
- data/spec/lib/migration/iiif_spec.rb +70 -0
- data/spec/models/spotlight/blacklight_configuration_spec.rb +17 -5
- data/spec/models/spotlight/contact_image_spec.rb +9 -0
- data/spec/models/spotlight/exhibit_spec.rb +17 -20
- data/spec/models/spotlight/exhibit_thumbnail_spec.rb +8 -0
- data/spec/models/spotlight/featured_image_spec.rb +59 -10
- data/spec/models/spotlight/masthead_spec.rb +33 -17
- data/spec/models/spotlight/page_spec.rb +14 -0
- data/spec/models/spotlight/reindex_progress_spec.rb +22 -73
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +30 -0
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +107 -0
- data/spec/models/spotlight/resources/iiif_service_spec.rb +52 -0
- data/spec/models/spotlight/resources/upload_spec.rb +7 -3
- data/spec/models/spotlight/search_spec.rb +0 -45
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +11 -29
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +123 -0
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +4 -0
- data/spec/routing/spotlight/featured_images_spec.rb +21 -0
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +15 -18
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +90 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/features/test_features_helpers.rb +3 -2
- data/spec/support/stub_iiif_response.rb +24 -0
- data/spec/support/views/test_view_helpers.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/uploaders/spotlight/attachment_uploader_spec.rb +24 -0
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +30 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +9 -5
- data/spec/views/shared/_masthead.html.erb_spec.rb +5 -2
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +4 -7
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +7 -2
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +3 -1
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +3 -1
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +3 -2
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +3 -2
- data/vendor/assets/javascripts/leaflet-areaselect.js +184 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +230 -0
- data/vendor/assets/javascripts/leaflet.js +9 -0
- data/vendor/assets/javascripts/polyfill.min.js +4 -0
- data/vendor/assets/stylesheets/leaflet-areaselect.css +15 -0
- data/vendor/assets/stylesheets/leaflet.css +624 -0
- metadata +136 -62
- data/app/assets/javascripts/spotlight/jcrop.js +0 -1696
- data/app/helpers/spotlight/jcrop_helper.rb +0 -37
- data/app/models/concerns/spotlight/default_thumbnailable.rb +0 -25
- data/app/models/concerns/spotlight/image_derivatives.rb +0 -58
- data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +0 -55
- data/app/uploaders/spotlight/avatar_uploader.rb +0 -24
- data/app/uploaders/spotlight/item_uploader.rb +0 -25
- data/app/uploaders/spotlight/masthead_uploader.rb +0 -22
- data/spec/helpers/spotlight/jcrop_helper_spec.rb +0 -33
- data/spec/models/spotlight/default_thumbnailable_concern_spec.rb +0 -16
- data/spec/models/spotlight/image_derivatives_spec.rb +0 -15
- data/spec/models/spotlight/solr_document/spotlight_images_spec.rb +0 -42
- data/spec/uploaders/spotlight/item_uploader_spec.rb +0 -67
@@ -6,7 +6,6 @@ module Spotlight
|
|
6
6
|
|
7
7
|
include Spotlight::SolrDocument::ActiveModelConcern
|
8
8
|
include Spotlight::SolrDocument::Finder
|
9
|
-
include Spotlight::SolrDocument::SpotlightImages
|
10
9
|
include GlobalID::Identification
|
11
10
|
|
12
11
|
included do
|
@@ -74,7 +73,7 @@ module Spotlight
|
|
74
73
|
|
75
74
|
def update_exhibit_resource(resource_attributes)
|
76
75
|
return unless resource_attributes && resource_attributes['url']
|
77
|
-
uploaded_resource.update
|
76
|
+
uploaded_resource.upload.update image: resource_attributes['url']
|
78
77
|
end
|
79
78
|
|
80
79
|
def reindex
|
@@ -17,29 +17,7 @@ module Spotlight
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_openseadragon(*_args)
|
20
|
-
|
21
|
-
{ LegacyImagePyramidTileSource.new(
|
22
|
-
image_url,
|
23
|
-
width: self[:spotlight_full_image_width_ssm][index],
|
24
|
-
height: self[:spotlight_full_image_height_ssm][index]
|
25
|
-
) => {} }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
##
|
30
|
-
# Stub legacy image pyramid property generators
|
31
|
-
class LegacyImagePyramidTileSource
|
32
|
-
attr_reader :to_tilesource
|
33
|
-
def initialize(url, dimensions = {})
|
34
|
-
@to_tilesource = {
|
35
|
-
type: 'legacy-image-pyramid',
|
36
|
-
levels: [{
|
37
|
-
url: url,
|
38
|
-
width: dimensions[:width],
|
39
|
-
height: dimensions[:height]
|
40
|
-
}]
|
41
|
-
}
|
42
|
-
end
|
20
|
+
[uploaded_resource.upload.iiif_tilesource] if uploaded_resource && uploaded_resource.upload
|
43
21
|
end
|
44
22
|
end
|
45
23
|
end
|
@@ -28,6 +28,16 @@ module SirTrevorRails
|
|
28
28
|
def display_item_counts?
|
29
29
|
send(:'display-item-counts') == 'true'
|
30
30
|
end
|
31
|
+
|
32
|
+
def as_json
|
33
|
+
result = super
|
34
|
+
|
35
|
+
result[:data][:item].each do |_k, v|
|
36
|
+
v['thumbnail_image_url'] = parent.exhibit.searches.find(v['id']).thumbnail_image_url
|
37
|
+
end
|
38
|
+
|
39
|
+
result
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
@@ -18,6 +18,16 @@ module SirTrevorRails
|
|
18
18
|
def pages?
|
19
19
|
!pages.empty?
|
20
20
|
end
|
21
|
+
|
22
|
+
def as_json
|
23
|
+
result = super
|
24
|
+
|
25
|
+
result[:data][:item].each do |_k, v|
|
26
|
+
v['thumbnail_image_url'] = parent.exhibit.pages.find(v['id']).thumbnail_image_url
|
27
|
+
end
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -16,6 +16,7 @@ module SirTrevorRails
|
|
16
16
|
|
17
17
|
items.each do |i|
|
18
18
|
document = documents.detect { |doc| doc.id == i[:id] }
|
19
|
+
i[:iiif_tilesource_base] = i.fetch(:iiif_tilesource, '').sub('/info.json', '')
|
19
20
|
yield i, document if document
|
20
21
|
end
|
21
22
|
end
|
@@ -40,6 +41,10 @@ module SirTrevorRails
|
|
40
41
|
secondary_caption_field.present? && send(:'show-secondary-caption')
|
41
42
|
end
|
42
43
|
|
44
|
+
def zpr_link?
|
45
|
+
zpr_link == 'true'
|
46
|
+
end
|
47
|
+
|
43
48
|
def primary_caption_field
|
44
49
|
val = send(:'primary-caption-field')
|
45
50
|
val unless val.blank?
|
@@ -17,7 +17,6 @@ module Spotlight
|
|
17
17
|
serialize :document_index_view_types, Array
|
18
18
|
|
19
19
|
include Spotlight::BlacklightConfigurationDefaults
|
20
|
-
include Spotlight::ImageDerivatives
|
21
20
|
|
22
21
|
delegate :document_model, to: :default_blacklight_config
|
23
22
|
|
@@ -96,6 +95,10 @@ module Spotlight
|
|
96
95
|
else
|
97
96
|
set_index_field_defaults(v)
|
98
97
|
end
|
98
|
+
|
99
|
+
v.immutable = Blacklight::OpenStructWithHashAccess.new(v.immutable)
|
100
|
+
v.merge! v.immutable.to_h.symbolize_keys
|
101
|
+
|
99
102
|
v.upstream_if = v.if unless v.if.nil?
|
100
103
|
v.if = :field_enabled? unless v.if == false
|
101
104
|
|
@@ -114,6 +117,9 @@ module Spotlight
|
|
114
117
|
set_show_field_defaults(v)
|
115
118
|
end
|
116
119
|
|
120
|
+
v.immutable = Blacklight::OpenStructWithHashAccess.new(v.immutable)
|
121
|
+
v.merge! v.immutable.to_h.symbolize_keys
|
122
|
+
|
117
123
|
v.upstream_if = v.if unless v.if.nil?
|
118
124
|
v.if = :field_enabled? unless v.if == false
|
119
125
|
|
@@ -162,6 +168,7 @@ module Spotlight
|
|
162
168
|
v.upstream_if = v.if unless v.if.nil?
|
163
169
|
v.enabled = v.show
|
164
170
|
v.if = :field_enabled? unless v.if == false
|
171
|
+
v.upstream_if = nil if v.upstream_if == v.if
|
165
172
|
v.normalize! config
|
166
173
|
v.validate!
|
167
174
|
end
|
@@ -204,6 +211,8 @@ module Spotlight
|
|
204
211
|
field = Blacklight::Configuration::FacetField.new x.configuration.merge(
|
205
212
|
key: x.field, field: x.solr_field, show: false, custom_field: true
|
206
213
|
)
|
214
|
+
field.if = :field_enabled?
|
215
|
+
field.enabled = false
|
207
216
|
[x.field, field]
|
208
217
|
end]
|
209
218
|
end
|
@@ -295,13 +304,12 @@ module Spotlight
|
|
295
304
|
end
|
296
305
|
|
297
306
|
def default_autocomplete_field_list(config)
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
end
|
307
|
+
[
|
308
|
+
config.document_model.unique_key,
|
309
|
+
config.view_config(:show).title_field,
|
310
|
+
config.index.thumbnail_field || Spotlight::Engine.config.thumbnail_field,
|
311
|
+
Spotlight::Engine.config.iiif_manifest_field
|
312
|
+
].flatten.join(' ')
|
305
313
|
end
|
306
314
|
|
307
315
|
# rubocop:disable Style/AccessorMethodName
|
@@ -10,24 +10,13 @@ module Spotlight
|
|
10
10
|
extend FriendlyId
|
11
11
|
friendly_id :name, use: [:slugged, :scoped, :finders], scope: :exhibit
|
12
12
|
|
13
|
-
|
13
|
+
belongs_to :avatar, class_name: 'Spotlight::ContactImage', dependent: :destroy
|
14
|
+
accepts_nested_attributes_for :avatar, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }
|
14
15
|
|
15
16
|
before_save do
|
16
17
|
self.contact_info = contact_info.symbolize_keys
|
17
18
|
end
|
18
19
|
|
19
|
-
## carrierwave-crop doesn't want to store the crop points. we do.
|
20
|
-
# so instead of this:
|
21
|
-
# crop_uploaded :avatar ## Add this
|
22
|
-
# we do this:
|
23
|
-
after_save do
|
24
|
-
if avatar.present?
|
25
|
-
avatar.cache! unless avatar.cached?
|
26
|
-
avatar.store!
|
27
|
-
recreate_avatar_versions
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
20
|
before_save on: :create do
|
32
21
|
self.show_in_sidebar = true if show_in_sidebar.nil?
|
33
22
|
end
|
@@ -17,6 +17,7 @@ module Spotlight
|
|
17
17
|
friendly_id :title, use: [:slugged, :finders]
|
18
18
|
validates :title, presence: true
|
19
19
|
validates :slug, uniqueness: true
|
20
|
+
validates :theme, inclusion: { in: Spotlight::Engine.config.exhibit_themes }, allow_blank: true
|
20
21
|
|
21
22
|
acts_as_tagger
|
22
23
|
acts_as_taggable
|
@@ -46,16 +47,16 @@ module Spotlight
|
|
46
47
|
|
47
48
|
belongs_to :site
|
48
49
|
belongs_to :masthead, dependent: :destroy
|
49
|
-
belongs_to :thumbnail, class_name: 'Spotlight::
|
50
|
+
belongs_to :thumbnail, class_name: 'Spotlight::ExhibitThumbnail', dependent: :destroy
|
50
51
|
|
51
52
|
accepts_nested_attributes_for :about_pages, :attachments, :contacts, :custom_fields, :feature_pages,
|
52
53
|
:main_navigations, :owned_taggings, :resources, :searches, :solr_document_sidecars
|
53
|
-
accepts_nested_attributes_for :blacklight_configuration, :home_page, :
|
54
|
+
accepts_nested_attributes_for :blacklight_configuration, :home_page, :filters, update_only: true
|
55
|
+
accepts_nested_attributes_for :masthead, :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }
|
54
56
|
accepts_nested_attributes_for :contact_emails, reject_if: proc { |attr| attr['email'].blank? }
|
55
57
|
accepts_nested_attributes_for :roles, allow_destroy: true, reject_if: proc { |attr| attr['user_key'].blank? && attr['id'].blank? }
|
56
58
|
|
57
59
|
before_save :sanitize_description, if: :description_changed?
|
58
|
-
include Spotlight::DefaultThumbnailable
|
59
60
|
|
60
61
|
def main_about_page
|
61
62
|
@main_about_page ||= about_pages.published.first
|
@@ -92,16 +93,12 @@ module Spotlight
|
|
92
93
|
blacklight_config.search_fields.any? { |_k, v| v.enabled && v.include_in_simple_select != false }
|
93
94
|
end
|
94
95
|
|
95
|
-
def set_default_thumbnail
|
96
|
-
self.thumbnail ||= searches.first.try(:thumbnail)
|
97
|
-
end
|
98
|
-
|
99
96
|
def requested_by
|
100
97
|
roles.first.user if roles.first
|
101
98
|
end
|
102
99
|
|
103
100
|
def reindex_progress
|
104
|
-
@reindex_progress ||= ReindexProgress.new(
|
101
|
+
@reindex_progress ||= ReindexProgress.new(current_reindexing_log_entry)
|
105
102
|
end
|
106
103
|
|
107
104
|
protected
|
@@ -113,5 +110,11 @@ module Spotlight
|
|
113
110
|
def new_reindexing_log_entry(user = nil)
|
114
111
|
Spotlight::ReindexingLogEntry.create(exhibit: self, user: user, items_reindexed_count: 0, job_status: 'unstarted')
|
115
112
|
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def current_reindexing_log_entry
|
117
|
+
reindexing_log_entries.started_or_completed.first || reindexing_log_entries.build
|
118
|
+
end
|
116
119
|
end
|
117
120
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Spotlight
|
2
|
+
##
|
3
|
+
# A simple sub-class of FeaturedImage to store the
|
4
|
+
# square thumbnail used on the exhibits landing page
|
5
|
+
class ExhibitThumbnail < Spotlight::FeaturedImage
|
6
|
+
private
|
7
|
+
|
8
|
+
def image_size
|
9
|
+
Spotlight::Engine.config.featured_image_square_size
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -9,7 +9,9 @@ module Spotlight
|
|
9
9
|
belongs_to :parent_page, class_name: 'Spotlight::FeaturePage'
|
10
10
|
|
11
11
|
accepts_nested_attributes_for :child_pages
|
12
|
-
|
12
|
+
|
13
|
+
belongs_to :thumbnail, class_name: 'Spotlight::FeaturedImage', dependent: :destroy
|
14
|
+
accepts_nested_attributes_for :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }
|
13
15
|
|
14
16
|
before_validation unless: :top_level_page? do
|
15
17
|
self.exhibit = top_level_page_or_self.exhibit
|
@@ -18,9 +20,5 @@ module Spotlight
|
|
18
20
|
def display_sidebar?
|
19
21
|
child_pages.published.present? || display_sidebar
|
20
22
|
end
|
21
|
-
|
22
|
-
def thumbnail_image_url
|
23
|
-
thumbnail.image.thumb.url if thumbnail && thumbnail.image
|
24
|
-
end
|
25
23
|
end
|
26
24
|
end
|
@@ -4,20 +4,24 @@ module Spotlight
|
|
4
4
|
class FeaturedImage < ActiveRecord::Base
|
5
5
|
mount_uploader :image, Spotlight::FeaturedImageUploader
|
6
6
|
|
7
|
-
before_validation :set_image_from_uploaded_resource
|
8
|
-
|
9
7
|
after_save do
|
10
8
|
if image.present?
|
11
9
|
image.cache! unless image.cached?
|
12
10
|
image.store!
|
13
|
-
recreate_image_versions
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
14
|
+
after_create :set_tilesource_from_uploaded_resource
|
15
|
+
|
16
|
+
def iiif_url
|
17
|
+
return unless iiif_service_base.present?
|
18
|
+
[iiif_service_base, iiif_region || 'full', image_size.join(','), '0', 'default.jpg'].join('/')
|
19
|
+
end
|
20
|
+
|
21
|
+
# This is used to fetch images given the URL field in the CSV uploads
|
22
|
+
# If the image is local, this step will fail, which is okay since the only
|
23
|
+
# consumer is CSV uploads and the URL is intended to be remote
|
17
24
|
def remote_image_url=(url)
|
18
|
-
# if the image is local, this step will fail..
|
19
|
-
# hopefully it's local because it's an uploaded resource, and we'll
|
20
|
-
# catch is in before_validation..
|
21
25
|
super url unless url.starts_with? '/'
|
22
26
|
end
|
23
27
|
|
@@ -37,11 +41,26 @@ module Spotlight
|
|
37
41
|
nil
|
38
42
|
end
|
39
43
|
|
44
|
+
def file_present?
|
45
|
+
image.file.present?
|
46
|
+
end
|
47
|
+
|
40
48
|
private
|
41
49
|
|
42
|
-
def
|
43
|
-
return
|
44
|
-
|
50
|
+
def set_tilesource_from_uploaded_resource
|
51
|
+
return if iiif_tilesource
|
52
|
+
riiif = Riiif::Engine.routes.url_helpers
|
53
|
+
self.iiif_tilesource = riiif.info_path(id)
|
54
|
+
save
|
55
|
+
end
|
56
|
+
|
57
|
+
def image_size
|
58
|
+
Spotlight::Engine.config.featured_image_thumb_size
|
59
|
+
end
|
60
|
+
|
61
|
+
def iiif_service_base
|
62
|
+
return unless iiif_tilesource
|
63
|
+
iiif_tilesource.sub('/info.json', '')
|
45
64
|
end
|
46
65
|
end
|
47
66
|
end
|
@@ -8,6 +8,8 @@ module Spotlight
|
|
8
8
|
before_save :publish
|
9
9
|
before_create :default_content
|
10
10
|
|
11
|
+
accepts_nested_attributes_for :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }
|
12
|
+
|
11
13
|
class << self
|
12
14
|
def default_title_text
|
13
15
|
I18n.t('spotlight.pages.index.home_pages.title')
|
@@ -2,20 +2,14 @@ module Spotlight
|
|
2
2
|
##
|
3
3
|
# Exhibit and browse category mastheads
|
4
4
|
class Masthead < Spotlight::FeaturedImage
|
5
|
-
mount_uploader :image, Spotlight::MastheadUploader
|
6
|
-
|
7
5
|
def display?
|
8
|
-
display &&
|
6
|
+
display && iiif_url.present?
|
9
7
|
end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# hopefully it's local because it's an uploaded resource, and we'll
|
16
|
-
# catch is in before_validation..
|
17
|
-
def remote_image_url=(url)
|
18
|
-
super url unless url.starts_with? '/'
|
9
|
+
private
|
10
|
+
|
11
|
+
def image_size
|
12
|
+
[1800, 180]
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
@@ -55,6 +55,11 @@ module Spotlight
|
|
55
55
|
nil
|
56
56
|
end
|
57
57
|
|
58
|
+
def thumbnail_image_url
|
59
|
+
return unless thumbnail && thumbnail.iiif_url
|
60
|
+
thumbnail.iiif_url
|
61
|
+
end
|
62
|
+
|
58
63
|
# explicitly set the partial path so that
|
59
64
|
# we don't have to duplicate view logic.
|
60
65
|
def to_partial_path
|
@@ -2,46 +2,41 @@ module Spotlight
|
|
2
2
|
##
|
3
3
|
# ReindexProgress is a class that models the progress of reindexing a list of resources
|
4
4
|
class ReindexProgress
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :current_log_entry
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
delegate :updated_at, to: :current_log_entry
|
8
|
+
|
9
|
+
def initialize(current_log_entry)
|
10
|
+
@current_log_entry = current_log_entry
|
9
11
|
end
|
10
12
|
|
11
13
|
def recently_in_progress?
|
12
|
-
return false if current_log_entry.blank?
|
13
14
|
return true if current_log_entry.in_progress?
|
14
15
|
|
15
16
|
current_log_entry.end_time.present? && (current_log_entry.end_time > Spotlight::Engine.config.reindex_progress_window.minutes.ago)
|
16
17
|
end
|
17
18
|
|
18
19
|
def started_at
|
19
|
-
current_log_entry.
|
20
|
-
end
|
21
|
-
|
22
|
-
def updated_at
|
23
|
-
current_log_entry.try(:updated_at)
|
20
|
+
current_log_entry.start_time
|
24
21
|
end
|
25
22
|
|
26
23
|
def finished?
|
27
|
-
return false if current_log_entry.blank?
|
28
24
|
current_log_entry.succeeded? || current_log_entry.failed?
|
29
25
|
end
|
30
26
|
|
31
27
|
def finished_at
|
32
|
-
current_log_entry.
|
28
|
+
current_log_entry.end_time
|
33
29
|
end
|
34
30
|
|
35
31
|
def total
|
36
|
-
current_log_entry.
|
32
|
+
current_log_entry.items_reindexed_estimate
|
37
33
|
end
|
38
34
|
|
39
35
|
def completed
|
40
|
-
current_log_entry.
|
36
|
+
current_log_entry.items_reindexed_count
|
41
37
|
end
|
42
38
|
|
43
39
|
def errored?
|
44
|
-
return false if current_log_entry.blank?
|
45
40
|
current_log_entry.failed?
|
46
41
|
end
|
47
42
|
|
@@ -53,16 +48,13 @@ module Spotlight
|
|
53
48
|
updated_at: localized_updated_time,
|
54
49
|
total: total,
|
55
50
|
completed: completed,
|
51
|
+
finished: finished?,
|
56
52
|
errored: errored?
|
57
53
|
}
|
58
54
|
end
|
59
55
|
|
60
56
|
private
|
61
57
|
|
62
|
-
def current_log_entry
|
63
|
-
exhibit.reindexing_log_entries.where.not(job_status: 'unstarted').first
|
64
|
-
end
|
65
|
-
|
66
58
|
def localized_start_time
|
67
59
|
return unless started_at
|
68
60
|
I18n.l(started_at, format: :short)
|