Sha256: e38dddb8145238d423f9263d71164687c1db0b25ba5d045fcce68fc629b43598

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

module Spotlight
  module Controller
    extend ActiveSupport::Concern
    include Blacklight::Controller
    include Spotlight::Config

    included do
      helper_method :current_exhibit
    end

    def current_exhibit
      @exhibit
    end

    # overwrites Blacklight::Controller#blacklight_config
    def blacklight_config
      if current_exhibit
        exhibit_specific_blacklight_config
      else
        default_catalog_controller.blacklight_config
      end
    end

    def search_action_url *args
      if current_exhibit
        exhibit_search_action_url *args
      else
        main_app.catalog_index_url *args
      end
    end

    def search_facet_url *args
      if current_exhibit
        exhibit_search_facet_url *args
      else
        main_app.catalog_facet_url *args
      end
    end

    def exhibit_search_action_url *args
      options = args.extract_options!
      only_path = options[:only_path]
      options.except! :exhibit_id, :only_path

      if only_path
        spotlight.exhibit_catalog_index_path(current_exhibit, *args, options)
      else
        spotlight.exhibit_catalog_index_url(current_exhibit, *args, options)
      end
    end

    def exhibit_search_facet_url *args
      options = args.extract_options!
      only_path = options[:only_path]
      options.except! :exhibit_id, :only_path

      if only_path
        spotlight.exhibit_catalog_facet_url(current_exhibit, *args, options)
      else
        spotlight.exhibit_catalog_facet_url(current_exhibit, *args, options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-0.3.1 lib/spotlight/controller.rb
blacklight-spotlight-0.3.0 lib/spotlight/controller.rb
blacklight-spotlight-0.2.0 lib/spotlight/controller.rb