breadcrumbs_on_rails 2.3.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +19 -12
- data/Appraisals +8 -11
- data/CHANGELOG.md +35 -28
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +202 -56
- data/Rakefile +6 -64
- data/breadcrumbs_on_rails.gemspec +23 -34
- data/gemfiles/4.0.gemfile +3 -3
- data/gemfiles/4.1.gemfile +7 -0
- data/gemfiles/4.2.gemfile +7 -0
- data/gemfiles/5.0.gemfile +7 -0
- data/lib/breadcrumbs_on_rails.rb +1 -1
- data/lib/breadcrumbs_on_rails/action_controller.rb +7 -3
- data/lib/breadcrumbs_on_rails/breadcrumbs.rb +2 -2
- data/lib/breadcrumbs_on_rails/railtie.rb +3 -5
- data/lib/breadcrumbs_on_rails/version.rb +2 -13
- data/test/test_helper.rb +3 -0
- data/test/unit/action_controller_test.rb +7 -6
- data/test/unit/simple_builder_test.rb +23 -0
- metadata +48 -18
- data/gemfiles/3.0.gemfile +0 -7
- data/gemfiles/3.1.gemfile +0 -7
- data/gemfiles/3.2.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee122bb4062b89a562c760486bfa006531ad8d0d
|
4
|
+
data.tar.gz: 45ade515b86324c2bfe3062cc834876f7a7f5a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70e1efd32dbc1a1f3b505763f2c577a311509faa46697661f95a1da0d1ca9234d17d06edd8d5837cf6c7e2ac63677c60134953f74b1db1f413f55b2dcac6d733
|
7
|
+
data.tar.gz: 2d14d97add461e23ef06dc50c18c0a2d88bd7f78472943a75dda59e2d5a114295dcc270cb27bd919a54658f4c382184fcfe3efa39c9f6305a7a1b4deb6d600f3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
rvm:
|
2
|
-
-
|
3
|
-
- 1
|
4
|
-
- 2.
|
5
|
-
- 2.1
|
6
|
-
|
2
|
+
- 2.0
|
3
|
+
- 2.1
|
4
|
+
- 2.2.5
|
5
|
+
- 2.3.1
|
6
|
+
|
7
7
|
gemfile:
|
8
|
-
- gemfiles/3.0.gemfile
|
9
|
-
- gemfiles/3.1.gemfile
|
10
|
-
- gemfiles/3.2.gemfile
|
11
8
|
- gemfiles/4.0.gemfile
|
9
|
+
- gemfiles/4.1.gemfile
|
10
|
+
- gemfiles/4.2.gemfile
|
11
|
+
- gemfiles/5.0.gemfile
|
12
|
+
|
13
|
+
before_install:
|
14
|
+
- gem install bundler
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
exclude:
|
18
|
+
- rvm: 2.0
|
19
|
+
gemfile: gemfiles/5.0.gemfile
|
20
|
+
- rvm: 2.1
|
21
|
+
gemfile: gemfiles/5.0.gemfile
|
22
|
+
|
12
23
|
notifications:
|
13
24
|
recipients:
|
14
25
|
- weppos@weppos.net
|
15
|
-
matrix:
|
16
|
-
exclude:
|
17
|
-
- rvm: 1.9.2
|
18
|
-
gemfile: gemfiles/4.0.gemfile
|
data/Appraisals
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
appraise "
|
2
|
-
gem "
|
1
|
+
appraise "4.0" do
|
2
|
+
gem "rails", "~> 4.0.0"
|
3
3
|
end
|
4
|
-
|
5
|
-
|
6
|
-
gem "activerecord", "~> 3.1.0"
|
4
|
+
appraise "4.1" do
|
5
|
+
gem "rails", "~> 4.1.0"
|
7
6
|
end
|
8
|
-
|
9
|
-
|
10
|
-
gem "activerecord", "~> 3.2.0"
|
7
|
+
appraise "4.2" do
|
8
|
+
gem "rails", "~> 4.2.0"
|
11
9
|
end
|
12
|
-
|
13
|
-
|
14
|
-
gem "activerecord", "~> 4.0.0"
|
10
|
+
appraise "5.0" do
|
11
|
+
gem "rails", "~> 5.0.0"
|
15
12
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,66 +1,73 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Release 2.3.1
|
4
3
|
|
5
|
-
|
4
|
+
#### Release 3.0.0
|
5
|
+
|
6
|
+
- FIXED: Fixed compatibility with Rails 5.0 (GH-80). [Thanks @ochko]
|
7
|
+
- FIXED: Fixed initialization error (GH-75). [Thanks @soulcutter]
|
8
|
+
- FIXED: Escape user input by default to avoid XSS attacks (GH-63). [Thanks @rdunlop]
|
6
9
|
|
10
|
+
- CHANGED: Minimum requirements Rails >= 4 and Ruby >= 2.
|
7
11
|
|
8
|
-
## Release 2.3.0
|
9
12
|
|
10
|
-
|
13
|
+
#### Release 2.3.1
|
14
|
+
|
15
|
+
- FIXED: Using `add_breadcrumbs` did not properly pass `options` (GH-46). [Thanks @link664]
|
11
16
|
|
12
|
-
* FIXED: Breadcrumbs now accepts a polymorphic path (GH-15).
|
13
17
|
|
14
|
-
|
18
|
+
#### Release 2.3.0
|
15
19
|
|
16
|
-
|
20
|
+
- FIXED: In some circumstances the BreadcrumbsOnRails::ActionController::HelperMethods is not mixed into the controller.
|
21
|
+
- FIXED: Breadcrumbs now accepts a polymorphic path (GH-15).
|
17
22
|
|
23
|
+
- CHANGED: Second argument on `add_breadcrumb` is now optional (GH-6, GH-32). [Thanks @mpartel]
|
24
|
+
- CHANGED: Breadcrumb path computation fallbacks to url_for in case of unknown arguments.
|
18
25
|
|
19
|
-
## Release 2.2.0
|
20
26
|
|
21
|
-
|
27
|
+
#### Release 2.2.0
|
22
28
|
|
23
|
-
|
29
|
+
- NEW: Support for Rails 3.2.
|
24
30
|
|
31
|
+
- FIXED: Fixed Rails 3.2 ActiveSupport::Concern deprecation warning (GH-17, GH-20).
|
25
32
|
|
26
|
-
## Release 2.1.0
|
27
33
|
|
28
|
-
|
34
|
+
#### Release 2.1.0
|
29
35
|
|
36
|
+
- NEW: Element now accepts a Hash of options. The options can be useful to customize the appearance of the element, for example to set a link title or class.
|
30
37
|
|
31
|
-
## Release 2.0.0
|
32
38
|
|
33
|
-
|
39
|
+
#### Release 2.0.0
|
34
40
|
|
35
|
-
|
41
|
+
- FIXED: Invalid documentation for Element target in the controller class context (closes #2)
|
36
42
|
|
43
|
+
- CHANGED: Upgraded to Rails 3
|
37
44
|
|
38
|
-
## Release 1.0.1
|
39
45
|
|
40
|
-
|
46
|
+
#### Release 1.0.1
|
41
47
|
|
48
|
+
- FIXED: Since the removal of rails/init.rb in 7278376ab77651e540e39552384ad9677e32ff7e, Rails fails to load the helpers.
|
42
49
|
|
43
|
-
## Release 1.0.0
|
44
50
|
|
45
|
-
|
51
|
+
#### Release 1.0.0
|
46
52
|
|
47
|
-
|
53
|
+
- CHANGED: Removed empty install/uninstall hooks and tasks folder.
|
54
|
+
- CHANGED: Removed rails/init hook because deprecated in Rails 3.
|
48
55
|
|
49
56
|
|
50
|
-
|
57
|
+
#### Release 0.2.0
|
51
58
|
|
52
|
-
|
59
|
+
- Releasing the library as open source project.
|
53
60
|
|
54
|
-
## Release 0.1.1
|
55
61
|
|
62
|
+
#### Release 0.1.1
|
56
63
|
|
57
|
-
* ADDED: documentation file.
|
58
64
|
|
59
|
-
|
65
|
+
- NEW: documentation file.
|
60
66
|
|
61
|
-
|
67
|
+
- CHANGED: run test against Rails ~> 2.3.0 but ensure compatibility with Rails 2.2.x.
|
68
|
+
- CHANGED: Removed BUILD and STATUS constants. Added Version::ALPHA constant to be used when I need to package prereleases (see RubyGem --prerelease flag).
|
62
69
|
|
63
70
|
|
64
|
-
|
71
|
+
#### Release 0.1.0
|
65
72
|
|
66
|
-
|
73
|
+
- Initial version
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,119 +1,265 @@
|
|
1
1
|
# Breadcrumbs On Rails
|
2
|
-
[![Code Climate](https://codeclimate.com/github/weppos/breadcrumbs_on_rails.png)](https://codeclimate.com/github/weppos/breadcrumbs_on_rails)
|
3
2
|
|
4
3
|
<tt>BreadcrumbsOnRails</tt> is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project. It provides helpers for creating navigation elements with a flexible interface.
|
5
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/weppos/breadcrumbs_on_rails.svg?branch=master)](https://travis-ci.org/weppos/breadcrumbs_on_rails)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/weppos/breadcrumbs_on_rails.png)](https://codeclimate.com/github/weppos/breadcrumbs_on_rails)
|
7
|
+
|
6
8
|
|
7
9
|
## Requirements
|
8
10
|
|
9
|
-
- Rails
|
10
|
-
|
11
|
-
Please note
|
11
|
+
- Rails 4 or Rails 5
|
12
12
|
|
13
|
-
|
14
|
-
- <tt>BreadcrumbsOnRails</tt> doesn't work with Rails 2.1 or lower.
|
13
|
+
For older versions of Ruby or Ruby on Rails, see the [CHANGELOG](CHANGELOG.md).
|
15
14
|
|
16
15
|
|
17
16
|
## Installation
|
18
17
|
|
19
|
-
|
18
|
+
Add this line to your application's `Gemfile`:
|
20
19
|
|
21
|
-
|
20
|
+
gem "breadcrumbs_on_rails"
|
22
21
|
|
23
|
-
|
22
|
+
And then execute `bundle` to install the dependencies:
|
24
23
|
|
25
|
-
|
24
|
+
$ bundle
|
26
25
|
|
27
26
|
Use [Bundler](http://bundler.io/) and the `:git` option if you want to grab the latest version from the Git repository.
|
28
27
|
|
29
28
|
|
30
|
-
##
|
29
|
+
## Usage
|
31
30
|
|
32
31
|
Creating a breadcrumb navigation menu in your Rails app using <tt>BreadcrumbsOnRails</tt> is really straightforward.
|
33
32
|
|
34
33
|
In your controller, call `add_breadcrumb` to push a new element on the breadcrumb stack. `add_breadcrumb` requires two arguments: the name of the breadcrumb and the target path.
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
add_breadcrumb "home", :root_path
|
39
|
-
add_breadcrumb "my", :my_path
|
40
|
-
|
41
|
-
def index
|
42
|
-
# ...
|
43
|
-
|
44
|
-
add_breadcrumb "index", index_path
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
35
|
+
```ruby
|
36
|
+
class MyController
|
48
37
|
|
49
|
-
|
38
|
+
add_breadcrumb "home", :root_path
|
39
|
+
add_breadcrumb "my", :my_path
|
50
40
|
|
51
|
-
|
52
|
-
|
41
|
+
def index
|
42
|
+
# ...
|
53
43
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
44
|
+
add_breadcrumb "index", index_path
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
See the section "Breadcrumb Element" for more details about name and target class types.
|
51
|
+
|
52
|
+
The third, optional argument is a Hash of options to customize the breadcrumb link.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
class MyController
|
56
|
+
def index
|
57
|
+
add_breadcrumb "index", index_path, :title => "Back to the Index"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
58
61
|
|
59
62
|
In your view, you can render the breadcrumb menu with the `render_breadcrumbs` helper.
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
```html
|
65
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
66
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
67
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
68
|
+
<head>
|
69
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
70
|
+
<title>untitled</title>
|
71
|
+
</head>
|
72
|
+
|
73
|
+
<body>
|
74
|
+
<%= render_breadcrumbs %>
|
75
|
+
</body>
|
76
|
+
</html>
|
77
|
+
```
|
71
78
|
|
72
79
|
`render_breadcrumbs` understands a limited set of options. For example, you can pass change the default separator with the `:separator` option.
|
73
80
|
|
74
|
-
|
75
|
-
|
76
|
-
|
81
|
+
```html
|
82
|
+
<body>
|
83
|
+
<%= render_breadcrumbs :separator => ' / ' %>
|
84
|
+
</body>
|
85
|
+
```
|
77
86
|
|
78
87
|
Current possible options are:
|
88
|
+
|
79
89
|
- `:separator`
|
80
90
|
- `:tag`
|
81
91
|
|
82
92
|
To use with Bootstrap you might use the following:
|
83
93
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
94
|
+
```html
|
95
|
+
<body>
|
96
|
+
<ol class="breadcrumb">
|
97
|
+
<%= render_breadcrumbs :tag => :li, :separator => "" %>
|
98
|
+
</ol>
|
99
|
+
</body>
|
100
|
+
```
|
101
|
+
|
102
|
+
More complex customizations require a custom `Builder`.
|
103
|
+
|
104
|
+
### HTML Escaping
|
105
|
+
|
106
|
+
The text of the breadcrumb is html-escaped by default unless it is a SafeBuffer, to prevent XSS attacks.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
class MyController
|
110
|
+
add_breadcrumb "This is the <b>Main</b> page".html_safe
|
111
|
+
|
112
|
+
def profile
|
113
|
+
add_breadcrumb "#{@user_name} Profile", users_profile
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
118
|
+
In this case, if `@user_name` is "<script>", it will output:
|
119
|
+
|
120
|
+
This is the <b>Main</b> page > <script> Profile
|
121
|
+
|
122
|
+
|
123
|
+
### Breadcrumb Element
|
124
|
+
|
125
|
+
A breadcrumbs menu is composed by a number of `Element` objects. Each object contains two attributes: the name of the breadcrumb and the target path.
|
126
|
+
|
127
|
+
When you call `add_breadcrumb`, the method automatically creates a new `Element` object for you and append it to the breadcrumbs stack. `Element` name and path can be one of the following Ruby types:
|
128
|
+
|
129
|
+
- `Symbol`
|
130
|
+
- `Proc`
|
131
|
+
- `String`
|
132
|
+
|
133
|
+
#### Symbol
|
134
|
+
|
135
|
+
If the value is a `Symbol`, the library calls the corresponding method defined in the same context the and sets the `Element` attribute to the returned value.
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
class MyController
|
139
|
+
|
140
|
+
# The Name is set to the value returned by
|
141
|
+
# the :root_name method.
|
142
|
+
add_breadcrumb :root_name, "/"
|
143
|
+
|
144
|
+
protected
|
145
|
+
|
146
|
+
def root_name
|
147
|
+
"the name"
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
153
|
+
#### Proc
|
154
|
+
|
155
|
+
If the value is a `Proc`, the library calls the proc passing the current view context as argument and sets the `Element` attribute to the returned value. This is useful if you want to postpone the execution to get access to some special methods/variables created in your controller action.
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
class MyController
|
159
|
+
|
160
|
+
# The Name is set to the value returned by
|
161
|
+
# the :root_name method.
|
162
|
+
add_breadcrumb Proc.new { |c| c.my_helper_method },
|
163
|
+
"/"
|
164
|
+
|
165
|
+
end
|
166
|
+
```
|
167
|
+
|
168
|
+
#### String
|
169
|
+
|
170
|
+
If the value is a `String`, the library sets the `Element` attribute to the string value.
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
class MyController
|
174
|
+
|
175
|
+
# The Name is set to the value returned by
|
176
|
+
# the :root_name method.
|
177
|
+
add_breadcrumb "homepage", "/"
|
178
|
+
|
179
|
+
end
|
180
|
+
```
|
181
|
+
|
182
|
+
### Restricting breadcrumb scope
|
183
|
+
|
184
|
+
The `add_breadcrumb` method understands all options you are used to pass to a Rails controller filter. In fact, behind the scenes this method uses a `before_filter` to store the tab in the `@breadcrumbs` variable.
|
185
|
+
|
186
|
+
Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
class PostsController < ApplicationController
|
190
|
+
add_breadcrumb "admin", :admin_path
|
191
|
+
add_breadcrumb "posts", :posts_path, :only => %w(index show)
|
192
|
+
end
|
193
|
+
|
194
|
+
class ApplicationController < ActionController::Base
|
195
|
+
add_breadcrumb "admin", :admin_path, :if => :admin_controller?
|
196
|
+
|
197
|
+
def admin_controller?
|
198
|
+
self.class.name =~ /^Admin(::|Controller)/
|
199
|
+
end
|
200
|
+
end
|
201
|
+
```
|
202
|
+
|
203
|
+
### Internationalization and Localization
|
204
|
+
|
205
|
+
<tt>BreadcrumbsOnRails</tt> is compatible with the standard Rails internationalization framework.
|
206
|
+
|
207
|
+
For example, if you want to localize your menu, define a new breadcrumbs node in your `.yml` file with all the keys for your elements.
|
208
|
+
|
209
|
+
```yaml
|
210
|
+
# config/locales/en.yml
|
211
|
+
en:
|
212
|
+
breadcrumbs:
|
213
|
+
homepage: Homepage
|
214
|
+
first: First
|
215
|
+
second: Second
|
216
|
+
third: Third
|
217
|
+
|
218
|
+
# config/locales/it.yml
|
219
|
+
it:
|
220
|
+
breadcrumbs:
|
221
|
+
homepage: Homepage
|
222
|
+
first: Primo
|
223
|
+
second: Secondo
|
224
|
+
third: Terzo
|
225
|
+
```
|
226
|
+
|
227
|
+
In your controller, use the `I18n.t` method.
|
89
228
|
|
90
|
-
|
229
|
+
```ruby
|
230
|
+
class PostsController < ApplicationController
|
231
|
+
add_breadcrumb I18n.t("breadcrumbs.first"), :first_path
|
232
|
+
add_breadcrumb I18n.t("breadcrumbs.second"), :second_path, :only => %w(second)
|
233
|
+
add_breadcrumb I18n.t("breadcrumbs.third"), :third_path, :only => %w(third)
|
234
|
+
end
|
91
235
|
|
92
|
-
|
236
|
+
class ApplicationController < ActionController::Base
|
237
|
+
add_breadcrumb I18n.t("breadcrumbs.homepage"), :root_path
|
238
|
+
end
|
239
|
+
```
|
93
240
|
|
94
241
|
|
95
242
|
## Credits
|
96
243
|
|
97
|
-
<tt>BreadcrumbsOnRails</tt> was created and is maintained by [Simone Carletti](http://simonecarletti.com/). Many improvements and bugfixes were contributed by the [open source community](https://github.com/weppos/
|
244
|
+
<tt>BreadcrumbsOnRails</tt> was created and is maintained by [Simone Carletti](http://simonecarletti.com/). Many improvements and bugfixes were contributed by the [open source community](https://github.com/weppos/breadcrumbs_on_rails/graphs/contributors).
|
98
245
|
|
99
246
|
|
100
247
|
## Contributing
|
101
248
|
|
102
249
|
Direct questions and discussions to [Stack Overflow](http://stackoverflow.com/questions/tagged/breadcrumbs-on-rails).
|
103
250
|
|
104
|
-
[Pull requests](https://github.com/weppos/
|
251
|
+
[Pull requests](https://github.com/weppos/breadcrumbs_on_rails) are very welcome! Please include tests for every patch, and create a topic branch for every separate change you make.
|
105
252
|
|
106
253
|
Report issues or feature requests to [GitHub Issues](https://github.com/weppos/breadcrumbs_on_rails/issues).
|
107
254
|
|
108
255
|
|
109
256
|
## More Information
|
110
257
|
|
111
|
-
- [Homepage](http://simonecarletti.com/code/
|
112
|
-
- [RubyGems](
|
113
|
-
- [Documentation](http://simonecarletti.com/code/breadcrumbs_on_rails/docs/)
|
258
|
+
- [Homepage](http://simonecarletti.com/code/breadcrumbs-on-rails)
|
259
|
+
- [RubyGems](https://rubygems.org/gems/breadcrumbs_on_rails)
|
114
260
|
- [Issues](https://github.com/weppos/breadcrumbs_on_rails/issues)
|
115
261
|
|
116
262
|
|
117
263
|
## License
|
118
264
|
|
119
|
-
|
265
|
+
Copyright (c) 2009-2015 Simone Carletti. This is Free Software distributed under the MIT license.
|
data/Rakefile
CHANGED
@@ -1,62 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require 'bundler'
|
1
|
+
require 'bundler/gem_tasks'
|
3
2
|
require 'appraisal'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
PKG_NAME = ENV['PKG_NAME'] || "breadcrumbs_on_rails"
|
10
|
-
PKG_VERSION = ENV['PKG_VERSION'] || BreadcrumbsOnRails::VERSION
|
11
|
-
|
12
|
-
|
13
|
-
# Run test by default.
|
14
|
-
task :default => :test
|
15
|
-
|
16
|
-
spec = Gem::Specification.new do |s|
|
17
|
-
s.name = PKG_NAME
|
18
|
-
s.version = PKG_VERSION
|
19
|
-
s.summary = "A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation."
|
20
|
-
s.description = "BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project."
|
21
|
-
|
22
|
-
s.author = "Simone Carletti"
|
23
|
-
s.email = "weppos@weppos.net"
|
24
|
-
s.homepage = "http://www.simonecarletti.com/code/breadcrumbs_on_rails"
|
25
|
-
|
26
|
-
s.files = `git ls-files`.split("\n")
|
27
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
|
-
s.require_paths = %w( lib )
|
29
|
-
|
30
|
-
s.add_development_dependency "rails", ">= 3.0"
|
31
|
-
s.add_development_dependency "appraisal"
|
32
|
-
s.add_development_dependency "mocha", "~> 1.0.0"
|
33
|
-
s.add_development_dependency "yard"
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
require 'rubygems/package_task'
|
38
|
-
|
39
|
-
Gem::PackageTask.new(spec) do |pkg|
|
40
|
-
pkg.gem_spec = spec
|
41
|
-
end
|
42
|
-
|
43
|
-
desc "Build the gemspec file #{spec.name}.gemspec"
|
44
|
-
task :gemspec do
|
45
|
-
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
46
|
-
File.open(file, "w") {|f| f << spec.to_ruby }
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "Remove any temporary products, including gemspec."
|
50
|
-
task :clean => [:clobber] do
|
51
|
-
rm "#{spec.name}.gemspec"
|
4
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
5
|
+
task :default => :appraisal
|
6
|
+
else
|
7
|
+
task :default => :test
|
52
8
|
end
|
53
9
|
|
54
|
-
desc "Remove any generated file"
|
55
|
-
task :clobber => [:clobber_package]
|
56
|
-
|
57
|
-
desc "Package the library and generates the gemspec"
|
58
|
-
task :package => [:gemspec]
|
59
|
-
|
60
10
|
|
61
11
|
require 'rake/testtask'
|
62
12
|
|
@@ -68,18 +18,10 @@ Rake::TestTask.new do |t|
|
|
68
18
|
end
|
69
19
|
|
70
20
|
|
71
|
-
require 'yard'
|
72
21
|
require 'yard/rake/yardoc_task'
|
73
22
|
|
74
23
|
YARD::Rake::YardocTask.new(:yardoc) do |y|
|
75
24
|
y.options = ["--output-dir", "yardoc"]
|
76
25
|
end
|
77
26
|
|
78
|
-
|
79
|
-
desc "Remove YARD products"
|
80
|
-
task :clobber do
|
81
|
-
rm_r "yardoc" rescue nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
task :clobber => "yardoc:clobber"
|
27
|
+
CLOBBER.include "yardoc"
|
@@ -1,39 +1,28 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'breadcrumbs_on_rails/version'
|
2
5
|
|
3
|
-
Gem::Specification.new do |
|
4
|
-
|
5
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "breadcrumbs_on_rails"
|
8
|
+
spec.version = BreadcrumbsOnRails::VERSION
|
9
|
+
spec.authors = ["Simone Carletti"]
|
10
|
+
spec.email = ["weppos@weppos.net"]
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
s.email = "weppos@weppos.net"
|
12
|
-
s.files = [".gitignore", ".ruby-gemset", ".ruby-version", ".travis.yml", "Appraisals", "CHANGELOG.md", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "breadcrumbs_on_rails.gemspec", "gemfiles/3.0.gemfile", "gemfiles/3.1.gemfile", "gemfiles/3.2.gemfile", "gemfiles/4.0.gemfile", "init.rb", "lib/breadcrumbs_on_rails.rb", "lib/breadcrumbs_on_rails/action_controller.rb", "lib/breadcrumbs_on_rails/breadcrumbs.rb", "lib/breadcrumbs_on_rails/railtie.rb", "lib/breadcrumbs_on_rails/version.rb", "test/dummy.rb", "test/test_helper.rb", "test/unit/action_controller_test.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb", "test/views/example/default.html.erb"]
|
13
|
-
s.homepage = "http://www.simonecarletti.com/code/breadcrumbs_on_rails"
|
14
|
-
s.require_paths = ["lib"]
|
15
|
-
s.rubygems_version = "2.0.14"
|
16
|
-
s.summary = "A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation."
|
17
|
-
s.test_files = ["test/dummy.rb", "test/test_helper.rb", "test/unit/action_controller_test.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb", "test/views/example/default.html.erb"]
|
12
|
+
spec.summary = %q{A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation}
|
13
|
+
spec.description = %q{BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.}
|
14
|
+
spec.homepage = "https://simonecarletti.com/code/breadcrumbs_on_rails"
|
15
|
+
spec.license = "MIT"
|
18
16
|
|
19
|
-
|
20
|
-
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
spec.require_paths = ["lib"]
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
s.add_dependency(%q<appraisal>, [">= 0"])
|
30
|
-
s.add_dependency(%q<mocha>, ["~> 1.0.0"])
|
31
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
32
|
-
end
|
33
|
-
else
|
34
|
-
s.add_dependency(%q<rails>, [">= 3.0"])
|
35
|
-
s.add_dependency(%q<appraisal>, [">= 0"])
|
36
|
-
s.add_dependency(%q<mocha>, ["~> 1.0.0"])
|
37
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
38
|
-
end
|
21
|
+
spec.required_ruby_version = ">= 2.0"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "appraisal"
|
25
|
+
spec.add_development_dependency "rails", ">= 4.0"
|
26
|
+
spec.add_development_dependency "mocha", ">= 1.0"
|
27
|
+
spec.add_development_dependency "yard"
|
39
28
|
end
|
data/gemfiles/4.0.gemfile
CHANGED
data/lib/breadcrumbs_on_rails.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2016 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
require 'breadcrumbs_on_rails/breadcrumbs'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2016 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
module BreadcrumbsOnRails
|
@@ -11,10 +11,14 @@ module BreadcrumbsOnRails
|
|
11
11
|
module ActionController
|
12
12
|
extend ActiveSupport::Concern
|
13
13
|
|
14
|
-
included do
|
14
|
+
included do |base|
|
15
15
|
extend ClassMethods
|
16
16
|
helper HelperMethods
|
17
17
|
helper_method :add_breadcrumb, :breadcrumbs
|
18
|
+
|
19
|
+
unless base.respond_to?(:before_action)
|
20
|
+
base.alias_method :before_action, :before_filter
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
protected
|
@@ -69,7 +73,7 @@ module BreadcrumbsOnRails
|
|
69
73
|
|
70
74
|
element_options = filter_options.delete(:options) || {}
|
71
75
|
|
72
|
-
|
76
|
+
before_action(filter_options) do |controller|
|
73
77
|
controller.send(:add_breadcrumb, name, path, element_options)
|
74
78
|
end
|
75
79
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2016 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
module BreadcrumbsOnRails
|
@@ -93,7 +93,7 @@ module BreadcrumbsOnRails
|
|
93
93
|
if @options[:tag]
|
94
94
|
@context.content_tag(@options[:tag], content)
|
95
95
|
else
|
96
|
-
content
|
96
|
+
ERB::Util.h(content)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -3,16 +3,14 @@
|
|
3
3
|
#
|
4
4
|
# A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2016 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
module BreadcrumbsOnRails
|
10
10
|
|
11
11
|
class Railtie < Rails::Railtie
|
12
|
-
|
13
|
-
|
14
|
-
include BreadcrumbsOnRails::ActionController
|
15
|
-
end
|
12
|
+
ActiveSupport.on_load(:action_controller) do
|
13
|
+
include BreadcrumbsOnRails::ActionController
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
@@ -3,20 +3,9 @@
|
|
3
3
|
#
|
4
4
|
# A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
5
5
|
#
|
6
|
-
# Copyright (c) 2009-
|
6
|
+
# Copyright (c) 2009-2016 Simone Carletti <weppos@weppos.net>
|
7
7
|
#++
|
8
8
|
|
9
9
|
module BreadcrumbsOnRails
|
10
|
-
|
11
|
-
module Version
|
12
|
-
MAJOR = 2
|
13
|
-
MINOR = 3
|
14
|
-
PATCH = 1
|
15
|
-
BUILD = nil
|
16
|
-
|
17
|
-
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
18
|
-
end
|
19
|
-
|
20
|
-
VERSION = Version::STRING
|
21
|
-
|
10
|
+
VERSION = "3.0.0"
|
22
11
|
end
|
data/test/test_helper.rb
CHANGED
@@ -48,7 +48,7 @@ class ExampleControllerTest < ActionController::TestCase
|
|
48
48
|
def test_render_compute_paths
|
49
49
|
get :action_compute_paths
|
50
50
|
assert_dom_equal %(<a href="/">String</a> » <a href="/?proc">Proc</a> » <a href="/?polymorphic">Polymorphic</a>),
|
51
|
-
@response.body
|
51
|
+
@response.body.to_s
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -78,14 +78,15 @@ class ClassLevelExampleControllerTest < ActionController::TestCase
|
|
78
78
|
|
79
79
|
def test_render_default
|
80
80
|
expected = [].tap { |links|
|
81
|
-
links <<
|
82
|
-
links <<
|
83
|
-
links <<
|
84
|
-
links <<
|
81
|
+
links << '<a href="/">String</a>'
|
82
|
+
links << '<a href="/?proc">Proc</a>'
|
83
|
+
links << '<a href="/?polymorphic">Polymorphic</a>'
|
84
|
+
links << '<a title="Awesome" href="/">With options</a>'
|
85
85
|
}
|
86
86
|
|
87
87
|
get :action_default
|
88
|
-
assert_dom_equal
|
88
|
+
assert_dom_equal expected.join(" » "),
|
89
|
+
@response.body.to_s
|
89
90
|
end
|
90
91
|
|
91
92
|
end
|
@@ -60,6 +60,29 @@ class SimpleBuilderTest < ActionView::TestCase
|
|
60
60
|
simplebuilder(@template, elements).render)
|
61
61
|
end
|
62
62
|
|
63
|
+
def test_render_with_embedded_html
|
64
|
+
elements = [BreadcrumbsOnRails::Breadcrumbs::Element.new("Element <b>One</b>", nil)]
|
65
|
+
assert_dom_equal("Element <b>One</b>",
|
66
|
+
simplebuilder(@template, elements).render)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_render_with_embedded_html_and_tags
|
70
|
+
elements = [BreadcrumbsOnRails::Breadcrumbs::Element.new("Element <b>One</b>", nil)]
|
71
|
+
assert_dom_equal("<li>Element <b>One</b></li>",
|
72
|
+
simplebuilder(@template, elements, {tag: :li} ).render)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_render_with_safe_embedded_html
|
76
|
+
elements = [BreadcrumbsOnRails::Breadcrumbs::Element.new("Element <b>One</b>".html_safe, nil)]
|
77
|
+
assert_dom_equal("Element <b>One</b>",
|
78
|
+
simplebuilder(@template, elements).render)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_render_with_embedded_html_and_tags
|
82
|
+
elements = [BreadcrumbsOnRails::Breadcrumbs::Element.new("Element <b>One</b>".html_safe, nil)]
|
83
|
+
assert_dom_equal("<li>Element <b>One</b></li>",
|
84
|
+
simplebuilder(@template, elements, {tag: :li} ).render)
|
85
|
+
end
|
63
86
|
|
64
87
|
protected
|
65
88
|
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadcrumbs_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: appraisal
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +52,34 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: mocha
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
|
-
- - "
|
73
|
+
- - ">="
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0
|
75
|
+
version: '1.0'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- - "
|
80
|
+
- - ">="
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0
|
82
|
+
version: '1.0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: yard
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,7 +96,8 @@ dependencies:
|
|
68
96
|
version: '0'
|
69
97
|
description: BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and
|
70
98
|
managing a breadcrumb navigation for a Rails project.
|
71
|
-
email:
|
99
|
+
email:
|
100
|
+
- weppos@weppos.net
|
72
101
|
executables: []
|
73
102
|
extensions: []
|
74
103
|
extra_rdoc_files: []
|
@@ -84,10 +113,10 @@ files:
|
|
84
113
|
- README.md
|
85
114
|
- Rakefile
|
86
115
|
- breadcrumbs_on_rails.gemspec
|
87
|
-
- gemfiles/3.0.gemfile
|
88
|
-
- gemfiles/3.1.gemfile
|
89
|
-
- gemfiles/3.2.gemfile
|
90
116
|
- gemfiles/4.0.gemfile
|
117
|
+
- gemfiles/4.1.gemfile
|
118
|
+
- gemfiles/4.2.gemfile
|
119
|
+
- gemfiles/5.0.gemfile
|
91
120
|
- init.rb
|
92
121
|
- lib/breadcrumbs_on_rails.rb
|
93
122
|
- lib/breadcrumbs_on_rails/action_controller.rb
|
@@ -101,8 +130,9 @@ files:
|
|
101
130
|
- test/unit/element_test.rb
|
102
131
|
- test/unit/simple_builder_test.rb
|
103
132
|
- test/views/example/default.html.erb
|
104
|
-
homepage:
|
105
|
-
licenses:
|
133
|
+
homepage: https://simonecarletti.com/code/breadcrumbs_on_rails
|
134
|
+
licenses:
|
135
|
+
- MIT
|
106
136
|
metadata: {}
|
107
137
|
post_install_message:
|
108
138
|
rdoc_options: []
|
@@ -112,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
142
|
requirements:
|
113
143
|
- - ">="
|
114
144
|
- !ruby/object:Gem::Version
|
115
|
-
version: '0'
|
145
|
+
version: '2.0'
|
116
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
147
|
requirements:
|
118
148
|
- - ">="
|
@@ -120,10 +150,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
150
|
version: '0'
|
121
151
|
requirements: []
|
122
152
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.5.1
|
124
154
|
signing_key:
|
125
155
|
specification_version: 4
|
126
|
-
summary: A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation
|
156
|
+
summary: A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation
|
127
157
|
test_files:
|
128
158
|
- test/dummy.rb
|
129
159
|
- test/test_helper.rb
|
data/gemfiles/3.0.gemfile
DELETED
data/gemfiles/3.1.gemfile
DELETED