loaf 0.6.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +67 -12
- data/LICENSE.txt +1 -1
- data/README.md +82 -39
- data/lib/loaf.rb +1 -0
- data/lib/loaf/configuration.rb +0 -12
- data/lib/loaf/controller_extensions.rb +9 -1
- data/lib/loaf/errors.rb +1 -1
- data/lib/loaf/translation.rb +12 -4
- data/lib/loaf/version.rb +3 -1
- data/lib/loaf/view_extensions.rb +16 -8
- metadata +19 -161
- data/.document +0 -5
- data/.gitignore +0 -23
- data/.rspec +0 -2
- data/.travis.yml +0 -48
- data/Appraisals +0 -36
- data/Gemfile +0 -19
- data/Gemfile.lock +0 -185
- data/Rakefile +0 -10
- data/assets/loaf_logo.png +0 -0
- data/bin/appraisal +0 -16
- data/bin/rake +0 -16
- data/bin/setup +0 -7
- data/gemfiles/rails3.2.gemfile +0 -24
- data/gemfiles/rails4.0.gemfile +0 -24
- data/gemfiles/rails4.1.gemfile +0 -23
- data/gemfiles/rails4.2.gemfile +0 -23
- data/gemfiles/rails5.0.gemfile +0 -22
- data/gemfiles/rails5.1.gemfile +0 -22
- data/lib/loaf/crumb_formatter.rb +0 -24
- data/loaf.gemspec +0 -28
- data/spec/integration/breadcrumb_trail_spec.rb +0 -60
- data/spec/integration/configuration_spec.rb +0 -12
- data/spec/rails_app/Rakefile +0 -8
- data/spec/rails_app/app/controllers/application_controller.rb +0 -5
- data/spec/rails_app/app/controllers/comments_controller.rb +0 -17
- data/spec/rails_app/app/controllers/home_controller.rb +0 -4
- data/spec/rails_app/app/controllers/posts_controller.rb +0 -20
- data/spec/rails_app/app/views/comments/index.html.erb +0 -1
- data/spec/rails_app/app/views/home/index.html.erb +0 -1
- data/spec/rails_app/app/views/layouts/_breadcrumbs.html.erb +0 -12
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -14
- data/spec/rails_app/app/views/posts/index.html.erb +0 -1
- data/spec/rails_app/app/views/posts/new.html.erb +0 -4
- data/spec/rails_app/app/views/posts/show.html.erb +0 -1
- data/spec/rails_app/config.ru +0 -4
- data/spec/rails_app/config/application.rb +0 -48
- data/spec/rails_app/config/boot.rb +0 -10
- data/spec/rails_app/config/database.yml +0 -25
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/development.rb +0 -32
- data/spec/rails_app/config/environments/production.rb +0 -62
- data/spec/rails_app/config/environments/test.rb +0 -41
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/inflections.rb +0 -10
- data/spec/rails_app/config/initializers/mime_types.rb +0 -5
- data/spec/rails_app/config/initializers/secret_token.rb +0 -7
- data/spec/rails_app/config/initializers/session_store.rb +0 -8
- data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails_app/config/locales/en.yml +0 -5
- data/spec/rails_app/config/locales/loaf.en.yml +0 -6
- data/spec/rails_app/config/routes.rb +0 -7
- data/spec/rails_app/config/secrets.yml +0 -22
- data/spec/rails_app/public/404.html +0 -26
- data/spec/rails_app/public/422.html +0 -26
- data/spec/rails_app/public/500.html +0 -26
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/robots.txt +0 -5
- data/spec/spec_helper.rb +0 -52
- data/spec/support/capybara.rb +0 -8
- data/spec/support/dummy_controller.rb +0 -9
- data/spec/support/dummy_view.rb +0 -47
- data/spec/support/load_routes.rb +0 -4
- data/spec/unit/configuration_spec.rb +0 -39
- data/spec/unit/controller_extensions_spec.rb +0 -54
- data/spec/unit/crumb_formatter_spec.rb +0 -36
- data/spec/unit/crumb_spec.rb +0 -15
- data/spec/unit/generators/install_generator_spec.rb +0 -17
- data/spec/unit/options_validator_spec.rb +0 -15
- data/spec/unit/translation_spec.rb +0 -22
- data/spec/unit/view_extensions/breadcrumb_spec.rb +0 -22
- data/spec/unit/view_extensions/breadcrumb_trail_spec.rb +0 -232
- data/spec/unit/view_extensions/has_breadcrumbs_spec.rb +0 -10
- data/tasks/console.rake +0 -10
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 194d167e400d76180e87b1d93637c9c3cf59048dbe03ea32c416d48236778e15
|
4
|
+
data.tar.gz: 7f5c9f0d0c5f92e541b282a281327ccd327f057b844d9970e8a086ee05b735d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30f9a6c9eb2e4ca2513d1ec3c95dff3038a10d4fd55f12391a9dac5568ad34eef28c23f3ef22a2fe8f810e954674a759e1537255929e18fe117dba550a644b0c
|
7
|
+
data.tar.gz: 47ea3af5b670ae2d02ecddae7a71d70a96206487f93ef415853d18a222dc2b63729d485743bd0d2249965fd6918150facfe80b4626c0c662f45f1d302af0004c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,55 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.10.0] - 2020-11-21
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
* Reduce gem dependencies to `railties` by Christian Sutter (@csutter)
|
7
|
+
* Use `URI::DEFAULT_PARSER` instead of deprecated `URI.parser` by (@dsazup)
|
8
|
+
* Support Rails 6.1 in tests
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
* Fix #breadcrumb_trail to allow overriding the match option
|
12
|
+
* Fix #breadcrumb_trail to return enumerator that includes passed in match option
|
13
|
+
|
14
|
+
## [v0.9.0] - 2020-01-19
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
* Change gemspec to include metadata, license info and remove test artifacts
|
18
|
+
* Change to update testing to include Ruby 2.7
|
19
|
+
* Change to limit Ruby to 1.9.3 or greater
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
* Fix Ruby 2.7 warnings
|
23
|
+
|
24
|
+
## [v0.8.1] - 2019-02-04
|
25
|
+
|
26
|
+
### Added
|
27
|
+
* Add console binary
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
* Remove rake & appraisal binaries
|
31
|
+
* Change setup binary to load correct env
|
32
|
+
* Change gemspec to load files directly in without using git
|
33
|
+
|
34
|
+
## [v0.8.0] - 2018-08-07
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
* Change Translation to skip translating nil and empty string
|
38
|
+
* Change view extension to only lookup breadcrumb name translation
|
39
|
+
* Remove Configuration #crumb_length and #capitalize options
|
40
|
+
* Remove CrumbFormatter to skip truncating and formatting crumb names
|
41
|
+
|
42
|
+
## Fix
|
43
|
+
* Fix issue with breadcrumb names being modified
|
44
|
+
|
45
|
+
## [v0.7.0] - 2018-06-20
|
46
|
+
|
47
|
+
### Added
|
48
|
+
* Add test setup for Rails 5.2 by Brendon Muir(@brendon)
|
49
|
+
|
50
|
+
### Changed
|
51
|
+
* Change controller level #breadcrumb helper to accept Proc as name without controller parameter by Brendon Muir(@brendon)
|
52
|
+
|
3
53
|
## [v0.6.2] - 2018-03-30
|
4
54
|
|
5
55
|
### Added
|
@@ -59,7 +109,7 @@
|
|
59
109
|
### Fixed
|
60
110
|
* Fix bug with url parameter to allow for regular rails path variables
|
61
111
|
|
62
|
-
## [
|
112
|
+
## [v0.3.0] - 2012-02-25
|
63
113
|
|
64
114
|
### Added
|
65
115
|
* Add loaf gem errors
|
@@ -70,13 +120,13 @@
|
|
70
120
|
* Renamed main gem helpers for adding breadcrumbs from `add_breadcrumb` to
|
71
121
|
`breadcrumb`, both inside controllers and views.
|
72
122
|
|
73
|
-
## [
|
123
|
+
## [v0.2.1] - 2012-02-22
|
74
124
|
|
75
125
|
### Added
|
76
126
|
* Add more integration tests and fixed bug with adding breadcrumbs inside view
|
77
127
|
* Add specs for controller extensions
|
78
128
|
|
79
|
-
## [
|
129
|
+
## [v0.2.0] - 2012-02-18
|
80
130
|
|
81
131
|
### Added
|
82
132
|
* Add integration tests for breadcrumbs view rendering
|
@@ -92,12 +142,17 @@
|
|
92
142
|
|
93
143
|
* Initial implementation and release
|
94
144
|
|
95
|
-
[v0.
|
96
|
-
[v0.
|
97
|
-
[v0.
|
98
|
-
[v0.
|
99
|
-
[v0.
|
100
|
-
[v0.
|
101
|
-
[v0.
|
102
|
-
[v0.
|
103
|
-
[v0.
|
145
|
+
[v0.10.0]: https://github.com/piotrmurach/loaf/compare/v0.9.0...v0.10.0
|
146
|
+
[v0.9.0]: https://github.com/piotrmurach/loaf/compare/v0.8.1...v0.9.0
|
147
|
+
[v0.8.1]: https://github.com/piotrmurach/loaf/compare/v0.8.0...v0.8.1
|
148
|
+
[v0.8.0]: https://github.com/piotrmurach/loaf/compare/v0.7.0...v0.8.0
|
149
|
+
[v0.7.0]: https://github.com/piotrmurach/loaf/compare/v0.6.2...v0.7.0
|
150
|
+
[v0.6.2]: https://github.com/piotrmurach/loaf/compare/v0.6.1...v0.6.2
|
151
|
+
[v0.6.1]: https://github.com/piotrmurach/loaf/compare/v0.6.0...v0.6.1
|
152
|
+
[v0.6.0]: https://github.com/piotrmurach/loaf/compare/v0.5.0...v0.6.0
|
153
|
+
[v0.5.0]: https://github.com/piotrmurach/loaf/compare/v0.4.0...v0.5.0
|
154
|
+
[v0.4.0]: https://github.com/piotrmurach/loaf/compare/v0.3.0...v0.4.0
|
155
|
+
[v0.3.0]: https://github.com/piotrmurach/loaf/compare/v0.2.1...v0.3.0
|
156
|
+
[v0.2.1]: https://github.com/piotrmurach/loaf/compare/v0.2.0...v0.2.1
|
157
|
+
[v0.2.0]: https://github.com/piotrmurach/loaf/compare/v0.1.0...v0.2.0
|
158
|
+
[v0.1.0]: https://github.com/piotrmurach/loaf/compare/v0.1.0...HEAD
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
<div align="center">
|
2
|
-
<img width="237" src="https://
|
2
|
+
<img width="237" src="https://github.com/piotrmurach/loaf/blob/master/assets/loaf_logo.png" alt="Loaf gem logo" />
|
3
3
|
</div>
|
4
4
|
|
5
5
|
# Loaf
|
6
6
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/loaf.svg)][gem]
|
8
|
-
[![
|
8
|
+
[![Actions CI](https://github.com/piotrmurach/loaf/workflows/CI/badge.svg?branch=master)][gh_actions_ci]
|
9
9
|
[![Maintainability](https://api.codeclimate.com/v1/badges/966193dafa3895766977/maintainability)][codeclimate]
|
10
|
-
[![Dependency Status](https://gemnasium.com/piotrmurach/loaf.svg?travis)][gemnasium]
|
11
10
|
[![Coverage Status](https://coveralls.io/repos/github/piotrmurach/loaf/badge.svg?branch=master)][coveralls]
|
12
11
|
[![Inline docs](http://inch-ci.org/github/piotrmurach/loaf.svg?branch=master)][inchpages]
|
13
12
|
|
14
13
|
[gem]: http://badge.fury.io/rb/loaf
|
15
|
-
[
|
14
|
+
[gh_actions_ci]: https://github.com/piotrmurach/loaf/actions?query=workflow%3ACI
|
16
15
|
[codeclimate]: https://codeclimate.com/github/piotrmurach/loaf/maintainability
|
17
|
-
[gemnasium]: https://gemnasium.com/piotrmurach/loaf
|
18
16
|
[coveralls]: https://coveralls.io/github/piotrmurach/loaf
|
19
17
|
[inchpages]: http://inch-ci.org/github/piotrmurach/loaf
|
20
18
|
|
@@ -33,7 +31,7 @@
|
|
33
31
|
Add this line to your application's Gemfile:
|
34
32
|
|
35
33
|
```ruby
|
36
|
-
gem
|
34
|
+
gem "loaf"
|
37
35
|
```
|
38
36
|
|
39
37
|
And then execute:
|
@@ -75,7 +73,7 @@ In order to add breadcrumbs in controller use `breadcrumb` method ([see 2.1](#21
|
|
75
73
|
```ruby
|
76
74
|
class Blog::CategoriesController < ApplicationController
|
77
75
|
|
78
|
-
breadcrumb
|
76
|
+
breadcrumb "Article Categories", :blog_categories_path, only: [:show]
|
79
77
|
|
80
78
|
def show
|
81
79
|
breadcrumb @category.title, blog_category_path(@category)
|
@@ -96,7 +94,7 @@ The `breadcrumb` method takes at minimum two arguments: the first is a name for
|
|
96
94
|
When using path variable `blog_categories_path`:
|
97
95
|
|
98
96
|
```ruby
|
99
|
-
breadcrumb
|
97
|
+
breadcrumb "Categories", blog_categories_path
|
100
98
|
```
|
101
99
|
|
102
100
|
When using an instance `@category`:
|
@@ -114,7 +112,7 @@ breadcrumb @category.title, [:blog, @category]
|
|
114
112
|
You can specify segments of the url:
|
115
113
|
|
116
114
|
```ruby
|
117
|
-
breadcrumb @category.title, {controller:
|
115
|
+
breadcrumb @category.title, {controller: "categories", action: "show", id: @category.id}
|
118
116
|
```
|
119
117
|
|
120
118
|
#### 2.1.1 controller
|
@@ -123,7 +121,7 @@ Breadcrumbs are inherited, so if you set a breadcrumb in `ApplicationController`
|
|
123
121
|
|
124
122
|
```ruby
|
125
123
|
class ApplicationController < ActionController::Base
|
126
|
-
breadcrumb
|
124
|
+
breadcrumb "Home", :root_path
|
127
125
|
end
|
128
126
|
```
|
129
127
|
|
@@ -131,7 +129,7 @@ Outside of controller actions the `breadcrumb` helper behaviour is similar to fi
|
|
131
129
|
|
132
130
|
```ruby
|
133
131
|
class ArticlesController < ApplicationController
|
134
|
-
breadcrumb
|
132
|
+
breadcrumb "All Articles", :articles_path, only: [:new, :create]
|
135
133
|
end
|
136
134
|
```
|
137
135
|
|
@@ -139,12 +137,12 @@ Each time you call the `breadcrumb` helper, a new element is added to a breadcru
|
|
139
137
|
|
140
138
|
```ruby
|
141
139
|
class ArticlesController < ApplicationController
|
142
|
-
breadcrumb
|
143
|
-
breadcrumb
|
140
|
+
breadcrumb "Home", :root_path
|
141
|
+
breadcrumb "All Articles", :articles_path
|
144
142
|
|
145
143
|
def show
|
146
|
-
breadcrumb
|
147
|
-
breadcrumb
|
144
|
+
breadcrumb "Article One", article_path(:one)
|
145
|
+
breadcrumb "Article Two", article_path(:two)
|
148
146
|
end
|
149
147
|
end
|
150
148
|
```
|
@@ -153,18 +151,30 @@ end
|
|
153
151
|
|
154
152
|
```ruby
|
155
153
|
class CommentsController < ApplicationController
|
156
|
-
breadcrumb ->
|
154
|
+
breadcrumb -> { find_article(params[:post_id]).title }, :articles_path
|
157
155
|
end
|
158
156
|
```
|
159
157
|
|
160
|
-
Also, to dynamically
|
158
|
+
Also, to dynamically evaluate parameters inside the url argument do:
|
161
159
|
|
162
160
|
```ruby
|
163
161
|
class CommentsController < ApplicationController
|
164
|
-
breadcrumb
|
162
|
+
breadcrumb "All Comments", -> { post_comments_path(params[:post_id]) }
|
165
163
|
end
|
166
164
|
```
|
167
165
|
|
166
|
+
You may wish to define breadcrumbs over a collection. This is easy within views, and controller actions (just loop your collection), but if you want to do this in the controller class you can use the `before_action` approach:
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
before_action do
|
170
|
+
ancestors.each do |ancestor|
|
171
|
+
breadcrumb ancestor.name, [:admin, ancestor]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
Assume `ancestors` method is defined inside the controller.
|
177
|
+
|
168
178
|
#### 2.1.2 view
|
169
179
|
|
170
180
|
**Loaf** adds `breadcrumb` helper also to the views. Together with controller breadcrumbs, the view breadcrumbs are appended as the last in breadcrumb trail. For instance, to specify view breadcrumb do:
|
@@ -181,25 +191,27 @@ The `:match` key accepts the following values:
|
|
181
191
|
|
182
192
|
* `:inclusive` - the default value, which matches nested paths
|
183
193
|
* `:exact` - matches only the exact same path
|
184
|
-
* `:exclusive` - matches only direct path and its query
|
194
|
+
* `:exclusive` - matches only direct path and its query parameters if present
|
185
195
|
* `/regex/` - matches based on regular expression
|
186
|
-
* `{foo: bar}` - match based on query
|
196
|
+
* `{foo: bar}` - match based on query parameters
|
187
197
|
|
188
198
|
For example, to force a breadcrumb to be the current regardless do:
|
189
199
|
|
190
200
|
```ruby
|
191
|
-
breadcrumb
|
201
|
+
breadcrumb "New Post", new_post_path, match: :exact
|
192
202
|
```
|
193
203
|
|
194
|
-
To make a breadcrumb current based on the query
|
204
|
+
To make a breadcrumb current based on the query parameters do:
|
195
205
|
|
196
206
|
```ruby
|
197
|
-
breadcrumb
|
207
|
+
breadcrumb "Posts", posts_path(order: :desc), match: {order: :desc}
|
198
208
|
```
|
199
209
|
|
200
210
|
### 2.2 breadcrumb_trail
|
201
211
|
|
202
|
-
In order to display breadcrumbs use the `breadcrumb_trail` view helper
|
212
|
+
In order to display breadcrumbs use the `breadcrumb_trail` view helper. It accepts optional argument of configuration options and can be used in two ways.
|
213
|
+
|
214
|
+
One way, given a block it will yield all the breadcrumbs in order of definition:
|
203
215
|
|
204
216
|
```ruby
|
205
217
|
breadcrumb_trail do |crumb|
|
@@ -207,7 +219,7 @@ breadcrumb_trail do |crumb|
|
|
207
219
|
end
|
208
220
|
```
|
209
221
|
|
210
|
-
The yielded
|
222
|
+
The yielded parameter is an instance of `Loaf::Crumb` object with the following methods:
|
211
223
|
|
212
224
|
```ruby
|
213
225
|
crumb.name # => the name as string
|
@@ -220,10 +232,10 @@ For example, you can add the following semantic markup to show breadcrumbs using
|
|
220
232
|
|
221
233
|
```erb
|
222
234
|
<nav aria-label="breadcrumb">
|
223
|
-
<ol class=
|
235
|
+
<ol class="breadcrumbs">
|
224
236
|
<% breadcrumb_trail do |crumb| %>
|
225
|
-
<li class="<%= crumb.current? ?
|
226
|
-
<%= link_to crumb.name, crumb.url, (crumb.current? ? {
|
237
|
+
<li class="<%= crumb.current? ? "current" : "" %>">
|
238
|
+
<%= link_to crumb.name, crumb.url, (crumb.current? ? {"aria-current" => "page"} : {}) %>
|
227
239
|
<% unless crumb.current? %><span>::</span><% end %>
|
228
240
|
</li>
|
229
241
|
<% end %>
|
@@ -231,36 +243,59 @@ For example, you can add the following semantic markup to show breadcrumbs using
|
|
231
243
|
</nav>
|
232
244
|
```
|
233
245
|
|
234
|
-
For
|
246
|
+
For Bootstrap 4:
|
247
|
+
|
235
248
|
```erb
|
249
|
+
<% #erb %>
|
236
250
|
<nav aria-label="breadcrumb">
|
237
|
-
<ol class=
|
251
|
+
<ol class="breadcrumb">
|
238
252
|
<% breadcrumb_trail do |crumb| %>
|
239
|
-
<li class="breadcrumb-item <%= crumb.current? ?
|
240
|
-
<%= link_to_unless crumb.current?, crumb.name, crumb.url, (crumb.current? ? {
|
253
|
+
<li class="breadcrumb-item <%= crumb.current? ? "active" : "" %>">
|
254
|
+
<%= link_to_unless crumb.current?, crumb.name, crumb.url, (crumb.current? ? {"aria-current" => "page"} : {}) %>
|
241
255
|
</li>
|
242
256
|
<% end %>
|
243
257
|
</ol>
|
244
258
|
</nav>
|
245
259
|
```
|
246
260
|
|
261
|
+
And, if you are using `HAML` do:
|
262
|
+
|
263
|
+
```haml
|
264
|
+
- # haml
|
265
|
+
%ol.breadcrumb
|
266
|
+
- breadcrumb_trail do |crumb|
|
267
|
+
%li.breadcrumb-item{class: crumb.current? ? "active" : "" }
|
268
|
+
= link_to_unless crumb.current?, crumb.name, crumb.url, (crumb.current? ? {"aria-current" => "page"} : {})
|
269
|
+
```
|
270
|
+
|
271
|
+
Usually best practice is to put such snippet inside its own `_breadcrumbs.html.erb` partial.
|
247
272
|
|
248
|
-
|
273
|
+
The second way is to use the `breadcrumb_trail` without passing a block. In this case, the helper will return an enumerator that you can use to, for example, access an array of names pushed into the breadcrumb trail in order of addition. This can be handy for generating page titles from breadcrumb data.
|
274
|
+
|
275
|
+
For example, you can define a `breadcrumbs_to_title` method in `ApplicationHelper` like so:
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
module ApplicationHelper
|
279
|
+
def breadcrumbs_to_title
|
280
|
+
breadcrumb_trail.map(&:name).join(">")
|
281
|
+
end
|
282
|
+
end
|
283
|
+
```
|
284
|
+
|
285
|
+
Use whichever of the two ways is more convenient given your application structure and needs.
|
249
286
|
|
250
287
|
## 3. Configuration
|
251
288
|
|
252
289
|
There is a small set of custom opinionated defaults. The following options are valid parameters:
|
253
290
|
|
254
291
|
```ruby
|
255
|
-
:
|
256
|
-
:crumb_length # breadcrumb length in integer, default length is 30 characters
|
257
|
-
:match # set match type, default :inclusive
|
292
|
+
:match # set match type, default :inclusive (see [:match](#213-match) for more details)
|
258
293
|
```
|
259
294
|
|
260
295
|
You can override them in your views by passing them to the view `breadcrumb` helper
|
261
296
|
|
262
297
|
```erb
|
263
|
-
<% breadcrumb_trail
|
298
|
+
<% breadcrumb_trail(match: :exclusive) do |name, url, styles| %>
|
264
299
|
..
|
265
300
|
<% end %>
|
266
301
|
```
|
@@ -269,7 +304,7 @@ or by configuring an option in `config/initializers/loaf.rb`:
|
|
269
304
|
|
270
305
|
```ruby
|
271
306
|
Loaf.configure do |config|
|
272
|
-
config.
|
307
|
+
config.match = :exclusive
|
273
308
|
end
|
274
309
|
```
|
275
310
|
|
@@ -306,6 +341,14 @@ en:
|
|
306
341
|
|
307
342
|
Questions or problems? Please post them on the [issue tracker](https://github.com/piotrmurach/loaf/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running `bundle` and `rake`.
|
308
343
|
|
344
|
+
## License
|
345
|
+
|
346
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
347
|
+
|
348
|
+
## Code of Conduct
|
349
|
+
|
350
|
+
Everyone interacting in the Loaf project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/loaf/blob/master/CODE_OF_CONDUCT.md).
|
351
|
+
|
309
352
|
## Copyright
|
310
353
|
|
311
|
-
Copyright (c) 2011
|
354
|
+
Copyright (c) 2011 Piotr Murach. See LICENSE.txt for further details.
|
data/lib/loaf.rb
CHANGED
data/lib/loaf/configuration.rb
CHANGED
@@ -4,8 +4,6 @@ module Loaf
|
|
4
4
|
class Configuration
|
5
5
|
VALID_ATTRIBUTES = [
|
6
6
|
:locales_path,
|
7
|
-
:crumb_length,
|
8
|
-
:capitalize,
|
9
7
|
:match
|
10
8
|
].freeze
|
11
9
|
|
@@ -13,18 +11,8 @@ module Loaf
|
|
13
11
|
|
14
12
|
DEFAULT_LOCALES_PATH = '/'
|
15
13
|
|
16
|
-
DEFAULT_STYLE_CLASSES = 'selected'
|
17
|
-
|
18
|
-
DEFAULT_CRUMB_LENGTH = 30
|
19
|
-
|
20
|
-
DEFAULT_LAST_CRUMB_LINKED = false
|
21
|
-
|
22
|
-
DEFAULT_CAPITALIZE = false
|
23
|
-
|
24
14
|
DEFAULT_MATCH = :inclusive
|
25
15
|
|
26
|
-
DEFAULT_ROOT = true
|
27
|
-
|
28
16
|
# Setup this configuration
|
29
17
|
#
|
30
18
|
# @api public
|
@@ -38,12 +38,20 @@ module Loaf
|
|
38
38
|
respond_to?(:before_action) ? :before_action : :before_filter
|
39
39
|
end
|
40
40
|
|
41
|
+
# Convert breadcrumb name to string
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
#
|
41
45
|
# @api private
|
42
46
|
def _normalize_name(name, instance)
|
43
47
|
case name
|
44
48
|
when NilClass
|
45
49
|
when Proc
|
46
|
-
name.
|
50
|
+
if name.arity == 1
|
51
|
+
instance.instance_exec(instance, &name)
|
52
|
+
else
|
53
|
+
instance.instance_exec(&name)
|
54
|
+
end
|
47
55
|
else
|
48
56
|
name
|
49
57
|
end
|