Sha256: 0f48b5cf6c18a259988fe482b30ea5e90e4a3c46b39ed0b59c56d58adf92a0ab

Contents?: true

Size: 978 Bytes

Versions: 8

Compression:

Stored size: 978 Bytes

Contents

# Returns a lambda that you can use with a before_filter in your
# CatalogController to catch and redirect query params using the old
# style, used prior to blacklight_advanced_search 5.0.
#
# This can be used to keep any old bookmarked URLs still working.
#
#     before_filter BlacklightAdvancedSearch::RedirectLegacyParamsFilter, :only => :index
#
module BlacklightAdvancedSearch
  class RedirectLegacyParamsFilter
    def self.before(controller)
      params = controller.send(:params)

      if params[:f_inclusive] && params[:f_inclusive].respond_to?(:each_pair)
        legacy_converted = false

        params[:f_inclusive].each_pair do |field, value|
          next unless value.is_a? Hash
          # old style! convert!
          legacy_converted = true
          params[:f_inclusive][field] = value.keys
        end

        if legacy_converted
          controller.send(:redirect_to, params, :status => :moved_permanently)
        end
      end
    end
  end
  end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blacklight_advanced_search-7.0.0 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.4.1 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.4.0 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.3.1 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.3.0 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.2.1 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.2.0 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb
blacklight_advanced_search-6.1.0 lib/blacklight_advanced_search/redirect_legacy_params_filter.rb