blacklight-spotlight 3.0.0.alpha.6 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +55 -1
- data/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +7 -2
- data/app/assets/javascripts/spotlight/admin/crop.es6 +11 -0
- data/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +21 -12
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +3 -2
- data/app/assets/stylesheets/spotlight/_accessibility.scss +8 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_curation.scss +9 -16
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +7 -4
- data/app/assets/stylesheets/spotlight/_header.scss +1 -1
- data/app/assets/stylesheets/spotlight/_item_text_block.scss +6 -0
- data/app/assets/stylesheets/spotlight/_nestable.scss +4 -0
- data/app/assets/stylesheets/spotlight/_pages.scss +3 -1
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +5 -2
- data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -0
- data/app/assets/stylesheets/spotlight/_translations.scss +1 -0
- data/app/controllers/concerns/spotlight/base.rb +8 -0
- data/app/controllers/spotlight/admin_users_controller.rb +4 -1
- data/app/controllers/spotlight/appearances_controller.rb +1 -0
- data/app/controllers/spotlight/browse_controller.rb +1 -1
- data/app/controllers/spotlight/catalog_controller.rb +2 -2
- data/app/controllers/spotlight/exhibits_controller.rb +4 -3
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +1 -5
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +3 -2
- data/app/controllers/spotlight/sites_controller.rb +8 -2
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/helpers/spotlight/title_helper.rb +12 -2
- data/app/jobs/spotlight/add_uploads_from_csv.rb +30 -5
- data/app/mailers/spotlight/indexing_complete_mailer.rb +3 -2
- data/app/models/concerns/spotlight/translatables.rb +17 -1
- data/app/models/spotlight/about_page.rb +3 -1
- data/app/models/spotlight/contact.rb +1 -1
- data/app/models/spotlight/custom_field.rb +3 -3
- data/app/models/spotlight/exhibit.rb +4 -2
- data/app/models/spotlight/feature_page.rb +3 -1
- data/app/models/spotlight/featured_image.rb +29 -12
- data/app/models/spotlight/home_page.rb +3 -1
- data/app/models/spotlight/main_navigation.rb +2 -2
- data/app/models/spotlight/masthead.rb +1 -1
- data/app/models/spotlight/page.rb +7 -3
- data/app/models/spotlight/page_configurations.rb +1 -0
- data/app/models/spotlight/page_content.rb +2 -0
- data/app/models/spotlight/resources/csv_upload.rb +2 -1
- data/app/models/spotlight/resources/iiif_manifest.rb +2 -0
- data/app/models/spotlight/resources/upload.rb +1 -1
- data/app/models/spotlight/search.rb +5 -1
- data/app/models/spotlight/solr_document_sidecar.rb +7 -5
- data/app/models/spotlight/temporary_image.rb +8 -0
- data/app/services/spotlight/exhibit_import_export_service.rb +454 -0
- data/app/services/spotlight/solr_document_builder.rb +1 -0
- data/app/values/custom_field_name.rb +1 -0
- data/app/views/catalog/_save_search.html.erb +1 -1
- data/app/views/layouts/spotlight/spotlight.html.erb +1 -1
- data/app/views/shared/_site_sidebar.html.erb +1 -1
- data/app/views/spotlight/about_pages/_contact.html.erb +15 -17
- data/app/views/spotlight/admin_users/index.html.erb +1 -1
- data/app/views/spotlight/appearances/edit.html.erb +1 -23
- data/app/views/spotlight/browse/_search.html.erb +3 -2
- data/app/views/spotlight/browse/_search_title.html.erb +2 -1
- data/app/views/spotlight/exhibits/new.html.erb +1 -1
- data/app/views/spotlight/feature_pages/_sidebar.html.erb +9 -5
- data/app/views/spotlight/indexing_complete_mailer/documents_indexed.html.erb +9 -0
- data/app/views/spotlight/pages/_form.html.erb +2 -2
- data/app/views/spotlight/pages/_page.html.erb +19 -35
- data/app/views/spotlight/search_configurations/_facets.html.erb +15 -34
- data/app/views/spotlight/search_configurations/_search_fields.html.erb +4 -19
- data/app/views/spotlight/search_configurations/_sort.html.erb +8 -22
- data/app/views/spotlight/searches/_form.html.erb +1 -0
- data/app/views/spotlight/searches/_search.html.erb +31 -29
- data/app/views/spotlight/shared/_dd3_item.html.erb +56 -0
- data/app/views/spotlight/shared/_honeypot_field.html.erb +4 -0
- data/app/views/spotlight/shared/_report_a_problem.html.erb +7 -10
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -0
- data/app/views/spotlight/sir_trevor/blocks/_uploaded_items_block.html.erb +7 -1
- data/app/views/spotlight/sites/edit.html.erb +1 -1
- data/app/views/spotlight/sites/edit_exhibits.html.erb +1 -1
- data/app/views/spotlight/translations/_browse_categories.html.erb +29 -3
- data/app/views/spotlight/translations/_general.html.erb +7 -7
- data/app/views/spotlight/translations/_import.html.erb +24 -0
- data/app/views/spotlight/translations/_metadata.html.erb +1 -1
- data/app/views/spotlight/translations/_page.html.erb +5 -5
- data/app/views/spotlight/translations/_pages.html.erb +4 -4
- data/app/views/spotlight/translations/_pages_table.html.erb +5 -5
- data/app/views/spotlight/translations/_search_fields.html.erb +3 -3
- data/app/views/spotlight/translations/edit.html.erb +8 -6
- data/app/views/spotlight/translations/show.yaml.yamlbuilder +81 -0
- data/config/i18n-tasks.yml +2 -0
- data/config/locales/spotlight.ar.yml +47 -24
- data/config/locales/spotlight.en.yml +82 -67
- data/config/routes.rb +6 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/lib/generators/spotlight/install_generator.rb +22 -1
- data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +10 -0
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +2 -0
- data/lib/spotlight/engine.rb +26 -0
- data/lib/spotlight/upload_field_config.rb +1 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/browse_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/translations_controller_spec.rb +53 -2
- data/spec/examples.txt +1410 -1389
- data/spec/factories/featured_images.rb +4 -0
- data/spec/features/add_contacts_spec.rb +1 -1
- data/spec/features/browse_category_admin_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +6 -6
- data/spec/features/dashboard_spec.rb +5 -5
- data/spec/features/exhibits/administration_spec.rb +3 -3
- data/spec/features/exhibits/language_create_edit_spec.rb +3 -3
- data/spec/features/exhibits/translation_editing_spec.rb +2 -2
- data/spec/features/home_page_spec.rb +9 -0
- data/spec/features/javascript/block_controls_spec.rb +2 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/features/report_a_problem_spec.rb +5 -4
- data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
- data/spec/helpers/spotlight/title_helper_spec.rb +13 -0
- data/spec/i18n_spec.rb +0 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +13 -1
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +11 -1
- data/spec/models/solr_document_spec.rb +2 -3
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -0
- data/spec/models/spotlight/exhibit_spec.rb +9 -1
- data/spec/models/spotlight/feature_page_spec.rb +0 -5
- data/spec/models/spotlight/featured_image_spec.rb +27 -0
- data/spec/models/spotlight/page_spec.rb +6 -1
- data/spec/models/spotlight/resources/upload_spec.rb +43 -79
- data/spec/models/spotlight/role_spec.rb +2 -2
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +120 -22
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/test_app_templates/Gemfile.extra +0 -3
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +1 -0
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +9 -10
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +46 -21
- metadata +69 -34
- data/app/serializers/spotlight/exhibit_export_serializer.rb +0 -205
- data/app/serializers/spotlight/featured_image_representer.rb +0 -29
- data/app/serializers/spotlight/main_navigation_representer.rb +0 -13
- data/app/serializers/spotlight/page_representer.rb +0 -33
@@ -1,205 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'roar/decorator'
|
4
|
-
require 'roar/json'
|
5
|
-
require 'base64'
|
6
|
-
require 'tempfile'
|
7
|
-
|
8
|
-
module Spotlight
|
9
|
-
##
|
10
|
-
# Serialize the Spotlight::BlacklightConfiguration
|
11
|
-
class ConfigurationRepresenter < Roar::Decorator
|
12
|
-
include Roar::JSON
|
13
|
-
|
14
|
-
(Spotlight::BlacklightConfiguration.attribute_names - %w[id exhibit_id]).each do |prop|
|
15
|
-
property prop
|
16
|
-
end
|
17
|
-
|
18
|
-
property :skip_default_configuration, exec_context: :decorator
|
19
|
-
|
20
|
-
def skip_default_configuration
|
21
|
-
true
|
22
|
-
end
|
23
|
-
|
24
|
-
delegate :skip_default_configuration=, to: :represented
|
25
|
-
end
|
26
|
-
|
27
|
-
##
|
28
|
-
# Serialize an exhibit with all the data needed to reconstruct it
|
29
|
-
# in a different environment
|
30
|
-
class ExhibitExportSerializer < Roar::Decorator
|
31
|
-
def self.config?(config)
|
32
|
-
lambda do |**_args|
|
33
|
-
Spotlight::Engine.config.exports[config]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
include Roar::JSON
|
38
|
-
|
39
|
-
(Spotlight::Exhibit.attribute_names - %w[id slug masthead_id thumbnail_id]).each do |prop|
|
40
|
-
property prop, if: config?(:config)
|
41
|
-
end
|
42
|
-
|
43
|
-
property :theme, if: config?(:config), setter: lambda { |fragment:, represented:, **|
|
44
|
-
represented.theme = fragment if Spotlight::Engine.config.exhibit_themes.include? fragment
|
45
|
-
}
|
46
|
-
|
47
|
-
collection :main_navigations, class: Spotlight::MainNavigation, decorator: MainNavigationRepresenter, if: config?(:config)
|
48
|
-
collection :contact_emails, class: Spotlight::ContactEmail, if: config?(:config) do
|
49
|
-
(Spotlight::ContactEmail.attribute_names - %w[id exhibit_id confirmation_token]).each do |prop|
|
50
|
-
property prop
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
collection :searches, populator: ->(fragment, options) { options[:represented].searches.find_or_initialize_by(slug: fragment['slug']) },
|
55
|
-
if: config?(:pages),
|
56
|
-
class: Spotlight::Search do
|
57
|
-
(Spotlight::Search.attribute_names - %w[id scope exhibit_id masthead_id thumbnail_id]).each do |prop|
|
58
|
-
property prop
|
59
|
-
end
|
60
|
-
|
61
|
-
property :masthead, class: Spotlight::Masthead,
|
62
|
-
decorator: FeaturedImageRepresenter,
|
63
|
-
if: Spotlight::ExhibitExportSerializer.config?(:attachments)
|
64
|
-
|
65
|
-
property :thumbnail, class: Spotlight::FeaturedImage,
|
66
|
-
decorator: FeaturedImageRepresenter,
|
67
|
-
if: Spotlight::ExhibitExportSerializer.config?(:attachments)
|
68
|
-
end
|
69
|
-
|
70
|
-
collection :about_pages, populator: ->(fragment, options) { options[:represented].about_pages.find_or_initialize_by(slug: fragment['slug']) },
|
71
|
-
if: config?(:pages),
|
72
|
-
class: Spotlight::AboutPage,
|
73
|
-
decorator: PageRepresenter
|
74
|
-
|
75
|
-
collection :feature_pages, populator: ->(fragment, options) { options[:represented].feature_pages.find_or_initialize_by(slug: fragment['slug']) },
|
76
|
-
getter: ->(_opts) { feature_pages.at_top_level },
|
77
|
-
class: Spotlight::FeaturePage,
|
78
|
-
decorator: NestedPageRepresenter,
|
79
|
-
if: config?(:pages)
|
80
|
-
|
81
|
-
property :home_page, populator: ->(_fragment, options) { options[:represented].home_page },
|
82
|
-
class: Spotlight::HomePage,
|
83
|
-
decorator: PageRepresenter,
|
84
|
-
if: config?(:pages)
|
85
|
-
|
86
|
-
collection :contacts, populator: ->(fragment, options) { options[:represented].contacts.find_or_initialize_by(slug: fragment['slug']) },
|
87
|
-
class: Spotlight::Contact,
|
88
|
-
if: config?(:pages) do
|
89
|
-
(Spotlight::Contact.attribute_names - %w[id exhibit_id]).each do |prop|
|
90
|
-
property prop
|
91
|
-
end
|
92
|
-
|
93
|
-
property :avatar, class: Spotlight::ContactImage, decorator: FeaturedImageRepresenter
|
94
|
-
end
|
95
|
-
|
96
|
-
property :masthead, class: Spotlight::Masthead, decorator: FeaturedImageRepresenter, if: config?(:attachments)
|
97
|
-
|
98
|
-
property :thumbnail, class: Spotlight::ExhibitThumbnail, decorator: FeaturedImageRepresenter, if: config?(:attachments)
|
99
|
-
|
100
|
-
property :blacklight_configuration, class: Spotlight::BlacklightConfiguration, decorator: ConfigurationRepresenter, if: config?(:blacklight_configuration)
|
101
|
-
|
102
|
-
collection :custom_fields, populator: ->(fragment, options) { options[:represented].custom_fields.find_or_initialize_by(slug: fragment['slug']) },
|
103
|
-
class: Spotlight::CustomField,
|
104
|
-
if: config?(:blacklight_configuration) do
|
105
|
-
(Spotlight::CustomField.attribute_names - %w[id exhibit_id]).each do |prop|
|
106
|
-
property prop
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
collection :solr_document_sidecars, class: Spotlight::SolrDocumentSidecar,
|
111
|
-
if: config?(:resources) do
|
112
|
-
(Spotlight::SolrDocumentSidecar.attribute_names - %w[id document_type exhibit_id]).each do |prop|
|
113
|
-
property prop
|
114
|
-
end
|
115
|
-
|
116
|
-
property :document_type, exec_context: :decorator
|
117
|
-
|
118
|
-
def document_type
|
119
|
-
represented.document_type.to_s
|
120
|
-
end
|
121
|
-
|
122
|
-
delegate :document_type=, to: :represented
|
123
|
-
end
|
124
|
-
|
125
|
-
collection :owned_taggings, class: ActsAsTaggableOn::Tagging,
|
126
|
-
if: config?(:resources) do
|
127
|
-
property :taggable_id
|
128
|
-
property :taggable_type
|
129
|
-
property :context
|
130
|
-
property :tag, exec_context: :decorator
|
131
|
-
|
132
|
-
def tag
|
133
|
-
represented.tag.name
|
134
|
-
end
|
135
|
-
|
136
|
-
def tag=(tag)
|
137
|
-
represented.tag = ActsAsTaggableOn::Tag.find_or_create_by name: tag
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
collection :attachments, class: Spotlight::Attachment, if: config?(:attachments) do
|
142
|
-
(Spotlight::Attachment.attribute_names - %w[id exhibit_id file]).each do |prop|
|
143
|
-
property prop
|
144
|
-
end
|
145
|
-
|
146
|
-
property :file, exec_context: :decorator
|
147
|
-
|
148
|
-
def file
|
149
|
-
file = represented.file.file
|
150
|
-
|
151
|
-
{ filename: file.filename, content_type: file.content_type, content: Base64.encode64(file.read) }
|
152
|
-
end
|
153
|
-
|
154
|
-
def file=(file)
|
155
|
-
represented.file = CarrierWave::SanitizedFile.new tempfile: StringIO.new(Base64.decode64(file['content'])),
|
156
|
-
filename: file['filename'],
|
157
|
-
content_type: file['content_type']
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
collection :resources, class: ->(options) { options[:fragment].key?('type') ? options[:fragment]['type'].constantize : Spotlight::Resource },
|
162
|
-
if: config?(:resources) do
|
163
|
-
(Spotlight::Resource.attribute_names - %w[id upload_id exhibit_id]).each do |prop|
|
164
|
-
property prop
|
165
|
-
end
|
166
|
-
|
167
|
-
property :upload, exec_context: :decorator
|
168
|
-
|
169
|
-
def upload
|
170
|
-
return unless represented.is_a? Spotlight::Resources::Upload
|
171
|
-
|
172
|
-
FeaturedImageRepresenter.new(represented.upload).to_json
|
173
|
-
end
|
174
|
-
|
175
|
-
def upload=(json)
|
176
|
-
return unless represented.is_a? Spotlight::Resources::Upload
|
177
|
-
|
178
|
-
FeaturedImageRepresenter.new(represented.build_upload).from_json(json)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
collection :languages, class: Spotlight::Language,
|
183
|
-
populator: ->(fragment, options) { options[:represented].languages.find_or_initialize_by(locale: fragment['locale']) },
|
184
|
-
if: config?(:config) do
|
185
|
-
(Spotlight::Language.attribute_names - %w[id exhibit_id]).each do |prop|
|
186
|
-
property prop
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
collection :translations, getter: ->(represented:, **) { represented.translations.unscope(where: :locale) },
|
191
|
-
populator: (lambda do |fragment, options|
|
192
|
-
options[:represented].translations
|
193
|
-
.unscope(where: :locale)
|
194
|
-
.find_or_initialize_by(locale: fragment['locale'], key: fragment['key'])
|
195
|
-
end),
|
196
|
-
class: I18n::Backend::ActiveRecord::Translation,
|
197
|
-
if: config?(:config) do
|
198
|
-
property :locale
|
199
|
-
property :key
|
200
|
-
property :value
|
201
|
-
property :interpolations
|
202
|
-
property :is_proc
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'roar/decorator'
|
4
|
-
require 'roar/json'
|
5
|
-
module Spotlight
|
6
|
-
##
|
7
|
-
# Serialize mastheads and thumbnails
|
8
|
-
class FeaturedImageRepresenter < Roar::Decorator
|
9
|
-
include Roar::JSON
|
10
|
-
(Spotlight::FeaturedImage.attribute_names - %w[id image]).each do |prop|
|
11
|
-
property prop
|
12
|
-
end
|
13
|
-
|
14
|
-
property :image, exec_context: :decorator
|
15
|
-
def image
|
16
|
-
file = represented.image.file
|
17
|
-
|
18
|
-
return unless file
|
19
|
-
|
20
|
-
{ filename: file.filename, content_type: file.content_type, content: Base64.encode64(file.read) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def image=(file)
|
24
|
-
represented.image = CarrierWave::SanitizedFile.new tempfile: StringIO.new(Base64.decode64(file['content'])),
|
25
|
-
filename: file['filename'],
|
26
|
-
content_type: file['content_type']
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spotlight
|
4
|
-
##
|
5
|
-
# Serialize the Spotlight::BlacklightConfiguration
|
6
|
-
class MainNavigationRepresenter < Roar::Decorator
|
7
|
-
include Roar::JSON
|
8
|
-
|
9
|
-
(Spotlight::MainNavigation.attribute_names - %w[id exhibit_id]).each do |prop|
|
10
|
-
property prop
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'roar/decorator'
|
4
|
-
require 'roar/json'
|
5
|
-
module Spotlight
|
6
|
-
##
|
7
|
-
# Serialize an exhibit page
|
8
|
-
class PageRepresenter < Roar::Decorator
|
9
|
-
include Roar::JSON
|
10
|
-
(Spotlight::Page.attribute_names - %w[id scope exhibit_id parent_page_id content thumbnail_id]).each do |prop|
|
11
|
-
property prop
|
12
|
-
end
|
13
|
-
|
14
|
-
property :content, exec_context: :decorator
|
15
|
-
|
16
|
-
def content
|
17
|
-
# get the original data, bypassing any Sir-Trevor transformations
|
18
|
-
represented.read_attribute(:content)
|
19
|
-
end
|
20
|
-
|
21
|
-
delegate :content=, to: :represented
|
22
|
-
end
|
23
|
-
|
24
|
-
##
|
25
|
-
# Serialize the page hierarchy (e.g. for Feature pages)
|
26
|
-
class NestedPageRepresenter < PageRepresenter
|
27
|
-
collection :child_pages, populator: ->(fragment, options) { options[:represented].child_pages.find_or_initialize_by(slug: fragment['slug']) },
|
28
|
-
class: Spotlight::FeaturePage,
|
29
|
-
extend: NestedPageRepresenter
|
30
|
-
|
31
|
-
property :thumbnail, class: Spotlight::FeaturedImage, decorator: FeaturedImageRepresenter, if: Spotlight::ExhibitExportSerializer.config?(:attachments)
|
32
|
-
end
|
33
|
-
end
|