Module: BlacklightAdvancedSearch

Defined in:
lib/blacklight_advanced_search/redirect_legacy_params_filter.rb,
lib/blacklight_advanced_search.rb,
lib/blacklight_advanced_search/engine.rb,
lib/blacklight_advanced_search/version.rb,
lib/blacklight_advanced_search/advanced_query_parser.rb,
lib/generators/blacklight_advanced_search/assets_generator.rb

Overview

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

Defined Under Namespace

Modules: CatalogHelperOverride, Controller, FilterParser, ParseBasicQ, ParsingNestingParser, RenderConstraintsOverride Classes: AdvancedController, AssetsGenerator, Engine, QueryParser, RedirectLegacyParamsFilter

Constant Summary collapse

VERSION =
self.version

Class Method Summary collapse

Class Method Details

.deep_merge!(source_hash, new_hash) ⇒ Object

Utility method used in our solr search logic. Merges new_hash into source_hash, but will recursively merge nested arrays and hashes too; also will NOT merge nil or blank values from new_hash into source_hash, nil or blank values in new_hash will not overwrite values in source_hash.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/blacklight_advanced_search.rb', line 19

def self.deep_merge!(source_hash, new_hash)
  # We used to use built-in source_hash.merge() with a block arg
  # to customize merge behavior, but that was breaking in some
  # versions of BL/Rails where source_hash was a kind of HashWithIndifferentAccess,
  # and hwia is unreliable in some versions of Rails. Oh well. 
  # https://github.com/projectblacklight/blacklight/issues/827

  new_hash.each_pair do |key, new_value|
    old = source_hash.fetch(key, nil)

    source_hash[key] =     
      if new_value.respond_to?(:blank) && new.blank?
        old        
      elsif (old.kind_of?(Hash) and new_value.kind_of?(Hash))          
        deep_merge!(old, new_value)
        old
      elsif (old.kind_of?(Array) and new_value.kind_of?(Array))
        old.concat(new_value).uniq
      elsif new_value.nil?
        # Allowing nil values to over-write on merge messes things up.
        # don't set a nil value if you really want to force blank, set
        # empty string. 
        old
      else
        new_value
      end
  end
  source_hash
end

.versionObject



3
4
5
# File 'lib/blacklight_advanced_search/version.rb', line 3

def self.version
  @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp
end