blacklight-spotlight 3.0.0.alpha.9 → 3.0.0.alpha.10
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 +5 -0
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +3 -2
- data/app/assets/stylesheets/spotlight/_accessibility.scss +1 -1
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_curation.scss +6 -0
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +3 -0
- data/app/assets/stylesheets/spotlight/_header.scss +1 -1
- data/app/assets/stylesheets/spotlight/_translations.scss +1 -0
- data/app/controllers/spotlight/appearances_controller.rb +1 -0
- data/app/controllers/spotlight/browse_controller.rb +1 -1
- data/app/controllers/spotlight/exhibits_controller.rb +2 -3
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +3 -2
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/models/concerns/spotlight/translatables.rb +17 -1
- data/app/models/spotlight/about_page.rb +3 -1
- 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 +5 -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/views/catalog/_save_search.html.erb +1 -1
- 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/pages/_form.html.erb +1 -1
- data/app/views/spotlight/searches/_form.html.erb +1 -0
- data/app/views/spotlight/searches/_search.html.erb +1 -0
- 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/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/locales/spotlight.ar.yml +43 -24
- data/config/locales/spotlight.en.yml +65 -53
- data/config/routes.rb +6 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/lib/spotlight/engine.rb +20 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/translations_controller_spec.rb +53 -2
- data/spec/factories/featured_images.rb +4 -0
- data/spec/features/exhibits/translation_editing_spec.rb +2 -2
- data/spec/features/home_page_spec.rb +9 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/i18n_spec.rb +0 -2
- data/spec/models/spotlight/exhibit_spec.rb +9 -1
- data/spec/models/spotlight/featured_image_spec.rb +28 -0
- data/spec/models/spotlight/page_spec.rb +6 -1
- data/spec/models/spotlight/resources/upload_spec.rb +43 -79
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +108 -22
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- metadata +14 -11
- 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
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.alpha.
|
4
|
+
version: 3.0.0.alpha.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-
|
14
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: acts-as-taggable-on
|
@@ -641,14 +641,14 @@ dependencies:
|
|
641
641
|
requirements:
|
642
642
|
- - "~>"
|
643
643
|
- !ruby/object:Gem::Version
|
644
|
-
version: 0.
|
644
|
+
version: 0.83.0
|
645
645
|
type: :development
|
646
646
|
prerelease: false
|
647
647
|
version_requirements: !ruby/object:Gem::Requirement
|
648
648
|
requirements:
|
649
649
|
- - "~>"
|
650
650
|
- !ruby/object:Gem::Version
|
651
|
-
version: 0.
|
651
|
+
version: 0.83.0
|
652
652
|
- !ruby/object:Gem::Dependency
|
653
653
|
name: rubocop-rspec
|
654
654
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1015,13 +1015,11 @@ files:
|
|
1015
1015
|
- app/models/spotlight/search.rb
|
1016
1016
|
- app/models/spotlight/site.rb
|
1017
1017
|
- app/models/spotlight/solr_document_sidecar.rb
|
1018
|
+
- app/models/spotlight/temporary_image.rb
|
1018
1019
|
- app/presenters/spotlight/iiif_manifest_presenter.rb
|
1019
|
-
- app/serializers/spotlight/exhibit_export_serializer.rb
|
1020
|
-
- app/serializers/spotlight/featured_image_representer.rb
|
1021
|
-
- app/serializers/spotlight/main_navigation_representer.rb
|
1022
|
-
- app/serializers/spotlight/page_representer.rb
|
1023
1020
|
- app/services/spotlight/carrierwave_file_resolver.rb
|
1024
1021
|
- app/services/spotlight/clone_translated_page_from_locale.rb
|
1022
|
+
- app/services/spotlight/exhibit_import_export_service.rb
|
1025
1023
|
- app/services/spotlight/iiif_resource_resolver.rb
|
1026
1024
|
- app/services/spotlight/invite_users_service.rb
|
1027
1025
|
- app/services/spotlight/resources/iiif_builder.rb
|
@@ -1206,12 +1204,14 @@ files:
|
|
1206
1204
|
- app/views/spotlight/tags/index.html.erb
|
1207
1205
|
- app/views/spotlight/translations/_browse_categories.html.erb
|
1208
1206
|
- app/views/spotlight/translations/_general.html.erb
|
1207
|
+
- app/views/spotlight/translations/_import.html.erb
|
1209
1208
|
- app/views/spotlight/translations/_metadata.html.erb
|
1210
1209
|
- app/views/spotlight/translations/_page.html.erb
|
1211
1210
|
- app/views/spotlight/translations/_pages.html.erb
|
1212
1211
|
- app/views/spotlight/translations/_pages_table.html.erb
|
1213
1212
|
- app/views/spotlight/translations/_search_fields.html.erb
|
1214
1213
|
- app/views/spotlight/translations/edit.html.erb
|
1214
|
+
- app/views/spotlight/translations/show.yaml.yamlbuilder
|
1215
1215
|
- config/i18n-tasks.yml
|
1216
1216
|
- config/locales/devise.en.yml
|
1217
1217
|
- config/locales/spotlight.ar.yml
|
@@ -1289,6 +1289,7 @@ files:
|
|
1289
1289
|
- db/migrate/20190813085432_add_is_multiple_to_custom_fields.rb
|
1290
1290
|
- db/migrate/20190910200927_create_spotlight_custom_search_fields.rb
|
1291
1291
|
- db/migrate/20191205112300_add_unique_index_to_sidecars.rb
|
1292
|
+
- db/migrate/20200403161512_add_subtitle_to_searches.rb
|
1292
1293
|
- lib/blacklight/spotlight.rb
|
1293
1294
|
- lib/generators/spotlight/install_generator.rb
|
1294
1295
|
- lib/generators/spotlight/scaffold_resource_generator.rb
|
@@ -1504,9 +1505,9 @@ files:
|
|
1504
1505
|
- spec/routing/spotlight/exhibit_catalog_spec.rb
|
1505
1506
|
- spec/routing/spotlight/featured_images_spec.rb
|
1506
1507
|
- spec/routing/spotlight/pages_routing_spec.rb
|
1507
|
-
- spec/serializers/spotlight/exhibit_export_serializer_spec.rb
|
1508
1508
|
- spec/services/spotlight/carrierwave_file_resolver_spec.rb
|
1509
1509
|
- spec/services/spotlight/clone_translated_page_from_locale_spec.rb
|
1510
|
+
- spec/services/spotlight/exhibit_import_export_service_spec.rb
|
1510
1511
|
- spec/services/spotlight/iiif_resource_resolver_spec.rb
|
1511
1512
|
- spec/services/spotlight/invite_users_service_spec.rb
|
1512
1513
|
- spec/services/spotlight/solr_document_builder_spec.rb
|
@@ -1584,6 +1585,7 @@ files:
|
|
1584
1585
|
- spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb
|
1585
1586
|
- spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb
|
1586
1587
|
- spec/views/spotlight/tags/index.html.erb_spec.rb
|
1588
|
+
- spec/views/spotlight/translations/_import.html.erb_spec.rb
|
1587
1589
|
- spec/views/spotlight/translations/_page.html.erb_spec.rb
|
1588
1590
|
- vendor/assets/images/sir-trevor-icons.svg
|
1589
1591
|
- vendor/assets/javascripts/Leaflet.Editable.js
|
@@ -1629,7 +1631,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1629
1631
|
requirements:
|
1630
1632
|
- - "~>"
|
1631
1633
|
- !ruby/object:Gem::Version
|
1632
|
-
version: '2.
|
1634
|
+
version: '2.5'
|
1633
1635
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1634
1636
|
requirements:
|
1635
1637
|
- - ">"
|
@@ -1753,7 +1755,6 @@ test_files:
|
|
1753
1755
|
- spec/models/translation_spec.rb
|
1754
1756
|
- spec/models/solr_document_spec.rb
|
1755
1757
|
- spec/presenters/spotlight/iiif_manifest_presenter_spec.rb
|
1756
|
-
- spec/serializers/spotlight/exhibit_export_serializer_spec.rb
|
1757
1758
|
- spec/support/features/capybara_default_max_wait_metadata_helper.rb
|
1758
1759
|
- spec/support/features/test_features_helpers.rb
|
1759
1760
|
- spec/support/stub_iiif_response.rb
|
@@ -1891,6 +1892,7 @@ test_files:
|
|
1891
1892
|
- spec/views/spotlight/pages/show.html.erb_spec.rb
|
1892
1893
|
- spec/views/spotlight/pages/new.html.erb_spec.rb
|
1893
1894
|
- spec/views/spotlight/pages/index.html.erb_spec.rb
|
1895
|
+
- spec/views/spotlight/translations/_import.html.erb_spec.rb
|
1894
1896
|
- spec/views/spotlight/translations/_page.html.erb_spec.rb
|
1895
1897
|
- spec/views/shared/_header_navbar.html.erb_spec.rb
|
1896
1898
|
- spec/views/shared/_exhibit_navbar.html.erb_spec.rb
|
@@ -1917,3 +1919,4 @@ test_files:
|
|
1917
1919
|
- spec/services/spotlight/iiif_resource_resolver_spec.rb
|
1918
1920
|
- spec/services/spotlight/solr_document_builder_spec.rb
|
1919
1921
|
- spec/services/spotlight/carrierwave_file_resolver_spec.rb
|
1922
|
+
- spec/services/spotlight/exhibit_import_export_service_spec.rb
|
@@ -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
|