rails_crumbs 0.0.2 → 1.0.0

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDk3NjEyZDJmMzQyNjc3YTFlZmE2MDk2MWRiY2UxZDc2ODI2MWJjNA==
4
+ MGNjZGU3NGM2MTFkYWQ3OTM1YmFiMWY0Zjc1NTA0M2JhYjA1NzFlNA==
5
5
  data.tar.gz: !binary |-
6
- YWJmNWI0NjhjMmUyYjU5MDQ2ZDQ3YjVjYTAwMTVjMDVmYzQ0MDU5NQ==
6
+ YTI3NDkyMDljMzBiZmNiMTU0MDUwODY0ZDhhZTczNTg5NDQ3NGRjMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjM5MWQ1ZDE0OTdkMzhhNTIwMjRhNTM2Njg3OWJiZTkwYzNkOWQxMThjNTQy
10
- YWIwOWE4MzE4ZDMxNzUxMjA1YWE3ZjlkMjYyNTQzZjM1OGEzOWY2OTAxZjNl
11
- NGNhNDc5NTM4MjJiZTNkZjEyMWMwNWU3NWI4ZThhZmI2ZTNkYzQ=
9
+ N2RjZGQ3NTk3Y2JhOWM4YjRmNDE0MzBiZTc3YzgxNjg0ZGJlYWY5NTcwOGEy
10
+ OWIxZjNiOTdhZjcwNzc3OGFhMmZjM2ZlODcxMmIxNjY4NmFkZjU4NjAzNjNl
11
+ ZjVhNzkzNDY0OWFlM2E0MDZhNzljYzYwNjc3YWY2YjYzNGFhODE=
12
12
  data.tar.gz: !binary |-
13
- ODlkNmRkNGM4NTk3YzNmMTVlYjFlMGVkYjIzNzM5ZTVmOWU3YWZkZjNkMjZh
14
- ZTExNDJmYzBlZTA3MjgxMGFjMmY0YTk5MjM2NThkYTUwMDNiNzAwN2FhZTRj
15
- YWU2ZDU3Yjg0ZDVmNWMyOWNjOGY0NjE3NDExNGVhMWNhMjljMWQ=
13
+ MGFkNzBkOGNlZWUyNTdlMGEwNWZiNWNmNDU2NzQzN2RlNDQyZTBiYThjNjhj
14
+ MGNhMGYxMDA3ZDY2Nzg5YmFjNGZlYzdjYjMxZmEwYTEyNjA0MjEyMWQzMjU4
15
+ ODlmZTJkZDU2YjJkYWU4MmQxY2FjZjYzMjk2YTNlMmFjMjM1MWI=
data/README.md CHANGED
@@ -1,24 +1,118 @@
1
1
  # Railscrumbs
2
2
 
3
- TODO: Write a gem description
3
+ *Railscrumbs* a simple Breadcrumbs navigation plugin for rails.
4
+
5
+ ## Requirements
6
+ * rails >= 3.1
4
7
 
5
8
  ## Installation
6
9
 
7
10
  Add this line to your application's Gemfile:
8
11
 
9
- gem 'Railscrumbs'
12
+ gem 'rails_crumbs'
10
13
 
11
14
  And then execute:
12
15
 
13
- $ bundle
16
+ $ bundle install
14
17
 
15
18
  Or install it yourself as:
16
19
 
17
- $ gem install Railscrumbs
20
+ $ gem install rails_crumbs
18
21
 
19
22
  ## Usage
20
23
 
21
- TODO: Write usage instructions here
24
+ In your controller, call `set_railscrumb` to push s new element to Railscrumbs stack.
25
+
26
+ class MyController < ApplicationController
27
+
28
+ def index
29
+ set_railscrumb 'My Controller', mycontroler_path
30
+ ...
31
+ end
32
+
33
+ end
34
+
35
+ Or if you can only some methods
36
+
37
+ class MyController < ApplicationController
38
+ set_railscrumb 'Home', :root_path
39
+ set_railscrumb 'My Controller', :some_path, :only => [:index, :new]
40
+
41
+ def index
42
+ ...
43
+ end
44
+
45
+ def show
46
+ @anything = ....
47
+ set_railscrumb @some.name, anything_path(@anything)
48
+
49
+ ...
50
+ end
51
+
52
+ def new
53
+ ...
54
+ end
55
+ end
56
+
57
+ to render the Railscrumb you can call on the `application.html.erb` file to Railscrumbs stack.
58
+
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>My Title</title>
65
+ </head>
66
+ <body>
67
+ <% @railscrumbs.each do |crumb| %>
68
+ <span><strong><%= crumb.name %></strong>
69
+ <%= ' >> ' unless crumb == @railscrumbs.last %></span>
70
+ <% end %>
71
+
72
+ <%= yield %>
73
+ </body>
74
+ </html>
75
+
76
+ ### Arguments
77
+
78
+ *set_railscrumb* requires two arguments:
79
+
80
+
81
+ *`name`: Name of the breadcrumb
82
+
83
+ *`path`: Target path, if your railscrumb are out of a method, you have to use a symbol (e.g :root_path ). in a method like 'show', you can use the helper method (e.g user_path(@user) or users_path )
84
+
85
+
86
+ #### optional arguments:
87
+
88
+ `only` the specification of the controller methods for the breadcrumb
89
+
90
+
91
+ #### custom arguments:
92
+
93
+ if you wanna have custom value for your breadcrumbs, you can pass the argument like `:custom => 'some value`
94
+ and use like `<%= @railscrumbs.first.custom %> `, this show 'some value'
95
+
96
+
97
+ for example if you wanna specify a icon value for the css you can pass like this
98
+
99
+ class MyController < ApplicationController
100
+
101
+ def index
102
+ set_railscrumb 'My Controller', mycontroler_path, :icon => 'mycontroller'
103
+
104
+ ...
105
+ end
106
+
107
+ end
108
+
109
+ and in `application.html.erb`:
110
+
111
+ <% @railscrumbs.each do |crumb| %>
112
+ <span><strong><i class="icon-<%= crumb.icon %>"></i><%= crumb.name %></strong>
113
+ <%= ' >> ' unless crumb == @railscrumbs.last %></span>
114
+ <% end %>
115
+
22
116
 
23
117
  ## Contributing
24
118
 
@@ -2,6 +2,14 @@ module RailsCrumbs
2
2
  module RailsCrumbsController
3
3
 
4
4
  def set_railscrumb(name, path, options = {})
5
+ case path
6
+ when Symbol
7
+ path = self.send(path)
8
+ when Proc
9
+ path = path.call(self)
10
+ else
11
+ path = self.url_for(path)
12
+ end
5
13
  self.railscrumbs << Crumb.new(name, path, options)
6
14
  end
7
15
 
@@ -14,6 +22,7 @@ module RailsCrumbs
14
22
  end
15
23
 
16
24
  module ClassMethods
25
+
17
26
  def set_railscrumb(name, path = nil, options = {})
18
27
  only = options.delete(:only){ [] }
19
28
  if only.empty?
@@ -7,7 +7,7 @@ module RailsCrumbs
7
7
  def initialize(name, path = nil, options = {})
8
8
  self.name = name
9
9
  self.path = path
10
- self.options = options
10
+ self.options = options
11
11
  end
12
12
 
13
13
  private
@@ -20,7 +20,5 @@ module RailsCrumbs
20
20
  end
21
21
  end
22
22
 
23
-
24
-
25
23
  end
26
24
  end
@@ -1,3 +1,3 @@
1
1
  module RailsCrumbs
2
- VERSION = '0.0.2'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_crumbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio Beckmann