solidus_searchkick 0.1.2 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +36 -7
- data/app/assets/javascripts/spree/frontend/{spree_searchkick.js → solidus_searchkick.js} +0 -0
- data/app/assets/javascripts/spree/frontend/typeahead.bundle.js +1 -1
- data/app/assets/stylesheets/spree/frontend/{spree_searchkick.css → solidus_searchkick.css} +0 -0
- data/app/helpers/spree/products_helper_decorator.rb +0 -1
- data/app/models/spree/product_decorator.rb +6 -13
- data/app/views/spree/shared/_filters.html.erb +26 -11
- data/lib/generators/solidus_searchkick/install/install_generator.rb +11 -0
- data/lib/solidus_searchkick.rb +6 -0
- data/lib/solidus_searchkick/version.rb +1 -1
- data/lib/spree/core/searchkick_filters.rb +37 -37
- data/lib/spree/search/searchkick.rb +98 -49
- data/spec/lib/spree/search/searchkick_spec.rb +12 -27
- metadata +5 -18
- data/app/assets/javascripts/spree/backend/spree_searchkick.js +0 -2
- data/app/assets/stylesheets/spree/backend/spree_searchkick.css +0 -4
- data/app/models/spree/property_decorator.rb +0 -7
- data/app/models/spree/taxonomy_decorator.rb +0 -7
- data/app/overrides/spree/admin/properties/_form/add_filterable_to_property_form.html.erb.deface +0 -8
- data/app/overrides/spree/admin/taxonomies/_form/add_filterable_to_taxonomy_form.html.erb.deface +0 -6
- data/app/views/spree/shared/_es_filter.html.erb +0 -15
- data/db/migrate/20150819222417_add_filtrable_to_spree_taxonomies.rb +0 -5
- data/db/migrate/20151009155442_add_filterable_to_spree_property.rb +0 -5
- data/lib/generators/spree_searchkick/install/install_generator.rb +0 -31
- data/spec/models/spree/property_spec.rb +0 -11
- data/spec/models/spree/taxonomy_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97fb4a93971a0e417baacc6a1278702f33755514
|
4
|
+
data.tar.gz: eab0be521331e7d3d22833c03fd56f925189e4ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa20f47574136f30fe35302ef73f16c228425b7222ee25217c4a621aca637dc0326e91ef9e2ffa1ab0bd06f73c9f23009116d3630155aafca0783b707d624038
|
7
|
+
data.tar.gz: 53bf2d7bba2adfd9a82dfdec695a6f9fab010f397028c3c15d43193c30b997dd491bfbfefa5c53257bfc534a240e5e9db1f28cd20ef3e9936d58e9c8b7d3e48c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -30,13 +30,46 @@ Bundle your dependencies and run the installation generator:
|
|
30
30
|
```shell
|
31
31
|
bundle
|
32
32
|
bundle exec rails g solidus_searchkick:install
|
33
|
+
```
|
34
|
+
|
35
|
+
Installing solidus_searchkick will copy over a new `spree/shared/_filters.html.erb` template. This includes a few minor changes to the default template, mainly changing a few `search` params to `filter` params to work nicely with solidus_searchkick and elasticsearch.
|
33
36
|
|
34
|
-
|
37
|
+
[Install elasticsearch](https://www.elastic.co/downloads/elasticsearch)
|
38
|
+
|
39
|
+
Implementation
|
40
|
+
-------------
|
41
|
+
Initially, you are started with a very basic filtering system which includes a price filter in order to show how the filtering works within elasticsearch. In order to add more filtering or change the price filtering, the following steps will need to be taken.
|
42
|
+
|
43
|
+
1. Copy the `Spree::Core::SearchkickFilters` file from this gem and place it in `lib/spree/core/`
|
44
|
+
2. Add it to the config load path, or require it in an initializer, e.g...
|
45
|
+
```
|
46
|
+
# config/initializers/spree.rb
|
47
|
+
require 'spree/core/searchkick_filters'
|
48
|
+
```
|
49
|
+
3. Modify SearchKickFilters as needed.
|
50
|
+
|
51
|
+
The `conds` for `SearchkickFilters` are similar to the `ProductFilters` in the default version of spree. Although the first parameters of each is still the label, the second item is the ElasticSerach DSL that will be used for that filter, eg... `{ range: { price: { lt: 1 } } }`
|
52
|
+
|
53
|
+
Autocomplete
|
54
|
+
-------------
|
55
|
+
SolidusSearchkick provides autocomplete for the `name` field of your products. In order to get this working, all you need to do is add the following lines to the corresponding files:
|
35
56
|
|
36
|
-
|
57
|
+
application.js
|
58
|
+
```
|
59
|
+
//= require spree/frontend/typeahead.bundle
|
60
|
+
//= require spree/frontend/solidus_searchkick
|
37
61
|
```
|
38
62
|
|
39
|
-
|
63
|
+
application.css
|
64
|
+
```
|
65
|
+
*= require spree/frontend/solidus_searchkick
|
66
|
+
```
|
67
|
+
|
68
|
+
After that, automplete should now be working in the search box.
|
69
|
+
|
70
|
+
Advanced Autocomplete
|
71
|
+
-------------
|
72
|
+
Documentation Coming Soon
|
40
73
|
|
41
74
|
Options
|
42
75
|
-------------
|
@@ -56,13 +89,9 @@ By default, only the `Spree::Product` class is indexed. The following items are
|
|
56
89
|
* orders.complete.count (indexed as `conversions`)
|
57
90
|
* taxon_ids
|
58
91
|
* taxon_names
|
59
|
-
* All Properties
|
60
|
-
* All Taxon ids by Taxonomy
|
61
92
|
|
62
93
|
In order to control what data is indexed, override `Spree::Product#search_data` method. Call `Spree::Product.reindex` after changing this method.
|
63
94
|
|
64
|
-
To enable or disable taxons filters, go to taxonomy form and change `filterable` boolean.
|
65
|
-
|
66
95
|
Testing
|
67
96
|
-------
|
68
97
|
|
File without changes
|
File without changes
|
@@ -1,5 +1,10 @@
|
|
1
1
|
Spree::Product.class_eval do
|
2
|
-
|
2
|
+
# Run after initialization, allows us to process product_decorator from application before this
|
3
|
+
Rails.application.config.after_initialize do
|
4
|
+
# Check if searchkick_options have been set by the application using this gem
|
5
|
+
# If they have, then do not initialize searchkick on the model. If they have not, then set the defaults
|
6
|
+
searchkick autocomplete: [:name] unless Spree::Product.try(:searchkick_options)
|
7
|
+
end
|
3
8
|
|
4
9
|
def search_data
|
5
10
|
json = {
|
@@ -14,21 +19,9 @@ Spree::Product.class_eval do
|
|
14
19
|
taxon_names: taxon_and_ancestors.map(&:name)
|
15
20
|
}
|
16
21
|
|
17
|
-
Spree::Property.all.each do |prop|
|
18
|
-
json.merge!(Hash[prop.name.downcase, property(prop.name)])
|
19
|
-
end
|
20
|
-
|
21
|
-
Spree::Taxonomy.all.each do |taxonomy|
|
22
|
-
json.merge!(Hash["#{ taxonomy.name.downcase }_ids", taxon_by_taxonomy(taxonomy.id).map(&:id)])
|
23
|
-
end
|
24
|
-
|
25
22
|
json
|
26
23
|
end
|
27
24
|
|
28
|
-
def taxon_by_taxonomy(taxonomy_id)
|
29
|
-
taxons.joins(:taxonomy).where(spree_taxonomies: { id: taxonomy_id })
|
30
|
-
end
|
31
|
-
|
32
25
|
def taxon_and_ancestors
|
33
26
|
taxons.map(&:self_and_ancestors).flatten.uniq
|
34
27
|
end
|
@@ -1,12 +1,27 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
4
|
-
%>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
<% filters = @taxon ? @taxon.applicable_filters : Spree::Core::SearchkickFilters.all_filters %>
|
2
|
+
<% unless filters.empty? %>
|
3
|
+
<%= form_tag '', :method => :get, :id => 'sidebar_products_search' do %>
|
4
|
+
<%= hidden_field_tag 'per_page', params[:per_page] %>
|
5
|
+
<% filters.each do |filter| %>
|
6
|
+
<% labels = filter[:labels] || filter[:conds].map {|m,c| [m,m]} %>
|
7
|
+
<% next if labels.empty? %>
|
8
|
+
<div class="navigation" data-hook="navigation">
|
9
|
+
<h6 class="filter-title"> <%= filter[:name] %> </h6>
|
10
|
+
<ul class="filter_choices">
|
11
|
+
<% labels.each do |nm,val| %>
|
12
|
+
<% label = "#{filter[:name]}_#{nm}".gsub(/\s+/,'_') %>
|
13
|
+
<li class="nowrap">
|
14
|
+
<input type="checkbox"
|
15
|
+
id="<%= label %>"
|
16
|
+
name="filter[<%= filter[:scope].to_s %>][]"
|
17
|
+
value="<%= val %>"
|
18
|
+
<%= params[:filter] && params[:filter][filter[:scope]] && params[:filter][filter[:scope]].include?(val.to_s) ? "checked" : "" %> />
|
19
|
+
<label class="nowrap" for="<%= label %>"> <%= nm %> </label>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
<%= submit_tag Spree.t(:search), :name => nil %>
|
10
26
|
<% end %>
|
11
|
-
|
12
|
-
<% end %>
|
27
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module SolidusSearchkick
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root SolidusSearchkick.root
|
5
|
+
|
6
|
+
def add_templates
|
7
|
+
copy_file "app/views/spree/shared/_filters.html.erb", "app/views/spree/shared/_filters.html.erb"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/solidus_searchkick.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
1
|
module Spree
|
2
2
|
module Core
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Spree::Taxonomy.filterable.each do |taxonomy|
|
7
|
-
es_filters << self.process_filter(taxonomy.filter_name, :taxon, aggregations[taxonomy.filter_name])
|
8
|
-
end
|
9
|
-
|
10
|
-
Spree::Property.filterable.each do |property|
|
11
|
-
es_filters << self.process_filter(property.filter_name, :property, aggregations[property.filter_name])
|
12
|
-
end
|
3
|
+
# THIS FILE SHOULD BE OVER-RIDDEN IN YOUR SITE EXTENSION!
|
4
|
+
# the exact code probably won't be useful, though you're welcome to modify and reuse
|
5
|
+
# the current contents are mainly for testing and documentation
|
13
6
|
|
14
|
-
|
15
|
-
|
7
|
+
# To override this file...
|
8
|
+
# 1) Make a copy of it in your sites local /lib/spree folder/core
|
9
|
+
# 2) Add it to the config load path, or require it in an initializer, e.g...
|
10
|
+
#
|
11
|
+
# # config/initializers/spree.rb
|
12
|
+
# require 'spree/core/searchkick_filters'
|
13
|
+
#
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
options = {min: min["key"].to_i, max: max["key"].to_i, step: 100}
|
25
|
-
else
|
26
|
-
options = {}
|
27
|
-
end
|
28
|
-
when :taxon
|
29
|
-
ids = filter["buckets"].map{|h| h["key"]}
|
30
|
-
taxons = Spree::Taxon.where(id: ids).order(name: :asc)
|
31
|
-
taxons.each {|t| options << {label: t.name, value: t.id }}
|
32
|
-
when :property
|
33
|
-
values = filter["buckets"].map{|h| h["key"]}
|
34
|
-
values.each {|t| options << {label: t, value: t }}
|
15
|
+
module SearchkickFilters
|
16
|
+
def self.all_filters
|
17
|
+
filters = []
|
18
|
+
# Find all methods that ends with '_filter'
|
19
|
+
filter_methods = Spree::Core::SearchkickFilters.methods.find_all { |m| m.to_s.end_with?('_filter') }
|
20
|
+
filter_methods.each do |filter_method|
|
21
|
+
filters << Spree::Core::SearchkickFilters.send(filter_method) if Spree::Core::SearchkickFilters.respond_to?(filter_method)
|
35
22
|
end
|
23
|
+
filters
|
24
|
+
end
|
36
25
|
|
26
|
+
def self.price_filter
|
27
|
+
conds = [
|
28
|
+
[Spree.t(:under_price, price: format_price(1)), { range: { price: { lt: 1 } } }],
|
29
|
+
["#{format_price(1)} - #{format_price(5)}", { range: { price: { from: 1, to: 5 } } }],
|
30
|
+
["#{format_price(5)} - #{format_price(10)}", { range: { price: { from: 5, to: 10 } } }],
|
31
|
+
["#{format_price(10)} - #{format_price(15)}", { range: { price: { from: 10, to: 15 } } }],
|
32
|
+
["#{format_price(15)} - #{format_price(25)}", { range: { price: { from: 15, to: 25 } } }],
|
33
|
+
["#{format_price(25)} - #{format_price(50)}", { range: { price: { from: 25, to: 50 } } }],
|
34
|
+
["#{format_price(50)} - #{format_price(100)}", { range: { price: { from: 50, to: 100 } } }],
|
35
|
+
[Spree.t(:over_price, price: format_price(100)), { range: { price: { gt: 100 } } }]
|
36
|
+
]
|
37
37
|
{
|
38
|
-
name:
|
39
|
-
|
40
|
-
|
38
|
+
name: 'Price',
|
39
|
+
scope: :price,
|
40
|
+
conds: Hash[*conds.flatten],
|
41
|
+
labels: conds.map { |k, _v| [k, k] }
|
41
42
|
}
|
42
|
-
|
43
43
|
end
|
44
44
|
|
45
|
-
def self.
|
46
|
-
|
45
|
+
def self.format_price(amount)
|
46
|
+
Spree::Money.new(amount)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
@@ -1,5 +1,23 @@
|
|
1
1
|
module Spree::Search
|
2
2
|
class Searchkick < Spree::Core::Search::Base
|
3
|
+
class << self
|
4
|
+
attr_accessor :configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.configure
|
8
|
+
self.configuration ||= Configuration.new
|
9
|
+
yield(configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
# Sample configurable_attribute
|
14
|
+
attr_accessor :configurable_attribute
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@configurable_attribute = false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
3
21
|
def retrieve_products
|
4
22
|
@products = get_base_search
|
5
23
|
end
|
@@ -7,52 +25,48 @@ module Spree::Search
|
|
7
25
|
protected
|
8
26
|
|
9
27
|
def get_base_search
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
# If a query is passed in, then we are only using the ElasticSearch DSL and don't care about any other options
|
29
|
+
if query
|
30
|
+
Spree::Product.search(query: query)
|
31
|
+
else
|
32
|
+
search_options = {
|
33
|
+
# Set execute to false in case we need to modify the search before it is executed
|
34
|
+
execute: false,
|
35
|
+
|
36
|
+
where: where_clause,
|
37
|
+
page: page,
|
38
|
+
per_page: per_page,
|
39
|
+
}
|
40
|
+
|
41
|
+
search_options.merge!(searchkick_options)
|
42
|
+
search_options.deep_merge!(includes: includes_clause)
|
43
|
+
|
44
|
+
keywords_clause = (keywords.nil? || keywords.empty?) ? '*' : keywords
|
45
|
+
search = Spree::Product.search(keywords_clause, search_options)
|
46
|
+
|
47
|
+
# Add any search filters passed in
|
48
|
+
# Adding search filters modifies the search query, which is why we need to wait on executing it until after search query is modified
|
49
|
+
search = add_search_filters(search)
|
50
|
+
|
51
|
+
# Execute the search
|
52
|
+
search.execute
|
53
|
+
end
|
24
54
|
end
|
25
55
|
|
26
|
-
def
|
27
|
-
|
56
|
+
def where_clause
|
57
|
+
# Default items for where_clause
|
58
|
+
where_clause = {
|
28
59
|
active: true,
|
29
60
|
currency: pricing_options.currency,
|
30
61
|
price: { not: nil }
|
31
62
|
}
|
32
|
-
|
33
|
-
add_search_filters(where_query)
|
34
|
-
end
|
63
|
+
where_clause.merge!({taxon_ids: taxon.id}) if taxon
|
35
64
|
|
36
|
-
|
37
|
-
(
|
65
|
+
# Add search attributes from params[:search]
|
66
|
+
add_search_attributes(where_clause)
|
38
67
|
end
|
39
68
|
|
40
|
-
def
|
41
|
-
order ? order : nil
|
42
|
-
end
|
43
|
-
|
44
|
-
def aggregations
|
45
|
-
fs = []
|
46
|
-
Spree::Taxonomy.filterable.each do |taxonomy|
|
47
|
-
fs << taxonomy.filter_name.to_sym
|
48
|
-
end
|
49
|
-
Spree::Property.filterable.each do |property|
|
50
|
-
fs << property.filter_name.to_sym
|
51
|
-
end
|
52
|
-
fs
|
53
|
-
end
|
54
|
-
|
55
|
-
def add_search_filters(query)
|
69
|
+
def add_search_attributes(query)
|
56
70
|
return query unless search
|
57
71
|
search.each do |name, scope_attribute|
|
58
72
|
query.merge!(Hash[name, scope_attribute])
|
@@ -61,24 +75,59 @@ module Spree::Search
|
|
61
75
|
query
|
62
76
|
end
|
63
77
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
78
|
+
def add_search_filters(search)
|
79
|
+
return search unless filters
|
80
|
+
all_filters = taxon ? taxon.applicable_filters : Spree::Core::SearchkickFilters.all_filters
|
81
|
+
|
82
|
+
applicable_filters = {}
|
83
|
+
|
84
|
+
# Find filter method definition from filters passed in
|
85
|
+
filters.each do |filter_param|
|
86
|
+
search_filter, search_labels = filter_param
|
87
|
+
filter = all_filters.find { |filter| filter[:scope] == search_filter.to_sym }
|
88
|
+
applicable_filters[search_filter.to_sym] = filter[:conds].find_all { |filter_condition| search_labels.include?(filter_condition.first) }
|
89
|
+
end
|
90
|
+
|
91
|
+
# Loop through the applicable filters, collect the conditions, and generate filter options
|
92
|
+
filter_items = []
|
93
|
+
applicable_filters.each do |applicable_filter|
|
94
|
+
filter_name, filter_details = applicable_filter
|
95
|
+
filter_options = []
|
96
|
+
filter_details.each do |details|
|
97
|
+
label, conditions = details
|
98
|
+
filter_options << conditions
|
99
|
+
end
|
100
|
+
|
101
|
+
# Add filter_options to filter_items for the conditions from an applicable_filter
|
102
|
+
filter_items << {
|
103
|
+
bool: {
|
104
|
+
should: filter_options
|
105
|
+
}
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
# Set search_filters with filter_items defined above
|
110
|
+
search_filters = {
|
111
|
+
bool: {
|
112
|
+
must: filter_items
|
113
|
+
}
|
114
|
+
}
|
69
115
|
|
70
|
-
|
71
|
-
|
116
|
+
# Update the search query filter hash in order to process the additional filters as well as the base_search
|
117
|
+
search.body[:query][:bool][:filter].push(search_filters)
|
118
|
+
search
|
72
119
|
end
|
73
120
|
|
74
|
-
def
|
75
|
-
|
121
|
+
def includes_clause
|
122
|
+
includes_clause = { master: [:currently_valid_prices] }
|
123
|
+
includes_clause[:master] << :images if include_images
|
124
|
+
includes_clause
|
76
125
|
end
|
77
126
|
|
78
127
|
def prepare(params)
|
79
|
-
@properties[:
|
80
|
-
@properties[:
|
81
|
-
@properties[:
|
128
|
+
@properties[:query] = params[:query].blank? ? nil : params[:query]
|
129
|
+
@properties[:filters] = params[:filter].blank? ? nil : params[:filter]
|
130
|
+
@properties[:searchkick_options] = params[:searchkick_options].blank? ? {} : params[:searchkick_options].deep_symbolize_keys
|
82
131
|
params = params.deep_symbolize_keys
|
83
132
|
super
|
84
133
|
end
|
@@ -7,37 +7,22 @@ describe Spree::Search::Searchkick do
|
|
7
7
|
Spree::Product.reindex
|
8
8
|
end
|
9
9
|
|
10
|
+
describe 'configure' do
|
11
|
+
before do
|
12
|
+
Spree::Search::Searchkick.configure do |config|
|
13
|
+
config.configurable_attribute = true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "allows configurable_attribute to be configured" do
|
18
|
+
expect(Spree::Search::Searchkick.configuration.configurable_attribute).to be_truthy
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
describe "#retrieve_products" do
|
11
23
|
it "returns matching products" do
|
12
24
|
products = Spree::Search::Searchkick.new({}).retrieve_products
|
13
25
|
expect(products.count).to eq 1
|
14
26
|
end
|
15
|
-
|
16
|
-
describe "aggregations" do
|
17
|
-
let(:taxonomy) { Spree::Taxonomy.where(id: 1, name: "Category").first_or_create }
|
18
|
-
|
19
|
-
before do
|
20
|
-
product.taxons << taxonomy.root
|
21
|
-
product.reindex
|
22
|
-
Spree::Product.reindex
|
23
|
-
end
|
24
|
-
|
25
|
-
it "has no aggregations by default" do
|
26
|
-
products = Spree::Search::Searchkick.new({}).retrieve_products
|
27
|
-
expect(products.aggs).to be_nil
|
28
|
-
end
|
29
|
-
|
30
|
-
context "with a filterable taxonomy" do
|
31
|
-
let(:taxonomy) { Spree::Taxonomy.where(id: 1, name: "Category", filterable: true).first_or_create }
|
32
|
-
|
33
|
-
it "retrieves aggregations" do
|
34
|
-
products = Spree::Search::Searchkick.new({}).retrieve_products
|
35
|
-
|
36
|
-
expect(products.count).to eq 1
|
37
|
-
expect(products.aggs["category_ids"]).to include("doc_count" => 1)
|
38
|
-
expect(products.aggs["category_ids"]["buckets"]).to be_a Array
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
27
|
end
|
43
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus
|
@@ -241,27 +241,18 @@ files:
|
|
241
241
|
- LICENSE
|
242
242
|
- README.md
|
243
243
|
- Rakefile
|
244
|
-
- app/assets/javascripts/spree/
|
245
|
-
- app/assets/javascripts/spree/frontend/spree_searchkick.js
|
244
|
+
- app/assets/javascripts/spree/frontend/solidus_searchkick.js
|
246
245
|
- app/assets/javascripts/spree/frontend/typeahead.bundle.js
|
247
|
-
- app/assets/stylesheets/spree/
|
248
|
-
- app/assets/stylesheets/spree/frontend/spree_searchkick.css
|
246
|
+
- app/assets/stylesheets/spree/frontend/solidus_searchkick.css
|
249
247
|
- app/controllers/spree/products_controller_decorator.rb
|
250
248
|
- app/helpers/spree/products_helper_decorator.rb
|
251
249
|
- app/models/spree/order_decorator.rb
|
252
250
|
- app/models/spree/product_decorator.rb
|
253
|
-
- app/models/spree/property_decorator.rb
|
254
|
-
- app/models/spree/taxonomy_decorator.rb
|
255
|
-
- app/overrides/spree/admin/properties/_form/add_filterable_to_property_form.html.erb.deface
|
256
|
-
- app/overrides/spree/admin/taxonomies/_form/add_filterable_to_taxonomy_form.html.erb.deface
|
257
|
-
- app/views/spree/shared/_es_filter.html.erb
|
258
251
|
- app/views/spree/shared/_filters.html.erb
|
259
252
|
- bin/rails
|
260
253
|
- config/locales/en.yml
|
261
254
|
- config/routes.rb
|
262
|
-
-
|
263
|
-
- db/migrate/20151009155442_add_filterable_to_spree_property.rb
|
264
|
-
- lib/generators/spree_searchkick/install/install_generator.rb
|
255
|
+
- lib/generators/solidus_searchkick/install/install_generator.rb
|
265
256
|
- lib/solidus_searchkick.rb
|
266
257
|
- lib/solidus_searchkick/engine.rb
|
267
258
|
- lib/solidus_searchkick/factories.rb
|
@@ -273,8 +264,6 @@ files:
|
|
273
264
|
- spec/lib/spree/search/searchkick_spec.rb
|
274
265
|
- spec/models/spree/order_spec.rb
|
275
266
|
- spec/models/spree/product_spec.rb
|
276
|
-
- spec/models/spree/property_spec.rb
|
277
|
-
- spec/models/spree/taxonomy_spec.rb
|
278
267
|
- spec/routing/spree/products_routes_spec.rb
|
279
268
|
- spec/spec_helper.rb
|
280
269
|
homepage: https://github.com/elevatorup/solidus_searchkick
|
@@ -307,7 +296,5 @@ test_files:
|
|
307
296
|
- spec/lib/spree/search/searchkick_spec.rb
|
308
297
|
- spec/models/spree/order_spec.rb
|
309
298
|
- spec/models/spree/product_spec.rb
|
310
|
-
- spec/models/spree/property_spec.rb
|
311
|
-
- spec/models/spree/taxonomy_spec.rb
|
312
299
|
- spec/routing/spree/products_routes_spec.rb
|
313
300
|
- spec/spec_helper.rb
|
data/app/overrides/spree/admin/properties/_form/add_filterable_to_property_form.html.erb.deface
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<!-- insert_bottom 'div[data-hook=admin_property_form]' -->
|
2
|
-
<div class="col-md-6">
|
3
|
-
<%= f.field_container :filterable, class: ['form-group'] do %>
|
4
|
-
<%= f.label :filterable, Spree.t(:filterable) %> <span class="required">*</span>
|
5
|
-
<%= error_message_on :property, :filterable, :class => 'error-message' %>
|
6
|
-
<%= check_box :property, :filterable, :class => 'form-control' %>
|
7
|
-
<% end %>
|
8
|
-
</div>
|
data/app/overrides/spree/admin/taxonomies/_form/add_filterable_to_taxonomy_form.html.erb.deface
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
<!-- insert_bottom 'div.form-group' -->
|
2
|
-
<%= f.field_container :filterable, class: ['form-group'] do %>
|
3
|
-
<%= f.label :filterable, Spree.t(:filterable) %> <span class="required">*</span>
|
4
|
-
<%= error_message_on :taxonomy, :filterable, :class => 'error-message' %>
|
5
|
-
<%= check_box :taxonomy, :filterable, :class => 'form-control' %>
|
6
|
-
<% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<div class="navigation" data-hook="navigation">
|
2
|
-
<h4 class="filter-title"><%= Spree.t("esfilters.#{filter[:name]}") %></h4>
|
3
|
-
<ul class="list-group">
|
4
|
-
<% filter[:options].each do |f| %>
|
5
|
-
<li class="list-group-item">
|
6
|
-
<input type="checkbox"
|
7
|
-
id="<%= f[:label] %>"
|
8
|
-
name="search[<%= filter[:name] %>][]"
|
9
|
-
value="<%= f[:value] %>"
|
10
|
-
/>
|
11
|
-
<label class="nowrap" for="<%= f[:label] %>"> <%= f[:label] %> </label>
|
12
|
-
</li>
|
13
|
-
<% end %>
|
14
|
-
</ul>
|
15
|
-
</div>
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module SolidusSearchkick
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
4
|
-
|
5
|
-
class_option :auto_run_migrations, :type => :boolean, :default => false
|
6
|
-
|
7
|
-
def add_javascripts
|
8
|
-
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_searchkick\n"
|
9
|
-
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_searchkick\n"
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_stylesheets
|
13
|
-
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_searchkick\n", :before => /\*\//, :verbose => true
|
14
|
-
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_searchkick\n", :before => /\*\//, :verbose => true
|
15
|
-
end
|
16
|
-
|
17
|
-
def add_migrations
|
18
|
-
run 'bundle exec rake railties:install:migrations FROM=solidus_searchkick'
|
19
|
-
end
|
20
|
-
|
21
|
-
def run_migrations
|
22
|
-
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
23
|
-
if run_migrations
|
24
|
-
run 'bundle exec rake db:migrate'
|
25
|
-
else
|
26
|
-
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Spree::Property, type: :model do
|
4
|
-
describe '#filter_name' do
|
5
|
-
let(:property) { create(:property, name: 'awesome_property') }
|
6
|
-
|
7
|
-
it 'respond with property name downcased' do
|
8
|
-
expect(property.filter_name).to eq('awesome_property')
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Spree::Taxonomy, type: :model do
|
4
|
-
describe '#filter_name' do
|
5
|
-
let(:taxonomy) { create(:taxonomy, name: 'awesome_category') }
|
6
|
-
|
7
|
-
it 'respond with taxonomy name downcased' do
|
8
|
-
expect(taxonomy.filter_name).to eq('awesome_category_ids')
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|