gretel 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -10
- data/README.md +12 -3
- data/lib/gretel/version.rb +1 -1
- data/lib/gretel/view_helpers.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3e002fa0feb5ee917e81324762d2d48274e7e35
|
4
|
+
data.tar.gz: 16338b4f9d61b4e689ec73c7e4d6bf34152aba11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae5738c15905088b11940343d2bfdcb4fa9df67cb999038a9df5334b78caf8db3b9c78c8941f74fb7c38fc991c50cc4f6da80990e98bcc201dbe72a05cac4c9e
|
7
|
+
data.tar.gz: f5571a9bf4caa6df4d4569c90667aeaab7e8e19d5c8d5f456516afffe1d97cdbe45689487654b8f31c024c0565e90b95c85e8449fc3ec5527d2517ba36aa06d1
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
Changelog
|
2
|
-
=========
|
1
|
+
# Changelog
|
3
2
|
|
4
|
-
Version 3.0.
|
5
|
-
|
3
|
+
## Version 3.0.2
|
4
|
+
* Inferring breadcrumbs is now supported on all instances of objects that respond to `model_name`.
|
5
|
+
|
6
|
+
## Version 3.0.1
|
6
7
|
* Breadcrumbs can now be inferred if you pass in an ActiveRecord model instance. E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
|
7
8
|
|
8
|
-
Version 3.0
|
9
|
-
-----------
|
9
|
+
# Version 3.0
|
10
10
|
* Support for defining breadcrumbs using `Gretel::Crumbs.layout do ... end` in an initializer has been removed. See the readme for details on how to upgrade.
|
11
11
|
* Breadcrumbs rendering is now done in a separate class to unclutter the view with helpers. The public API is still the same.
|
12
12
|
* Support for rendering the breadcrumbs in different styles like ul- and ol lists, and for use with [Twitter Bootstrap](http://getbootstrap.com/). See the `:style` option in the readme for more info.
|
@@ -15,12 +15,10 @@ Version 3.0
|
|
15
15
|
* New view helper: `parent_breadcrumb` returns the parent breadcrumb link (with `#key`, `#text`, and `#url`). This can for example be used to create a dynamic back link. You can supply options like `:autoroot` etc.
|
16
16
|
If you supply a block, it will yield the parent breadcrumb if it is present.
|
17
17
|
|
18
|
-
Version 2.1
|
19
|
-
-----------
|
18
|
+
# Version 2.1
|
20
19
|
* Breadcrumbs are now configured in `config/breadcrumbs.rb` and `config/breadcrumbs/**/*.rb` and reloaded when changed in the development environment instead of the initializer that required restart when configuration changed.
|
21
20
|
|
22
|
-
Version 2.0
|
23
|
-
-----------
|
21
|
+
# Version 2.0
|
24
22
|
|
25
23
|
* Totally rewritten for better structure.
|
26
24
|
* `options[:autoroot]` is now `true` by default which means it will automatically link to the `:root` breadcrumb if no parent is specified.
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Have fun! And please do write, if you (dis)like it – [lassebunk@gmail.com](mai
|
|
18
18
|
* New view helper: `parent_breadcrumb` returns the parent breadcrumb link (with `#key`, `#text`, and `#url`). This can for example be used to create a dynamic back link.
|
19
19
|
You can supply options like `:autoroot` etc.
|
20
20
|
If you supply a block, it will yield the parent breadcrumb if it is present.
|
21
|
-
* Breadcrumbs can now be inferred if you pass in an ActiveRecord model instance. E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
|
21
|
+
* Breadcrumbs can now be inferred if you pass in an instance of an object that responds to `model_name` (like an ActiveRecord model instance). E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
|
22
22
|
|
23
23
|
|
24
24
|
I hope you find these changes as useful as I did – if you have more suggestions, please create an [Issue](https://github.com/lassebunk/gretel/issues) or [Pull Request](https://github.com/lassebunk/gretel/pulls).
|
@@ -256,10 +256,19 @@ The format is the same as `config/breadcrumbs.rb` which is also loaded.
|
|
256
256
|
|
257
257
|
### Inferring breadcrumbs
|
258
258
|
|
259
|
-
Breadcrumbs can be automatically inferred if you pass
|
259
|
+
Breadcrumbs can be automatically inferred if you pass an instance of an object that responds to `model_name` (like an ActiveRecord model instance).
|
260
260
|
|
261
|
-
For example
|
261
|
+
For example:
|
262
262
|
|
263
|
+
```erb
|
264
|
+
<% breadcrumb @product %>
|
265
|
+
```
|
266
|
+
|
267
|
+
is short for
|
268
|
+
|
269
|
+
```erb
|
270
|
+
<% breadcrumb :product, @product %>
|
271
|
+
```
|
263
272
|
|
264
273
|
### Automatic reloading of breadcrumb configuration files
|
265
274
|
|
data/lib/gretel/version.rb
CHANGED
data/lib/gretel/view_helpers.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
module Gretel
|
2
2
|
module ViewHelpers
|
3
3
|
# Sets the current breadcrumb to be rendered elsewhere. Put it somewhere in the view, preferably in the top, before you render any breadcrumbs HTML:
|
4
|
-
#
|
5
|
-
# breadcrumb :category, @category
|
6
|
-
#
|
4
|
+
#
|
5
|
+
# <% breadcrumb :category, @category %>
|
6
|
+
#
|
7
|
+
# If you pass an instance of an object that responds to +model_name+ (like an ActiveRecord model instance), the breadcrumb can be automatically inferred, so a shortcut for the above would be:
|
8
|
+
#
|
9
|
+
# <% breadcrumb @category %>
|
7
10
|
def breadcrumb(key = nil, *args)
|
8
11
|
if key.nil? || key.is_a?(Hash)
|
9
12
|
raise ArgumentError, "The `breadcrumb` method was called with #{key.inspect} as the key. This method is used to set the breadcrumb. Maybe you meant to call the `breadcrumbs` method (with an 's' in the end) which is used to render the breadcrumbs?"
|
10
|
-
elsif key.
|
13
|
+
elsif key.class.respond_to?(:model_name)
|
11
14
|
# Enables calling `breadcrumb @product` instead of `breadcrumb :product, @product`
|
12
15
|
args.unshift key
|
13
16
|
key = key.class.model_name.to_s.underscore.to_sym
|
@@ -54,6 +57,10 @@ module Gretel
|
|
54
57
|
end
|
55
58
|
|
56
59
|
# Returns or yields parent breadcrumb (second-to-last in the trail) if it is present.
|
60
|
+
#
|
61
|
+
# <% parent_breadcrumb do |link| %>
|
62
|
+
# <%= link_to link.text, link.url %> (<%= link.key %>)
|
63
|
+
# <% end %>
|
57
64
|
def parent_breadcrumb(options = {}, &block)
|
58
65
|
if block_given?
|
59
66
|
gretel_renderer.yield_parent_breadcrumb(options, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gretel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|