blacklight_advanced_search 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.2
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# Need to sub-class CatalogController so we get all other plugins behavior
|
|
2
|
-
# for our own "inside a search context" lookup of facets.
|
|
3
|
-
class AdvancedController < CatalogController
|
|
4
|
-
include AdvancedHelper # so we get the #advanced_search_context method
|
|
5
|
-
|
|
6
|
-
before_filter :setup_advanced_search_assets, :only => :index
|
|
7
|
-
|
|
8
|
-
def index
|
|
9
|
-
unless request.method==:post
|
|
10
|
-
@response = get_advanced_search_facets
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
protected
|
|
15
|
-
def get_advanced_search_facets
|
|
16
|
-
|
|
17
|
-
search_context_params = {}
|
|
18
|
-
if (advanced_search_context.length > 0 )
|
|
19
|
-
# We have a search context, need to fetch facets from within
|
|
20
|
-
# that context -- but we dont' want to search within any
|
|
21
|
-
# existing :q or ADVANCED facets, so we remove those params.
|
|
22
|
-
adv_keys = BlacklightAdvancedSearch.config[:search_fields].collect {|d| d[:key].to_sym}
|
|
23
|
-
trimmed_params = params.reject do |k,v|
|
|
24
|
-
adv_keys.include?(k.to_sym) # the individual q params
|
|
25
|
-
end
|
|
26
|
-
trimmed_params.delete(:f_inclusive) # adv facets
|
|
27
|
-
|
|
28
|
-
search_context_params = solr_search_params(trimmed_params)
|
|
29
|
-
# Don't want to include the 'q' from basic search in our search
|
|
30
|
-
# context. Kind of hacky becuase solr_search_params insists on
|
|
31
|
-
# using controller.params, not letting us over-ride.
|
|
32
|
-
search_context_params.delete(:q)
|
|
33
|
-
search_context_params.delete("q")
|
|
34
|
-
|
|
35
|
-
# Also delete any facet-related params, or anything else
|
|
36
|
-
# we want to set ourselves or inherit from Solr request handler
|
|
37
|
-
# defaults.
|
|
38
|
-
search_context_params.delete_if do |k, v|
|
|
39
|
-
k = k.to_s
|
|
40
|
-
(["facet.limit", "facet.sort", "f", "facets", "facet.fields", "qt", "per_page"].include?(k) ||
|
|
41
|
-
k =~ /f\..+\.facet\.limit/ ||
|
|
42
|
-
k =~ /f\..+\.facet\.sort/
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
input = HashWithIndifferentAccess.new
|
|
48
|
-
input.merge!( search_context_params )
|
|
49
|
-
input.merge!( :qt => BlacklightAdvancedSearch.config[:qt] , :per_page => 0)
|
|
50
|
-
input.merge!( BlacklightAdvancedSearch.config[:form_solr_parameters] )
|
|
51
|
-
input[:q] ||= '{!lucene}*:*'
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
def setup_advanced_search_assets
|
|
57
|
-
unless BlacklightAdvancedSearch.use_asset_pipeline?
|
|
58
|
-
stylesheet_links << ["blacklight_advanced_search_styles", {:plugin=>:blacklight_advanced_search}]
|
|
59
|
-
javascript_includes << ["blacklight_advanced_search_javascript", {:plugin=>:blacklight_advanced_search}]
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|
|
1
|
+
# Need to sub-class CatalogController so we get all other plugins behavior
|
|
2
|
+
# for our own "inside a search context" lookup of facets.
|
|
3
|
+
class AdvancedController < CatalogController
|
|
4
|
+
include AdvancedHelper # so we get the #advanced_search_context method
|
|
5
|
+
|
|
6
|
+
before_filter :setup_advanced_search_assets, :only => :index
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
unless request.method==:post
|
|
10
|
+
@response = get_advanced_search_facets
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
def get_advanced_search_facets
|
|
16
|
+
|
|
17
|
+
search_context_params = {}
|
|
18
|
+
if (advanced_search_context.length > 0 )
|
|
19
|
+
# We have a search context, need to fetch facets from within
|
|
20
|
+
# that context -- but we dont' want to search within any
|
|
21
|
+
# existing :q or ADVANCED facets, so we remove those params.
|
|
22
|
+
adv_keys = BlacklightAdvancedSearch.config[:search_fields].collect {|d| d[:key].to_sym}
|
|
23
|
+
trimmed_params = params.reject do |k,v|
|
|
24
|
+
adv_keys.include?(k.to_sym) # the individual q params
|
|
25
|
+
end
|
|
26
|
+
trimmed_params.delete(:f_inclusive) # adv facets
|
|
27
|
+
|
|
28
|
+
search_context_params = solr_search_params(trimmed_params)
|
|
29
|
+
# Don't want to include the 'q' from basic search in our search
|
|
30
|
+
# context. Kind of hacky becuase solr_search_params insists on
|
|
31
|
+
# using controller.params, not letting us over-ride.
|
|
32
|
+
search_context_params.delete(:q)
|
|
33
|
+
search_context_params.delete("q")
|
|
34
|
+
|
|
35
|
+
# Also delete any facet-related params, or anything else
|
|
36
|
+
# we want to set ourselves or inherit from Solr request handler
|
|
37
|
+
# defaults.
|
|
38
|
+
search_context_params.delete_if do |k, v|
|
|
39
|
+
k = k.to_s
|
|
40
|
+
(["facet.limit", "facet.sort", "f", "facets", "facet.fields", "qt", "per_page"].include?(k) ||
|
|
41
|
+
k =~ /f\..+\.facet\.limit/ ||
|
|
42
|
+
k =~ /f\..+\.facet\.sort/
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
input = HashWithIndifferentAccess.new
|
|
48
|
+
input.merge!( search_context_params )
|
|
49
|
+
input.merge!( :qt => BlacklightAdvancedSearch.config[:qt] , :per_page => 0)
|
|
50
|
+
input.merge!( BlacklightAdvancedSearch.config[:form_solr_parameters] )
|
|
51
|
+
input[:q] ||= '{!lucene}*:*'
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
find(input.to_hash)
|
|
55
|
+
end
|
|
56
|
+
def setup_advanced_search_assets
|
|
57
|
+
unless BlacklightAdvancedSearch.use_asset_pipeline?
|
|
58
|
+
stylesheet_links << ["blacklight_advanced_search_styles", {:plugin=>:blacklight_advanced_search}]
|
|
59
|
+
javascript_includes << ["blacklight_advanced_search_javascript", {:plugin=>:blacklight_advanced_search}]
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
# Copy BlacklightAdvancedSearch assets to public folder in current app.
|
|
2
|
-
# If you want to do this on application startup, you can
|
|
3
|
-
# add this next line to your one of your environment files --
|
|
4
|
-
# generally you'd only want to do this in 'development', and can
|
|
5
|
-
# add it to environments/development.rb:
|
|
6
|
-
# require File.join(BlacklightAdvancedSearch.root, "lib", "generators", "blacklight", "assets_generator.rb")
|
|
7
|
-
# BlacklightAdvancedSearch::AssetsGenerator.start(["--force", "--quiet"])
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Need the requires here so we can call the generator from environment.rb
|
|
11
|
-
# as suggested above.
|
|
12
|
-
require 'rails/generators'
|
|
13
|
-
require 'rails/generators/base'
|
|
14
|
-
module BlacklightAdvancedSearch
|
|
15
|
-
class AssetsGenerator < Rails::Generators::Base
|
|
16
|
-
source_root File.join(BlacklightAdvancedSearch::Engine.root, 'app', 'assets')
|
|
17
|
-
|
|
18
|
-
def assets
|
|
19
|
-
if BlacklightAdvancedSearch.use_asset_pipeline?
|
|
20
|
-
original_css = File.binread("app/assets/stylesheets/application.css")
|
|
21
|
-
if original_css.include?("require 'blacklight_advanced_search'")
|
|
22
|
-
say_status("skipped", "insert into app/assets/stylesheets/application.css", :yellow)
|
|
23
|
-
else
|
|
24
|
-
insert_into_file "app/assets/stylesheets/application.css", :before => "*/" do
|
|
25
|
-
"\n *= require 'blacklight_advanced_search'\n\n"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
original_js = File.binread("app/assets/javascripts/application.js")
|
|
30
|
-
if original_js.include?("require 'blacklight_advanced_search'")
|
|
31
|
-
say_status("skipped", "insert into app/assets/javascripts/application.js", :yellow)
|
|
32
|
-
else
|
|
33
|
-
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require ['"]?jquery['"]?} do
|
|
34
|
-
"\n//= require 'blacklight_advanced_search'\n\n"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
else
|
|
38
|
-
directory("stylesheets/blacklight_advanced_search", "public/stylesheets")
|
|
39
|
-
directory("javascripts/blacklight_advanced_search", "public/javascripts")
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
1
|
+
# Copy BlacklightAdvancedSearch assets to public folder in current app.
|
|
2
|
+
# If you want to do this on application startup, you can
|
|
3
|
+
# add this next line to your one of your environment files --
|
|
4
|
+
# generally you'd only want to do this in 'development', and can
|
|
5
|
+
# add it to environments/development.rb:
|
|
6
|
+
# require File.join(BlacklightAdvancedSearch.root, "lib", "generators", "blacklight", "assets_generator.rb")
|
|
7
|
+
# BlacklightAdvancedSearch::AssetsGenerator.start(["--force", "--quiet"])
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Need the requires here so we can call the generator from environment.rb
|
|
11
|
+
# as suggested above.
|
|
12
|
+
require 'rails/generators'
|
|
13
|
+
require 'rails/generators/base'
|
|
14
|
+
module BlacklightAdvancedSearch
|
|
15
|
+
class AssetsGenerator < Rails::Generators::Base
|
|
16
|
+
source_root File.join(BlacklightAdvancedSearch::Engine.root, 'app', 'assets')
|
|
17
|
+
|
|
18
|
+
def assets
|
|
19
|
+
if BlacklightAdvancedSearch.use_asset_pipeline?
|
|
20
|
+
original_css = File.binread("app/assets/stylesheets/application.css")
|
|
21
|
+
if original_css.include?("require 'blacklight_advanced_search'")
|
|
22
|
+
say_status("skipped", "insert into app/assets/stylesheets/application.css", :yellow)
|
|
23
|
+
else
|
|
24
|
+
insert_into_file "app/assets/stylesheets/application.css", :before => "*/" do
|
|
25
|
+
"\n *= require 'blacklight_advanced_search'\n\n"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
original_js = File.binread("app/assets/javascripts/application.js")
|
|
30
|
+
if original_js.include?("require 'blacklight_advanced_search'")
|
|
31
|
+
say_status("skipped", "insert into app/assets/javascripts/application.js", :yellow)
|
|
32
|
+
else
|
|
33
|
+
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require ['"]?jquery['"]?} do
|
|
34
|
+
"\n//= require 'blacklight_advanced_search'\n\n"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
directory("stylesheets/blacklight_advanced_search", "public/stylesheets")
|
|
39
|
+
directory("javascripts/blacklight_advanced_search", "public/javascripts")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blacklight_advanced_search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 1.1.
|
|
9
|
+
- 2
|
|
10
|
+
version: 1.1.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jonathan Rochkind
|
|
@@ -16,8 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2011-
|
|
20
|
-
default_executable:
|
|
19
|
+
date: 2011-11-02 00:00:00 Z
|
|
21
20
|
dependencies:
|
|
22
21
|
- !ruby/object:Gem::Dependency
|
|
23
22
|
name: rails
|
|
@@ -118,7 +117,6 @@ files:
|
|
|
118
117
|
- spec/spec_helper.rb
|
|
119
118
|
- spec/support/blacklight_mock.rb
|
|
120
119
|
- uninstall.rb
|
|
121
|
-
has_rdoc: true
|
|
122
120
|
homepage: http://projectblacklight.org/
|
|
123
121
|
licenses: []
|
|
124
122
|
|
|
@@ -148,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
148
146
|
requirements: []
|
|
149
147
|
|
|
150
148
|
rubyforge_project: blacklight
|
|
151
|
-
rubygems_version: 1.
|
|
149
|
+
rubygems_version: 1.7.2
|
|
152
150
|
signing_key:
|
|
153
151
|
specification_version: 3
|
|
154
152
|
summary: Blacklight Advanced Search plugin
|