navi 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +117 -134
- data/README.md +8 -0
- data/features/step_definitions/category_steps.rb +1 -1
- data/features/step_definitions/page_steps.rb +1 -1
- data/features/support/env.rb +7 -2
- data/lib/navi.rb +2 -1
- data/lib/navi/renderers/base.rb +12 -10
- data/lib/navi/renderers/simple_navigation.rb +6 -32
- data/lib/navi/renderers/simple_navigation/dynamic_item.rb +18 -0
- data/lib/navi/renderers/simple_navigation/dynamic_items.rb +26 -0
- data/lib/navi/renderers/simple_navigation/generates_uri.rb +32 -0
- data/lib/navi/renderers/simple_navigation/renderer.rb +27 -0
- data/lib/navi/version.rb +1 -1
- data/navi.gemspec +6 -17
- data/spec/dummy/app/assets/javascripts/application.js +1 -1
- data/spec/dummy/app/controllers/categories_controller.rb +4 -4
- data/spec/dummy/app/controllers/menu_items_controller.rb +11 -4
- data/spec/dummy/app/controllers/pages_controller.rb +5 -4
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/config/application.rb +0 -1
- data/spec/dummy/config/navigation.rb +0 -0
- data/spec/dummy/db/seeds.rb +4 -6
- data/spec/dummy/vendor/assets/javascripts/nestedSortable.js +382 -0
- data/spec/navi/navi_spec.rb +3 -3
- data/spec/navi/navigable_spec.rb +2 -2
- data/spec/navi/navigator_spec.rb +7 -7
- data/spec/navi/renderers/simple_navigation/dynamic_item_spec.rb +49 -0
- data/spec/navi/renderers/simple_navigation/dynamic_items_spec.rb +30 -0
- data/spec/navi/renderers/simple_navigation/generates_uri_spec.rb +57 -0
- data/spec/navi/renderers/simple_navigation/renderer_spec.rb +41 -0
- metadata +229 -142
- data/.rvmrc +0 -1
- data/spec/navi/renderers/simple_navigation_spec.rb +0 -49
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-1.9.3-p286
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,62 +1,62 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
navi (0.
|
4
|
+
navi (0.2.0)
|
5
5
|
activerecord (>= 3.0.0)
|
6
6
|
activesupport (>= 3.0.0)
|
7
|
+
easy_class_to_instance_method (= 0.0.1)
|
7
8
|
ordered_tree (>= 0.1.6)
|
9
|
+
simple-navigation (~> 3.11.0)
|
8
10
|
|
9
11
|
GEM
|
10
|
-
remote:
|
12
|
+
remote: https://rubygems.org/
|
11
13
|
specs:
|
12
|
-
actionmailer (3.2.
|
13
|
-
actionpack (= 3.2.
|
14
|
-
mail (~> 2.
|
15
|
-
actionpack (3.2.
|
16
|
-
activemodel (= 3.2.
|
17
|
-
activesupport (= 3.2.
|
14
|
+
actionmailer (3.2.13)
|
15
|
+
actionpack (= 3.2.13)
|
16
|
+
mail (~> 2.5.3)
|
17
|
+
actionpack (3.2.13)
|
18
|
+
activemodel (= 3.2.13)
|
19
|
+
activesupport (= 3.2.13)
|
18
20
|
builder (~> 3.0.0)
|
19
21
|
erubis (~> 2.7.0)
|
20
|
-
journey (~> 1.0.
|
21
|
-
rack (~> 1.4.
|
22
|
-
rack-cache (~> 1.
|
22
|
+
journey (~> 1.0.4)
|
23
|
+
rack (~> 1.4.5)
|
24
|
+
rack-cache (~> 1.2)
|
23
25
|
rack-test (~> 0.6.1)
|
24
|
-
sprockets (~> 2.1
|
25
|
-
activemodel (3.2.
|
26
|
-
activesupport (= 3.2.
|
26
|
+
sprockets (~> 2.2.1)
|
27
|
+
activemodel (3.2.13)
|
28
|
+
activesupport (= 3.2.13)
|
27
29
|
builder (~> 3.0.0)
|
28
|
-
activerecord (3.2.
|
29
|
-
activemodel (= 3.2.
|
30
|
-
activesupport (= 3.2.
|
31
|
-
arel (~> 3.0.
|
30
|
+
activerecord (3.2.13)
|
31
|
+
activemodel (= 3.2.13)
|
32
|
+
activesupport (= 3.2.13)
|
33
|
+
arel (~> 3.0.2)
|
32
34
|
tzinfo (~> 0.3.29)
|
33
|
-
activeresource (3.2.
|
34
|
-
activemodel (= 3.2.
|
35
|
-
activesupport (= 3.2.
|
36
|
-
activesupport (3.2.
|
37
|
-
i18n (
|
35
|
+
activeresource (3.2.13)
|
36
|
+
activemodel (= 3.2.13)
|
37
|
+
activesupport (= 3.2.13)
|
38
|
+
activesupport (3.2.13)
|
39
|
+
i18n (= 0.6.1)
|
38
40
|
multi_json (~> 1.0)
|
39
|
-
addressable (2.
|
40
|
-
apotomo (1.2.
|
41
|
+
addressable (2.3.4)
|
42
|
+
apotomo (1.2.3)
|
41
43
|
cells (>= 3.6.7)
|
42
44
|
hooks (~> 0.2.0)
|
43
45
|
onfire (~> 0.2.0)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
capybara (1.1.2)
|
46
|
+
arel (3.0.2)
|
47
|
+
builder (3.0.4)
|
48
|
+
capybara (2.1.0)
|
48
49
|
mime-types (>= 1.16)
|
49
50
|
nokogiri (>= 1.3.3)
|
50
51
|
rack (>= 1.0.0)
|
51
52
|
rack-test (>= 0.5.4)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
columnize (0.3.6)
|
53
|
+
xpath (~> 2.0)
|
54
|
+
cells (3.8.8)
|
55
|
+
actionpack (>= 3.0)
|
56
|
+
railties (>= 3.0)
|
57
|
+
childprocess (0.3.9)
|
58
|
+
ffi (~> 1.0, >= 1.0.11)
|
59
|
+
coderay (1.0.9)
|
60
60
|
cucumber (0.10.7)
|
61
61
|
builder (>= 2.1.2)
|
62
62
|
diff-lcs (>= 1.1.2)
|
@@ -68,12 +68,14 @@ GEM
|
|
68
68
|
cucumber (>= 0.10.5)
|
69
69
|
nokogiri (>= 1.4.4)
|
70
70
|
rack-test (>= 0.5.7)
|
71
|
-
database_cleaner (0.
|
72
|
-
diff-lcs (1.
|
71
|
+
database_cleaner (1.0.1)
|
72
|
+
diff-lcs (1.2.4)
|
73
|
+
easy_class_to_instance_method (0.0.1)
|
74
|
+
activesupport (>= 3.0.0)
|
73
75
|
erubis (2.7.0)
|
74
|
-
factory_girl (2.
|
75
|
-
activesupport
|
76
|
-
ffi (1.
|
76
|
+
factory_girl (4.2.0)
|
77
|
+
activesupport (>= 3.0.0)
|
78
|
+
ffi (1.8.1)
|
77
79
|
gherkin (2.4.21)
|
78
80
|
json (>= 1.4.6)
|
79
81
|
guard (0.3.4)
|
@@ -81,136 +83,117 @@ GEM
|
|
81
83
|
guard-cucumber (0.3.4)
|
82
84
|
cucumber (~> 0.10.0)
|
83
85
|
guard (~> 0.3.0)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
thor (~> 0.14)
|
98
|
-
json (1.6.5)
|
99
|
-
launchy (2.0.5)
|
100
|
-
addressable (~> 2.2.6)
|
101
|
-
libnotify (0.7.2)
|
102
|
-
linecache19 (0.5.12)
|
103
|
-
ruby_core_source (>= 0.1.4)
|
104
|
-
mail (2.4.1)
|
105
|
-
i18n (>= 0.4.0)
|
86
|
+
haml (4.0.3)
|
87
|
+
tilt
|
88
|
+
hike (1.2.3)
|
89
|
+
hooks (0.2.2)
|
90
|
+
i18n (0.6.1)
|
91
|
+
journey (1.0.4)
|
92
|
+
jquery-rails (2.2.2)
|
93
|
+
railties (>= 3.0, < 5.0)
|
94
|
+
thor (>= 0.14, < 2.0)
|
95
|
+
json (1.8.0)
|
96
|
+
launchy (2.3.0)
|
97
|
+
addressable (~> 2.3)
|
98
|
+
mail (2.5.4)
|
106
99
|
mime-types (~> 1.16)
|
107
100
|
treetop (~> 1.4.8)
|
108
|
-
|
109
|
-
|
101
|
+
method_source (0.8.1)
|
102
|
+
mime-types (1.23)
|
103
|
+
multi_json (1.7.6)
|
110
104
|
nifty-generators (0.4.6)
|
111
|
-
nokogiri (1.5.
|
105
|
+
nokogiri (1.5.9)
|
112
106
|
onfire (0.2.0)
|
113
107
|
ordered_tree (0.2.1)
|
114
108
|
activerecord (>= 3.1.1)
|
115
109
|
polyglot (0.3.3)
|
116
|
-
|
117
|
-
|
110
|
+
pry (0.9.12.2)
|
111
|
+
coderay (~> 1.0.5)
|
112
|
+
method_source (~> 0.8)
|
113
|
+
slop (~> 3.4)
|
114
|
+
rack (1.4.5)
|
115
|
+
rack-cache (1.2)
|
118
116
|
rack (>= 0.4)
|
119
|
-
rack-ssl (1.3.
|
117
|
+
rack-ssl (1.3.3)
|
120
118
|
rack
|
121
|
-
rack-test (0.6.
|
119
|
+
rack-test (0.6.2)
|
122
120
|
rack (>= 1.0)
|
123
|
-
rails (3.2.
|
124
|
-
actionmailer (= 3.2.
|
125
|
-
actionpack (= 3.2.
|
126
|
-
activerecord (= 3.2.
|
127
|
-
activeresource (= 3.2.
|
128
|
-
activesupport (= 3.2.
|
121
|
+
rails (3.2.13)
|
122
|
+
actionmailer (= 3.2.13)
|
123
|
+
actionpack (= 3.2.13)
|
124
|
+
activerecord (= 3.2.13)
|
125
|
+
activeresource (= 3.2.13)
|
126
|
+
activesupport (= 3.2.13)
|
129
127
|
bundler (~> 1.0)
|
130
|
-
railties (= 3.2.
|
131
|
-
railties (3.2.
|
132
|
-
actionpack (= 3.2.
|
133
|
-
activesupport (= 3.2.
|
128
|
+
railties (= 3.2.13)
|
129
|
+
railties (3.2.13)
|
130
|
+
actionpack (= 3.2.13)
|
131
|
+
activesupport (= 3.2.13)
|
134
132
|
rack-ssl (~> 1.3.2)
|
135
133
|
rake (>= 0.8.7)
|
136
134
|
rdoc (~> 3.4)
|
137
|
-
thor (
|
138
|
-
rake (0.
|
139
|
-
|
140
|
-
ffi (>= 0.5.0)
|
141
|
-
rdoc (3.12)
|
135
|
+
thor (>= 0.14.6, < 2.0)
|
136
|
+
rake (10.0.4)
|
137
|
+
rdoc (3.12.2)
|
142
138
|
json (~> 1.4)
|
143
|
-
|
144
|
-
rspec (2.
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
rspec (~> 2.6.0)
|
157
|
-
ruby-debug-base19 (0.11.25)
|
158
|
-
columnize (>= 0.3.1)
|
159
|
-
linecache19 (>= 0.5.11)
|
160
|
-
ruby_core_source (>= 0.1.4)
|
161
|
-
ruby-debug19 (0.11.6)
|
162
|
-
columnize (>= 0.3.1)
|
163
|
-
linecache19 (>= 0.5.11)
|
164
|
-
ruby-debug-base19 (>= 0.11.19)
|
165
|
-
ruby_core_source (0.1.5)
|
166
|
-
archive-tar-minitar (>= 0.5.2)
|
167
|
-
rubyzip (0.9.5)
|
168
|
-
selenium-webdriver (2.18.0)
|
139
|
+
rspec-core (2.13.1)
|
140
|
+
rspec-expectations (2.13.0)
|
141
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
142
|
+
rspec-mocks (2.13.1)
|
143
|
+
rspec-rails (2.13.2)
|
144
|
+
actionpack (>= 3.0)
|
145
|
+
activesupport (>= 3.0)
|
146
|
+
railties (>= 3.0)
|
147
|
+
rspec-core (~> 2.13.0)
|
148
|
+
rspec-expectations (~> 2.13.0)
|
149
|
+
rspec-mocks (~> 2.13.0)
|
150
|
+
rubyzip (0.9.9)
|
151
|
+
selenium-webdriver (2.32.1)
|
169
152
|
childprocess (>= 0.2.5)
|
170
|
-
|
171
|
-
multi_json (~> 1.0.4)
|
153
|
+
multi_json (~> 1.0)
|
172
154
|
rubyzip
|
173
|
-
|
155
|
+
websocket (~> 1.0.4)
|
156
|
+
simple-navigation (3.11.0)
|
174
157
|
activesupport (>= 2.3.2)
|
175
|
-
|
158
|
+
slop (3.4.4)
|
159
|
+
sprockets (2.2.2)
|
176
160
|
hike (~> 1.2)
|
161
|
+
multi_json (~> 1.0)
|
177
162
|
rack (~> 1.0)
|
178
163
|
tilt (~> 1.1, != 1.3.0)
|
179
|
-
sqlite3 (1.3.
|
180
|
-
term-ansicolor (1.
|
164
|
+
sqlite3 (1.3.7)
|
165
|
+
term-ansicolor (1.2.2)
|
166
|
+
tins (~> 0.8)
|
181
167
|
thor (0.14.6)
|
182
|
-
tilt (1.
|
183
|
-
|
168
|
+
tilt (1.4.1)
|
169
|
+
tins (0.8.0)
|
170
|
+
treetop (1.4.14)
|
184
171
|
polyglot
|
185
172
|
polyglot (>= 0.3.1)
|
186
|
-
tzinfo (0.3.
|
187
|
-
|
173
|
+
tzinfo (0.3.37)
|
174
|
+
websocket (1.0.7)
|
175
|
+
xpath (2.0.0)
|
188
176
|
nokogiri (~> 1.3)
|
189
177
|
|
190
178
|
PLATFORMS
|
191
179
|
ruby
|
192
180
|
|
193
181
|
DEPENDENCIES
|
194
|
-
apotomo (~> 1.2.
|
195
|
-
bundler (~> 1.0.0)
|
182
|
+
apotomo (~> 1.2.3)
|
196
183
|
capybara (>= 1.0.0.rc1)
|
197
184
|
cucumber
|
198
185
|
cucumber-rails (= 0.5.2)
|
199
186
|
database_cleaner
|
200
|
-
factory_girl (~> 2.
|
187
|
+
factory_girl (~> 4.2.0)
|
201
188
|
guard-cucumber (= 0.3.4)
|
202
|
-
guard-rspec
|
203
189
|
haml
|
204
|
-
|
205
|
-
jquery-rails (~> 2.0.0)
|
190
|
+
jquery-rails (~> 2.2.1)
|
206
191
|
launchy
|
207
|
-
libnotify
|
208
192
|
navi!
|
209
193
|
nifty-generators
|
194
|
+
pry
|
210
195
|
rails (~> 3.2.0)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
ruby-debug19
|
215
|
-
simple-navigation (= 3.2.0)
|
196
|
+
rspec-rails (~> 2.13.2)
|
197
|
+
selenium-webdriver
|
198
|
+
simple-navigation
|
216
199
|
sqlite3
|
data/README.md
CHANGED
@@ -58,6 +58,14 @@ You must supply an array of top-most items to render. What do I mean? "top-most"
|
|
58
58
|
|
59
59
|
You can create your own renderer too. For this, see the wiki. I could add these into the gem. Send me a pull request.
|
60
60
|
|
61
|
+
## Namespace
|
62
|
+
|
63
|
+
You can render all your links in a namespace:
|
64
|
+
|
65
|
+
<%= navi_render NavItem.roots, namespace: 'preview' %>
|
66
|
+
|
67
|
+
This is useful if you want to generate the same links but have them all point to a different route. For example, you have a CMS and there's a preview section where you want the links that are generated to be the same, yet point to all other preview pages in the CMS.
|
68
|
+
|
61
69
|
# Contributing to navigable
|
62
70
|
|
63
71
|
_To develop and run tests, see the Gemfile and read the comments right above the :development, :test, :cucumber group._
|
data/features/support/env.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= "test"
|
2
|
-
|
3
|
-
require File.
|
2
|
+
SPEC_DIR = File.join(File.dirname(__FILE__), '..', '..', 'spec')
|
3
|
+
require File.join(SPEC_DIR, 'dummy', 'config', 'environment')
|
4
|
+
|
5
|
+
require 'factory_girl'
|
6
|
+
require File.join(SPEC_DIR, 'factories')
|
7
|
+
Dir.glob(File.join(SPEC_DIR, 'factories', '**', '*.rb')).each {|f| require f}
|
4
8
|
|
5
9
|
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
6
10
|
require 'cucumber/rails/rspec'
|
@@ -56,6 +60,7 @@ if defined?(ActiveRecord::Base)
|
|
56
60
|
begin
|
57
61
|
require 'database_cleaner'
|
58
62
|
DatabaseCleaner.strategy = :truncation
|
63
|
+
DatabaseCleaner.clean
|
59
64
|
rescue LoadError => ignore_if_database_cleaner_not_present
|
60
65
|
end
|
61
66
|
end
|
data/lib/navi.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'easy_class_to_instance_method'
|
1
2
|
require 'active_support'
|
2
3
|
require "active_support/core_ext/module" # so we can use mattr_accessor
|
3
4
|
require 'active_record'
|
@@ -18,5 +19,5 @@ module Navi
|
|
18
19
|
@@navigator ||= :nav_item
|
19
20
|
|
20
21
|
mattr_accessor :renderer
|
21
|
-
@@renderer ||= Navi::Renderers::SimpleNavigation
|
22
|
+
@@renderer ||= Navi::Renderers::SimpleNavigation::Renderer
|
22
23
|
end
|
data/lib/navi/renderers/base.rb
CHANGED
@@ -5,8 +5,6 @@ module Navi
|
|
5
5
|
|
6
6
|
def initialize(context)
|
7
7
|
@context = context
|
8
|
-
@controller = controller_from @context
|
9
|
-
@template = template_from @controller
|
10
8
|
end
|
11
9
|
|
12
10
|
def render(collection)
|
@@ -15,16 +13,20 @@ module Navi
|
|
15
13
|
|
16
14
|
private
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def controller
|
17
|
+
@controller ||= if @context.respond_to?(:controller)
|
18
|
+
@context.controller
|
19
|
+
else
|
20
|
+
@context
|
21
|
+
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def template
|
25
|
+
@template ||= if controller.respond_to?(:view_context)
|
26
|
+
controller.view_context
|
27
|
+
else
|
28
|
+
controller.instance_variable_get(:@template)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|