spree_solr_search 0.40.3 → 1.0.0.rc

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/README.md CHANGED
@@ -3,12 +3,13 @@ Solr Search
3
3
 
4
4
  ### Installation
5
5
 
6
+ 1. add `gem 'acts_as_solr_reloaded', :git => 'git://github.com/evrone/acts_as_solr_reloaded.git', :branch => "ar_namespace_support"` to your Gemfile
6
7
  1. Add `gem "spree_solr_search"` to your Gemfile
7
8
  1. Run `bundle install`
8
9
  1. Run `rails g spree_solr_search:install`
9
10
 
10
- **NOTE:** Master branch works only with Spree 0.30.x.
11
- If you want use this extension with Spree 0.10.x or 0.11.x, then you should use spree-0-11-stable branch
11
+ Master branch 1.0.x compatible.
12
+ If you want use this extension with Spree 0.10.x or 0.11.x, then you should use spree-0-11-stable branch.
12
13
 
13
14
  ### Usage
14
15
 
@@ -16,7 +17,6 @@ To perform the indexing:
16
17
 
17
18
  rake solr:reindex BATCH=500
18
19
 
19
-
20
20
  To start Solr demo-server:
21
21
 
22
22
  rake solr:start SOLR_PATH="/home/roman/www/jetty-solr"
@@ -29,6 +29,11 @@ To configure production Solr server:
29
29
 
30
30
  edit RAILS_ROOT/config/solr.yml
31
31
 
