blacklight_advanced_search 5.1.4 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff76b283a42b92cb447e1a22d9c1db3e06f9663e
4
- data.tar.gz: b53695523cade9db3640aa233ef422ea90c1428b
3
+ metadata.gz: 42196e18fa408ad581faf0d48166bf86578c40f6
4
+ data.tar.gz: 6137564dd1ffdbc2b29e9e553515b74834af7fff
5
5
  SHA512:
6
- metadata.gz: 29dd20956b18315dac983e2757cec1f9571c53e91c9530fad07a66e40c02d3f02fdff9036124fb33c9995c38cef82f67ac1bb6dfcb55c82c3b36e87c98ce63db
7
- data.tar.gz: 0114f011d414f3900857f052530880a41faa2e592a313a4ba430743a24cd922fcad9b9a84010e2ecb43fc2c9247d18fb881ad807bd06044de4ac9c779d601c0c
6
+ metadata.gz: 94fd18c2f7bf110903cd2f8a6c33de4e56b6422ab37337b9e0690046fc068a4073d2d27912719da12b296af7797cdfa339ac44b39ee580b3856f108dd5f8b0df
7
+ data.tar.gz: df99f7c358ab936301edb9fafc0d710164ff05b5f086f313dd8e4218fd53bdbf7df05a56dfc7df26cad36aad57f9ef6d3fd4e1f9ac15065c635d61441c4f0536
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  This is an advanced search plugin for Blacklight ( http://www.projectblacklight.org ).
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/blacklight_advanced_search.svg)](http://badge.fury.io/rb/blacklight_advanced_search) [![Build Status](https://travis-ci.org/projectblacklight/blacklight_advanced_search.svg)](https://travis-ci.org/projectblacklight/blacklight_advanced_search)
4
+
3
5
  ## Blacklight version compatibility
4
6
 
5
7
  This is a plugin for [Blacklight](http://github.com/projectblacklight/blacklight)
@@ -32,12 +34,12 @@ Add to your application's Gemfile:
32
34
 
33
35
  then run 'bundle install'. Then run:
34
36
 
35
- rails generate blacklight_advanced_search:install
37
+ rails generate blacklight_advanced_search
36
38
 
37
39
  * The 'generate' command will install 'require' statements for the plugin's assets into your application's application.js/application.css asset pipeline files
38
40
  * And it can optionally install a localized search form with a link to advanced search. If you've already localized your search form you'll want to do this manually instead.
39
41
 
40
- You may want to `include BlacklightAdvancedSearch::ParseBasicQ` in your CatalogController to enable AND/OR/NOT parsing even in ordinary search, this is not on by default.
42
+ You may want turn to enable AND/OR/NOT parsing even in ordinary search, this is not on by default. See "Expression parsing in ordinary search" below.
41
43
 
42
44
  ## Accessing
43
45
 
@@ -64,7 +66,11 @@ If your application uses a single Solr qt request handler for all its search fie
64
66
 
65
67
  Turn this feature on by adding to your CatalogController definition:
66
68
 
67
- include BlacklightAdvancedSearch::ParseBasicQ
69
+ self.search_params_logic << :add_advanced_parse_q_to_solr
70
+
71
+ And/or, if you've switched over to configuration in SearchBuilder, then to your ./app/models/search_builder.rb:
72
+
73
+ self.default_processor_chain << :add_advanced_parse_q_to_solr
68
74
 
69
75
  This will intercept queries entered in ordinary Blacklight search interface, and parse them for AND/OR/NOT (and parens), producing appropriate Solr query. This allows single-field boolean expressions to be entered in ordinary search, providing a consistent experience with advanced search.
70
76
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ end
26
26
  task :fixtures => ['engine_cart:generate'] do
27
27
  within_test_app do
28
28
  ENV['RAILS_ENV'] ||= 'test'
29
- system "rake blacklight:solr:seed"
29
+ system "rake blacklight:index:seed"
30
30
  abort "Error running fixtures" unless $?.success?
31
31
  end
32
32
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.1.4
1
+ 5.2.0
@@ -1,8 +1,6 @@
1
1
  # Need to sub-class CatalogController so we get all other plugins behavior
2
2
  # for our own "inside a search context" lookup of facets.
3
3
  class BlacklightAdvancedSearch::AdvancedController < CatalogController
4
- include AdvancedHelper # so we get the #advanced_search_context method
5
-
6
4
 
7
5
  def index
8
6
  unless request.method==:post
@@ -12,48 +10,13 @@ class BlacklightAdvancedSearch::AdvancedController < CatalogController
12
10
 
13
11
  protected
14
12
  def get_advanced_search_facets
15
-
16
- search_context_params = {}
17
- if (advanced_search_context.length > 0 )
18
- # We have a search context, need to fetch facets from within
19
- # that context -- but we dont' want to search within any
20
- # existing :q or ADVANCED facets, so we remove those params.
21
- adv_keys = blacklight_config.search_fields.keys.map {|k| k.to_sym}
22
- trimmed_params = params.except *adv_keys
23
- trimmed_params.delete(:f_inclusive) # adv facets
24
-
25
- search_context_params = solr_search_params(trimmed_params)
26
-
27
- # Don't want to include the 'q' from basic search in our search
28
- # context. Kind of hacky becuase solr_search_params insists on
29
- # using controller.params, not letting us over-ride.
30
- search_context_params.delete(:q)
31
- search_context_params.delete("q")
32
-
33
- # Also delete any facet-related params, or anything else
34
- # we want to set ourselves
35
- search_context_params.delete_if do |k, v|
36
- k = k.to_s
37
- (["facet.limit", "facet.sort", "f", "facets", "facet.fields", "per_page"].include?(k) ||
38
- k =~ /f\..+\.facet\.limit/ ||
39
- k =~ /f\..+\.facet\.sort/
40
- )
41
- end
13
+ # We want to find the facets available for the current search, but:
14
+ # * IGNORING current query (add in facets_for_advanced_search_form filter)
15
+ # * IGNORING current advanced search facets (remove add_advanced_search_to_solr filter)
16
+ response, _ = search_results(params, search_params_logic) do |search_builder|
17
+ search_builder.except(:add_advanced_search_to_solr).append(:facets_for_advanced_search_form)
42
18
  end
43
19
 
44
- input = HashWithIndifferentAccess.new
45
- input.merge!( search_context_params )
46
-
47
- input[:per_page] = 0 # force
48
-
49
- # force if set
50
- input[:qt] = blacklight_config.advanced_search[:qt] if blacklight_config.advanced_search[:qt]
51
-
52
- input.merge!( blacklight_config.advanced_search[:form_solr_parameters] ) if blacklight_config.advanced_search[:form_solr_parameters]
53
-
54
- # ensure empty query is all records, to fetch available facets on entire corpus
55
- input[:q] ||= '{!lucene}*:*'
56
-
57
- repository.search(input)
20
+ return response
58
21
  end
59
22
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency "blacklight", "~> 5.10"
20
+ s.add_dependency "blacklight", "~> 5.15"
21
21
  s.add_dependency "parslet"
22
22
 
23
23
  s.add_development_dependency "rails"
@@ -76,5 +76,25 @@ module BlacklightAdvancedSearch
76
76
  end
77
77
  end
78
78
  end
79
+
80
+ # A Solr param filter that is NOT included by default in the chain,
81
+ # but is appended by AdvancedController#index, to do a search
82
+ # for facets _ignoring_ the current query, we want the facets
83
+ # as if the current query weren't there.
84
+ #
85
+ # Also adds any solr params set in blacklight_config.advanced_search[:form_solr_parameters]
86
+ def facets_for_advanced_search_form(solr_p)
87
+ # ensure empty query is all records, to fetch available facets on entire corpus
88
+ solr_p["q"] = '{!lucene}*:*'
89
+
90
+ # We only care about facets, we don't need any rows.
91
+ solr_p["rows"] = "0"
92
+
93
+ # Anything set in config as a literal
94
+ if blacklight_config.advanced_search[:form_solr_parameters]
95
+ solr_p.merge!( blacklight_config.advanced_search[:form_solr_parameters] )
96
+ end
97
+
98
+ end
79
99
  end
80
- end
100
+ end
@@ -23,7 +23,7 @@ module BlacklightAdvancedSearch::RenderConstraintsOverride
23
23
  content << render_constraint_element(
24
24
  label, query,
25
25
  :remove =>
26
- catalog_index_path(remove_advanced_keyword_query(field,my_params))
26
+ search_action_path(remove_advanced_keyword_query(field, my_params).except(:controller, :action))
27
27
  )
28
28
  end
29
29
  if (advanced_query.keyword_op == "OR" &&
@@ -48,7 +48,7 @@ module BlacklightAdvancedSearch::RenderConstraintsOverride
48
48
  label = facet_field_label(field)
49
49
  content << render_constraint_element(label,
50
50
  safe_join(value_list, " <strong class='text-muted constraint-connector'>OR</strong> ".html_safe),
51
- :remove => catalog_index_path( remove_advanced_filter_group(field, my_params) )
51
+ :remove => search_action_path( remove_advanced_filter_group(field, my_params).except(:controller, :action) )
52
52
  )
53
53
  end
54
54
  end
@@ -15,7 +15,7 @@ module BlacklightAdvancedSearch
15
15
  # Blacklight into local app as custom local override -- but add our link at the end too.
16
16
  source_file = File.read(File.join(Blacklight.root, "app/views/catalog/_search_form.html.erb"))
17
17
 
18
- new_file_contents = source_file + "\n\n<%= link_to 'More options', advanced_search_path(params), :class=>'advanced_search'%>"
18
+ new_file_contents = source_file + "\n\n<%= link_to 'More options', advanced_search_path(params.except(:controller, :action)), :class=>'advanced_search'%>"
19
19
 
20
20
  create_file("app/views/catalog/_search_form.html.erb", new_file_contents)
21
21
  end
@@ -7,7 +7,7 @@ describe "Blacklight Advanced Search Form" do
7
7
 
8
8
  describe "advanced search form" do
9
9
  before do
10
- visit '/advanced'
10
+ visit '/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query'
11
11
  end
12
12
 
13
13
  it "should have field and facet blocks" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_advanced_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.4
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-19 00:00:00.000000000 Z
12
+ date: 2015-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: blacklight
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '5.10'
20
+ version: '5.15'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '5.10'
27
+ version: '5.15'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: parslet
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project: blacklight
199
- rubygems_version: 2.4.6
199
+ rubygems_version: 2.4.5
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Blacklight Advanced Search plugin