breadcrumbs_on_rails 2.3.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6d3c25bc4d93a1dfdc12e5799934b535c6d4744f147343ace66f097fdd47fad3
4
+ data.tar.gz: 88ab7e1a451f3d272964e463ad6bb5e30ecdf133f00fa50143f18db1876433ad
5
+ SHA512:
6
+ metadata.gz: e5db1d12f40c3b2e737f99efb071dc96a1c07868f8f6e0116cac647102c142d7b21fc58a426e90198010843cb7b638bc7731a819f75d6b9a0ce5bd5fa22319a2
7
+ data.tar.gz: 10121bc98e524b146e1de35658fd0076f39f581919c475cb11916248a6c38dead2bbf8ab259e48ff65eb7f50484661bc5b4c97316857fe451437effe86424c6d
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: "rubygems/breadcrumbs_on_rails"
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/.gitignore CHANGED
@@ -1,8 +1,11 @@
1
1
  # Bundler
2
- .bundle
3
- pkg/*
4
- Gemfile.lock
2
+ /.bundle
3
+ /Gemfile.lock
4
+ /gemfiles/*.gemfile.lock
5
+ /pkg/*
5
6
 
6
7
  # YARD
7
- .yardoc
8
- yardoc/
8
+ /.yardoc
9
+ /yardoc/
10
+
11
+ /.tool-versions
data/.travis.yml CHANGED
@@ -1,12 +1,31 @@
1
+ language: ruby
2
+
1
3
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
- - 1.9.3
5
- - ree
4
+ - 2.4
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ - ruby-head
9
+
10
+ env:
11
+ global:
12
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
13
+
14
+ cache:
15
+ - bundler
16
+
6
17
  gemfile:
7
- - gemfiles/3.0.gemfile
8
- - gemfiles/3.1.gemfile
9
- - gemfiles/3.2.gemfile
10
- notifications:
11
- recipients:
12
- - weppos@weppos.net
18
+ - gemfiles/5.0.gemfile
19
+ - gemfiles/5.1.gemfile
20
+ - gemfiles/5.2.gemfile
21
+ - gemfiles/6.0.gemfile
22
+
23
+ matrix:
24
+ allow_failures:
25
+ - rvm: ruby-head
26
+ exclude:
27
+ - rvm: 2.4
28
+ gemfile: gemfiles/6.0.gemfile
29
+
30
+ before_install:
31
+ - gem install bundler -v 1.17.3
data/Appraisals CHANGED
@@ -1,11 +1,12 @@
1
- appraise "3.0" do
2
- gem "activerecord", "~> 3.0"
1
+ appraise "5.0" do
2
+ gem "rails", "~> 5.0.0"
3
3
  end
4
-
5
- appraise "3.1" do
6
- gem "activerecord", "~> 3.1"
4
+ appraise "5.1" do
5
+ gem "rails", "~> 5.1.0"
6
+ end
7
+ appraise "5.2" do
8
+ gem "rails", "~> 5.2.0"
9
+ end
10
+ appraise "6.0" do
11
+ gem "rails", "~> 6.0.0"
7
12
  end
8
-
9
- appraise "3.2" do
10
- gem "activerecord", "~> 3.2"
11
- end
data/CHANGELOG.md CHANGED
@@ -1,62 +1,100 @@
1
1
  # Changelog
2
2
 
3
+ ## Release 4.1.0
4
+
5
+ ### Changed
6
+
7
+ - Swapped dependency on "rails" to "railties" (GH-135)
8
+
9
+ ## Release 4.0.0
10
+
11
+ ### Changed
12
+
13
+ - Minimum requirements Rails >= 5
14
+
15
+ ### Enhancements
16
+
17
+ - Prefixed shared helpers to reduce collision probability (GH-65, GH-129). [Thanks @justame, @ngelx]
18
+
19
+
20
+ ## Release 3.0.1
21
+
22
+ ### Fixed
23
+
24
+ - Fixed compatibility with Rails 5.0 and ActionController::API (GH-99). [Thanks @jcoyne]
3
25
 
4
- ## Release 2.3.0
5
26
 
6
- * FIXED: In some circumstances the BreadcrumbsOnRails::ActionController::HelperMethods is not mixed into the controller.
27
+ ## Release 3.0.0
7
28
 
8
- * FIXED: Breadcrumbs now accepts a polymorphic path (GH-15).
29
+ ### Fixed
9
30
 
10
- * CHANGED: Second argument on `add_breadcrumb` is now optional (GH-6, GH-32). [Thanks @mpartel]
31
+ - Fixed compatibility with Rails 5.0 (GH-80). [Thanks @ochko]
32
+ - Fixed initialization error (GH-75). [Thanks @soulcutter]
33
+ - Escape user input by default to avoid XSS attacks (GH-63). [Thanks @rdunlop]
11
34
 
12
- * CHANGED: Breadcrumb path computation fallbacks to url_for in case of unknown arguments.
35
+ ### Changed
36
+
37
+ - Minimum requirements Rails >= 4 and Ruby >= 2.
38
+
39
+
40
+ ## Release 2.3.1
41
+
42
+ - FIXED: Using `add_breadcrumbs` did not properly pass `options` (GH-46). [Thanks @link664]
43
+
44
+
45
+ ## Release 2.3.0
46
+
47
+ - FIXED: In some circumstances the BreadcrumbsOnRails::ActionController::HelperMethods is not mixed into the controller.
48
+ - FIXED: Breadcrumbs now accepts a polymorphic path (GH-15).
49
+
50
+ - CHANGED: Second argument on `add_breadcrumb` is now optional (GH-6, GH-32). [Thanks @mpartel]
51
+ - CHANGED: Breadcrumb path computation fallbacks to url_for in case of unknown arguments.
13
52
 
14
53
 
15
54
  ## Release 2.2.0
16
55
 
17
- * NEW: Support for Rails 3.2.
56
+ - NEW: Support for Rails 3.2.
18
57
 
19
- * FIXED: Fixed Rails 3.2 ActiveSupport::Concern deprecation warning (GH-17, GH-20).
58
+ - FIXED: Fixed Rails 3.2 ActiveSupport::Concern deprecation warning (GH-17, GH-20).
20
59
 
21
60
 
22
61
  ## Release 2.1.0
23
62
 
24
- * 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.
63
+ - 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.
25
64
 
26
65
 
27
66
  ## Release 2.0.0
28
67
 
29
- * FIXED: Invalid documentation for Element target in the controller class context (closes #2)
68
+ - FIXED: Invalid documentation for Element target in the controller class context (closes #2)
30
69
 
31
- * CHANGED: Upgraded to Rails 3
70
+ - CHANGED: Upgraded to Rails 3
32
71
 
33
72
 
34
73
  ## Release 1.0.1
35
74
 
36
- * FIXED: Since the removal of rails/init.rb in 7278376ab77651e540e39552384ad9677e32ff7e, Rails fails to load the helpers.
75
+ - FIXED: Since the removal of rails/init.rb in 7278376ab77651e540e39552384ad9677e32ff7e, Rails fails to load the helpers.
37
76
 
38
77
 
39
78
  ## Release 1.0.0
40
79
 
41
- * CHANGED: Removed empty install/uninstall hooks and tasks folder.
42
-
43
- * CHANGED: Removed rails/init hook because deprecated in Rails 3.
80
+ - CHANGED: Removed empty install/uninstall hooks and tasks folder.
81
+ - CHANGED: Removed rails/init hook because deprecated in Rails 3.
44
82
 
45
83
 
46
84
  ## Release 0.2.0
47
85
 
48
- * Releasing the library as open source project.
86
+ - Releasing the library as open source project.
49
87
 
50
- ## Release 0.1.1
51
88
 
89
+ ## Release 0.1.1
52
90
 
53
- * ADDED: documentation file.
54
91
 
55
- * CHANGED: run test against Rails ~> 2.3.0 but ensure compatibility with Rails 2.2.x.
92
+ - NEW: documentation file.
56
93
 
57
- * CHANGED: Removed BUILD and STATUS constants. Added Version::ALPHA constant to be used when I need to package prereleases (see RubyGem --prerelease flag).
94
+ - CHANGED: run test against Rails ~> 2.3.0 but ensure compatibility with Rails 2.2.x.
95
+ - CHANGED: Removed BUILD and STATUS constants. Added Version::ALPHA constant to be used when I need to package prereleases (see RubyGem --prerelease flag).
58
96
 
59
97
 
60
98
  ## Release 0.1.0
61
99
 
62
- * Initial version
100
+ - Initial version
data/Gemfile CHANGED
@@ -1,3 +1,11 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "rake"
6
+ gem "bundler"
7
+
8
+ gem "appraisal"
9
+ gem "rails", ">= 5.0"
10
+ gem "mocha", ">= 1.0"
11
+ gem "yard"
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
1
+ Copyright (c) 2009-2020 Simone Carletti <weppos@weppos.net>
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,99 +1,285 @@
1
1
  # Breadcrumbs On Rails
2
2
 
3
- *BreadcrumbsOnRails* is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.
4
- It provides helpers for creating navigation elements with a flexible interface.
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.com/weppos/breadcrumbs_on_rails.svg?branch=master)](https://travis-ci.com/weppos/breadcrumbs_on_rails)
6
+ [![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/breadcrumbs_on_rails)](https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails&utm_medium=referral&utm_campaign=enterprise)
7
+
8
+
9
+ ## Links
10
+
11
+ - [Homepage](https://simonecarletti.com/code/breadcrumbs-on-rails)
12
+ - [Repository](https://github.com/weppos/breadcrumbs_on_rails)
13
+ - [API Documentation](https://rubydoc.info/gems/breadcrumbs_on_rails)
6
14
 
7
- ## Requirements
8
15
 
9
- * Rails 3
16
+ ## Requirements
10
17
 
11
- Please note
18
+ - Ruby >= 2.4
19
+ - Rails >= 5
12
20
 
13
- * BreadcrumbsOnRails 2.x requires Rails 3. Use BreadcrumbsOnRails 1.x with Rails 2.
14
- * BreadcrumbsOnRails doesn't work with Rails 2.1 or lower.
21
+ For older versions use a previous release.
15
22
 
16
23
 
17
24
  ## Installation
18
25
 
19
- [RubyGems](http://rubygems.org) is the preferred way to install *BreadcrumbsOnRails* and the best way if you want install a stable version.
26
+ Add this line to your application's `Gemfile`:
20
27
 
21
- $ gem install breadcrumbs_on_rails
28
+ ```
29
+ gem "breadcrumbs_on_rails"
30
+ ```
22
31
 
23
- Specify the Gem dependency in the [Bundler](http://gembundler.com) `Gemfile`.
32
+ And then execute `bundle` to install the dependencies:
24
33
 
25
- gem "breadcrumbs_on_rails"
34
+ ```
35
+ bundle
36
+ ```
26
37
 
27
- Use [Bundler](http://gembundler.com) and the [:git option](http://gembundler.com/v1.0/git.html) if you want to grab the latest version from the Git repository.
38
+ Use [Bundler](http://bundler.io/) and the `:git` option if you want to grab the latest version from the Git repository.
28
39
 
29
40
 
30
- ## Basic Usage
41
+ ## Usage
31
42
 
32
- Creating a breadcrumb navigation menu in your Rails app using *BreadcrumbsOnRails* is really straightforward.
43
+ Creating a breadcrumb navigation menu in your Rails app using <tt>BreadcrumbsOnRails</tt> is really straightforward.
33
44
 
34
45
  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
46
 
36
- class MyController
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
47
+ ```ruby
48
+ class MyController
49
+
50
+ add_breadcrumb "home", :root_path
51
+ add_breadcrumb "my", :my_path
52
+
53
+ def index
54
+ # ...
55
+
56
+ add_breadcrumb "index", index_path
57
+ end
58
+
59
+ end
60
+ ```
61
+
62
+ See the section "Breadcrumb Element" for more details about name and target class types.
48
63
 
49
64
  The third, optional argument is a Hash of options to customize the breadcrumb link.
50
65
 
51
- class MyController
52
- def index
53
- add_breadcrumb "index", index_path, :title => "Back to the Index"
54
- end
55
- end
66
+ ```ruby
67
+ class MyController
68
+ def index
69
+ add_breadcrumb "index", index_path, title: "Back to the Index"
70
+ end
71
+ end
72
+ ```
56
73
 
57
74
  In your view, you can render the breadcrumb menu with the `render_breadcrumbs` helper.
58
75
 
59
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
60
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
61
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
62
- <head>
63
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
64
- <title>untitled</title>
65
- </head>
66
-
67
- <body>
68
- <%= render_breadcrumbs %>
69
- </body>
70
- </html>
76
+ ```html
77
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
78
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
79
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
80
+ <head>
81
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
82
+ <title>untitled</title>
83
+ </head>
84
+
85
+ <body>
86
+ <%= render_breadcrumbs %>
87
+ </body>
88
+ </html>
89
+ ```
71
90
 
72
91
  `render_breadcrumbs` understands a limited set of options. For example, you can pass change the default separator with the `:separator` option.
73
92
 
74
- <body>
75
- <%= render_breadcrumbs :separator => ' / ' %>
76
- </body>
93
+ ```html
94
+ <body>
95
+ <%= render_breadcrumbs :separator => ' / ' %>
96
+ </body>
97
+ ```
98
+
99
+ Current possible options are:
100
+
101
+ - `:separator`
102
+ - `:tag`
103
+
104
+ To use with Bootstrap you might use the following:
105
+
106
+ ```html
107
+ <body>
108
+ <ol class="breadcrumb">
109
+ <%= render_breadcrumbs :tag => :li, :separator => "" %>
110
+ </ol>
111
+ </body>
112
+ ```
113
+
114
+ More complex customizations require a custom `Builder`.
115
+
116
+ ### HTML Escaping
117
+
118
+ The text of the breadcrumb is html-escaped by default unless it is a SafeBuffer, to prevent XSS attacks.
119
+
120
+ ```ruby
121
+ class MyController
122
+ add_breadcrumb "This is the <b>Main</b> page".html_safe
123
+
124
+ def profile
125
+ add_breadcrumb "#{@user_name} Profile", users_profile
126
+ end
127
+ end
128
+ ```
129
+
130
+ In this case, if `@user_name` is `<script>`, it will output:
131
+
132
+ ```
133
+ This is the <b>Main</b> page > &lt;script&gt; Profile
134
+ ```
135
+
136
+
137
+ ### Breadcrumb Element
138
+
139
+ 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.
140
+
141
+ 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:
142
+
143
+ - `Symbol`
144
+ - `Proc`
145
+ - `String`
146
+
147
+ #### Symbol
148
+
149
+ 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.
150
+
151
+ ```ruby
152
+ class MyController
153
+
154
+ # The Name is set to the value returned by
155
+ # the :root_name method.
156
+ add_breadcrumb :root_name, "/"
157
+
158
+ protected
159
+
160
+ def root_name
161
+ "the name"
162
+ end
163
+
164
+ end
165
+ ```
166
+
167
+ #### Proc
168
+
169
+ 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.
170
+
171
+ ```ruby
172
+ class MyController
173
+
174
+ # The Name is set to the value returned by
175
+ # the :root_name method.
176
+ add_breadcrumb Proc.new { |c| c.my_helper_method },
177
+ "/"
178
+
179
+ end
180
+ ```
181
+
182
+ #### String
183
+
184
+ If the value is a `String`, the library sets the `Element` attribute to the string value.
185
+
186
+ ```ruby
187
+ class MyController
188
+
189
+ # The Name is set to the value returned by
190
+ # the :root_name method.
191
+ add_breadcrumb "homepage", "/"
192
+
193
+ end
194
+ ```
195
+
196
+ ### Restricting breadcrumb scope
197
+
198
+ 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.
199
+
200
+ Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.
201
+
202
+ ```ruby
203
+ class PostsController < ApplicationController
204
+ add_breadcrumb "admin", :admin_path
205
+ add_breadcrumb "posts", :posts_path, only: [:index, :show]
206
+ end
207
+
208
+ class ApplicationController < ActionController::Base
209
+ add_breadcrumb "admin", :admin_path, if: :admin_controller?
210
+
211
+ def admin_controller?
212
+ self.class.name =~ /^Admin(::|Controller)/
213
+ end
214
+ end
215
+ ```
77
216
 
78
- More complex customizations require a custom Builder.
217
+ ### Internationalization and Localization
79
218
 
80
- Read the [documentation](http://www.simonecarletti.com/code/breadcrumbs_on_rails/docs/) to learn more about advanced usage and builders.
219
+ <tt>BreadcrumbsOnRails</tt> is compatible with the standard Rails internationalization framework.
220
+
221
+ 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.
222
+
223
+ ```yaml
224
+ # config/locales/en.yml
225
+ en:
226
+ breadcrumbs:
227
+ homepage: Homepage
228
+ first: First
229
+ second: Second
230
+ third: Third
231
+
232
+ # config/locales/it.yml
233
+ it:
234
+ breadcrumbs:
235
+ homepage: Homepage
236
+ first: Primo
237
+ second: Secondo
238
+ third: Terzo
239
+ ```
240
+
241
+ In your controller, use the `I18n.t` method.
242
+
243
+ ```ruby
244
+ class PostsController < ApplicationController
245
+ add_breadcrumb I18n.t("breadcrumbs.first"), :first_path
246
+ add_breadcrumb I18n.t("breadcrumbs.second"), :second_path, only: [:second]
247
+ add_breadcrumb I18n.t("breadcrumbs.third"), :third_path, only: [:third]
248
+ end
249
+
250
+ class ApplicationController < ActionController::Base
251
+ add_breadcrumb I18n.t("breadcrumbs.homepage"), :root_path
252
+ end
253
+ ```
254
+
255
+
256
+ ## Support
257
+
258
+ Library documentation is auto-generated from the [README](https://github.com/weppos/breadcrumbs_on_rails/blob/master/README.md) and the source code, and it's available at https://rubydoc.info/gems/breadcrumbs_on_rails.
259
+
260
+ - The bug tracker is here: https://github.com/weppos/breadcrumbs_on_rails/issues
261
+ - The code repository is here: https://github.com/weppos/breadcrumbs_on_rails. Contributions are welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make.
262
+
263
+ **Commercial support available as part of the Tidelift Subscription** - [Learn more](https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
264
+
265
+ The maintainers of breadcrumbs_on_rails and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Consider subscribing to Tidelift which provides Enterprise support for this project.](https://tidelift.com/subscription/pkg/rubygems-breadcrumbs.on.rails?utm_source=rubygems-breadcrumbs-on-rails&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
81
266
 
82
267
 
83
268
  ## Credits
84
269
 
85
- * [Simone Carletti](http://www.simonecarletti.com/) <weppos@weppos.net> - The Author
270
+ <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).
271
+
272
+
273
+ ## Security and Vulnerability Reporting
274
+
275
+ Full information and description of our security policy please visit [SECURITY.md](SECURITY.md)
86
276
 
87
277
 
88
- ## Resources
278
+ ## Changelog
89
279
 
90
- * [Homepage](http://www.simonecarletti.com/code/breadcrumbs_on_rails)
91
- * [Documentation](http://www.simonecarletti.com/code/breadcrumbs_on_rails/docs/)
92
- * [API](http://rubydoc.info/gems/breadcrumbs_on_rails)
93
- * [Repository](https://github.com/weppos/breadcrumbs_on_rails)
94
- * [Issue Tracker](http://github.com/weppos/breadcrumbs_on_rails/issues)
280
+ See the [CHANGELOG.md](CHANGELOG.md) file for details.
95
281
 
96
282
 
97
283
  ## License
98
284
 
99
- *BreadcrumbsOnRails* is Copyright (c) 2009-2012 Simone Carletti. This is Free Software distributed under the MIT license.
285
+ Copyright (c) 2009-2020 Simone Carletti. This is Free Software distributed under the MIT license.