32
+
33
+ ### Running rake tasks in background
34
+
35
+ Read [instructions](https://gist.github.com/890215) how to run rake tasks in background.
36
+
32
37
  P.S. For development recommended use [jetty-solr](http://github.com/dcrec1/jetty-solr) server.
33
38
 
34
39
 
data/Rakefile CHANGED
@@ -11,8 +11,7 @@ end
11
11
  require 'rake'
12
12
  require 'rake/testtask'
13
13
  #require 'rake/rdoctask'
14
- require 'rake/packagetask'
15
- require 'rake/gempackagetask'
14
+ require 'rubygems/package_task'
16
15
 
17
16
  Jeweler::Tasks.new do |s|
18
17
  s.name = "spree_solr_search"
@@ -21,7 +20,7 @@ Jeweler::Tasks.new do |s|
21
20
  s.email = "roman@railsdog.com"
22
21
  s.homepage = "http://github.com/romul/spree-solr-search"
23
22
  s.authors = ["Roman Smirnov"]
24
- s.add_dependency 'spree_core', ['>= 0.30.1']
23
+ s.add_dependency 'spree_core', ['>= 1.0.0']
25
24
  s.add_dependency 'acts_as_solr_reloaded', ['>= 1.6.0']
26
25
  s.has_rdoc = false
27
26
  #s.extra_rdoc_files = [ "README.rdoc"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.40.3
1
+ 1.0.0.rc
data/Versionfile ADDED
@@ -0,0 +1,4 @@
1
+ "0.11.x" => { :branch => "spree-0-11-stable" }
2
+ "0.50.x" => { :branch => "0-60-stable" }
3
+ "0.60.x" => { :branch => "0-60-stable" }
4
+ "1.0.x" => { :branch => "master" }
@@ -0,0 +1,3 @@
1
+ $ ->
2
+ $('#product_sort_by').change ->
3
+ window.location.href = @value
@@ -6,4 +6,11 @@ Spree::BaseHelper.module_eval do
6
6
  request.params.delete(:page)
7
7
  link_to("#{value} (#{count})", url_for(request.params.merge({:facets => facets_hash})))
8
8
  end
9
+
10
+ # hate to clutter up the BaseHelper with this one-time
11
+ def sort_by_options_list
12
+ # generate <options></options> list
13
+ options = ::PRODUCT_SORT_FIELDS.map { |k, v| [t(k), url_for(request.params.merge({:sort => k}))] }
14
+ options_for_select(options, url_for(request.params.merge({ :sort => params[:sort] || ::PRODUCT_SORT_FIELDS.keys.first })))
15
+ end
9
16
  end
@@ -0,0 +1,80 @@
1
+ Spree::Product.class_eval do
2
+ acts_as_solr :fields => PRODUCT_SOLR_FIELDS, :facets => PRODUCT_SOLR_FACETS rescue nil
3
+
4
+ def taxon_ids
5
+ taxons.map(&:id)
6
+ end
7
+
8
+ def is_active
9
+ !deleted_at && available_on &&
10
+ (available_on <= Time.zone.now) &&
11
+ (Spree::Config[:allow_backorders] || count_on_hand > 0)
12
+ end
13
+
14
+ # saves product to the Solr index
15
+ def solr_save
16
+ return true if indexing_disabled?
17
+ if evaluate_condition(:if, self)
18
+ if defined? Delayed::Job
19
+ Delayed::Job.enqueue SolrManager.new("solr_save", self, Spree::SolrSearch::Config[:auto_commit])
20
+ else
21
+ debug "solr_save: #{self.class.name} : #{record_id(self)}"
22
+ solr_add to_solr_doc
23
+ solr_commit if Spree::SolrSearch::Config[:auto_commit]
24
+ end
25
+ true
26
+ else
27
+ solr_destroy
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def store_ids
34
+ if self.respond_to? :stores
35
+ stores.map(&:id)
36
+ else
37
+ []
38
+ end
39
+ end
40
+
41
+ def taxon_names
42
+ taxons.map(&:name)
43
+ end
44
+
45
+ def price_range
46
+ max = 0
47
+ PRODUCT_PRICE_RANGES.each do |range, name|
48
+ return name if range.include?(price)
49
+ max = range.max if range.max > max
50
+ end
51
+ I18n.t(:price_and_above, :price => max)
52
+ end
53
+
54
+ def brand_property
55
+ pp = Spree::ProductProperty.first(:joins => :property,
56
+ :conditions => {:product_id => self.id, :spree_properties => {:name => 'brand'}})
57
+ pp ? pp.value : ''
58
+ end
59
+
60
+ def color_option
61
+ get_option_values('color')
62
+ end
63
+
64
+ def size_option
65
+ get_option_values('size')
66
+ end
67
+
68
+ def get_option_values(option_name)
69
+ sql = <<-eos
70
+ SELECT DISTINCT ov.id, ov.presentation
71
+ FROM spree_option_values AS ov
72
+ LEFT JOIN spree_option_types AS ot ON (ov.option_type_id = ot.id)
73
+ LEFT JOIN spree_option_values_variants AS ovv ON (ovv.option_value_id = ov.id)
74
+ LEFT JOIN spree_variants AS v ON (ovv.variant_id = v.id)
75
+ LEFT JOIN spree_products AS p ON (v.product_id = p.id)
76
+ WHERE (ot.name = '#{option_name}' AND p.id = #{self.id});
77
+ eos
78
+ Spree::OptionValue.find_by_sql(sql).map(&:presentation)
79
+ end
80
+ end
@@ -0,0 +1,3 @@
1
+ class Spree::SolrSearchConfiguration < Spree::Preferences::Configuration
2
+ preference :auto_commit, :boolean, :default => true
3
+ end
@@ -0,0 +1,11 @@
1
+ Deface::Override.new(:virtual_path => "spree/shared/_taxonomies",
2
+ :name => "show_search_partials_facets",
3
+ :insert_top => "#taxonomies",
4
+ :partial => "spree/products/facets",
5
+ :disabled => false)
6
+
7
+ Deface::Override.new(:virtual_path => "spree/products/index",
8
+ :name => "show_search_partials_suggestion",
9
+ :insert_top => "[data-hook='search_results']",
10
+ :partial => "spree/products/suggestion",
11
+ :disabled => false)
@@ -9,8 +9,8 @@ facets = @searcher.facets || []
9
9
  options = options.sort{|x, y| y.count <=> x.count}
10
10
  end
11
11
  unless options.empty? %>
12
- <h4><%= t "#{facet.name}_facet" %></h4>
13
- <ul><%
12
+ <h6 class="taxonomy-root"><%= t "#{facet.name}_facet" %></h6>
13
+ <ul class="taxons-list"><%
14
14
  for option in options %>
15
15
  <li>
16
16
  <%= link_to_facet(facet.name, option.name, option.count) %>
@@ -0,0 +1 @@
1
+ <div id="product-list-sort">Sort by: <%= select_tag("product_sort_by", sort_by_options_list) %></div>
@@ -1,5 +1,5 @@
1
1
  <% if suggestion = @searcher.suggest %>
2
- <p>
2
+ <p class="search-results-suggestion">
3
3
  <%= t(:did_you_mean, :default => "Did you mean") %>
4
4
  <%= link_to h(suggestion), url_for(request.params.merge({:keywords => suggestion})) %>?
5
5
  </p>
@@ -11,3 +11,14 @@ unless defined?(PRODUCT_SOLR_FACETS)
11
11
  PRODUCT_SOLR_FACETS = [:price_range, :taxon_names,
12
12
  :brand_property, :color_option, :size_option]
13
13
  end
14
+
15
+ unless defined?(PRODUCT_SORT_FIELDS)
16
+ PRODUCT_SORT_FIELDS = {
17
+ "price_asc" => ["spree_variants.price", "asc"],
18
+ "price_desc" => ["spree_variants.price", "desc"],
19
+ "date_asc" => ["spree_products.available_on", "asc"],
20
+ "date_desc" => ["spree_products.available_on", "desc"],
21
+ "name_asc" => ["spree_products.name", "asc"],
22
+ "name_desc" => ["spree_products.name", "desc"]
23
+ }
24
+ end
@@ -0,0 +1,17 @@
1
+ class SolrManager
2
+ def initialize(mode, object, auto_commit)
3
+ @mode = mode
4
+ @object = object
5
+ @auto_commit = auto_commit
6
+ end
7
+
8
+ def perform
9
+ puts "#{@mode}: #{@object.class.name} : #{@object.id}"
10
+ if @mode == "solr_save"
11
+ @object.solr_add(@object.to_solr_doc)
12
+ elsif @mode == "solr_destroy"
13
+ @object.solr_delete(@object.solr_id)
14
+ end
15
+ @object.solr_commit if @auto_commit
16
+ end
17
+ end
@@ -1,17 +1,31 @@
1
1
  module Spree::Search
2
- class Solr < defined?(Spree::Search::MultiDomain) ? Spree::Search::MultiDomain : Spree::Search::Base
2
+ class Solr < defined?(Spree::Core::Search::MultiDomain) ? Spree::Core::Search::MultiDomain : Spree::Core::Search::Base
3
3
  protected
4
4
 
5
+ # NOTE: This class seems to loaded and init'd on rails startup
6
+ # this means that any changes to the code will not take effect until the rails app is reloaded.
7
+
5
8
  def get_products_conditions_for(base_scope, query)
6
9
  facets = {
7
10
  :fields => PRODUCT_SOLR_FACETS,
8
11
  :browse => @properties[:facets_hash].map{|k,v| "#{k}:#{v}"},
9
12
  :zeros => false
10
13
  }
14
+
15
+ # adding :scores => true here should return relevance scoring, but the underlying acts_as_solr library seems broken
11
16
  search_options = {:facets => facets, :limit => 25000, :lazy => true}
12
- if order_by_price
13
- search_options.merge!(:order => (order_by_price == 'descend') ? "price desc" : "price asc")
17
+
18
+ # the order option does not work... it generates the solr query request correctly
19
+ # but the returned result.records are not ordered correctly
20
+ # search_options.merge!(:order => (order_by_price == 'descend') ? "price desc" : "price asc")
21
+
22
+ # TODO: find a better place to put the PRODUCT_SORT_FIELDS instead of the global constant namespace
23
+ if not @properties[:sort].nil? and PRODUCT_SORT_FIELDS.has_key? @properties[:sort]
24
+ sort_option = PRODUCT_SORT_FIELDS[@properties[:sort]]
25
+ base_scope = base_scope.order("#{sort_option[0]} #{sort_option[1].upcase}")
14
26
  end
27
+
28
+ # Solr query parameters: http://wiki.apache.org/solr/CommonQueryParameters
15
29
  full_query = query + " AND is_active:(true)"
16
30
  if taxon
17
31
  taxons_query = taxon.self_and_descendants.map{|t| "taxon_ids:(#{t.id})"}.join(" OR ")
@@ -20,30 +34,34 @@ module Spree::Search
20
34
 
21
35
  full_query += " AND store_ids:(#{current_store_id})" if current_store_id
22
36
 
23
- result = Product.find_by_solr(full_query, search_options)
37
+ # Rails.logger.info "Solr Query: #{full_query}\nOptions: #{search_options}"
38
+
39
+ result = Spree::Product.find_by_solr(full_query, search_options)
24
40
 
25
- count = result.records.size
26
- products = result.records.paginate(:page => page, :per_page => per_page, :total_entries => count)
41
+ products = result.records
42
+
43
+ # Rails.logger.info "Solr Response: #{result.records}"
27
44
 
28
45
  @properties[:products] = products
29
46
  @properties[:suggest] = nil
30
47
  begin
31
- if suggest = result.suggest
32
- suggest.sub!(/\sAND.*/, '')
33
- @properties[:suggest] = suggest if suggest != query
34
- end
48
+ if suggest = result.suggest
49
+ suggest.sub!(/\sAND.*/, '')
50
+ @properties[:suggest] = suggest if suggest != query
51
+ end
35
52
  rescue
36
53
  end
37
-
54
+
38
55
  @properties[:facets] = parse_facets_hash(result.facets)
39
- base_scope.where ["products.id IN (?)", products.map(&:id)]
56
+ base_scope.where(["spree_products.id IN (?)", products.map(&:id)])
40
57
  end
41
58
 
42
59
  def prepare(params)
43
60
  super
44
61
  @properties[:facets_hash] = params[:facets] || {}
45
- @properties[:manage_pagination] = true
46
- @properties[:order_by_price] = params[:order_by_price]
62
+ @properties[:manage_pagination] = false
63
+ @properties[:sort] = params[:sort] || nil
64
+ # @properties[:order_by_price] = params[:order_by_price]
47
65
  end
48
66
 
49
67
  private
@@ -55,7 +73,7 @@ module Spree::Search
55
73
  next if options.size <= 1
56
74
  facet = Facet.new(name.sub('_facet', ''))
57
75
  options.each do |value, count|
58
- facet.options << FacetOption.new(value, count)
76
+ facet.options << FacetOption.new(value, count, facet.name)
59
77
  end
60
78
  facets << facet
61
79
  end
@@ -76,9 +94,11 @@ module Spree::Search
76
94
  class FacetOption
77
95
  attr_accessor :name
78
96
  attr_accessor :count
79
- def initialize(name, count)
97
+ attr_accessor :facet_name
98
+ def initialize(name, count, facet_name)
80
99
  self.name = name
81
100
  self.count = count
101
+ self.facet_name = facet_name
82
102
  end
83
103
  end
84
104
  end
@@ -1,18 +1,28 @@
1
1
  require 'spree_core'
2
- require 'spree_solr_search_hooks'
2
+
3
+ module Spree::SolrSearch
4
+ end
3
5
 
4
6
  module SpreeSolrSearch
5
7
  class Engine < Rails::Engine
8
+ engine_name 'spree_solr_search'
9
+
10
+ initializer "spree.solr_search.preferences", :after => "spree.environment" do |app|
11
+ Spree::SolrSearch::Config = Spree::SolrSearchConfiguration.new
12
+ Spree::Config.searcher_class = Spree::Search::Solr
13
+ end
14
+
6
15
  def self.activate
7
16
  require 'websolr_acts_as_solr'
8
17
  ENV['RAILS_ENV'] = Rails.env
9
-
10
- if Spree::Config.instance
11
- Spree::Config.searcher_class = Spree::Search::Solr
12
- end
13
18
 
14
19
  Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
15
- Rails.env == "production" ? require(c) : load(c)
20
+ Rails.configuration.cache_classes ? require(c) : load(c)
21
+ end
22
+
23
+ # Load application's view overrides
24
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/**/*.rb")) do |c|
25
+ Rails.configuration.cache_classes ? require(c) : load(c)
16
26
  end
17
27
 
18
28
  end
@@ -1,5 +1,5 @@
1
1
  begin
2
- ENV['ONLY'] = "Product"
2
+ ENV['ONLY'] = "Spree::Product"
3
3
  SOLR_PATH = ENV['SOLR_PATH']
4
4
  RAILS_DEFAULT_LOGGER = Logger.new(Rails.root.join("log", Rails.env + ".log"))
5
5
  RAILS_ROOT = Rails.root.to_s unless defined?(RAILS_ROOT)
@@ -8,3 +8,17 @@ begin
8
8
  rescue LoadError
9
9
  puts "WARNING: acts_as_solr_reloaded gem appears to be unavailable. Please install with bundle install."
10
10
  end
11
+
12
+ namespace :solr do
13
+ task :optimize => :environment do
14
+ acts_as_solr_lib_path = $LOAD_PATH.find{|path| path =~ /acts_as_solr_reloaded/ }
15
+ require File.expand_path("#{acts_as_solr_lib_path}/../config/solr_environment")
16
+ begin
17
+ puts "Optimizing..."
18
+ Spree::Product.solr_optimize
19
+ rescue Errno::ECONNREFUSED
20
+ puts "Can't run optimizing, b/c Solr server is unavailable."
21
+ end
22
+ end
23
+ end
24
+
@@ -1,61 +1,63 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{spree_solr_search}
8
- s.version = "0.40.3"
7
+ s.name = "spree_solr_search"
8
+ s.version = "1.0.0.rc"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roman Smirnov"]
12
- s.date = %q{2011-03-21}
13
- s.description = %q{Provides search via Apache Solr for a Spree store.}
14
- s.email = %q{roman@railsdog.com}
12
+ s.date = "2012-04-02"
13
+ s.description = "Provides search via Apache Solr for a Spree store."
14
+ s.email = "roman@railsdog.com"
15
15
  s.extra_rdoc_files = [
16
16
  "README.md"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
20
- "README.md",
21
- "Rakefile",
22
- "VERSION",
23
- "app/helpers/spree/base_helper_decorator.rb",
24
- "app/models/product_decorator.rb",
25
- "app/views/products/_facets.html.erb",
26
- "app/views/products/_suggestion.html.erb",
27
- "config/initializers/solr_config.rb",
28
- "config/locales/en.yml",
29
- "config/locales/ru-RU.yml",
30
- "config/locales/ru.yml",
31
- "lib/generators/spree_solr_search/install_generator.rb",
32
- "lib/generators/templates/solr.yml",
33
- "lib/spree/search/solr.rb",
34
- "lib/spree_solr_search.rb",
35
- "lib/spree_solr_search_hooks.rb",
36
- "lib/tasks/acts_as_solr.rake",
37
- "lib/websolr_acts_as_solr.rb",
38
- "spree_solr_search.gemspec"
19
+ "README.md",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "Versionfile",
23
+ "app/assets/javascripts/store/solr_sort_by.js.coffee",
24
+ "app/helpers/spree/base_helper_decorator.rb",
25
+ "app/models/spree/product_decorator.rb",
26
+ "app/models/spree/solr_search_configuration.rb",
27
+ "app/overrides/show_search_partials.rb",
28
+ "app/views/spree/products/_facets.html.erb",
29
+ "app/views/spree/products/_sort_bar.html.erb",
30
+ "app/views/spree/products/_suggestion.html.erb",
31
+ "config/initializers/solr_config.rb",
32
+ "config/locales/en.yml",
33
+ "config/locales/ru-RU.yml",
34
+ "config/locales/ru.yml",
35
+ "lib/generators/spree_solr_search/install_generator.rb",
36
+ "lib/generators/templates/solr.yml",
37
+ "lib/solr_manager.rb",
38
+ "lib/spree/search/solr.rb",
39
+ "lib/spree_solr_search.rb",
40
+ "lib/tasks/acts_as_solr.rake",
41
+ "lib/websolr_acts_as_solr.rb",
42
+ "spree_solr_search.gemspec"
39
43
  ]
40
- s.homepage = %q{http://github.com/romul/spree-solr-search}
41
- s.rdoc_options = ["--charset=UTF-8"]
44
+ s.homepage = "http://github.com/romul/spree-solr-search"
42
45
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.6}
44
- s.summary = %q{Provides search via Apache Solr for a Spree store.}
46
+ s.rubygems_version = "1.8.15"
47
+ s.summary = "Provides search via Apache Solr for a Spree store."
45
48
 
46
49
  if s.respond_to? :specification_version then
47
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
50
  s.specification_version = 3
49
51
 
50
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
- s.add_runtime_dependency(%q<spree_core>, [">= 0.30.1"])
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<spree_core>, [">= 1.0.0"])
52
54
  s.add_runtime_dependency(%q<acts_as_solr_reloaded>, [">= 1.6.0"])
53
55
  else
54
- s.add_dependency(%q<spree_core>, [">= 0.30.1"])
56
+ s.add_dependency(%q<spree_core>, [">= 1.0.0"])
55
57
  s.add_dependency(%q<acts_as_solr_reloaded>, [">= 1.6.0"])
56
58
  end
57
59
  else
58
- s.add_dependency(%q<spree_core>, [">= 0.30.1"])
60
+ s.add_dependency(%q<spree_core>, [">= 1.0.0"])
59
61
  s.add_dependency(%q<acts_as_solr_reloaded>, [">= 1.6.0"])
60
62
  end
61
63
  end
metadata CHANGED
@@ -1,12 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_solr_search
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 981947206
5
+ prerelease: 6
5
6
  segments:
7
+ - 1
8
+ - 0
6
9
  - 0
7
- - 40
8
- - 3
9
- version: 0.40.3
10
+ - rc
11
+ version: 1.0.0.rc
10
12
  platform: ruby
11
13
  authors:
12
14
  - Roman Smirnov
@@ -14,30 +16,33 @@ autorequire:
14
16
  bindir: bin
15
17
  cert_chain: []
16
18
 
17
- date: 2011-03-21 00:00:00 +03:00
18
- default_executable:
19
+ date: 2012-04-02 00:00:00 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: spree_core
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 23
27
30
  segments:
28
- - 0
29
- - 30
30
31
  - 1
31
- version: 0.30.1
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: acts_as_solr_reloaded
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 15
41
46
  segments:
42
47
  - 1
43
48
  - 6
@@ -54,53 +59,62 @@ extensions: []
54
59
  extra_rdoc_files:
55
60
  - README.md
56
61
  files:
57
- - .gitignore
58
62
  - README.md
59
63
  - Rakefile
60
64
  - VERSION
65
+ - Versionfile
66
+ - app/assets/javascripts/store/solr_sort_by.js.coffee
61
67
  - app/helpers/spree/base_helper_decorator.rb
62
- - app/models/product_decorator.rb
63
- - app/views/products/_facets.html.erb
64
- - app/views/products/_suggestion.html.erb
68
+ - app/models/spree/product_decorator.rb
69
+ - app/models/spree/solr_search_configuration.rb
70
+ - app/overrides/show_search_partials.rb
71
+ - app/views/spree/products/_facets.html.erb
72
+ - app/views/spree/products/_sort_bar.html.erb
73
+ - app/views/spree/products/_suggestion.html.erb
65
74
  - config/initializers/solr_config.rb
66
75
  - config/locales/en.yml
67
76
  - config/locales/ru-RU.yml
68
77
  - config/locales/ru.yml
69
78
  - lib/generators/spree_solr_search/install_generator.rb
70
79
  - lib/generators/templates/solr.yml
80
+ - lib/solr_manager.rb
71
81
  - lib/spree/search/solr.rb
72
82
  - lib/spree_solr_search.rb
73
- - lib/spree_solr_search_hooks.rb
74
83
  - lib/tasks/acts_as_solr.rake
75
84
  - lib/websolr_acts_as_solr.rb
76
85
  - spree_solr_search.gemspec
77
- has_rdoc: true
78
86
  homepage: http://github.com/romul/spree-solr-search
79
87
  licenses: []
80
88
 
81
89
  post_install_message:
82
- rdoc_options:
83
- - --charset=UTF-8
90
+ rdoc_options: []
91
+
84
92
  require_paths:
85
93
  - lib
86
94
  required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
87
96
  requirements:
88
97
  - - ">="
89
98
  - !ruby/object:Gem::Version
99
+ hash: 3
90
100
  segments:
91
101
  - 0
92
102
  version: "0"
93
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
94
105
  requirements:
95
- - - ">="
106
+ - - ">"
96
107
  - !ruby/object:Gem::Version
108
+ hash: 25
97
109
  segments:
98
- - 0
99
- version: "0"
110
+ - 1
111
+ - 3
112
+ - 1
113
+ version: 1.3.1
100
114
  requirements: []
101
115
 
102
116
  rubyforge_project:
103
- rubygems_version: 1.3.6
117
+ rubygems_version: 1.8.15
104
118
  signing_key:
105
119
  specification_version: 3
106
120
  summary: Provides search via Apache Solr for a Spree store.
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- solr
2
- log/*.log
3
- tmp/pids/*
@@ -1,63 +0,0 @@
1
- Product.class_eval do
2
- acts_as_solr :fields => PRODUCT_SOLR_FIELDS, :facets => PRODUCT_SOLR_FACETS
3
-
4
- def taxon_ids
5
- taxons.map(&:id)
6
- end
7
-
8
- def is_active
9
- !deleted_at &&
10
- (available_on <= Time.zone.now) &&
11
- (Spree::Config[:allow_backorders] || count_on_hand > 0)
12
- end
13
-
14
- private
15
-
16
- def store_ids
17
- if self.respond_to? :stores
18
- stores.map(&:id)
19
- else
20
- []
21
- end
22
- end
23
-
24
- def taxon_names
25
- taxons.map(&:name)
26
- end
27
-
28
- def price_range
29
- max = 0
30
- PRODUCT_PRICE_RANGES.each do |range, name|
31
- return name if range.include?(price)
32
- max = range.max if range.max > max
33
- end
34
- I18n.t(:price_and_above, :price => max)
35
- end
36
-
37
- def brand_property
38
- pp = ProductProperty.first(:joins => :property,
39
- :conditions => {:product_id => self.id, :properties => {:name => 'brand'}})
40
- pp ? pp.value : ''
41
- end
42
-
43
- def color_option
44
- get_option_values('color')
45
- end
46
-
47
- def size_option
48
- get_option_values('size')
49
- end
50
-
51
- def get_option_values(option_name)
52
- sql = <<-eos
53
- SELECT DISTINCT ov.id, ov.presentation
54
- FROM option_values AS ov
55
- LEFT JOIN option_types AS ot ON (ov.option_type_id = ot.id)
56
- LEFT JOIN option_values_variants AS ovv ON (ovv.option_value_id = ov.id)
57
- LEFT JOIN variants AS v ON (ovv.variant_id = v.id)
58
- LEFT JOIN products AS p ON (v.product_id = p.id)
59
- WHERE (ot.name = '#{option_name}' AND p.id = #{self.id});
60
- eos
61
- OptionValue.find_by_sql(sql).map(&:presentation)
62
- end
63
- end
@@ -1,6 +0,0 @@
1
- class SpreeSolrSearchHooks < Spree::ThemeSupport::HookListener
2
-
3
- insert_before :search_results, 'products/facets'
4
- insert_before :search_results, 'products/suggestion'
5
-
6
- end