spree_essential_menus 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +10 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +220 -0
  5. data/LICENSE +26 -0
  6. data/README.md +52 -0
  7. data/Rakefile +29 -0
  8. data/Versionfile +11 -0
  9. data/app/assets/javascripts/admin/spree_essential_menus.js +1 -0
  10. data/app/assets/javascripts/store/spree_essential_menus.js +1 -0
  11. data/app/assets/stylesheets/admin/admin_tabs.css +17 -0
  12. data/app/assets/stylesheets/admin/spree_essential_menus.css +4 -0
  13. data/app/assets/stylesheets/store/spree_essential_menus.css +3 -0
  14. data/app/controllers/spree/admin/menu_bars_controller.rb +6 -0
  15. data/app/controllers/spree/admin/menus_controller.rb +49 -0
  16. data/app/models/spree/menu.rb +29 -0
  17. data/app/models/spree/menu_bar.rb +9 -0
  18. data/app/views/spree/admin/menu_bars/_form.html.haml +20 -0
  19. data/app/views/spree/admin/menu_bars/edit.html.haml +11 -0
  20. data/app/views/spree/admin/menu_bars/index.html.haml +27 -0
  21. data/app/views/spree/admin/menu_bars/new.html.haml +13 -0
  22. data/app/views/spree/admin/menus/_form.html.haml +44 -0
  23. data/app/views/spree/admin/menus/edit.html.haml +11 -0
  24. data/app/views/spree/admin/menus/index.html.haml +36 -0
  25. data/app/views/spree/admin/menus/new.html.haml +12 -0
  26. data/app/views/spree/admin/shared/_spree_menus_sidebar.html.haml +7 -0
  27. data/app/views/spree/shared/_render_menu.html.haml +5 -0
  28. data/config/locales/en.yml +5 -0
  29. data/config/locales/pl.yml +34 -0
  30. data/config/routes.rb +11 -0
  31. data/db/migrate/20120424223831_create_spree_menu.rb +19 -0
  32. data/db/migrate/20120427043237_create_spree_menu_bars.rb +14 -0
  33. data/lib/generators/spree_essential_menus/install/install_generator.rb +29 -0
  34. data/lib/spree_essential_menus/engine.rb +20 -0
  35. data/lib/spree_essential_menus/version.rb +3 -0
  36. data/lib/spree_essential_menus.rb +19 -0
  37. data/script/rails +7 -0
  38. data/spec/spec_helper.rb +43 -0
  39. data/spree_essential_menus.gemspec +32 -0
  40. metadata +211 -0
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,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'haml'
4
+ if RUBY_VERSION < '1.9'
5
+ gem 'ruby-debug'
6
+ else
7
+ gem 'ruby-debug19'
8
+ end
9
+
10
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,220 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spree-essential-menus (0.1.0)
5
+ spree_essentials (~> 0.5.0.rc1)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.3)
11
+ actionpack (= 3.2.3)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.3)
14
+ activemodel (= 3.2.3)
15
+ activesupport (= 3.2.3)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.1)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.2)
23
+ active_utils (1.0.3)
24
+ activesupport (>= 2.3.11)
25
+ i18n
26
+ activemerchant (1.20.4)
27
+ active_utils (>= 1.0.2)
28
+ activesupport (>= 2.3.11)
29
+ braintree (>= 2.0.0)
30
+ builder (>= 2.0.0)
31
+ i18n
32
+ json (>= 1.5.1)
33
+ money (<= 3.7.1)
34
+ activemodel (3.2.3)
35
+ activesupport (= 3.2.3)
36
+ builder (~> 3.0.0)
37
+ activerecord (3.2.3)
38
+ activemodel (= 3.2.3)
39
+ activesupport (= 3.2.3)
40
+ arel (~> 3.0.2)
41
+ tzinfo (~> 0.3.29)
42
+ activeresource (3.2.3)
43
+ activemodel (= 3.2.3)
44
+ activesupport (= 3.2.3)
45
+ activesupport (3.2.3)
46
+ i18n (~> 0.6)
47
+ multi_json (~> 1.0)
48
+ acts_as_list (0.1.4)
49
+ addressable (2.2.7)
50
+ arel (3.0.2)
51
+ aws-sdk (1.3.9)
52
+ httparty (~> 0.7)
53
+ json (~> 1.4)
54
+ nokogiri (>= 1.4.4)
55
+ uuidtools (~> 2.1)
56
+ braintree (2.16.0)
57
+ builder (>= 2.0.0)
58
+ builder (3.0.0)
59
+ capybara (1.0.1)
60
+ mime-types (>= 1.16)
61
+ nokogiri (>= 1.3.3)
62
+ rack (>= 1.0.0)
63
+ rack-test (>= 0.5.4)
64
+ selenium-webdriver (~> 2.0)
65
+ xpath (~> 0.1.4)
66
+ childprocess (0.3.2)
67
+ ffi (~> 1.0.6)
68
+ cocaine (0.2.1)
69
+ columnize (0.3.6)
70
+ deface (0.8.0)
71
+ nokogiri (~> 1.5.0)
72
+ rails (>= 3.0.9)
73
+ diff-lcs (1.1.3)
74
+ erubis (2.7.0)
75
+ factory_girl (2.6.4)
76
+ activesupport (>= 2.3.9)
77
+ ffaker (1.12.1)
78
+ ffi (1.0.11)
79
+ highline (1.6.11)
80
+ hike (1.2.1)
81
+ httparty (0.8.3)
82
+ multi_json (~> 1.0)
83
+ multi_xml
84
+ i18n (0.6.0)
85
+ journey (1.0.3)
86
+ jquery-rails (2.0.2)
87
+ railties (>= 3.2.0, < 5.0)
88
+ thor (~> 0.14)
89
+ json (1.6.6)
90
+ kaminari (0.13.0)
91
+ actionpack (>= 3.0.0)
92
+ activesupport (>= 3.0.0)
93
+ railties (>= 3.0.0)
94
+ libwebsocket (0.1.3)
95
+ addressable
96
+ linecache (0.46)
97
+ rbx-require-relative (> 0.0.4)
98
+ mail (2.4.4)
99
+ i18n (>= 0.4.0)
100
+ mime-types (~> 1.16)
101
+ treetop (~> 1.4.8)
102
+ mime-types (1.18)
103
+ money (3.7.1)
104
+ i18n (~> 0.4)
105
+ multi_json (1.3.2)
106
+ multi_xml (0.4.4)
107
+ nested_set (1.7.0)
108
+ activerecord (>= 3.0.0)
109
+ railties (>= 3.0.0)
110
+ nokogiri (1.5.2)
111
+ paperclip (2.7.0)
112
+ activerecord (>= 2.3.0)
113
+ activesupport (>= 2.3.2)
114
+ cocaine (>= 0.0.2)
115
+ mime-types
116
+ polyamorous (0.5.0)
117
+ activerecord (~> 3.0)
118
+ polyglot (0.3.3)
119
+ rack (1.4.1)
120
+ rack-cache (1.2)
121
+ rack (>= 0.4)
122
+ rack-ssl (1.3.2)
123
+ rack
124
+ rack-test (0.6.1)
125
+ rack (>= 1.0)
126
+ rails (3.2.3)
127
+ actionmailer (= 3.2.3)
128
+ actionpack (= 3.2.3)
129
+ activerecord (= 3.2.3)
130
+ activeresource (= 3.2.3)
131
+ activesupport (= 3.2.3)
132
+ bundler (~> 1.0)
133
+ railties (= 3.2.3)
134
+ railties (3.2.3)
135
+ actionpack (= 3.2.3)
136
+ activesupport (= 3.2.3)
137
+ rack-ssl (~> 1.3.2)
138
+ rake (>= 0.8.7)
139
+ rdoc (~> 3.4)
140
+ thor (~> 0.14.6)
141
+ rake (0.9.2.2)
142
+ ransack (0.6.0)
143
+ actionpack (~> 3.0)
144
+ activerecord (~> 3.0)
145
+ polyamorous (~> 0.5.0)
146
+ rbx-require-relative (0.0.9)
147
+ rdiscount (1.6.8)
148
+ rdoc (3.12)
149
+ json (~> 1.4)
150
+ rspec (2.9.0)
151
+ rspec-core (~> 2.9.0)
152
+ rspec-expectations (~> 2.9.0)
153
+ rspec-mocks (~> 2.9.0)
154
+ rspec-core (2.9.0)
155
+ rspec-expectations (2.9.1)
156
+ diff-lcs (~> 1.1.3)
157
+ rspec-mocks (2.9.0)
158
+ rspec-rails (2.9.0)
159
+ actionpack (>= 3.0)
160
+ activesupport (>= 3.0)
161
+ railties (>= 3.0)
162
+ rspec (~> 2.9.0)
163
+ ruby-debug (0.10.4)
164
+ columnize (>= 0.1)
165
+ ruby-debug-base (~> 0.10.4.0)
166
+ ruby-debug-base (0.10.4)
167
+ linecache (>= 0.3)
168
+ rubyzip (0.9.7)
169
+ selenium-webdriver (2.21.2)
170
+ childprocess (>= 0.2.5)
171
+ ffi (~> 1.0)
172
+ libwebsocket (~> 0.1.3)
173
+ multi_json (~> 1.0)
174
+ rubyzip
175
+ spree_core (1.1.0.rc2)
176
+ activemerchant (= 1.20.4)
177
+ acts_as_list (= 0.1.4)
178
+ aws-sdk (~> 1.3.4)
179
+ deface (>= 0.8.0)
180
+ ffaker (~> 1.12.0)
181
+ highline (= 1.6.11)
182
+ jquery-rails (~> 2.0.0)
183
+ kaminari (>= 0.13.0)
184
+ nested_set (= 1.7.0)
185
+ paperclip (~> 2.7)
186
+ rails (>= 3.2.2, <= 3.2.3)
187
+ ransack (~> 0.6.0)
188
+ state_machine (= 1.1.2)
189
+ stringex (~> 1.3.2)
190
+ spree_essentials (0.5.0.rc1)
191
+ rdiscount (~> 1.6.8)
192
+ spree_core (~> 1.1.0.rc1)
193
+ sprockets (2.1.2)
194
+ hike (~> 1.2)
195
+ rack (~> 1.0)
196
+ tilt (~> 1.1, != 1.3.0)
197
+ sqlite3 (1.3.6)
198
+ state_machine (1.1.2)
199
+ stringex (1.3.3)
200
+ thor (0.14.6)
201
+ tilt (1.3.3)
202
+ treetop (1.4.10)
203
+ polyglot
204
+ polyglot (>= 0.3.1)
205
+ tzinfo (0.3.33)
206
+ uuidtools (2.1.2)
207
+ xpath (0.1.4)
208
+ nokogiri (~> 1.3)
209
+
210
+ PLATFORMS
211
+ ruby
212
+
213
+ DEPENDENCIES
214
+ capybara (= 1.0.1)
215
+ factory_girl (~> 2.6.4)
216
+ ffaker
217
+ rspec-rails (~> 2.9)
218
+ ruby-debug
219
+ spree-essential-menus!
220
+ 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,52 @@
1
+ SpreeEssentialMenus
2
+ ===================
3
+
4
+ The extension closely cooperates with citrus/spree_essential_cms. It allows you to organize menus in you Spree app.
5
+ Both extensions together opens possibility to have a fully customizeable CMS with pages, picutres and attachments in you app.
6
+
7
+ Installation
8
+ ------------
9
+
10
+ Add the following line to your gemfile:
11
+
12
+ gem 'spree_essential_menus', :git => 'git://github.com/matfiz/spree_essential_menus.git'
13
+
14
+ Then run *bundle*.
15
+
16
+ Copy the migrations to your app and run *rake db:migrate*. You are ready to play!
17
+
18
+ Usage
19
+ -----
20
+ The SpreeEssentialMenus extension adds a subtab *Menus* to spree_essential tab (usually *Static content*, depending on you translation).
21
+ You should first create *Menu bars* that you need for your shop (usually **main menu** and **footer menu**, but can be infinitely many).
22
+ Then in every menu bar, you can create as many menu elements as you want to. You can either manually type the path (it can be both relative or absolute, but in case of aboulute path remember to start with "http://")
23
+ or you can select a static page created in citrus/spree_essential_cms, that the menu element should point to. In this case, the path will be filled in automatically.
24
+
25
+ ### How to reorganize menu elements? ###
26
+
27
+ The menu elements can be easily reorganized by drag&drop functionality - just click on green arrows left to the element's name and drag it where you want to.
28
+
29
+ Example
30
+ =======
31
+
32
+ When you create *Menu bars*, you can easily embedd them in your layout by the partial, like below (written in *HAML*):
33
+
34
+ %header
35
+ %nav
36
+ - @menu_bar = Spree::MenuBar.find_by_name("main_menu")
37
+ = render :partial => "spree/shared/render_menu", :locals => {:menu_bar => @menu_bar}
38
+
39
+
40
+ Testing
41
+ -------
42
+
43
+ **So far there are no tests for this extension - I will be thankful for any help you can give me with that!**
44
+
45
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
46
+
47
+ $ bundle
48
+ $ bundle exec rake test_app
49
+ $ bundle exec rspec spec
50
+
51
+ Copyright (c) 2012 Grzegorz Brzezinka, released under the New BSD License
52
+
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_essential_menus.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_essential_menus'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1,11 @@
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.2.x' => { :branch => 'master' }
7
+ '1.1.x' => { :branch => 'master' }
8
+ # '1.0.x' => { :branch => '1-0-stable' }
9
+ # '0.70.x' => { :branch => '0-70-stable' }
10
+ # '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' }
11
+
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1 @@
1
+ //= require store/spree_core
@@ -0,0 +1,17 @@
1
+ #menus_sidebar a {
2
+ display: block;
3
+ margin-bottom: 5px;
4
+ height: 34px;
5
+
6
+ }
7
+
8
+ #menus_sidebar div.clearfix {
9
+ clear: both;
10
+ }
11
+
12
+ #menus_sidebar img {
13
+ float: left;
14
+ margin: 0 3px 0 0;
15
+ }
16
+
17
+
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ *= require admin/admin_tabs
4
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -0,0 +1,6 @@
1
+ class Spree::Admin::MenuBarsController < Spree::Admin::ResourceController
2
+ def index
3
+
4
+ end
5
+
6
+ end
@@ -0,0 +1,49 @@
1
+ class Spree::Admin::MenusController < Spree::Admin::ResourceController
2
+ before_filter :load_resource
3
+ before_filter :parent, :only => :index
4
+ before_filter :update_sequence, :only => :new
5
+
6
+ #before_filter :get_menu_bars, :only => [ :new, :edit, :create, :update ]
7
+
8
+ belongs_to 'spree/menu_bar'
9
+
10
+ def update_positions
11
+ @menu_bar = parent
12
+ if params[:positions]
13
+ params[:positions].each do |id, index|
14
+ @menu_bar.menus.update_all(['sequence=?', index], ['id=?', id])
15
+ end
16
+ end
17
+ respond_to do |format|
18
+ format.html { redirect_to admin_menu_bar_menus_url(@menu_bar) }
19
+ format.js { render :text => 'Ok' }
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def update_sequence
26
+ if params[:menu_bar_id].present?
27
+ @sequence = Spree::MenuBar.find(params[:menu_bar_id]).menus.count + 1
28
+ end
29
+ end
30
+
31
+ def get_menu_bars
32
+ @menu_bars = Spree::MenuBar.order(:sequence).all
33
+ end
34
+
35
+ def parent
36
+ if params[:menu_bar_id].present?
37
+ @menu_bar ||= Spree::MenuBar.find(params[:menu_bar_id])
38
+ end
39
+ end
40
+
41
+ def collection
42
+ params[:q] ||= {}
43
+ params[:q][:sort] ||= "menu_bar.asc"
44
+ @search = parent.menus.search(params[:q])
45
+ @collection = @search.result.page(params[:menu_bar]).per(Spree::Config[:orders_per_page])
46
+ end
47
+
48
+
49
+ end
@@ -0,0 +1,29 @@
1
+ class Spree::Menu < ActiveRecord::Base
2
+
3
+ before_validation :get_static_page_path
4
+
5
+ belongs_to :menu_bar
6
+ belongs_to :page
7
+
8
+ attr_accessible :page_id, :sequence,:parent_id, :link_text, :url, :visible, :menu_bar_id
9
+ alias_attribute :position, :sequence
10
+
11
+ acts_as_tree :order => "sequence"
12
+
13
+ #validates_presence_of :sequence
14
+ #validates_numericality_of :sequence
15
+
16
+ validates_presence_of :link_text
17
+ validates_presence_of :url
18
+ validates_presence_of :menu_bar
19
+
20
+ default_scope order(:sequence)
21
+ scope :visible, where(:visible => true)
22
+
23
+ private
24
+ def get_static_page_path
25
+ if attribute_present?("page_id")
26
+ self.url = self.page.path
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ class Spree::MenuBar < ActiveRecord::Base
2
+
3
+ has_many :menus
4
+
5
+ attr_accessible :name, :description, :css_class
6
+
7
+ validates_presence_of :name
8
+
9
+ end
@@ -0,0 +1,20 @@
1
+ = form.field_container :name do
2
+ = form.label :name, t('spree.admin.menu_bars.name')
3
+ %span.required
4
+ %br
5
+ = form.text_field :name, :class => "name"
6
+ = error_message_on :menu_bar, :name
7
+
8
+ = form.field_container :description do
9
+ = form.label :description, t('spree.admin.menu_bars.description')
10
+ %span.required
11
+ %br
12
+ = form.text_field :description, :class => "description"
13
+ = error_message_on :menu_bar, :description
14
+
15
+ = form.field_container :css_class do
16
+ = form.label :css_class, t('spree.admin.menu_bars.css_class')
17
+ %span.required
18
+ %br
19
+ = form.text_field :css_class, :class => "css_class"
20
+ = error_message_on :menu_bar, :css_class
@@ -0,0 +1,11 @@
1
+ - if @menu_bar.try(:errors).present?
2
+ = render 'spree/shared/error_messages', :target => @menu_bar
3
+
4
+ = form_for([:admin, @menu_bar], :html => { :multipart => true }) do |f|
5
+ = render "form", :form => f
6
+ %p.form-buttons
7
+ = button t('update')
8
+ = t('or')
9
+ = link_to t('cancel'), collection_url
10
+
11
+ = render :partial => 'spree/admin/shared/spree_menus_sidebar'
@@ -0,0 +1,27 @@
1
+ %div.toolbar
2
+ %ul.actions
3
+ %li
4
+ %p= button_link_to t('spree.admin.menu_bars.new_menu_bar'), new_object_url, :icon => 'add'
5
+ %br.clear
6
+
7
+ %h1= t('spree.admin.menu_bars.list_of_menu_bars')
8
+
9
+ %table.index
10
+ %thead
11
+ %tr
12
+ %th= t('spree.admin.menu_bars.name')
13
+ %th= t('spree.admin.menu_bars.css_class')
14
+ %th= t('action')
15
+ %tbody
16
+ - @menu_bars.each do |bar|
17
+ %tr
18
+ %td= bar.name
19
+ %td= bar.css_class
20
+ %td
21
+ = link_to_with_icon :pages, t('spree.admin.menus.list_of_menus'), admin_menu_bar_menus_path(bar)
22
+ = link_to_edit bar
23
+ = link_to_delete bar
24
+
25
+
26
+ =# render :partial => 'spree/admin/shared/spree_menus_sidebar'
27
+
@@ -0,0 +1,13 @@
1
+ - if @menu_bar.try(:errors).present?
2
+ = render 'spree/shared/error_messages', :target => @menu_bar
3
+
4
+ %h1= t('spree.admin.menu_bars.new_menu_bar')
5
+
6
+ = form_for([:admin, @menu_bar], :html => { :multipart => true }) do |f|
7
+ = render "form", :form => f
8
+ %p.form-buttons
9
+ = button t('create')
10
+ = t('or')
11
+ = link_to t('cancel'), collection_url
12
+
13
+ = render :partial => 'spree/admin/shared/spree_menus_sidebar'
@@ -0,0 +1,44 @@
1
+ - if @menu.sequence.blank?
2
+ = form.hidden_field :sequence, :class => "sequence", :value => @sequence
3
+
4
+
5
+
6
+ = form.field_container :link_text do
7
+ = form.label :link_text, t('spree.admin.menus.link_text')
8
+ %span.required
9
+ %br
10
+ = form.text_field :link_text, :class => "link_text"
11
+ = error_message_on :menu, :link_text
12
+
13
+ = form.field_container :url do
14
+ = form.label :url, t('spree.admin.menus.url')
15
+ %span.required
16
+ %br
17
+ = form.text_field :url, :class => "url"
18
+ %br
19
+ %em= t("spree.admin.menus.explain_url")
20
+ = error_message_on :menu, :url
21
+
22
+ = form.field_container :visible do
23
+ = form.check_box :visible, :class => "text"
24
+ = form.label :visible, t('spree.admin.menus.visible')
25
+ %em= t("spree.admin.menus.explain_visible")
26
+ = error_message_on :menu, :visible
27
+ %h3 Opcjonalnie
28
+ - if Spree::Menu.all.count > 0 and false#turn off for futher improvement
29
+ = form.field_container :parent_id do
30
+ = form.label :parent_id, t('spree.admin.menus.parent_id')
31
+ %br
32
+ = collection_select(:menu,:parent_id,Spree::Menu.where(:menu_bar_id => @menu_bar.id).all, :id, :link_text, :prompt => t("spree.admin.menus.select_parent"))
33
+ %em= t("spree.admin.menus.explain_parent_id")
34
+ = error_message_on :menu, :parent_id
35
+
36
+
37
+
38
+ - if Spree::Page.all.count > 0
39
+ = form.field_container :spree_page_id do
40
+ = form.label :spree_page_id, t('spree.admin.menus.page_id')
41
+ %br
42
+ = collection_select(:menu,:page_id,Spree::Page.visible, :id, :name, :prompt => t("spree.admin.menus.select_page_id"), :include_blank => true)
43
+ %em= t("spree.admin.menus.explain_page_id")
44
+ = error_message_on :menu, :page_id
@@ -0,0 +1,11 @@
1
+ - if @menu.try(:errors).present?
2
+ = render 'spree/shared/error_messages', :target => @menu
3
+
4
+ %h1= t('spree.admin.menus.edit_menu')
5
+
6
+ = form_for([:admin, @menu_bar, @menu], :html => { :multipart => true }) do |f|
7
+ = render "form", :form => f
8
+ %p.form-buttons
9
+ = button t('update')
10
+ = t('or')
11
+ = link_to t('cancel'), collection_url
@@ -0,0 +1,36 @@
1
+ %div.toolbar
2
+ %ul.actions
3
+ %li
4
+ %p= button_link_to t('spree.admin.menus.new_menu'), new_object_url, :icon => 'add'
5
+ %br.clear
6
+
7
+ %h1= t('.listing_menus')
8
+ %h2= @menu_bar.description
9
+
10
+ %table.index.sortable{:data => {:"sortable-link" => update_positions_admin_menu_bar_menus_url(@menu_bar)}}
11
+ %thead
12
+ %tr
13
+ %th= sort_link @search, :link_text, t('spree.admin.menus.link_text')
14
+ %th= sort_link @search, :url, t('spree.admin.menus.url')
15
+ %th= t('spree.admin.menus.page_id')
16
+ %th= t('action')
17
+ %tbody
18
+ - @collection.each do |menu|
19
+ %tr{:id => "#{spree_dom_id menu}"}
20
+ %td
21
+ %span.handle &nbsp;
22
+ = link_to menu.link_text
23
+ %td
24
+ = link_to menu.url
25
+ %td
26
+ - if menu.page.present?
27
+ = link_to menu.page.title
28
+ - else
29
+ = t('.static_path')
30
+ %td
31
+ = link_to_edit menu
32
+ &nbsp;
33
+ = link_to_delete menu
34
+
35
+ = render :partial => 'spree/admin/shared/spree_menus_sidebar'
36
+
@@ -0,0 +1,12 @@
1
+ - if @menu.try(:errors).present?
2
+ = render 'spree/shared/error_messages', :target => @menu
3
+
4
+ %h1= t('spree.admin.menus.new_menu')
5
+
6
+ = form_for([:admin, @menu_bar, @menu], :html => { :multipart => true }) do |f|
7
+ = render "form", :form => f
8
+ %p.form-buttons
9
+ = button t('create')
10
+ = t('or')
11
+ = link_to t('cancel'), collection_url
12
+
@@ -0,0 +1,7 @@
1
+ - content_for :sidebar do
2
+ %div.box#menus_sidebar
3
+ %h3= t('menu_bars')
4
+ %div
5
+ = button_link_to t('spree.admin.menu_bars.list_of_menu_bars'), admin_menu_bars_path, :icon => 'pages'
6
+ = button_link_to t('spree.admin.menu_bars.new_menu_bar'), new_admin_menu_bar_path, :icon => 'add'
7
+ %div.clearfix
@@ -0,0 +1,5 @@
1
+ - if menu_bar.present?
2
+ %ul{:class => "menu #{menu_bar.css_class}"}
3
+ - menu_bar.menus.visible.each do |menu|
4
+ %li
5
+ = link_to menu.link_text, menu.url
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,34 @@
1
+ pl:
2
+ menus: Menu
3
+ menu_bars: Paski menu
4
+
5
+ spree:
6
+ admin:
7
+ menus:
8
+ index:
9
+ listing_menus: Menu na stronie
10
+ static_path: Ścieżka statyczna
11
+ new_menu: "Nowy element menu"
12
+ edit_menu: "Edytuj menu"
13
+ list_of_menus: "Lista elementów menu"
14
+ link_text: "Etykieta w menu"
15
+ url: "Ścieżka"
16
+ explain_url: "Jeśli wybierasz stronę statyczną, uzupełni się automatycznie. W przeciwnym razie - wpisz adres."
17
+ visible: "Widoczny w menu?"
18
+ explain_visible: "Jeśli zaznaczony, element pojawi się w menu"
19
+ parent_id: "Element nadrzędny"
20
+ explain_parent_id: "Wybierz element, pod którym ma znaleźć się ta pozycja."
21
+ select_parent: "Wybierz element nadrzędny"
22
+ menu_bar_id: "Wybierz pasek menu"
23
+ select_menu_bar_id: "Wybierz docelową pozycję z listy"
24
+ explain_menu_bar_id: "Wybierz pasek, na którym znajdzie się element"
25
+ page_id: "Strona statyczna"
26
+ select_page_id: "Wybierz stronę statyczną"
27
+ explain_page_id: "Wybierz stronę statyczną, do której odnosi się pozycja"
28
+ sequence: "Kolejność"
29
+ menu_bars:
30
+ list_of_menu_bars: "Lista pasków menu"
31
+ new_menu_bar: "Nowy pasek menu"
32
+ name: "Nazwa"
33
+ description: "Krótki opis"
34
+ css_class: "Klasa CSS"
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ Spree::Core::Engine.routes.prepend do
2
+ namespace :admin do
3
+ resources :menu_bars do
4
+ resources :menus do
5
+ collection do
6
+ post :update_positions
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSpreeMenu < ActiveRecord::Migration
2
+ def up
3
+ create_table :spree_menus, :force => true do |t|
4
+ t.references :page
5
+ t.references :menu_bar
6
+ t.integer :sequence
7
+ t.integer :parent_id
8
+ t.string :link_text
9
+ t.string :url
10
+ t.boolean :visible, :default => true
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+
16
+ def down
17
+ drop_table :spree_menus
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ class CreateSpreeMenuBars < ActiveRecord::Migration
2
+ def up
3
+ create_table :spree_menu_bars, :force => true do |t|
4
+ t.string :name
5
+ t.string :description
6
+ t.string :css_class
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def down
12
+ drop_table :spree_menu_bars
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module SpreeEssentialMenus
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def add_javascripts
6
+ append_file 'app/assets/javascripts/store/all.js', "//= require store/spree_essential_menus\n"
7
+ append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_essential_menus\n"
8
+ end
9
+
10
+ def add_stylesheets
11
+ inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_essential_menus\n", :before => /\*\//, :verbose => true
12
+ inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_essential_menus\n", :before => /\*\//, :verbose => true
13
+ end
14
+
15
+ def add_migrations
16
+ run 'bundle exec rake railties:install:migrations FROM=spree_essential_menus'
17
+ end
18
+
19
+ def run_migrations
20
+ res = ask 'Would you like to run the migrations now? [Y/n]'
21
+ if res == '' || res.downcase == 'y'
22
+ run 'bundle exec rake db:migrate'
23
+ else
24
+ puts 'Skiping rake db:migrate, don\'t forget to run it!'
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeEssentialMenus
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_essential_menus'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module SpreeEssentialMenus
2
+ VERSION = "0.1.8"
3
+ end
@@ -0,0 +1,19 @@
1
+ require "spree_essentials"
2
+ require "spree_sample" unless Rails.env.production?
3
+
4
+ require "spree_essential_menus/version"
5
+ require "spree_essential_menus/engine"
6
+
7
+ module SpreeEssentialMenus
8
+
9
+ def self.tab
10
+ { :label => "Menu bars", :route => :admin_menu_bars }
11
+ end
12
+
13
+ def self.sub_tab
14
+ [ :menu_bars, { :match_path => '/menu_bars' }]
15
+ end
16
+
17
+ end
18
+
19
+ SpreeEssentials.register :menu_bars, SpreeEssentialMenus
data/script/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_essential_menus/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,43 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+
4
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
5
+
6
+ require 'rspec/rails'
7
+ require 'ffaker'
8
+
9
+ # Requires supporting ruby files with custom matchers and macros, etc,
10
+ # in spec/support/ and its subdirectories.
11
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
12
+
13
+ # Requires factories defined in spree_core
14
+ require 'spree/core/testing_support/factories'
15
+ require 'spree/core/url_helpers'
16
+
17
+ RSpec.configure do |config|
18
+
19
+ # == URL Helpers
20
+ #
21
+ # Allows access to Spree's routes in specs:
22
+ #
23
+ # visit spree.admin_path
24
+ # current_path.should eql(spree.products_path)
25
+ config.include Spree::Core::UrlHelpers
26
+
27
+ # == Mock Framework
28
+ #
29
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
30
+ #
31
+ # config.mock_with :mocha
32
+ # config.mock_with :flexmock
33
+ # config.mock_with :rr
34
+ config.mock_with :rspec
35
+
36
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
37
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
38
+
39
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
40
+ # examples within a transaction, remove the following line or assign false
41
+ # instead of true.
42
+ config.use_transactional_fixtures = true
43
+ end
@@ -0,0 +1,32 @@
1
+ #encoding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "spree_essential_menus/version"
4
+ Gem::Specification.new do |s|
5
+ s.platform = Gem::Platform::RUBY
6
+ s.name = 'spree_essential_menus'
7
+ s.version = SpreeEssentialMenus::VERSION
8
+ s.summary = 'Add menu customization for Spree'
9
+ s.description = "Add menu customization for Spree. It's designed to be used with the spree_essentials base."
10
+ s.required_ruby_version = '>= 1.8.7'
11
+
12
+ s.author = 'Grzegorz Brzezinka'
13
+ s.email = 'grzegorz@brzezinka.eu'
14
+ s.homepage = 'http://www.brzezinka.eu'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_path = 'lib'
19
+ s.requirements << 'none'
20
+
21
+ #s.add_dependency 'spree_core', '~> 1.1.0'
22
+ # Spree Essentials
23
+ s.add_runtime_dependency('spree_essentials', '~> 0.5.0.rc1')
24
+
25
+ s.add_runtime_dependency('haml')
26
+
27
+ s.add_development_dependency 'capybara', '1.0.1'
28
+ s.add_development_dependency 'factory_girl', '~> 2.6.4'
29
+ s.add_development_dependency 'ffaker'
30
+ s.add_development_dependency 'rspec-rails', '~> 2.9'
31
+ s.add_development_dependency 'sqlite3'
32
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_essential_menus
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 8
10
+ version: 0.1.8
11
+ platform: ruby
12
+ authors:
13
+ - Grzegorz Brzezinka
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-07 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: spree_essentials
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 15424071
29
+ segments:
30
+ - 0
31
+ - 5
32
+ - 0
33
+ - rc
34
+ - 1
35
+ version: 0.5.0.rc1
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: haml
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: capybara
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - "="
59
+ - !ruby/object:Gem::Version
60
+ hash: 21
61
+ segments:
62
+ - 1
63
+ - 0
64
+ - 1
65
+ version: 1.0.1
66
+ type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: factory_girl
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 31
77
+ segments:
78
+ - 2
79
+ - 6
80
+ - 4
81
+ version: 2.6.4
82
+ type: :development
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: ffaker
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ type: :development
97
+ version_requirements: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ name: rspec-rails
100
+ prerelease: false
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ~>
105
+ - !ruby/object:Gem::Version
106
+ hash: 17
107
+ segments:
108
+ - 2
109
+ - 9
110
+ version: "2.9"
111
+ type: :development
112
+ version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ name: sqlite3
115
+ prerelease: false
116
+ requirement: &id007 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ type: :development
126
+ version_requirements: *id007
127
+ description: Add menu customization for Spree. It's designed to be used with the spree_essentials base.
128
+ email: grzegorz@brzezinka.eu
129
+ executables: []
130
+
131
+ extensions: []
132
+
133
+ extra_rdoc_files: []
134
+
135
+ files:
136
+ - .gitignore
137
+ - .rspec
138
+ - Gemfile
139
+ - Gemfile.lock
140
+ - LICENSE
141
+ - README.md
142
+ - Rakefile
143
+ - Versionfile
144
+ - app/assets/javascripts/admin/spree_essential_menus.js
145
+ - app/assets/javascripts/store/spree_essential_menus.js
146
+ - app/assets/stylesheets/admin/admin_tabs.css
147
+ - app/assets/stylesheets/admin/spree_essential_menus.css
148
+ - app/assets/stylesheets/store/spree_essential_menus.css
149
+ - app/controllers/spree/admin/menu_bars_controller.rb
150
+ - app/controllers/spree/admin/menus_controller.rb
151
+ - app/models/spree/menu.rb
152
+ - app/models/spree/menu_bar.rb
153
+ - app/views/spree/admin/menu_bars/_form.html.haml
154
+ - app/views/spree/admin/menu_bars/edit.html.haml
155
+ - app/views/spree/admin/menu_bars/index.html.haml
156
+ - app/views/spree/admin/menu_bars/new.html.haml
157
+ - app/views/spree/admin/menus/_form.html.haml
158
+ - app/views/spree/admin/menus/edit.html.haml
159
+ - app/views/spree/admin/menus/index.html.haml
160
+ - app/views/spree/admin/menus/new.html.haml
161
+ - app/views/spree/admin/shared/_spree_menus_sidebar.html.haml
162
+ - app/views/spree/shared/_render_menu.html.haml
163
+ - config/locales/en.yml
164
+ - config/locales/pl.yml
165
+ - config/routes.rb
166
+ - db/migrate/20120424223831_create_spree_menu.rb
167
+ - db/migrate/20120427043237_create_spree_menu_bars.rb
168
+ - lib/generators/spree_essential_menus/install/install_generator.rb
169
+ - lib/spree_essential_menus.rb
170
+ - lib/spree_essential_menus/engine.rb
171
+ - lib/spree_essential_menus/version.rb
172
+ - script/rails
173
+ - spec/spec_helper.rb
174
+ - spree_essential_menus.gemspec
175
+ homepage: http://www.brzezinka.eu
176
+ licenses: []
177
+
178
+ post_install_message:
179
+ rdoc_options: []
180
+
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ hash: 57
189
+ segments:
190
+ - 1
191
+ - 8
192
+ - 7
193
+ version: 1.8.7
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
203
+ requirements:
204
+ - none
205
+ rubyforge_project:
206
+ rubygems_version: 1.8.10
207
+ signing_key:
208
+ specification_version: 3
209
+ summary: Add menu customization for Spree
210
+ test_files: []
211
+