breadcrumble 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,6 +17,7 @@ Or install it yourself as:
17
17
  $ gem install breadcrumble
18
18
 
19
19
  ## Usage
20
+ ### Controller
20
21
  In your controller, call `add_crumb` to push a new crumb on the breadcrumb stack.
21
22
 
22
23
  class SampleController
@@ -30,12 +31,24 @@ In your controller, call `add_crumb` to push a new crumb on the breadcrumb stack
30
31
 
31
32
  end
32
33
 
34
+ Second arugment passed url_for method for convenient use, except specify nil.
35
+
36
+ ### View
33
37
  In your view, you can render the breadcrumb navigation with the `render_breadcrumbs` helper.
34
38
 
35
39
  <body>
36
40
  <%= render_breadcrumbs %>
37
41
  </body>
38
42
 
43
+ ### Customizing layout
44
+ Breadcrumble generates default partial template for your app.
45
+
46
+ Generate template. Run the follwoing.
47
+
48
+ $ rails g breadcrumble:views
49
+
50
+ then edit the partials in your app's `app/views/breadcrumble/` directory.
51
+
39
52
  ## Contributing
40
53
 
41
54
  1. Fork it
@@ -2,7 +2,12 @@
2
2
  <% breadcrumbs.each_with_index do |crumb, i| %>
3
3
  <%= '>' unless i == 0 %>
4
4
  <span itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
5
- <%= link_to_unless_current content_tag(:span, crumb[:name], itemprop: "title"), crumb[:url], itemprop: "url" %>
5
+ <% span_title = content_tag(:span, crumb[:name], itemprop: "title") %>
6
+ <% if crumb[:url] == nil %>
7
+ <%= span_title %>
8
+ <% else %>
9
+ <%= link_to_unless_current span_title, crumb[:url], itemprop: "url" %>
10
+ <% end %>
6
11
  </span>
7
12
  <% end %>
8
13
  </div>
@@ -6,7 +6,7 @@ module Breadcrumble
6
6
  end
7
7
 
8
8
  module ClassMethods
9
- def add_crumb name, url
9
+ def add_crumb name, url = nil
10
10
  before_filter do |controller|
11
11
  controller.send :add_crumb, name, url
12
12
  end
@@ -15,10 +15,9 @@ module Breadcrumble
15
15
 
16
16
  protected
17
17
 
18
- def add_crumb(name, url = '')
18
+ def add_crumb name, url = nil
19
19
  @breadcrumbs ||= []
20
- @breadcrumbs << { name: name, url: url }
21
- puts @breadcrumbs
20
+ @breadcrumbs << { name: name, url: url ? url_for(url) : nil }
22
21
  end
23
22
 
24
23
  def breadcrumbs
@@ -1,3 +1,3 @@
1
1
  module Breadcrumble
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breadcrumble
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-02 00:00:00.000000000 Z
12
+ date: 2012-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails