gretel 2.2.0.rc1 → 2.2.0.rc2
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/.travis.yml +0 -1
- data/README.md +10 -2
- data/lib/gretel/trail.rb +3 -3
- data/lib/gretel/version.rb +1 -1
- data/test/helper_methods_test.rb +3 -3
- data/test/trail_test.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63912baa8d7b8687330b6469ca18b82fef24a6d9
|
|
4
|
+
data.tar.gz: 93e5d1939577261f3ee204f6874749c4675d4c41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d99b7fe134a685a49f6eb4b6d167ebe9e6c22134e2851fac27f3bee17159ab51bd5290a9647400a64b0a52470630e31305a62443469b29983e792036e0ed2ac
|
|
7
|
+
data.tar.gz: f17fdfdc5ab2a03578230b8d5c00b48b3094a611234621facbba87448c96b896b202e6ddc102d275583d6fa725b144f427a1c0f6c12eec9168f2f57d09a3bc26
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -205,10 +205,10 @@ If you supply a block to the `breadcrumbs` method, it will yield an array with t
|
|
|
205
205
|
<% end %>
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
Setting
|
|
208
|
+
Setting breadcrumb trails
|
|
209
209
|
--------------------------------
|
|
210
210
|
|
|
211
|
-
You can set a
|
|
211
|
+
You can set a breadcrumb trail via `params[:trail]`. This makes it possible to link to a different breadcrumb trail than the one specified in your breadcrumb.
|
|
212
212
|
|
|
213
213
|
An example is if you have a store with products that have a default parent to their category, but when linking from the review section, you want to link back to the reviews instead.
|
|
214
214
|
|
|
@@ -247,6 +247,14 @@ Gretel has a built-in view helper method named `breadcrumb_trail` that contains
|
|
|
247
247
|
|
|
248
248
|
The product view will now have the breadcrumb trail from the first page (reviews) instead of its default parent.
|
|
249
249
|
|
|
250
|
+
### Custom trail param
|
|
251
|
+
|
|
252
|
+
The default trail param is `params[:trail]`. You can change it in an initializer:
|
|
253
|
+
|
|
254
|
+
```ruby
|
|
255
|
+
Gretel::Trail.trail_param = :other_param
|
|
256
|
+
```
|
|
257
|
+
|
|
250
258
|
### Note
|
|
251
259
|
|
|
252
260
|
Please use the trail functionality with care; the trails can get very long.
|
data/lib/gretel/trail.rb
CHANGED
|
@@ -50,13 +50,13 @@ module Gretel
|
|
|
50
50
|
# Encodes links array to Base64, internally using YAML for serialization.
|
|
51
51
|
def encode_base64(links)
|
|
52
52
|
arr = links.map { |link| [link.key, link.text, link.url] }
|
|
53
|
-
Base64.urlsafe_encode64(arr.
|
|
53
|
+
Base64.urlsafe_encode64(arr.to_json)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# Decodes links array from Base64.
|
|
57
57
|
def decode_base64(base64)
|
|
58
|
-
|
|
59
|
-
arr =
|
|
58
|
+
json = Base64.urlsafe_decode64(base64)
|
|
59
|
+
arr = JSON.parse(json)
|
|
60
60
|
arr.map { |key, text, url| Link.new(key, text, url) }
|
|
61
61
|
rescue
|
|
62
62
|
Rails.logger.info "[Gretel] Trail decode failed: Invalid Base64 '#{base64}' in trail"
|
data/lib/gretel/version.rb
CHANGED
data/test/helper_methods_test.rb
CHANGED
|
@@ -181,11 +181,11 @@ class HelperMethodsTest < ActionView::TestCase
|
|
|
181
181
|
test "trail helper" do
|
|
182
182
|
breadcrumb :basic
|
|
183
183
|
|
|
184
|
-
assert_equal "
|
|
184
|
+
assert_equal "12MoG3DY5eLzU_W1siYmFzaWMiLCJBYm91dCIsIi9hYm91dCJdXQ==", breadcrumb_trail
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
test "loading trail" do
|
|
188
|
-
params[:trail] = "
|
|
188
|
+
params[:trail] = "12MoG3DY5eLzU_W1siYmFzaWMiLCJBYm91dCIsIi9hYm91dCJdXQ=="
|
|
189
189
|
breadcrumb :multiple_links
|
|
190
190
|
|
|
191
191
|
assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> > <a href="/about">About</a> > <a href="/about/contact">Contact</a> > <span class="current">Contact form</span></div>},
|
|
@@ -194,7 +194,7 @@ class HelperMethodsTest < ActionView::TestCase
|
|
|
194
194
|
|
|
195
195
|
test "different trail param" do
|
|
196
196
|
Gretel::Trail.trail_param = :mytest
|
|
197
|
-
params[:mytest] = "
|
|
197
|
+
params[:mytest] = "12MoG3DY5eLzU_W1siYmFzaWMiLCJBYm91dCIsIi9hYm91dCJdXQ=="
|
|
198
198
|
breadcrumb :multiple_links
|
|
199
199
|
|
|
200
200
|
assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> > <a href="/about">About</a> > <a href="/about/contact">Contact</a> > <span class="current">Contact form</span></div>},
|
data/test/trail_test.rb
CHANGED
|
@@ -15,16 +15,16 @@ class TrailTest < ActiveSupport::TestCase
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
test "encoding" do
|
|
18
|
-
assert_equal "
|
|
18
|
+
assert_equal "122.5Th13fvkg_W1sicm9vdCIsIkhvbWUiLCIvIl0sWyJzdG9yZSIsIlN0b3JlIiwiL3N0b3JlIl0sWyJzZWFyY2giLCJTZWFyY2giLCIvc3RvcmUvc2VhcmNoP3E9dGVzdCJdXQ==",
|
|
19
19
|
Gretel::Trail.encode(@links.map { |key, text, url| Gretel::Link.new(key, text, url) })
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
test "decoding" do
|
|
23
23
|
assert_equal @links,
|
|
24
|
-
Gretel::Trail.decode("
|
|
24
|
+
Gretel::Trail.decode("122.5Th13fvkg_W1sicm9vdCIsIkhvbWUiLCIvIl0sWyJzdG9yZSIsIlN0b3JlIiwiL3N0b3JlIl0sWyJzZWFyY2giLCJTZWFyY2giLCIvc3RvcmUvc2VhcmNoP3E9dGVzdCJdXQ==").map { |link| [link.key, link.text, link.url] }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
test "invalid trail" do
|
|
28
|
-
assert_equal [], Gretel::Trail.decode("
|
|
28
|
+
assert_equal [], Gretel::Trail.decode("122.5Th13fvkg_X1sicm9vdCIsIkhvbWUiLCIvIl0sWyJzdG9yZSIsIlN0b3JlIiwiL3N0b3JlIl0sWyJzZWFyY2giLCJTZWFyY2giLCIvc3RvcmUvc2VhcmNoP3E9dGVzdCJdXQ==")
|
|
29
29
|
end
|
|
30
30
|
end
|