lib/spotlight/engine.rb in blacklight-spotlight-0.2.0 vs lib/spotlight/engine.rb in blacklight-spotlight-0.3.0

- old
+ new

@@ -1,14 +1,14 @@ #Load blacklight which will give spotlight views a higher preference than those in blacklight require 'blacklight' require 'blacklight/oembed' require 'autoprefixer-rails' require 'spotlight/rails/routes' -require 'spotlight/utils' require 'friendly_id' require 'devise' -require 'active_model_serializers' +require 'tophat' +require 'paper_trail' module Spotlight class Engine < ::Rails::Engine isolate_namespace Spotlight # Breadcrumbs on rails must be required outside of an initializer or it doesn't get loaded. @@ -34,13 +34,26 @@ initializer "oembed.initialize" do OEmbed::Providers.register_all end + def self.catalog_controller + @catalog_controller ||= Spotlight::Engine.config.catalog_controller_class.constantize + end + + def self.blacklight_config + Spotlight::Engine.config.default_blacklight_config || catalog_controller.blacklight_config + end + + Spotlight::Engine.config.catalog_controller_class = "::CatalogController" + Spotlight::Engine.config.default_blacklight_config = nil + + Spotlight::Engine.config.exhibit_main_navigation = [:curated_features, :browse, :about] + Spotlight::Engine.config.resource_providers = [] Spotlight::Engine.config.new_resource_partials = [] # e.g. "spotlight/resources/bookmarklet" - + Spotlight::Engine.config.filter_resources_by_exhibit = false # The allowed file extensions for uploading non-repository items. Spotlight::Engine.config.allowed_upload_extensions = %w(jpg jpeg png) # Suffixes for exhibit-specific solr fields Spotlight::Engine.config.solr_fields = OpenStruct.new @@ -49,19 +62,48 @@ Spotlight::Engine.config.solr_fields.string_suffix = "_ssim".freeze Spotlight::Engine.config.solr_fields.text_suffix = "_tesim".freeze # The solr field that original (largest) images will be stored. Spotlight::Engine.config.full_image_field = :full_image_url_ssm + Spotlight::Engine.config.thumbnail_field = :thumbnail_url_ssm + Spotlight::Engine.config.square_image_field = :thumbnail_square_url_ssm Spotlight::Engine.config.uploaded_description_field = :spotlight_upload_description_tesim Spotlight::Engine.config.uploaded_attribution_field = :spotlight_upload_attribution_tesim Spotlight::Engine.config.uploaded_date_field = :spotlight_upload_date_tesim - Spotlight::Engine.config.upload_fields = { - description: OpenStruct.new(solr_field: Spotlight::Engine.config.uploaded_description_field, form_field_type: :text_area), - attribution: OpenStruct.new(solr_field: Spotlight::Engine.config.uploaded_attribution_field), - date: OpenStruct.new(solr_field: Spotlight::Engine.config.uploaded_date_field) - } + # Defaults to the blacklight_config.index.title_field: + Spotlight::Engine.config.upload_title_field = nil # OpenStruct.new(...) + + Spotlight::Engine.config.upload_fields = [ + OpenStruct.new(field_name: Spotlight::Engine.config.uploaded_description_field, form_field_type: :text_area), + OpenStruct.new(field_name: Spotlight::Engine.config.uploaded_attribution_field), + OpenStruct.new(field_name: Spotlight::Engine.config.uploaded_date_field) + ] + + # To present curators with analytics reports on the exhibit dashboard, you need to configure + # an Analytics provider. Google Analytics support is provided out-of-the-box. + Spotlight::Engine.config.analytics_provider = nil + + initializer "analytics.initialize" do + Spotlight::Engine.config.analytics_provider = Spotlight::Analytics::Ga + end + + # If you use Google Analytics, you need to wire your site to report to a Google Analytics property. + # Adding Google Analytics to your site is left as an excersize for the implementor (you could + # consider overriding the layout to inject GA code..) + # + # After getting your site to report to Google Analytics, you need to: + # a) register an OAuth service account with access to your analytics property: + # (https://github.com/tpitale/legato/wiki/OAuth2-and-Google#registering-for-api-access) + # b) download the pkcs12 key and make it accessible to your application + # c) in e.g. an initializer, set these configuration values as appropriate + # to your OAuth2 service account and analytics property: + Spotlight::Engine.config.ga_pkcs12_key_path = nil + Spotlight::Engine.config.ga_web_property_id = nil + Spotlight::Engine.config.ga_email = nil + Spotlight::Engine.config.ga_analytics_options = { } + Spotlight::Engine.config.ga_page_analytics_options = Spotlight::Engine.config.ga_analytics_options.merge(limit: 5) Blacklight::Engine.config.inject_blacklight_helpers = false # Query parameters for autocomplete requests Blacklight::Configuration.default_values[:default_autocomplete_solr_params] = {qf: 'id^1000 full_title_tesim^100 id_ng full_title_ng'}