blacklight-spotlight 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/spotlight/catalog.rb +1 -0
- data/app/controllers/spotlight/browse_controller.rb +1 -0
- data/app/controllers/spotlight/contact_forms_controller.rb +1 -0
- data/app/controllers/spotlight/pages_controller.rb +1 -0
- data/app/helpers/spotlight/languages_helper.rb +1 -0
- data/app/models/concerns/spotlight/exhibit_analytics.rb +1 -0
- data/app/models/concerns/spotlight/solr_document.rb +1 -0
- data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +1 -0
- data/app/models/sir_trevor_rails/blocks/textable.rb +1 -0
- data/app/models/spotlight/analytics/ga.rb +5 -5
- data/app/models/spotlight/blacklight_configuration.rb +2 -0
- data/app/models/spotlight/featured_image.rb +3 -0
- data/app/models/spotlight/page.rb +3 -0
- data/app/models/spotlight/page_configurations.rb +1 -0
- data/app/models/spotlight/reindex_progress.rb +3 -0
- data/app/models/spotlight/resource.rb +1 -0
- data/app/models/spotlight/resources/iiif_harvester.rb +1 -0
- data/app/models/spotlight/resources/iiif_manifest.rb +8 -0
- data/app/models/spotlight/search.rb +1 -0
- data/app/models/spotlight/solr_document_sidecar.rb +1 -1
- data/app/serializers/spotlight/exhibit_export_serializer.rb +1 -0
- data/app/services/spotlight/carrierwave_file_resolver.rb +1 -0
- data/app/services/spotlight/iiif_resource_resolver.rb +13 -10
- data/app/services/spotlight/solr_document_builder.rb +2 -0
- data/db/migrate/20180822233601_change_type_of_taggings_taggable.rb +8 -0
- data/lib/generators/spotlight/install_generator.rb +0 -4
- data/lib/migration/iiif.rb +6 -0
- data/lib/spotlight/upload_field_config.rb +4 -2
- data/lib/spotlight/version.rb +1 -1
- data/spec/examples.txt +1282 -1295
- data/spec/features/exhibits/translation_editing_spec.rb +9 -9
- data/spec/features/javascript/edit_in_place_spec.rb +1 -0
- data/spec/models/solr_document_spec.rb +3 -2
- data/spec/models/spotlight/blacklight_configuration_spec.rb +1 -1
- data/spec/models/spotlight/exhibit_spec.rb +1 -1
- data/spec/models/spotlight/page_spec.rb +1 -1
- data/spec/models/spotlight/resources/upload_spec.rb +4 -3
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +13 -0
- data/spec/support/features/capybara_default_max_wait_metadata_helper.rb +2 -0
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +2 -2
- metadata +11 -12
- data/lib/generators/spotlight/increase_paper_trail_column_size_generator.rb +0 -17
- data/lib/generators/spotlight/templates/migrations/20180814221815_change_paper_trail_versions_object_column_to_medium_text.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4652ccafaff959547b28737b36d4b072a0b743e8
|
|
4
|
+
data.tar.gz: 40a4c98ab046b271b2d353b03aeebacbc3c3f651
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de8c2d7f707973d768ad438b0c8388c6c51816efbc321602973a305fb9db0dc02c2d743fcf115c847cfe7faba331edcd770ac7cc1a5e8c9e2dd4f192d0997e4a
|
|
7
|
+
data.tar.gz: '029ba01acc829eba450a6960869bae7da2ad0c56f098bd9db41bc50864652cb1756cec34a65a7288811d0f73e61995979978aa6c8eb9cbdb3e7cb16437510fdf'
|
|
@@ -14,6 +14,7 @@ module Spotlight
|
|
|
14
14
|
# if the user is a curator
|
|
15
15
|
def add_facet_visibility_field
|
|
16
16
|
return unless current_exhibit && can?(:curate, current_exhibit)
|
|
17
|
+
|
|
17
18
|
blacklight_config.add_facet_field 'exhibit_visibility',
|
|
18
19
|
label: I18n.t(:'spotlight.catalog.facets.exhibit_visibility.label'),
|
|
19
20
|
query: {
|
|
@@ -4,6 +4,7 @@ module Spotlight
|
|
|
4
4
|
module ExhibitAnalytics
|
|
5
5
|
def analytics(start_date = 1.month, path = nil)
|
|
6
6
|
return OpenStruct.new unless analytics_provider && analytics_provider.enabled?
|
|
7
|
+
|
|
7
8
|
@analytics ||= {}
|
|
8
9
|
@analytics[start_date] ||= begin
|
|
9
10
|
analytics_provider.exhibit_data(path || self, start_date: start_date.ago)
|
|
@@ -24,11 +24,11 @@ module Spotlight
|
|
|
24
24
|
|
|
25
25
|
def self.user(scope = 'https://www.googleapis.com/auth/analytics.readonly')
|
|
26
26
|
@user ||= begin
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
Legato::User.new(oauth_token(scope))
|
|
28
|
+
rescue => e
|
|
29
|
+
Rails.logger.info(e)
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def self.site
|
|
@@ -331,12 +331,14 @@ module Spotlight
|
|
|
331
331
|
# Check to see whether config.view.foobar.title_only_by_default is available
|
|
332
332
|
def title_only_by_default?(view)
|
|
333
333
|
return false if [:show, :enabled].include?(view)
|
|
334
|
+
|
|
334
335
|
title_only = default_blacklight_config.view.send(:[], view).try(:title_only_by_default)
|
|
335
336
|
title_only.nil? ? false : title_only
|
|
336
337
|
end
|
|
337
338
|
|
|
338
339
|
def set_show_field_defaults(field)
|
|
339
340
|
return unless index_fields.blank?
|
|
341
|
+
|
|
340
342
|
views = default_blacklight_config.view.keys
|
|
341
343
|
field.merge! Hash[views.map { |v| [v, false] }]
|
|
342
344
|
field.enabled = true
|
|
@@ -15,6 +15,7 @@ module Spotlight
|
|
|
15
15
|
|
|
16
16
|
def iiif_url
|
|
17
17
|
return unless iiif_service_base.present?
|
|
18
|
+
|
|
18
19
|
[iiif_service_base, iiif_region || 'full', image_size.join(','), '0', 'default.jpg'].join('/')
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -49,6 +50,7 @@ module Spotlight
|
|
|
49
50
|
|
|
50
51
|
def set_tilesource_from_uploaded_resource
|
|
51
52
|
return if iiif_tilesource
|
|
53
|
+
|
|
52
54
|
riiif = Riiif::Engine.routes.url_helpers
|
|
53
55
|
self.iiif_tilesource = riiif.info_path(id)
|
|
54
56
|
save
|
|
@@ -60,6 +62,7 @@ module Spotlight
|
|
|
60
62
|
|
|
61
63
|
def iiif_service_base
|
|
62
64
|
return unless iiif_tilesource
|
|
65
|
+
|
|
63
66
|
iiif_tilesource.sub('/info.json', '')
|
|
64
67
|
end
|
|
65
68
|
end
|
|
@@ -70,6 +70,7 @@ module Spotlight
|
|
|
70
70
|
|
|
71
71
|
def thumbnail_image_url
|
|
72
72
|
return unless thumbnail && thumbnail.iiif_url
|
|
73
|
+
|
|
73
74
|
thumbnail.iiif_url
|
|
74
75
|
end
|
|
75
76
|
|
|
@@ -113,6 +114,7 @@ module Spotlight
|
|
|
113
114
|
|
|
114
115
|
def updated_after?(other_page)
|
|
115
116
|
return false unless other_page
|
|
117
|
+
|
|
116
118
|
updated_at > other_page.updated_at
|
|
117
119
|
end
|
|
118
120
|
|
|
@@ -139,6 +141,7 @@ module Spotlight
|
|
|
139
141
|
def update_translated_pages_weights_and_parent_page
|
|
140
142
|
return unless locale.to_sym == I18n.default_locale
|
|
141
143
|
return unless saved_change_to_weight? || saved_change_to_parent_page_id?
|
|
144
|
+
|
|
142
145
|
update_params = {}
|
|
143
146
|
update_params[:weight] = weight if saved_change_to_weight?
|
|
144
147
|
update_params[:parent_page_id] = parent_page_id if saved_change_to_parent_page_id?
|
|
@@ -57,16 +57,19 @@ module Spotlight
|
|
|
57
57
|
|
|
58
58
|
def localized_start_time
|
|
59
59
|
return unless started_at
|
|
60
|
+
|
|
60
61
|
I18n.l(started_at, format: :short)
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
def localized_finish_time
|
|
64
65
|
return unless finished_at
|
|
66
|
+
|
|
65
67
|
I18n.l(finished_at, format: :short)
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def localized_updated_time
|
|
69
71
|
return unless updated_at
|
|
72
|
+
|
|
70
73
|
I18n.l(updated_at, format: :short)
|
|
71
74
|
end
|
|
72
75
|
end
|
|
@@ -54,11 +54,13 @@ module Spotlight
|
|
|
54
54
|
|
|
55
55
|
def add_thumbnail_url
|
|
56
56
|
return unless thumbnail_field && manifest['thumbnail'].present?
|
|
57
|
+
|
|
57
58
|
solr_hash[thumbnail_field] = manifest['thumbnail']['@id']
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def add_full_image_urls
|
|
61
62
|
return unless full_image_field && full_image_url
|
|
63
|
+
|
|
62
64
|
solr_hash[full_image_field] = full_image_url
|
|
63
65
|
end
|
|
64
66
|
|
|
@@ -82,10 +84,12 @@ module Spotlight
|
|
|
82
84
|
def manifest_metadata
|
|
83
85
|
metadata = metadata_class.new(manifest).to_solr
|
|
84
86
|
return {} unless metadata.present?
|
|
87
|
+
|
|
85
88
|
create_sidecars_for(*metadata.keys)
|
|
86
89
|
|
|
87
90
|
metadata.each_with_object({}) do |(key, value), hash|
|
|
88
91
|
next unless (field = exhibit_custom_fields[key])
|
|
92
|
+
|
|
89
93
|
hash[field.field] = value
|
|
90
94
|
end
|
|
91
95
|
end
|
|
@@ -93,6 +97,7 @@ module Spotlight
|
|
|
93
97
|
def json_ld_value(value)
|
|
94
98
|
return value['@value'] if value.is_a?(Hash)
|
|
95
99
|
return value.find { |v| v['@language'] == default_json_ld_language }.try(:[], '@value') if value.is_a?(Array)
|
|
100
|
+
|
|
96
101
|
value
|
|
97
102
|
end
|
|
98
103
|
|
|
@@ -119,6 +124,7 @@ module Spotlight
|
|
|
119
124
|
def image_urls
|
|
120
125
|
@image_urls ||= resources.map do |resource|
|
|
121
126
|
next unless resource && !resource.service.empty?
|
|
127
|
+
|
|
122
128
|
image_url = resource.service['@id']
|
|
123
129
|
image_url << '/info.json' unless image_url.downcase.ends_with?('/info.json')
|
|
124
130
|
image_url
|
|
@@ -201,6 +207,7 @@ module Spotlight
|
|
|
201
207
|
|
|
202
208
|
metadata.each_with_object({}) do |md, hash|
|
|
203
209
|
next unless md['label'] && md['value']
|
|
210
|
+
|
|
204
211
|
hash[md['label']] ||= []
|
|
205
212
|
hash[md['label']] += Array(md['value'])
|
|
206
213
|
end
|
|
@@ -210,6 +217,7 @@ module Spotlight
|
|
|
210
217
|
manifest_fields.each_with_object({}) do |field, hash|
|
|
211
218
|
next unless manifest.respond_to?(field) &&
|
|
212
219
|
manifest.send(field).present?
|
|
220
|
+
|
|
213
221
|
hash[field.capitalize] ||= []
|
|
214
222
|
hash[field.capitalize] += Array(manifest.send(field))
|
|
215
223
|
end
|
|
@@ -72,7 +72,7 @@ module Spotlight
|
|
|
72
72
|
field_name = field.field_name.to_s
|
|
73
73
|
next unless configured_fields && configured_fields[field_name].present?
|
|
74
74
|
|
|
75
|
-
solr_fields = Array(field.solr_field || field.field_name)
|
|
75
|
+
solr_fields = field.solr_fields || Array(field.solr_field || field.field_name)
|
|
76
76
|
|
|
77
77
|
solr_fields.each do |solr_field|
|
|
78
78
|
solr_hash[solr_field] = configured_fields[field_name]
|
|
@@ -12,6 +12,7 @@ module Spotlight
|
|
|
12
12
|
def resolve!
|
|
13
13
|
resource.iiif_tilesource = updated_tilesource
|
|
14
14
|
return resource.save if resource.changed?
|
|
15
|
+
|
|
15
16
|
Rails.logger.info("#{self.class.name} resolved #{iiif_manifest_url}, but nothing changed.")
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -29,6 +30,7 @@ module Spotlight
|
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
raise(ManifestError, "No image with @id #{iiif_image_id} found in #{iiif_manifest_url}") unless new_image
|
|
33
|
+
|
|
32
34
|
new_image
|
|
33
35
|
end
|
|
34
36
|
|
|
@@ -38,6 +40,7 @@ module Spotlight
|
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
raise(ManifestError, "No canvas with @id #{iiif_canvas_id} found in #{iiif_manifest_url}") unless new_canvas
|
|
43
|
+
|
|
41
44
|
new_canvas
|
|
42
45
|
end
|
|
43
46
|
|
|
@@ -52,20 +55,20 @@ module Spotlight
|
|
|
52
55
|
|
|
53
56
|
def response
|
|
54
57
|
@response ||= begin
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
Faraday.get(iiif_manifest_url).body
|
|
59
|
+
rescue Faraday::Error => e
|
|
60
|
+
Rails.logger.warn("#{self.class.name} failed to fetch #{iiif_manifest_url} with: #{e}")
|
|
61
|
+
'{}'
|
|
62
|
+
end
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
def manifest
|
|
63
66
|
@manifest ||= begin
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
JSON.parse(response)
|
|
68
|
+
rescue JSON::ParserError => e
|
|
69
|
+
Rails.logger.warn("#{self.class.name} failed to parse #{iiif_manifest_url} with: #{e}")
|
|
70
|
+
{}
|
|
71
|
+
end
|
|
69
72
|
end
|
|
70
73
|
|
|
71
74
|
class ManifestError < RuntimeError; end
|
|
@@ -13,6 +13,7 @@ module Spotlight
|
|
|
13
13
|
def documents_to_index
|
|
14
14
|
data = to_solr
|
|
15
15
|
return [] if data.blank?
|
|
16
|
+
|
|
16
17
|
data &&= [data] if data.is_a? Hash
|
|
17
18
|
|
|
18
19
|
return to_enum(:documents_to_index) { data.size } unless block_given?
|
|
@@ -51,6 +52,7 @@ module Spotlight
|
|
|
51
52
|
# @returns [#to_solr] something that responds to `to_solr'
|
|
52
53
|
def exhibit_solr_doc(id)
|
|
53
54
|
return NilSolrDocument unless document_model || id.present?
|
|
55
|
+
|
|
54
56
|
document_model.build_for_exhibit(id, exhibit, resource: resource)
|
|
55
57
|
end
|
|
56
58
|
|
data/lib/migration/iiif.rb
CHANGED
|
@@ -49,11 +49,13 @@ module Migration
|
|
|
49
49
|
# as copy the file over to the correct directory given the new class name
|
|
50
50
|
def copy_exhibit_thumbnail_from_featured_image(image)
|
|
51
51
|
return unless Spotlight::Exhibit.where(thumbnail_id: image.id).any?
|
|
52
|
+
|
|
52
53
|
filename = image.read_attribute_before_type_cast('image')
|
|
53
54
|
filepath = "public/#{image.image.store_dir}/#{filename}"
|
|
54
55
|
image.becomes!(Spotlight::ExhibitThumbnail)
|
|
55
56
|
image.save
|
|
56
57
|
return unless filename.present? && File.exist?(filepath)
|
|
58
|
+
|
|
57
59
|
old_file = File.new(filepath)
|
|
58
60
|
# AR + STI seems to require that we re-query for this
|
|
59
61
|
# otherwise we get an association miss-match
|
|
@@ -66,6 +68,7 @@ module Migration
|
|
|
66
68
|
filename = contact.read_attribute_before_type_cast('avatar')
|
|
67
69
|
filepath = "public/uploads/spotlight/contact/avatar/#{contact.id}/#{filename}"
|
|
68
70
|
return unless filename.present? && File.exist?(filepath)
|
|
71
|
+
|
|
69
72
|
old_file = File.new(filepath)
|
|
70
73
|
image = contact.create_avatar { |i| i.image.store!(old_file) }
|
|
71
74
|
iiif_tilesource = riiif.info_path(image.id)
|
|
@@ -75,9 +78,11 @@ module Migration
|
|
|
75
78
|
|
|
76
79
|
def copy_upload_to_featured_image(upload)
|
|
77
80
|
return unless upload.exhibit # We need exhibit context to re-index, and you can't find an item not in an exhibit
|
|
81
|
+
|
|
78
82
|
filename = upload.read_attribute_before_type_cast('url')
|
|
79
83
|
filepath = "public/uploads/spotlight/resources/upload/url/#{upload.id}/#{filename}"
|
|
80
84
|
return unless filename.present? && File.exist?(filepath)
|
|
85
|
+
|
|
81
86
|
old_file = File.new(filepath)
|
|
82
87
|
image = upload.create_upload { |i| i.image.store!(old_file) }
|
|
83
88
|
iiif_tilesource = riiif.info_path(image.id)
|
|
@@ -95,6 +100,7 @@ module Migration
|
|
|
95
100
|
|
|
96
101
|
def coordinates(image)
|
|
97
102
|
return unless image.image_crop_x.present?
|
|
103
|
+
|
|
98
104
|
[image.image_crop_x, image.image_crop_y, image.image_crop_w, image.image_crop_h].join(',')
|
|
99
105
|
end
|
|
100
106
|
|