spree_solr_search 0.30.0.beta1 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/controllers/spree/base_controller_decorator.rb +0 -5
- data/app/helpers/solr_helper.rb +1 -0
- data/app/views/products/_facets.html.erb +1 -1
- data/app/views/products/_suggestion.html.erb +1 -1
- data/lib/spree/search/solr.rb +7 -10
- data/lib/spree_solr_search.rb +5 -3
- data/spree_solr_search.gemspec +6 -4
- metadata +22 -12
- data/lib/solr_pagination.rb +0 -19
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ Jeweler::Tasks.new do |s|
|
|
21
21
|
s.email = "roman@railsdog.com"
|
22
22
|
s.homepage = "http://github.com/romul/spree-solr-search"
|
23
23
|
s.authors = ["Roman Smirnov"]
|
24
|
-
|
24
|
+
s.add_dependency 'spree_core', ['>= 0.30.0']
|
25
25
|
s.add_dependency 'acts_as_solr_reloaded', ['>= 1.4.0']
|
26
26
|
s.has_rdoc = false
|
27
27
|
#s.extra_rdoc_files = [ "README.rdoc"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.30.0
|
1
|
+
0.30.0
|
data/app/helpers/solr_helper.rb
CHANGED
@@ -3,6 +3,7 @@ module SolrHelper
|
|
3
3
|
facets_hash = params[:facets]
|
4
4
|
facets_hash = {} unless facets_hash.is_a?(Hash)
|
5
5
|
facets_hash = facets_hash.merge({name => ["\"#{value}\"", facets_hash[name]].join(',')})
|
6
|
+
request.params.delete(:page)
|
6
7
|
link_to("#{value} (#{count})", url_for(request.params.merge({:facets => facets_hash})))
|
7
8
|
end
|
8
9
|
end
|
data/lib/spree/search/solr.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Spree::Search
|
2
2
|
class Solr < Spree::Search::Base
|
3
|
-
|
4
|
-
|
3
|
+
protected
|
4
|
+
|
5
|
+
def get_products_conditions_for(base_scope, query)
|
5
6
|
facets = {
|
6
7
|
:fields => [:price_range, :taxon_names, :brand_property, :color_option, :size_option],
|
7
8
|
:browse => @properties[:facets_hash].map{|k,v| "#{k}:#{v}"},
|
@@ -18,11 +19,9 @@ module Spree::Search
|
|
18
19
|
end
|
19
20
|
|
20
21
|
result = Product.find_by_solr(full_query, search_options)
|
21
|
-
@properties[:products] = result.records
|
22
|
-
count = result.records.size
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
count = result.records.size
|
24
|
+
products = result.records.paginate(:page => page, :per_page => per_page, :total_entries => count)
|
26
25
|
|
27
26
|
@properties[:products] = products
|
28
27
|
@properties[:suggest] = nil
|
@@ -35,14 +34,12 @@ module Spree::Search
|
|
35
34
|
end
|
36
35
|
|
37
36
|
@properties[:facets] = parse_facets_hash(result.facets)
|
38
|
-
|
37
|
+
base_scope.where ["products.id IN (?)", products.map(&:id)]
|
39
38
|
end
|
40
39
|
|
41
40
|
def prepare(params)
|
41
|
+
super
|
42
42
|
@properties[:facets_hash] = params[:facets] || {}
|
43
|
-
@properties[:taxon] = params[:taxon].blank? ? nil : Taxon.find(params[:taxon])
|
44
|
-
@properties[:per_page] = params[:per_page]
|
45
|
-
@properties[:page] = params[:page]
|
46
43
|
@properties[:manage_pagination] = true
|
47
44
|
@properties[:order_by_price] = params[:order_by_price]
|
48
45
|
end
|
data/lib/spree_solr_search.rb
CHANGED
@@ -5,11 +5,13 @@ module SpreeSolrSearch
|
|
5
5
|
class Engine < Rails::Engine
|
6
6
|
def self.activate
|
7
7
|
require 'acts_as_solr'
|
8
|
-
require 'solr_pagination'
|
9
8
|
ENV['RAILS_ENV'] = Rails.env
|
10
|
-
|
11
|
-
Spree::Config.
|
9
|
+
|
10
|
+
if Spree::Config.instance
|
11
|
+
Spree::Config.searcher_class = Spree::Search::Solr
|
12
|
+
Spree::Config.set(:product_price_ranges =>
|
12
13
|
["Under $25", "$25 to $50", "$50 to $100", "$100 to $200", "$200 and above"])
|
14
|
+
end
|
13
15
|
|
14
16
|
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
15
17
|
Rails.env == "production" ? require(c) : load(c)
|
data/spree_solr_search.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{spree_solr_search}
|
8
|
-
s.version = "0.30.0
|
8
|
+
s.version = "0.30.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Roman Smirnov"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-11}
|
13
13
|
s.description = %q{Provides search via Apache Solr for a Spree store.}
|
14
14
|
s.email = %q{roman@railsdog.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
|
|
30
30
|
"config/locales/ru.yml",
|
31
31
|
"lib/generators/spree_solr_search/install_generator.rb",
|
32
32
|
"lib/generators/templates/solr.yml",
|
33
|
-
"lib/solr_pagination.rb",
|
34
33
|
"lib/spree/search/solr.rb",
|
35
34
|
"lib/spree_solr_search.rb",
|
36
35
|
"lib/spree_solr_search_hooks.rb",
|
@@ -48,11 +47,14 @@ Gem::Specification.new do |s|
|
|
48
47
|
s.specification_version = 3
|
49
48
|
|
50
49
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<spree_core>, [">= 0.30.0"])
|
51
51
|
s.add_runtime_dependency(%q<acts_as_solr_reloaded>, [">= 1.4.0"])
|
52
52
|
else
|
53
|
+
s.add_dependency(%q<spree_core>, [">= 0.30.0"])
|
53
54
|
s.add_dependency(%q<acts_as_solr_reloaded>, [">= 1.4.0"])
|
54
55
|
end
|
55
56
|
else
|
57
|
+
s.add_dependency(%q<spree_core>, [">= 0.30.0"])
|
56
58
|
s.add_dependency(%q<acts_as_solr_reloaded>, [">= 1.4.0"])
|
57
59
|
end
|
58
60
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_solr_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 30
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 0.30.0.beta1
|
9
|
+
version: 0.30.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Roman Smirnov
|
@@ -15,13 +14,27 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2011-01-11 00:00:00 +03:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
21
|
+
name: spree_core
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 30
|
30
|
+
- 0
|
31
|
+
version: 0.30.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: acts_as_solr_reloaded
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
38
|
requirements:
|
26
39
|
- - ">="
|
27
40
|
- !ruby/object:Gem::Version
|
@@ -31,7 +44,7 @@ dependencies:
|
|
31
44
|
- 0
|
32
45
|
version: 1.4.0
|
33
46
|
type: :runtime
|
34
|
-
version_requirements: *
|
47
|
+
version_requirements: *id002
|
35
48
|
description: Provides search via Apache Solr for a Spree store.
|
36
49
|
email: roman@railsdog.com
|
37
50
|
executables: []
|
@@ -55,7 +68,6 @@ files:
|
|
55
68
|
- config/locales/ru.yml
|
56
69
|
- lib/generators/spree_solr_search/install_generator.rb
|
57
70
|
- lib/generators/templates/solr.yml
|
58
|
-
- lib/solr_pagination.rb
|
59
71
|
- lib/spree/search/solr.rb
|
60
72
|
- lib/spree_solr_search.rb
|
61
73
|
- lib/spree_solr_search_hooks.rb
|
@@ -79,13 +91,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
91
|
version: "0"
|
80
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
93
|
requirements:
|
82
|
-
- - "
|
94
|
+
- - ">="
|
83
95
|
- !ruby/object:Gem::Version
|
84
96
|
segments:
|
85
|
-
-
|
86
|
-
|
87
|
-
- 1
|
88
|
-
version: 1.3.1
|
97
|
+
- 0
|
98
|
+
version: "0"
|
89
99
|
requirements: []
|
90
100
|
|
91
101
|
rubyforge_project:
|
data/lib/solr_pagination.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# By Henrik Nyh <http://henrik.nyh.se> 2007-06-15.
|
2
|
-
# Free to modify and redistribute with credit.
|
3
|
-
|
4
|
-
# Adds a find_all_by_solr method to acts_as_solr models to enable
|
5
|
-
# will_paginate for acts_as_solr search results.
|
6
|
-
|
7
|
-
module ActsAsSolr
|
8
|
-
module PaginationExtension
|
9
|
-
|
10
|
-
def find_all_by_solr(query, options)
|
11
|
-
Spree::Config.searcher.products.slice(options[:offset], options[:limit])
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module ActsAsSolr::ClassMethods
|
18
|
-
include ActsAsSolr::PaginationExtension
|
19
|
-
end
|