blacklight-spotlight 3.0.0.alpha.9 → 3.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/assets/images/blacklight/arrow-alt-circle-left.svg +1 -0
- data/app/assets/images/blacklight/arrow-alt-circle-right.svg +1 -0
- data/app/assets/javascripts/spotlight/admin/{add_new_page_button.js → add_new_button.js} +7 -0
- data/app/assets/javascripts/spotlight/admin/block_mixins/autocompleteable.js +4 -4
- data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +55 -1
- data/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
- data/app/assets/javascripts/spotlight/admin/blocks/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js +1 -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/croppable.js +1 -1
- data/app/assets/javascripts/spotlight/admin/index.js +0 -2
- data/app/assets/javascripts/spotlight/admin/reindex_monitor.js +1 -0
- data/app/assets/javascripts/spotlight/admin/search_typeahead.js +2 -2
- data/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +21 -12
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +11 -3
- data/app/assets/javascripts/spotlight/user/browse_group_categories.js +59 -0
- data/app/assets/javascripts/spotlight/user/index.js +1 -0
- data/app/assets/stylesheets/spotlight/_accessibility.scss +1 -1
- data/app/assets/stylesheets/spotlight/_breadcrumbs.scss +8 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_catalog.scss +6 -6
- data/app/assets/stylesheets/spotlight/_curation.scss +6 -0
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +214 -83
- 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/_pages.scss +9 -4
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +5 -2
- data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -0
- data/app/assets/stylesheets/spotlight/_translations.scss +7 -0
- data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +92 -0
- data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +1 -2
- data/app/controllers/concerns/spotlight/search_helper.rb +2 -8
- data/app/controllers/spotlight/appearances_controller.rb +0 -12
- data/app/controllers/spotlight/browse_controller.rb +7 -3
- data/app/controllers/spotlight/catalog_controller.rb +5 -2
- data/app/controllers/spotlight/concerns/application_controller.rb +13 -2
- data/app/controllers/spotlight/dashboards_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/groups_controller.rb +80 -0
- data/app/controllers/spotlight/pages_controller.rb +6 -9
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +7 -19
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/application_helper.rb +20 -1
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/helpers/spotlight/crud_link_helpers.rb +1 -1
- data/app/helpers/spotlight/main_app_helpers.rb +1 -1
- data/app/helpers/spotlight/pages_helper.rb +1 -1
- data/app/jobs/concerns/spotlight/job_tracking.rb +47 -0
- data/app/jobs/concerns/spotlight/limit_concurrency.rb +33 -0
- data/app/jobs/spotlight/add_uploads_from_csv.rb +34 -6
- data/app/jobs/spotlight/application_job.rb +8 -0
- data/app/jobs/spotlight/cleanup_job_trackers_job.rb +13 -0
- data/app/jobs/spotlight/default_thumbnail_job.rb +1 -3
- data/app/jobs/spotlight/reindex_exhibit_job.rb +36 -0
- data/app/jobs/spotlight/reindex_job.rb +49 -41
- data/app/jobs/spotlight/rename_sidecar_field_job.rb +2 -2
- data/app/jobs/spotlight/update_job_trackers_job.rb +20 -0
- data/app/mailers/spotlight/indexing_complete_mailer.rb +3 -2
- data/app/models/concerns/spotlight/exhibit_defaults.rb +1 -1
- data/app/models/concerns/spotlight/translatables.rb +17 -1
- data/app/models/concerns/spotlight/user.rb +2 -1
- data/app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb +25 -0
- data/app/models/spotlight/ability.rb +2 -0
- data/app/models/spotlight/about_page.rb +3 -1
- data/app/models/spotlight/blacklight_configuration.rb +2 -1
- data/app/models/spotlight/contact.rb +1 -1
- data/app/models/spotlight/custom_field.rb +3 -3
- data/app/models/spotlight/event.rb +13 -0
- data/app/models/spotlight/exhibit.rb +18 -14
- data/app/models/spotlight/feature_page.rb +3 -1
- data/app/models/spotlight/featured_image.rb +29 -12
- data/app/models/spotlight/group.rb +22 -0
- data/app/models/spotlight/group_member.rb +11 -0
- data/app/models/spotlight/home_page.rb +3 -1
- data/app/models/spotlight/job_tracker.rb +105 -0
- 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/page_configurations.rb +6 -0
- data/app/models/spotlight/page_content.rb +2 -0
- data/app/models/spotlight/reindex_progress.rb +44 -27
- data/app/models/spotlight/resource.rb +24 -58
- data/app/models/spotlight/resources/csv_upload.rb +2 -1
- data/app/models/spotlight/resources/iiif_harvester.rb +10 -1
- data/app/models/spotlight/resources/iiif_manifest.rb +11 -7
- data/app/models/spotlight/resources/iiif_service.rb +1 -1
- data/app/models/spotlight/resources/json_upload.rb +12 -0
- data/app/models/spotlight/resources/upload.rb +25 -2
- data/app/models/spotlight/search.rb +10 -1
- data/app/models/spotlight/solr_document_sidecar.rb +9 -6
- data/app/models/spotlight/temporary_image.rb +8 -0
- data/app/services/spotlight/etl.rb +7 -0
- data/app/services/spotlight/etl/context.rb +52 -0
- data/app/services/spotlight/etl/executor.rb +194 -0
- data/app/services/spotlight/etl/loaders.rb +12 -0
- data/app/services/spotlight/etl/pipeline.rb +81 -0
- data/app/services/spotlight/etl/solr_loader.rb +96 -0
- data/app/services/spotlight/etl/sources.rb +25 -0
- data/app/services/spotlight/etl/step.rb +82 -0
- data/app/services/spotlight/etl/transforms.rb +64 -0
- data/app/services/spotlight/exhibit_import_export_service.rb +482 -0
- data/app/services/spotlight/validity_checker.rb +5 -5
- data/app/values/custom_field_name.rb +1 -0
- data/app/views/catalog/_save_search.html.erb +1 -1
- data/app/views/spotlight/about_pages/_empty.html.erb +5 -5
- data/app/views/spotlight/browse/_search.html.erb +5 -3
- data/app/views/spotlight/browse/_search_title.html.erb +2 -1
- data/app/views/spotlight/browse/index.html.erb +13 -0
- data/app/views/spotlight/catalog/_document.html.erb +2 -4
- data/app/views/spotlight/catalog/index.iiif_json.jbuilder +22 -0
- data/app/views/spotlight/contacts/_form.html.erb +1 -1
- data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +6 -6
- data/app/views/spotlight/feature_pages/_empty.html.erb +5 -5
- data/app/views/spotlight/featured_images/_form.html.erb +1 -1
- data/app/views/spotlight/featured_images/_upload_form.html.erb +1 -1
- data/app/views/spotlight/home_pages/_empty.html.erb +3 -3
- 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/searches/_form.html.erb +13 -0
- data/app/views/spotlight/searches/_group.html.erb +27 -0
- data/app/views/spotlight/searches/_search.html.erb +1 -0
- data/app/views/spotlight/searches/index.html.erb +58 -17
- data/app/views/spotlight/shared/_honeypot_field.html.erb +4 -0
- data/app/views/spotlight/shared/_locale_picker.html.erb +1 -1
- 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/_browse_group_categories_block.html.erb +45 -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/_groups.html.erb +34 -0
- 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 +14 -6
- data/app/views/spotlight/translations/show.yaml.yamlbuilder +81 -0
- data/config/i18n-tasks.yml +7 -0
- data/config/locales/spotlight.ar.yml +57 -24
- data/config/locales/spotlight.en.yml +184 -128
- data/config/routes.rb +16 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/db/migrate/20210113092223_create_spotlight_groups.rb +23 -0
- data/db/migrate/20210122082032_create_job_trackers.rb +22 -0
- data/db/migrate/20210126123041_create_events.rb +15 -0
- data/lib/generators/spotlight/install_generator.rb +23 -2
- data/lib/generators/spotlight/scaffold_resource_generator.rb +5 -13
- data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +10 -0
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +3 -1
- data/lib/spotlight/engine.rb +35 -4
- data/lib/spotlight/upload_field_config.rb +1 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/browse_controller_spec.rb +24 -1
- data/spec/controllers/spotlight/catalog_controller_spec.rb +4 -2
- data/spec/controllers/spotlight/contacts_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +11 -0
- data/spec/controllers/spotlight/groups_controller_spec.rb +103 -0
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/searches_controller_spec.rb +10 -3
- data/spec/controllers/spotlight/translations_controller_spec.rb +53 -2
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +1 -1
- data/spec/examples.txt +1448 -125
- data/spec/factories/featured_images.rb +4 -0
- data/spec/factories/group.rb +17 -0
- data/spec/factories/job_trackers.rb +9 -0
- data/spec/factories/searches.rb +11 -1
- data/spec/features/add_contacts_spec.rb +1 -1
- data/spec/features/add_items_spec.rb +9 -4
- data/spec/features/browse_category_admin_spec.rb +39 -7
- data/spec/features/browse_category_navigation_spec.rb +44 -0
- data/spec/features/browse_category_spec.rb +2 -2
- data/spec/features/catalog_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +5 -4
- data/spec/features/dashboard_spec.rb +7 -7
- data/spec/features/edit_search_fields_spec.rb +2 -2
- data/spec/features/exhibits/administration_spec.rb +3 -3
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +1 -1
- data/spec/features/exhibits/language_create_edit_spec.rb +3 -3
- data/spec/features/exhibits/translation_editing_spec.rb +57 -8
- data/spec/features/home_page_spec.rb +13 -4
- data/spec/features/item_admin_spec.rb +4 -4
- data/spec/features/javascript/about_page_admin_spec.rb +1 -1
- data/spec/features/javascript/block_controls_spec.rb +3 -1
- data/spec/features/javascript/blocks/browse_group_categories_block_spec.rb +64 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/features/javascript/browse_group_admin_spec.rb +45 -0
- data/spec/features/javascript/edit_in_place_spec.rb +3 -3
- data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
- data/spec/features/javascript/reindex_monitor_spec.rb +1 -1
- data/spec/features/javascript/search_config_admin_spec.rb +1 -1
- data/spec/features/report_a_problem_spec.rb +6 -5
- data/spec/features/site_users_management_spec.rb +4 -4
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +3 -3
- data/spec/helpers/spotlight/pages_helper_spec.rb +10 -2
- data/spec/i18n_spec.rb +0 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +13 -1
- data/spec/jobs/spotlight/reindex_exhibit_job_spec.rb +43 -0
- data/spec/jobs/spotlight/reindex_job_spec.rb +30 -59
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +11 -1
- data/spec/models/sir_trevor_rails/blocks/browse_group_categories_block_spec.rb +41 -0
- 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 +21 -59
- data/spec/models/spotlight/featured_image_spec.rb +27 -0
- data/spec/models/spotlight/group_spec.rb +19 -0
- data/spec/models/spotlight/main_navigation_spec.rb +1 -1
- data/spec/models/spotlight/page_spec.rb +6 -1
- data/spec/models/spotlight/reindex_progress_spec.rb +89 -87
- data/spec/models/spotlight/resource_spec.rb +69 -90
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +9 -10
- data/spec/models/spotlight/resources/upload_spec.rb +43 -79
- data/spec/models/spotlight/role_spec.rb +3 -3
- data/spec/models/spotlight/search_spec.rb +30 -3
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -0
- data/spec/services/spotlight/etl/context_spec.rb +66 -0
- data/spec/services/spotlight/etl/executor_spec.rb +149 -0
- data/spec/services/spotlight/etl/pipeline_spec.rb +22 -0
- data/spec/services/spotlight/etl/solr_loader_spec.rb +76 -0
- data/spec/services/spotlight/etl/step_spec.rb +70 -0
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +168 -23
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -6
- data/spec/support/features/test_features_helpers.rb +15 -0
- data/spec/test_app_templates/Gemfile.extra +1 -3
- data/spec/test_app_templates/catalog_controller.rb +6 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +2 -0
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +28 -25
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +1 -0
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +7 -8
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +46 -21
- data/vendor/assets/javascripts/tiny-slider.js +3218 -0
- data/vendor/assets/stylesheets/tiny-slider.css +1 -0
- metadata +444 -289
- data/app/models/concerns/spotlight/resources/open_graph.rb +0 -36
- data/app/models/spotlight/reindexing_log_entry.rb +0 -42
- 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
- data/app/services/spotlight/resources/iiif_builder.rb +0 -19
- data/app/services/spotlight/solr_document_builder.rb +0 -76
- data/app/services/spotlight/upload_solr_document_builder.rb +0 -57
- data/spec/factories/reindexing_log_entries.rb +0 -54
- data/spec/models/spotlight/reindexing_log_entry_spec.rb +0 -129
- data/spec/models/spotlight/resources/open_graph_spec.rb +0 -65
- data/spec/services/spotlight/solr_document_builder_spec.rb +0 -66
- data/vendor/assets/javascripts/handlebars-v1.3.0.js +0 -2746
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spotlight
|
4
|
-
module Resources
|
5
|
-
##
|
6
|
-
# OpenGraph metadata harvester
|
7
|
-
module OpenGraph
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
include Spotlight::Resources::Web
|
10
|
-
|
11
|
-
def opengraph
|
12
|
-
@opengraph ||= begin
|
13
|
-
page = {}
|
14
|
-
|
15
|
-
body.css('meta').select { |m| m.attribute('property') }.each do |m|
|
16
|
-
page[m.attribute('property').to_s] = m.attribute('content').to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
page
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def opengraph_properties
|
24
|
-
Hash[opengraph.map do |k, v|
|
25
|
-
["#{opengraph_solr_field_name(k)}_tesim", v]
|
26
|
-
end]
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def opengraph_solr_field_name(field)
|
32
|
-
field.parameterize(separator: '_')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spotlight
|
4
|
-
##
|
5
|
-
# a log entry representing an attempt to reindex some number of records in an exhibit
|
6
|
-
class ReindexingLogEntry < ActiveRecord::Base
|
7
|
-
enum job_status: { unstarted: 0, in_progress: 1, succeeded: 2, failed: 3 }
|
8
|
-
|
9
|
-
belongs_to :exhibit, class_name: 'Spotlight::Exhibit'
|
10
|
-
belongs_to :user, class_name: '::User', optional: true
|
11
|
-
|
12
|
-
# null start times sort to the top, to more easily surface pending reindexing
|
13
|
-
default_scope { order(Arel.sql('start_time IS NOT NULL, start_time DESC')) }
|
14
|
-
scope :recent, -> { limit(5) }
|
15
|
-
scope :started_or_completed, -> { where.not(job_status: 'unstarted') }
|
16
|
-
|
17
|
-
def duration
|
18
|
-
end_time - start_time if end_time
|
19
|
-
end
|
20
|
-
|
21
|
-
def in_progress!
|
22
|
-
self.start_time = Time.zone.now
|
23
|
-
super
|
24
|
-
rescue StandardError
|
25
|
-
Rails.logger.error "unexpected error updating log entry to :in_progress from #{caller}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def succeeded!
|
29
|
-
self.end_time = Time.zone.now
|
30
|
-
super
|
31
|
-
rescue StandardError
|
32
|
-
Rails.logger.error "unexpected error updating log entry to :succeeded from #{caller}"
|
33
|
-
end
|
34
|
-
|
35
|
-
def failed!
|
36
|
-
self.end_time = Time.zone.now
|
37
|
-
super
|
38
|
-
rescue StandardError
|
39
|
-
Rails.logger.error "unexpected error updating log entry to :failed from #{caller}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -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
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spotlight
|
4
|
-
module Resources
|
5
|
-
# transforms a IiifHarvester into solr documents
|
6
|
-
class IiifBuilder < Spotlight::SolrDocumentBuilder
|
7
|
-
def to_solr
|
8
|
-
return to_enum(:to_solr) { 0 } unless block_given?
|
9
|
-
|
10
|
-
base_doc = super
|
11
|
-
resource.iiif_manifests.each do |manifest|
|
12
|
-
manifest.with_exhibit(exhibit)
|
13
|
-
manifest_solr = manifest.to_solr
|
14
|
-
yield base_doc.merge(manifest_solr) if manifest_solr.present?
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spotlight
|
4
|
-
# Creates solr documents for the documents in a resource
|
5
|
-
class SolrDocumentBuilder
|
6
|
-
def initialize(resource)
|
7
|
-
@resource = resource
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_reader :resource
|
11
|
-
delegate :exhibit, :document_model, to: :resource
|
12
|
-
|
13
|
-
##
|
14
|
-
# @return an enumerator of all the indexable documents for this resource
|
15
|
-
def documents_to_index
|
16
|
-
data = to_solr
|
17
|
-
return [] if data.blank?
|
18
|
-
|
19
|
-
data &&= [data] if data.is_a? Hash
|
20
|
-
|
21
|
-
return to_enum(:documents_to_index) { data.size } unless block_given?
|
22
|
-
|
23
|
-
data.lazy.reject(&:blank?).each do |doc|
|
24
|
-
yield doc.reverse_merge(exhibit_solr_doc(doc[unique_key]).to_solr)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
##
|
31
|
-
# @abstract
|
32
|
-
# Convert this resource into zero-to-many new solr documents. The data here
|
33
|
-
# should be merged into the resource-specific {#to_solr} data.
|
34
|
-
#
|
35
|
-
# @return [Hash] a single solr document hash
|
36
|
-
# @return [Enumerator<Hash>] multiple solr document hashes. This can be a
|
37
|
-
# simple array, or an lazy enumerator
|
38
|
-
def to_solr
|
39
|
-
spotlight_resource_metadata_for_solr
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
# Null object for SolrDocument
|
45
|
-
module NilSolrDocument
|
46
|
-
def self.to_solr
|
47
|
-
{}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
##
|
52
|
-
# Get any exhibit-specific metadata stored in e.g. sidecars, tags, etc
|
53
|
-
# This needs the generated solr document
|
54
|
-
# @returns [#to_solr] something that responds to `to_solr'
|
55
|
-
def exhibit_solr_doc(id)
|
56
|
-
return NilSolrDocument unless document_model || id.present?
|
57
|
-
|
58
|
-
document_model.build_for_exhibit(id, exhibit, resource: (resource if resource.persisted?))
|
59
|
-
end
|
60
|
-
|
61
|
-
def unique_key
|
62
|
-
if document_model
|
63
|
-
document_model.unique_key.to_sym
|
64
|
-
else
|
65
|
-
:id
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def spotlight_resource_metadata_for_solr
|
70
|
-
{
|
71
|
-
Spotlight::Engine.config.resource_global_id_field => (resource.to_global_id.to_s if resource.persisted?),
|
72
|
-
document_model.resource_type_field => resource.class.to_s.tableize
|
73
|
-
}
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|