blacklight-spotlight 2.6.1.1 → 2.9.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/assets/javascripts/spotlight/admin/add_another.js +22 -0
- data/app/assets/javascripts/spotlight/{add_new_page_button.js → admin/add_new_page_button.js} +0 -0
- data/app/assets/javascripts/spotlight/{appearance.js → admin/appearance.js} +0 -0
- data/app/assets/javascripts/spotlight/{attachments.js → admin/attachments.js} +0 -0
- data/app/assets/javascripts/spotlight/{blacklight_configuration.js → admin/blacklight_configuration.js} +0 -0
- data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/autocompleteable.js +0 -0
- data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/formable.js +0 -0
- data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/plustextable.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/browse_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/iframe_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/link_to_search_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/oembed_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/resources_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/rule_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/search_result_block.js +3 -3
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_base_block.js +3 -3
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_carousel_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_embed_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_features_block.js +2 -2
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_grid_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/uploaded_items_block.js +0 -0
- data/app/assets/javascripts/spotlight/{catalog_edit.js → admin/catalog_edit.js} +0 -0
- data/app/assets/javascripts/spotlight/{copy_email_addresses.js → admin/copy_email_addresses.js} +0 -0
- data/app/assets/javascripts/spotlight/{crop.es6 → admin/crop.es6} +5 -0
- data/app/assets/javascripts/spotlight/{croppable.js → admin/croppable.js} +1 -1
- data/app/assets/javascripts/spotlight/{edit_in_place.js → admin/edit_in_place.js} +0 -0
- data/app/assets/javascripts/spotlight/{exhibits.js → admin/exhibits.js} +0 -0
- data/app/assets/javascripts/spotlight/{form_observer.js → admin/form_observer.js} +0 -0
- data/app/assets/javascripts/spotlight/{iiif.es6 → admin/iiif.es6} +0 -0
- data/app/assets/javascripts/spotlight/admin/index.js +18 -0
- data/app/assets/javascripts/spotlight/{locks.js → admin/locks.js} +0 -0
- data/app/assets/javascripts/spotlight/{multi_image_selector.js → admin/multi_image_selector.js} +0 -0
- data/app/assets/javascripts/spotlight/{pages.js.erb → admin/pages.js.erb} +0 -2
- data/app/assets/javascripts/spotlight/{readonly_checkbox.js → admin/readonly_checkbox.js} +0 -0
- data/app/assets/javascripts/spotlight/{reindex_monitor.js → admin/reindex_monitor.js} +0 -0
- data/app/assets/javascripts/spotlight/{search_typeahead.js → admin/search_typeahead.js} +1 -1
- data/app/assets/javascripts/spotlight/{select_related_input.js → admin/select_related_input.js} +0 -0
- data/app/assets/javascripts/spotlight/{sir-trevor → admin/sir-trevor}/block_controls.js +0 -0
- data/app/assets/javascripts/spotlight/{sir-trevor → admin/sir-trevor}/block_limits.js +0 -0
- data/app/assets/javascripts/spotlight/{sir-trevor → admin/sir-trevor}/locales.js +0 -0
- data/app/assets/javascripts/spotlight/{spotlight_nestable.js → admin/spotlight_nestable.js} +0 -0
- data/app/assets/javascripts/spotlight/{tabs.js → admin/tabs.js} +0 -0
- data/app/assets/javascripts/spotlight/{translation_progress.js → admin/translation_progress.js} +0 -0
- data/app/assets/javascripts/spotlight/{users.js → admin/users.js} +0 -0
- data/app/assets/javascripts/spotlight/application.js +2 -22
- data/app/assets/javascripts/spotlight/{analytics.js → user/analytics.js} +0 -0
- data/app/assets/javascripts/spotlight/user/carousel.js +3 -0
- data/app/assets/javascripts/spotlight/{clear_form_button.js → user/clear_form_button.js} +0 -0
- data/app/assets/javascripts/spotlight/user/index.js +6 -0
- data/app/assets/javascripts/spotlight/{report_a_problem.js → user/report_a_problem.js} +0 -0
- data/app/assets/javascripts/spotlight/{zpr_links.js.erb → user/zpr_links.js.erb} +0 -0
- data/app/controllers/spotlight/catalog_controller.rb +1 -1
- data/app/controllers/spotlight/custom_fields_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +1 -1
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/resources/upload_controller.rb +17 -13
- data/app/controllers/spotlight/resources_controller.rb +5 -0
- data/app/controllers/spotlight/searches_controller.rb +0 -2
- data/app/controllers/spotlight/solr_controller.rb +18 -1
- data/app/helpers/spotlight/application_helper.rb +4 -1
- data/app/helpers/spotlight/pages_helper.rb +10 -0
- data/app/jobs/spotlight/add_uploads_from_csv.rb +1 -1
- data/app/jobs/spotlight/rename_sidecar_field_job.rb +21 -7
- data/app/models/concerns/spotlight/custom_translation_extension.rb +2 -0
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +10 -3
- data/app/models/spotlight/blacklight_configuration.rb +5 -3
- data/app/models/spotlight/custom_field.rb +20 -20
- data/app/models/spotlight/exhibit.rb +11 -1
- data/app/models/spotlight/page.rb +11 -4
- data/app/models/spotlight/page_content.rb +18 -0
- data/app/models/spotlight/page_content/sir_trevor.rb +17 -0
- data/app/models/spotlight/solr_document_sidecar.rb +3 -0
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +2 -2
- data/app/serializers/spotlight/exhibit_export_serializer.rb +5 -1
- data/app/services/spotlight/solr_document_builder.rb +1 -1
- data/app/services/spotlight/upload_solr_document_builder.rb +10 -3
- data/app/values/custom_field_name.rb +6 -6
- data/app/views/spotlight/catalog/_edit_sidecar.html.erb +9 -14
- data/app/views/spotlight/custom_fields/_form.html.erb +7 -2
- data/app/views/spotlight/custom_fields/form_group/_text.html.erb +14 -0
- data/app/views/spotlight/custom_fields/form_group/_vocab.html.erb +14 -0
- data/app/views/spotlight/pages/_form.html.erb +1 -1
- data/app/views/spotlight/resources/new.html.erb +9 -3
- data/app/views/spotlight/resources/upload/_form.html.erb +3 -1
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/spotlight.ar.yml +40 -0
- data/config/locales/spotlight.en.yml +5 -0
- data/config/locales/spotlight.fr.yml +40 -0
- data/db/migrate/20190807085432_add_content_type_to_pages.rb +5 -0
- data/db/migrate/20190813085432_add_is_multiple_to_custom_fields.rb +7 -0
- data/lib/spotlight/engine.rb +8 -1
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/catalog_controller_spec.rb +6 -0
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +9 -1
- data/spec/controllers/spotlight/solr_controller_spec.rb +16 -0
- data/spec/examples.txt +1335 -1319
- data/spec/factories/pages.rb +6 -0
- data/spec/features/add_custom_field_metadata_spec.rb +19 -1
- data/spec/features/add_items_spec.rb +19 -2
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +23 -0
- data/spec/features/exhibits/translation_editing_spec.rb +8 -0
- data/spec/features/javascript/locale_selector_spec.rb +6 -0
- data/spec/fixtures/sample_solr_documents.yml +110 -110
- data/spec/helpers/spotlight/pages_helper_spec.rb +14 -0
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +4 -2
- data/spec/models/spotlight/blacklight_configuration_spec.rb +2 -2
- data/spec/models/spotlight/custom_field_spec.rb +8 -3
- data/spec/models/spotlight/custom_translation_extension_spec.rb +23 -0
- data/spec/models/spotlight/page_spec.rb +45 -0
- data/spec/services/spotlight/solr_document_builder_spec.rb +9 -0
- data/spec/spec_helper.rb +14 -16
- data/spec/test_app_templates/Gemfile.extra +0 -1
- metadata +80 -52
|
@@ -4,7 +4,6 @@ module Spotlight
|
|
|
4
4
|
##
|
|
5
5
|
# CRUD actions for curating browse categories (see
|
|
6
6
|
# {Spotlight::BrowseController} for the end-user read and index actions)
|
|
7
|
-
# rubocop:disable Metrics/ClassLength
|
|
8
7
|
class SearchesController < Spotlight::ApplicationController
|
|
9
8
|
load_resource :exhibit, class: 'Spotlight::Exhibit'
|
|
10
9
|
before_action :authenticate_user!
|
|
@@ -142,5 +141,4 @@ module Spotlight
|
|
|
142
141
|
@search = current_exhibit.searches.find(params[:id]) if params[:id].present?
|
|
143
142
|
end
|
|
144
143
|
end
|
|
145
|
-
# rubocop:enable Metrics/ClassLength
|
|
146
144
|
end
|
|
@@ -36,7 +36,14 @@ module Spotlight
|
|
|
36
36
|
req = ActiveSupport::JSON.decode(json_content)
|
|
37
37
|
|
|
38
38
|
Array.wrap(req).map do |r|
|
|
39
|
-
|
|
39
|
+
custom_field_data = r.dup.extract! @exhibit.custom_fields.pluck(:slug)
|
|
40
|
+
other_field_data = r.except(custom_field_data.keys)
|
|
41
|
+
|
|
42
|
+
doc = blacklight_config.document_model.new(other_field_data)
|
|
43
|
+
|
|
44
|
+
create_or_update_solr_document_sidecar(doc, r)
|
|
45
|
+
|
|
46
|
+
doc.to_solr.merge(@exhibit.solr_data).merge(other_field_data)
|
|
40
47
|
end
|
|
41
48
|
end
|
|
42
49
|
|
|
@@ -53,5 +60,15 @@ module Spotlight
|
|
|
53
60
|
|
|
54
61
|
render plain: 'Spotlight is unable to write to solr', status: 409
|
|
55
62
|
end
|
|
63
|
+
|
|
64
|
+
def create_or_update_solr_document_sidecar(doc, data)
|
|
65
|
+
return if data.blank?
|
|
66
|
+
|
|
67
|
+
sidecar = doc.sidecar(@exhibit)
|
|
68
|
+
sidecar.data = sidecar.data.merge(data)
|
|
69
|
+
sidecar.save
|
|
70
|
+
|
|
71
|
+
sidecar
|
|
72
|
+
end
|
|
56
73
|
end
|
|
57
74
|
end
|
|
@@ -17,7 +17,10 @@ module Spotlight
|
|
|
17
17
|
name ||= super
|
|
18
18
|
|
|
19
19
|
if current_exhibit
|
|
20
|
-
t :'spotlight.application_name',
|
|
20
|
+
t :'spotlight.application_name',
|
|
21
|
+
exhibit: current_exhibit.title,
|
|
22
|
+
application_name: name,
|
|
23
|
+
default: t('spotlight.application_name', locale: I18n.default_locale, exhibit: current_exhibit.title, application_name: name)
|
|
21
24
|
else
|
|
22
25
|
name
|
|
23
26
|
end
|
|
@@ -6,6 +6,16 @@ module Spotlight
|
|
|
6
6
|
module PagesHelper
|
|
7
7
|
include Spotlight::RenderingHelper
|
|
8
8
|
|
|
9
|
+
def content_editor_class(page)
|
|
10
|
+
page_content = page.content_type
|
|
11
|
+
|
|
12
|
+
if page_content == 'SirTrevor'
|
|
13
|
+
'js-st-instance'
|
|
14
|
+
else
|
|
15
|
+
"js-#{page_content.parameterize}-instance"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
9
19
|
##
|
|
10
20
|
# Override the default #sir_trevor_markdown so we can use
|
|
11
21
|
# a more complete markdown rendered
|
|
@@ -7,15 +7,29 @@ module Spotlight
|
|
|
7
7
|
class RenameSidecarFieldJob < ActiveJob::Base
|
|
8
8
|
queue_as :default
|
|
9
9
|
|
|
10
|
-
def perform(exhibit, old_field, new_field)
|
|
10
|
+
def perform(exhibit, old_field, new_field, old_slug = nil, new_slug = nil)
|
|
11
11
|
exhibit.solr_document_sidecars.find_each do |s|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
# this data migration should be relatively rare
|
|
13
|
+
migrate_data!(s, old_slug, new_slug)
|
|
14
|
+
migrate_data!(s, old_field, new_slug || new_field) # for backwards compatibility
|
|
15
|
+
|
|
16
|
+
# more likely, the indexing rules changed and we have to reindex
|
|
17
|
+
reindex_document!(s) if old_field != new_field && s.data[new_slug || new_field]
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def migrate_data!(sidecar, old_field, new_field)
|
|
24
|
+
return if old_field == new_field || !sidecar.data.key?(old_field)
|
|
25
|
+
|
|
26
|
+
sidecar.data_will_change!
|
|
27
|
+
sidecar.data[new_field] = sidecar.data.delete(old_field)
|
|
28
|
+
sidecar.save
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def reindex_document!(sidecar)
|
|
32
|
+
sidecar.document.reindex
|
|
33
|
+
end
|
|
20
34
|
end
|
|
21
35
|
end
|
|
@@ -21,17 +21,24 @@ module SirTrevorRails
|
|
|
21
21
|
!pages.empty?
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
# rubocop:disable Metrics/MethodLength
|
|
24
25
|
def as_json
|
|
25
26
|
result = super
|
|
26
|
-
|
|
27
27
|
result[:data][:item] ||= {}
|
|
28
28
|
|
|
29
|
-
result[:data][:item].
|
|
30
|
-
|
|
29
|
+
result[:data][:item].transform_values! do |v|
|
|
30
|
+
begin
|
|
31
|
+
v['thumbnail_image_url'] = parent.exhibit.pages.find(v['id']).thumbnail_image_url
|
|
32
|
+
rescue ActiveRecord::RecordNotFound
|
|
33
|
+
v = nil
|
|
34
|
+
end
|
|
35
|
+
v
|
|
31
36
|
end
|
|
32
37
|
|
|
38
|
+
result[:data][:item].compact!
|
|
33
39
|
result
|
|
34
40
|
end
|
|
41
|
+
# rubocop:enable Metrics/MethodLength
|
|
35
42
|
end
|
|
36
43
|
end
|
|
37
44
|
end
|
|
@@ -216,7 +216,7 @@ module Spotlight
|
|
|
216
216
|
end
|
|
217
217
|
|
|
218
218
|
def custom_facet_fields
|
|
219
|
-
Hash[exhibit.custom_fields.
|
|
219
|
+
Hash[exhibit.custom_fields.facetable.reject(&:new_record?).map do |x|
|
|
220
220
|
field = Blacklight::Configuration::FacetField.new x.configuration.merge(
|
|
221
221
|
key: x.field, field: x.solr_field, show: false, custom_field: true
|
|
222
222
|
)
|
|
@@ -277,11 +277,13 @@ module Spotlight
|
|
|
277
277
|
def add_exhibit_tags_fields(config)
|
|
278
278
|
# rubocop:disable Style/GuardClause
|
|
279
279
|
unless config.show_fields.include? :exhibit_tags
|
|
280
|
-
config.add_show_field :exhibit_tags, field: config.document_model.solr_field_for_tagger(exhibit),
|
|
280
|
+
config.add_show_field :exhibit_tags, field: config.document_model.solr_field_for_tagger(exhibit),
|
|
281
|
+
link_to_search: true,
|
|
282
|
+
separator_options: { words_connector: nil, two_words_connector: nil, last_word_connector: nil }
|
|
281
283
|
end
|
|
282
284
|
|
|
283
285
|
unless config.facet_fields.include? :exhibit_tags
|
|
284
|
-
config.add_facet_field :exhibit_tags, field: config.document_model.solr_field_for_tagger(exhibit)
|
|
286
|
+
config.add_facet_field :exhibit_tags, field: config.document_model.solr_field_for_tagger(exhibit), limit: true
|
|
285
287
|
end
|
|
286
288
|
# rubocop:enable Style/GuardClause
|
|
287
289
|
end
|
|
@@ -10,7 +10,7 @@ module Spotlight
|
|
|
10
10
|
extend FriendlyId
|
|
11
11
|
friendly_id :slug_candidates, use: [:slugged, :scoped, :finders], scope: :exhibit
|
|
12
12
|
|
|
13
|
-
scope :
|
|
13
|
+
scope :facetable, -> { where(field_type: Spotlight::Engine.config.custom_field_types.select { |_k, v| v[:facetable] }.keys) }
|
|
14
14
|
scope :writeable, -> { where(readonly_field: false) }
|
|
15
15
|
|
|
16
16
|
before_create do
|
|
@@ -18,9 +18,10 @@ module Spotlight
|
|
|
18
18
|
self.field_type ||= 'text'
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
before_save
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
before_save :update_field_name, on: :update, if: -> { field_type_changed? || readonly_field_changed? }
|
|
22
|
+
|
|
23
|
+
after_commit :update_blacklight_configuration_after_field_name_change, on: :update, if: -> { saved_change_to_field? || saved_change_to_slug? }
|
|
24
|
+
after_commit :update_sidecar_data_after_field_name_change, on: :update, if: -> { saved_change_to_field? || saved_change_to_slug? }
|
|
24
25
|
|
|
25
26
|
def label=(label)
|
|
26
27
|
configuration['label'] = label
|
|
@@ -92,7 +93,7 @@ module Spotlight
|
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
def should_generate_new_friendly_id?
|
|
95
|
-
|
|
96
|
+
new_record? && slug.blank?
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
# Try building a slug based on the following fields in
|
|
@@ -107,26 +108,25 @@ module Spotlight
|
|
|
107
108
|
##
|
|
108
109
|
# Rename this custom field to new_name
|
|
109
110
|
# @param [String] the new name for the field
|
|
110
|
-
def update_field_name
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
f = blacklight_configuration.index_fields.delete(old_field)
|
|
117
|
-
blacklight_configuration.index_fields[field] = f
|
|
118
|
-
blacklight_configuration.save
|
|
119
|
-
end
|
|
111
|
+
def update_field_name
|
|
112
|
+
self.field = field_name
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def update_blacklight_configuration_after_field_name_change
|
|
116
|
+
return unless blacklight_configuration && blacklight_configuration.index_fields.key?(field_before_last_save)
|
|
120
117
|
|
|
121
|
-
|
|
118
|
+
blacklight_configuration.index_fields_will_change!
|
|
119
|
+
f = blacklight_configuration.index_fields.delete(field_before_last_save)
|
|
120
|
+
blacklight_configuration.index_fields[field] = f
|
|
121
|
+
blacklight_configuration.save
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
def
|
|
125
|
-
|
|
124
|
+
def update_sidecar_data_after_field_name_change
|
|
125
|
+
Spotlight::RenameSidecarFieldJob.perform_later(exhibit, field_before_last_save, self.field, slug_before_last_save, slug)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
def
|
|
129
|
-
|
|
128
|
+
def document_model
|
|
129
|
+
blacklight_configuration.document_model
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
end
|
|
@@ -36,7 +36,17 @@ module Spotlight
|
|
|
36
36
|
has_many :attachments, dependent: :destroy
|
|
37
37
|
has_many :contact_emails, dependent: :delete_all # These are the contacts who get "Contact us" emails
|
|
38
38
|
has_many :contacts, dependent: :delete_all # These are the contacts who appear in the sidebar
|
|
39
|
-
has_many :custom_fields, dependent: :delete_all
|
|
39
|
+
has_many :custom_fields, dependent: :delete_all do
|
|
40
|
+
def as_strong_params
|
|
41
|
+
multivalued_params, single_valued_params = writeable.partition(&:is_multiple?)
|
|
42
|
+
single_valued_params.pluck(:slug, :field).flatten +
|
|
43
|
+
[multivalued_params.each_with_object({}) do |f, h|
|
|
44
|
+
h[f.slug] = []
|
|
45
|
+
h[f.field] = []
|
|
46
|
+
end]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
40
50
|
has_many :feature_pages, -> { for_default_locale }, extend: FriendlyId::FinderMethods
|
|
41
51
|
has_many :main_navigations, dependent: :delete_all
|
|
42
52
|
has_many :reindexing_log_entries, dependent: :destroy
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
module Spotlight
|
|
4
4
|
##
|
|
5
5
|
# Base page class. See {Spotlight::AboutPage}, {Spotlight::FeaturePage}, {Spotlight::HomePage}
|
|
6
|
-
# rubocop:disable Metrics/ClassLength
|
|
7
6
|
class Page < ActiveRecord::Base
|
|
8
7
|
MAX_PAGES = 1000
|
|
9
8
|
|
|
@@ -35,14 +34,12 @@ module Spotlight
|
|
|
35
34
|
scope :for_default_locale, -> { for_locale(I18n.default_locale) }
|
|
36
35
|
|
|
37
36
|
has_one :lock, as: :on, dependent: :destroy
|
|
38
|
-
sir_trevor_content :content
|
|
39
37
|
has_paper_trail
|
|
40
38
|
|
|
41
39
|
accepts_nested_attributes_for :thumbnail, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }
|
|
42
40
|
|
|
43
41
|
# display_sidebar should be set to true by default
|
|
44
42
|
before_create do
|
|
45
|
-
self.content ||= [].to_json
|
|
46
43
|
self.display_sidebar = true
|
|
47
44
|
end
|
|
48
45
|
|
|
@@ -52,6 +49,16 @@ module Spotlight
|
|
|
52
49
|
@content = nil
|
|
53
50
|
end
|
|
54
51
|
|
|
52
|
+
def content
|
|
53
|
+
@content ||= begin
|
|
54
|
+
Spotlight::PageContent.for(self, :content)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def content_type
|
|
59
|
+
self[:content_type] || Spotlight::Engine.config.default_page_content_type
|
|
60
|
+
end
|
|
61
|
+
|
|
55
62
|
def content=(content)
|
|
56
63
|
if content.is_a? Array
|
|
57
64
|
super content.to_json
|
|
@@ -135,6 +142,7 @@ module Spotlight
|
|
|
135
142
|
np.locale = locale
|
|
136
143
|
np.default_locale_page = self
|
|
137
144
|
np.published = false
|
|
145
|
+
np.slug = slug
|
|
138
146
|
|
|
139
147
|
if !top_level_page? && (parent_translation = parent_page.translated_page_for(locale)).present?
|
|
140
148
|
np.parent_page = parent_translation
|
|
@@ -159,5 +167,4 @@ module Spotlight
|
|
|
159
167
|
translated_pages.update(weight: weight) if saved_change_to_weight?
|
|
160
168
|
end
|
|
161
169
|
end
|
|
162
|
-
# rubocop:enable Metrics/ClassLength
|
|
163
170
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spotlight
|
|
4
|
+
# Factory for picking the right page content renderer
|
|
5
|
+
module PageContent
|
|
6
|
+
def self.for(page, attribute)
|
|
7
|
+
content_type = page.content_type
|
|
8
|
+
content_class = Spotlight::PageContent.const_get(content_type) if Spotlight::PageContent.const_defined?(content_type)
|
|
9
|
+
content_class ||= default_page_content_class
|
|
10
|
+
|
|
11
|
+
content_class.parse(page, attribute)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.default_page_content_class
|
|
15
|
+
Spotlight::PageContent.const_get(Spotlight::Engine.config.default_page_content_type)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spotlight
|
|
4
|
+
module PageContent
|
|
5
|
+
# Sir-Trevor created content
|
|
6
|
+
class SirTrevor
|
|
7
|
+
def self.parse(page, attribute)
|
|
8
|
+
content = page.read_attribute(attribute)
|
|
9
|
+
content ||= [].to_json
|
|
10
|
+
|
|
11
|
+
return SirTrevorRails::BlockArray.new if content.blank?
|
|
12
|
+
|
|
13
|
+
SirTrevorRails::BlockArray.from_json(content, page)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -27,8 +27,8 @@ module Spotlight
|
|
|
27
27
|
# IIIFManifest expects leaf nodes to implement #display_image, which returns an instance of IIIFManifest::DisplayImage.
|
|
28
28
|
def display_image
|
|
29
29
|
IIIFManifest::DisplayImage.new(id,
|
|
30
|
-
width: resource.first(:spotlight_full_image_width_ssm),
|
|
31
|
-
height: resource.first(:spotlight_full_image_height_ssm),
|
|
30
|
+
width: resource.first(:spotlight_full_image_width_ssm)&.to_i,
|
|
31
|
+
height: resource.first(:spotlight_full_image_height_ssm)&.to_i,
|
|
32
32
|
format: 'image/jpeg',
|
|
33
33
|
iiif_endpoint: endpoint)
|
|
34
34
|
end
|
|
@@ -34,6 +34,10 @@ module Spotlight
|
|
|
34
34
|
property prop
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
property :theme, setter: lambda { |fragment:, represented:, **|
|
|
38
|
+
represented.theme = fragment if Spotlight::Engine.config.exhibit_themes.include? fragment
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
collection :searches, populator: ->(fragment, options) { options[:represented].searches.find_or_initialize_by(slug: fragment['slug']) },
|
|
38
42
|
class: Spotlight::Search do
|
|
39
43
|
(Spotlight::Search.attribute_names - %w(id scope exhibit_id masthead_id thumbnail_id)).each do |prop|
|
|
@@ -83,7 +87,7 @@ module Spotlight
|
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
collection :contact_emails, class: Spotlight::ContactEmail do
|
|
86
|
-
(Spotlight::ContactEmail.attribute_names - %w(id exhibit_id)).each do |prop|
|
|
90
|
+
(Spotlight::ContactEmail.attribute_names - %w(id exhibit_id confirmation_token)).each do |prop|
|
|
87
91
|
property prop
|
|
88
92
|
end
|
|
89
93
|
end
|
|
@@ -55,7 +55,7 @@ module Spotlight
|
|
|
55
55
|
def exhibit_solr_doc(id)
|
|
56
56
|
return NilSolrDocument unless document_model || id.present?
|
|
57
57
|
|
|
58
|
-
document_model.build_for_exhibit(id, exhibit, resource: resource)
|
|
58
|
+
document_model.build_for_exhibit(id, exhibit, resource: (resource if resource.persisted?))
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def unique_key
|
|
@@ -8,10 +8,13 @@ module Spotlight
|
|
|
8
8
|
def to_solr
|
|
9
9
|
super.tap do |solr_hash|
|
|
10
10
|
add_default_solr_fields solr_hash
|
|
11
|
-
add_image_dimensions solr_hash
|
|
12
|
-
add_file_versions solr_hash
|
|
13
11
|
add_sidecar_fields solr_hash
|
|
14
|
-
|
|
12
|
+
|
|
13
|
+
if attached_file?
|
|
14
|
+
add_image_dimensions solr_hash
|
|
15
|
+
add_file_versions solr_hash
|
|
16
|
+
add_manifest_path solr_hash
|
|
17
|
+
end
|
|
15
18
|
end
|
|
16
19
|
end
|
|
17
20
|
|
|
@@ -46,5 +49,9 @@ module Spotlight
|
|
|
46
49
|
def riiif
|
|
47
50
|
Riiif::Engine.routes.url_helpers
|
|
48
51
|
end
|
|
52
|
+
|
|
53
|
+
def attached_file?
|
|
54
|
+
resource.upload&.file_present?
|
|
55
|
+
end
|
|
49
56
|
end
|
|
50
57
|
end
|