spree_grid_faq 0.0.6 → 0.0.7

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.
Files changed (57) hide show
  1. data/.gitignore +10 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +226 -0
  5. data/LICENSE +26 -0
  6. data/README.md +19 -0
  7. data/Rakefile +29 -0
  8. data/Versionfile +6 -0
  9. data/app/assets/stylesheets/store/spree_grid_faq.css +3 -0
  10. data/app/controllers/spree/admin/products_decorator.rb +46 -0
  11. data/app/controllers/spree/admin/questions_controller.rb +25 -0
  12. data/app/controllers/spree/admin/taxons_decorator.rb +46 -0
  13. data/app/controllers/spree/questions_controller.rb +28 -0
  14. data/app/models/spree/product_decorator.rb +3 -0
  15. data/app/models/spree/question.rb +24 -0
  16. data/app/models/spree/taxon_decorator.rb +3 -0
  17. data/app/overrides/grid_faq_admin_tab.rb +4 -0
  18. data/app/overrides/grid_faq_footer_right.rb +4 -0
  19. data/app/overrides/grid_faq_product_right_part_wrap.rb +4 -0
  20. data/app/overrides/grid_faq_taxonomies_sidebar_item.rb +4 -0
  21. data/app/views/spree/admin/products/_question_product_table.html.erb +23 -0
  22. data/app/views/spree/admin/products/available_for_question.js.erb +26 -0
  23. data/app/views/spree/admin/products/remove_for_question.js.erb +1 -0
  24. data/app/views/spree/admin/products/select_for_question.js.erb +2 -0
  25. data/app/views/spree/admin/products/selected_for_question.html.erb +40 -0
  26. data/app/views/spree/admin/questions/_form.html.erb +21 -0
  27. data/app/views/spree/admin/questions/edit.html.erb +9 -0
  28. data/app/views/spree/admin/questions/index.html.erb +36 -0
  29. data/app/views/spree/admin/questions/new.html.erb +7 -0
  30. data/app/views/spree/admin/shared/_question_tabs.html.erb +24 -0
  31. data/app/views/spree/admin/taxons/_question_taxon_table.html.erb +23 -0
  32. data/app/views/spree/admin/taxons/available_for_question.js.erb +26 -0
  33. data/app/views/spree/admin/taxons/remove_for_question.js.erb +1 -0
  34. data/app/views/spree/admin/taxons/select_for_question.js.erb +2 -0
  35. data/app/views/spree/admin/taxons/selected_for_question.html.erb +40 -0
  36. data/app/views/spree/questions/index.html.haml +14 -0
  37. data/app/views/spree/questions/index.xml.builder +19 -0
  38. data/app/views/spree/questions/show.html.haml +15 -0
  39. data/app/views/spree/shared/_product_faq.html.haml +5 -0
  40. data/app/views/spree/shared/_taxon_faq.html.erb +10 -0
  41. data/app/views/spree/shared/_taxon_faq.html.haml +5 -0
  42. data/config/locales/en.yml +5 -0
  43. data/config/routes.rb +33 -0
  44. data/db/migrate/20120526221807_create_spree_questions.rb +12 -0
  45. data/db/migrate/20120527180748_create_spree_questions_taxons.rb +10 -0
  46. data/db/migrate/20120527181205_create_spree_products_questions.rb +10 -0
  47. data/lib/generators/spree_faqs/install/install_generator.rb +24 -0
  48. data/lib/spree_grid_faq/engine.rb +20 -0
  49. data/lib/spree_grid_faq/version.rb +3 -0
  50. data/lib/spree_grid_faq.rb +3 -0
  51. data/script/rails +7 -0
  52. data/spec/factories/question_factory.rb +7 -0
  53. data/spec/requests/questions_spec.rb +57 -0
  54. data/spec/requests/taxonomies_spec.rb +34 -0
  55. data/spec/spec_helper.rb +49 -0
  56. data/spree_grid_faq.gemspec +31 -0
  57. metadata +74 -18
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ if RUBY_VERSION < '1.9'
4
+ gem 'ruby-debug'
5
+ else
6
+ gem 'ruby-debug19'
7
+ end
8
+
9
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,226 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spree_grid_faq (0.0.3)
5
+ haml
6
+ spree_core (~> 1.1.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.3)
12
+ actionpack (= 3.2.3)
13
+ mail (~> 2.4.4)
14
+ actionpack (3.2.3)
15
+ activemodel (= 3.2.3)
16
+ activesupport (= 3.2.3)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.1)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.1.2)
24
+ active_utils (1.0.3)
25
+ activesupport (>= 2.3.11)
26
+ i18n
27
+ activemerchant (1.20.4)
28
+ active_utils (>= 1.0.2)
29
+ activesupport (>= 2.3.11)
30
+ braintree (>= 2.0.0)
31
+ builder (>= 2.0.0)
32
+ i18n
33
+ json (>= 1.5.1)
34
+ money (<= 3.7.1)
35
+ activemodel (3.2.3)
36
+ activesupport (= 3.2.3)
37
+ builder (~> 3.0.0)
38
+ activerecord (3.2.3)
39
+ activemodel (= 3.2.3)
40
+ activesupport (= 3.2.3)
41
+ arel (~> 3.0.2)
42
+ tzinfo (~> 0.3.29)
43
+ activeresource (3.2.3)
44
+ activemodel (= 3.2.3)
45
+ activesupport (= 3.2.3)
46
+ activesupport (3.2.3)
47
+ i18n (~> 0.6)
48
+ multi_json (~> 1.0)
49
+ acts_as_list (0.1.4)
50
+ addressable (2.2.8)
51
+ archive-tar-minitar (0.5.2)
52
+ arel (3.0.2)
53
+ aws-sdk (1.3.9)
54
+ httparty (~> 0.7)
55
+ json (~> 1.4)
56
+ nokogiri (>= 1.4.4)
57
+ uuidtools (~> 2.1)
58
+ braintree (2.16.0)
59
+ builder (>= 2.0.0)
60
+ builder (3.0.0)
61
+ capybara (1.0.1)
62
+ mime-types (>= 1.16)
63
+ nokogiri (>= 1.3.3)
64
+ rack (>= 1.0.0)
65
+ rack-test (>= 0.5.4)
66
+ selenium-webdriver (~> 2.0)
67
+ xpath (~> 0.1.4)
68
+ childprocess (0.3.2)
69
+ ffi (~> 1.0.6)
70
+ cocaine (0.2.1)
71
+ columnize (0.3.6)
72
+ deface (0.9.1)
73
+ nokogiri (~> 1.5.0)
74
+ rails (~> 3.1)
75
+ diff-lcs (1.1.3)
76
+ erubis (2.7.0)
77
+ factory_girl (2.6.4)
78
+ activesupport (>= 2.3.9)
79
+ ffaker (1.12.1)
80
+ ffi (1.0.11)
81
+ haml (3.1.6)
82
+ highline (1.6.11)
83
+ hike (1.2.1)
84
+ httparty (0.8.3)
85
+ multi_json (~> 1.0)
86
+ multi_xml
87
+ i18n (0.6.0)
88
+ journey (1.0.3)
89
+ jquery-rails (2.0.2)
90
+ railties (>= 3.2.0, < 5.0)
91
+ thor (~> 0.14)
92
+ json (1.7.3)
93
+ kaminari (0.13.0)
94
+ actionpack (>= 3.0.0)
95
+ activesupport (>= 3.0.0)
96
+ railties (>= 3.0.0)
97
+ launchy (2.1.0)
98
+ addressable (~> 2.2.6)
99
+ libwebsocket (0.1.3)
100
+ addressable
101
+ linecache19 (0.5.12)
102
+ ruby_core_source (>= 0.1.4)
103
+ mail (2.4.4)
104
+ i18n (>= 0.4.0)
105
+ mime-types (~> 1.16)
106
+ treetop (~> 1.4.8)
107
+ mime-types (1.18)
108
+ money (3.7.1)
109
+ i18n (~> 0.4)
110
+ multi_json (1.3.6)
111
+ multi_xml (0.5.1)
112
+ nested_set (1.7.0)
113
+ activerecord (>= 3.0.0)
114
+ railties (>= 3.0.0)
115
+ nokogiri (1.5.2)
116
+ paperclip (2.7.0)
117
+ activerecord (>= 2.3.0)
118
+ activesupport (>= 2.3.2)
119
+ cocaine (>= 0.0.2)
120
+ mime-types
121
+ polyamorous (0.5.0)
122
+ activerecord (~> 3.0)
123
+ polyglot (0.3.3)
124
+ rack (1.4.1)
125
+ rack-cache (1.2)
126
+ rack (>= 0.4)
127
+ rack-ssl (1.3.2)
128
+ rack
129
+ rack-test (0.6.1)
130
+ rack (>= 1.0)
131
+ rails (3.2.3)
132
+ actionmailer (= 3.2.3)
133
+ actionpack (= 3.2.3)
134
+ activerecord (= 3.2.3)
135
+ activeresource (= 3.2.3)
136
+ activesupport (= 3.2.3)
137
+ bundler (~> 1.0)
138
+ railties (= 3.2.3)
139
+ railties (3.2.3)
140
+ actionpack (= 3.2.3)
141
+ activesupport (= 3.2.3)
142
+ rack-ssl (~> 1.3.2)
143
+ rake (>= 0.8.7)
144
+ rdoc (~> 3.4)
145
+ thor (~> 0.14.6)
146
+ rake (0.9.2.2)
147
+ ransack (0.6.0)
148
+ actionpack (~> 3.0)
149
+ activerecord (~> 3.0)
150
+ polyamorous (~> 0.5.0)
151
+ rdoc (3.12)
152
+ json (~> 1.4)
153
+ rspec (2.10.0)
154
+ rspec-core (~> 2.10.0)
155
+ rspec-expectations (~> 2.10.0)
156
+ rspec-mocks (~> 2.10.0)
157
+ rspec-core (2.10.1)
158
+ rspec-expectations (2.10.0)
159
+ diff-lcs (~> 1.1.3)
160
+ rspec-mocks (2.10.1)
161
+ rspec-rails (2.10.1)
162
+ actionpack (>= 3.0)
163
+ activesupport (>= 3.0)
164
+ railties (>= 3.0)
165
+ rspec (~> 2.10.0)
166
+ ruby-debug-base19 (0.11.25)
167
+ columnize (>= 0.3.1)
168
+ linecache19 (>= 0.5.11)
169
+ ruby_core_source (>= 0.1.4)
170
+ ruby-debug19 (0.11.6)
171
+ columnize (>= 0.3.1)
172
+ linecache19 (>= 0.5.11)
173
+ ruby-debug-base19 (>= 0.11.19)
174
+ ruby_core_source (0.1.5)
175
+ archive-tar-minitar (>= 0.5.2)
176
+ rubyzip (0.9.8)
177
+ selenium-webdriver (2.21.2)
178
+ childprocess (>= 0.2.5)
179
+ ffi (~> 1.0)
180
+ libwebsocket (~> 0.1.3)
181
+ multi_json (~> 1.0)
182
+ rubyzip
183
+ spree_core (1.1.1)
184
+ activemerchant (= 1.20.4)
185
+ acts_as_list (= 0.1.4)
186
+ aws-sdk (~> 1.3.4)
187
+ deface (>= 0.8.0)
188
+ ffaker (~> 1.12.0)
189
+ highline (= 1.6.11)
190
+ jquery-rails (~> 2.0.0)
191
+ kaminari (>= 0.13.0)
192
+ nested_set (= 1.7.0)
193
+ paperclip (~> 2.7)
194
+ rails (>= 3.2.2, <= 3.2.3)
195
+ ransack (~> 0.6.0)
196
+ state_machine (= 1.1.2)
197
+ stringex (~> 1.3.2)
198
+ sprockets (2.1.3)
199
+ hike (~> 1.2)
200
+ rack (~> 1.0)
201
+ tilt (~> 1.1, != 1.3.0)
202
+ sqlite3 (1.3.6)
203
+ state_machine (1.1.2)
204
+ stringex (1.3.3)
205
+ thor (0.14.6)
206
+ tilt (1.3.3)
207
+ treetop (1.4.10)
208
+ polyglot
209
+ polyglot (>= 0.3.1)
210
+ tzinfo (0.3.33)
211
+ uuidtools (2.1.2)
212
+ xpath (0.1.4)
213
+ nokogiri (~> 1.3)
214
+
215
+ PLATFORMS
216
+ ruby
217
+
218
+ DEPENDENCIES
219
+ capybara (= 1.0.1)
220
+ factory_girl (~> 2.6.4)
221
+ ffaker
222
+ launchy
223
+ rspec-rails (~> 2.9)
224
+ ruby-debug19
225
+ spree_grid_faq!
226
+ sqlite3
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ Spree Grid FAQ
2
+ =========
3
+ This Spree extension will install a pretty advanced FAQ (Frequently Asked Question) to your Spree store. Warning, it was designed for [Alarm Grid] (http://www.alarmgrid.com), so I make no guarantees it will work for your store. Feel free to submit Pull requests to make it work for you. Don't break stuff for me and it's in.
4
+
5
+ Known Issues / Coming Soon
6
+ =========
7
+ * Breadcrumbs
8
+ * Browse by taxon (in sidebar) for FAQ pages
9
+ * Search by SKU
10
+ * DRY up copy and pasted product / taxon code
11
+ * Double active tabs in admin
12
+
13
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
14
+
15
+ $ bundle
16
+ $ bundle exec rake test_app
17
+ $ bundle exec rspec spec
18
+
19
+ Copyright (c) 2012 Eric Hochberger, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/core/testing_support/common_rake'
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => [:spec]
11
+
12
+ spec = eval(File.read('spree_grid_faq.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |p|
15
+ p.gem_spec = spec
16
+ end
17
+
18
+ desc 'Release to gemcutter'
19
+ task :release => :package do
20
+ require 'rake/gemcutter'
21
+ Rake::Gemcutter::Tasks.new(spec).define
22
+ Rake::Task['gem:push'].invoke
23
+ end
24
+
25
+ desc 'Generates a dummy app for testing'
26
+ task :test_app do
27
+ ENV['LIB_NAME'] = 'spree_grid_faq'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1,6 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ '1.1.x' => { :branch => 'master' }
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -0,0 +1,46 @@
1
+ module Spree
2
+ module Admin
3
+ ProductsController.class_eval do
4
+ def selected_for_question
5
+ @question = load_question
6
+ @products = @question.products
7
+
8
+ respond_with(:admin, @products)
9
+ end
10
+
11
+ def available_for_question
12
+ @question = load_question
13
+ @products = params[:q].blank? ? [] : Spree::Product.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%")
14
+ @products.delete_if { |product| @question.products.include?(product) }
15
+
16
+ respond_with(:admin, @products)
17
+ end
18
+
19
+ def select_for_question
20
+ @question = load_question
21
+ @product = Product.find_by_permalink(params[:id])
22
+ @question.products << @product
23
+ @question.save
24
+ @products = @question.products
25
+
26
+ respond_with(:admin, @products)
27
+ end
28
+
29
+ def remove_for_question
30
+ @question = load_question
31
+ @product = Product.find_by_permalink(params[:id])
32
+ @question.products.delete(@product)
33
+ @question.save
34
+ @products = @question.products
35
+
36
+ respond_with(:admin, @product)
37
+ end
38
+
39
+ private
40
+
41
+ def load_question
42
+ Question.find_by_slug(params[:question_id])
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ module Spree
2
+ module Admin
3
+ class QuestionsController < ResourceController
4
+
5
+ def index
6
+ respond_with(@collection) do |format|
7
+ format.html
8
+ format.json { render :json => json_data }
9
+ end
10
+ end
11
+
12
+ protected
13
+
14
+ def find_resource
15
+ Question.find_by_slug!(params[:id])
16
+ end
17
+
18
+ def collection
19
+ return @collection if @collection.present?
20
+ @search = Spree::Question.search(params[:q])
21
+ @collection = @search.result.page(params[:page]).per(20)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,46 @@
1
+ module Spree
2
+ module Admin
3
+ TaxonsController.class_eval do
4
+ def selected_for_question
5
+ @question = load_question
6
+ @taxons = @question.taxons
7
+
8
+ respond_with(:admin, @taxons)
9
+ end
10
+
11
+ def available_for_question
12
+ @question = load_question
13
+ @taxons = params[:q].blank? ? [] : Spree::Taxon.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%")
14
+ @taxons.delete_if { |taxon| @question.taxons.include?(taxon) }
15
+
16
+ respond_with(:admin, @taxons)
17
+ end
18
+
19
+ def select_for_question
20
+ @question = load_question
21
+ @taxon = Taxon.find(params[:id])
22
+ @question.taxons << @taxon
23
+ @question.save
24
+ @taxons = @question.taxons
25
+
26
+ respond_with(:admin, @taxons)
27
+ end
28
+
29
+ def remove_for_question
30
+ @question = load_question
31
+ @taxon = Taxon.find(params[:id])
32
+ @question.taxons.delete(@taxon)
33
+ @question.save
34
+ @taxons = @question.taxons
35
+
36
+ respond_with(:admin, @taxon)
37
+ end
38
+
39
+ private
40
+
41
+ def load_question
42
+ Question.find_by_slug(params[:question_id])
43
+ end
44
+ end
45
+ end
46
+ end