breadcrumbs_on_rails 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -6
- data/.travis.yml +12 -0
- data/Appraisals +11 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +22 -8
- data/Gemfile.lock +76 -58
- data/LICENSE +1 -1
- data/README.md +99 -0
- data/Rakefile +13 -20
- data/breadcrumbs_on_rails.gemspec +13 -13
- data/gemfiles/3.0.gemfile +7 -0
- data/gemfiles/3.0.gemfile.lock +100 -0
- data/gemfiles/3.1.gemfile +7 -0
- data/gemfiles/3.1.gemfile.lock +100 -0
- data/gemfiles/3.2.gemfile +7 -0
- data/gemfiles/3.2.gemfile.lock +100 -0
- data/lib/breadcrumbs_on_rails.rb +2 -2
- data/lib/breadcrumbs_on_rails/{controller_mixin.rb → action_controller.rb} +12 -15
- data/lib/breadcrumbs_on_rails/breadcrumbs.rb +1 -1
- data/lib/breadcrumbs_on_rails/railtie.rb +2 -2
- data/lib/breadcrumbs_on_rails/version.rb +2 -2
- data/test/unit/builder_test.rb +51 -55
- data/test/unit/simple_builder_test.rb +9 -13
- metadata +30 -22
- data/README.rdoc +0 -205
@@ -2,15 +2,11 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class SimpleBuilderTest < ActionView::TestCase
|
4
4
|
|
5
|
-
Template = Class.new do
|
6
|
-
include ActionView::Helpers::TagHelper
|
7
|
-
include ActionView::Helpers::UrlHelper
|
8
|
-
end
|
9
|
-
|
10
5
|
def setup
|
11
|
-
@template =
|
6
|
+
@template = self
|
12
7
|
end
|
13
8
|
|
9
|
+
|
14
10
|
def test_render_should_be_implemented
|
15
11
|
assert_nothing_raised { simplebuilder(@template, []).render }
|
16
12
|
end
|
@@ -59,14 +55,14 @@ class SimpleBuilderTest < ActionView::TestCase
|
|
59
55
|
|
60
56
|
protected
|
61
57
|
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
def simplebuilder(*args)
|
59
|
+
BreadcrumbsOnRails::Breadcrumbs::SimpleBuilder.new(*args)
|
60
|
+
end
|
65
61
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
62
|
+
def generate_elements(number)
|
63
|
+
(1..number).collect do |index|
|
64
|
+
BreadcrumbsOnRails::Breadcrumbs::Element.new("Element #{index}", "/element/#{index}")
|
70
65
|
end
|
66
|
+
end
|
71
67
|
|
72
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadcrumbs_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: rails
|
16
|
+
requirement: &70311920950420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
21
|
+
version: '3.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70311920950420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: appraisal
|
27
|
+
requirement: &70311920948980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,29 +32,29 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70311920948980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: mocha
|
38
|
+
requirement: &70311920940920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 0.9.10
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70311920940920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: yard
|
49
|
+
requirement: &70311920940160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70311920940160
|
58
58
|
description: BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and
|
59
59
|
managing a breadcrumb navigation for a Rails project.
|
60
60
|
email: weppos@weppos.net
|
@@ -63,17 +63,25 @@ extensions: []
|
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
65
|
- .gitignore
|
66
|
-
-
|
66
|
+
- .travis.yml
|
67
|
+
- Appraisals
|
68
|
+
- CHANGELOG.md
|
67
69
|
- Gemfile
|
68
70
|
- Gemfile.lock
|
69
71
|
- LICENSE
|
70
|
-
- README.
|
72
|
+
- README.md
|
71
73
|
- Rakefile
|
72
74
|
- breadcrumbs_on_rails.gemspec
|
75
|
+
- gemfiles/3.0.gemfile
|
76
|
+
- gemfiles/3.0.gemfile.lock
|
77
|
+
- gemfiles/3.1.gemfile
|
78
|
+
- gemfiles/3.1.gemfile.lock
|
79
|
+
- gemfiles/3.2.gemfile
|
80
|
+
- gemfiles/3.2.gemfile.lock
|
73
81
|
- init.rb
|
74
82
|
- lib/breadcrumbs_on_rails.rb
|
83
|
+
- lib/breadcrumbs_on_rails/action_controller.rb
|
75
84
|
- lib/breadcrumbs_on_rails/breadcrumbs.rb
|
76
|
-
- lib/breadcrumbs_on_rails/controller_mixin.rb
|
77
85
|
- lib/breadcrumbs_on_rails/railtie.rb
|
78
86
|
- lib/breadcrumbs_on_rails/version.rb
|
79
87
|
- test/test_helper.rb
|
@@ -100,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
108
|
version: '0'
|
101
109
|
requirements: []
|
102
110
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.11
|
104
112
|
signing_key:
|
105
113
|
specification_version: 3
|
106
114
|
summary: A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
data/README.rdoc
DELETED
@@ -1,205 +0,0 @@
|
|
1
|
-
= Breadcrumbs On Rails
|
2
|
-
|
3
|
-
*BreadcrumbsOnRails* is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.
|
4
|
-
It provides helpers for creating navigation elements with a flexible interface.
|
5
|
-
|
6
|
-
|
7
|
-
== Requirements
|
8
|
-
|
9
|
-
* Rails 3
|
10
|
-
|
11
|
-
Please note
|
12
|
-
|
13
|
-
* BreadcrumbsOnRails 2.x requires Rails 3. Use BreadcrumbsOnRails 1.x with Rails 2.
|
14
|
-
* BreadcrumbsOnRails doesn't work with Rails 2.1 or lower.
|
15
|
-
|
16
|
-
|
17
|
-
== Installation
|
18
|
-
|
19
|
-
"RubyGems":http://rubygems.org is the preferred way to install *BreadcrumbsOnRails* and the best way if you want install a stable version.
|
20
|
-
|
21
|
-
$ gem install breadcrumbs_on_rails
|
22
|
-
|
23
|
-
Specify the Gem dependency in the "Bundler":http://gembundler.com Gemfile.
|
24
|
-
|
25
|
-
gem "breadcrumbs_on_rails"
|
26
|
-
|
27
|
-
Use "Bundler":http://gembundler.com and the ":git option":http://gembundler.com/v1.0/git.html if you want to grab the latest version from the Git repository.
|
28
|
-
|
29
|
-
|
30
|
-
== Usage
|
31
|
-
|
32
|
-
Creating a breadcrumb navigation menu in your Rails app using BreadcrumbsOnRails is really straightforward.
|
33
|
-
|
34
|
-
In your controller, call <tt>add_breadcrumb</tt> to push a new element on the breadcrumb stack. <tt>add_breadcrumb</tt> requires two arguments: the name of the breadcrumb and the target path. See the section "Breadcrumb Element" for more details about name and target class types.
|
35
|
-
|
36
|
-
class MyController
|
37
|
-
|
38
|
-
add_breadcrumb "home", :root_path
|
39
|
-
add_breadcrumb "my", :my_path
|
40
|
-
|
41
|
-
def index
|
42
|
-
# ...
|
43
|
-
|
44
|
-
add_breadcrumb "index", index_path
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
The third, optional argument is a Hash of options to customize the breadcrumb link.
|
50
|
-
|
51
|
-
class MyController
|
52
|
-
def index
|
53
|
-
add_breadcrumb "index", index_path, :title => "Back to the Index"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
In your view, you can render the breadcrumb menu with the <tt>render_breadcrumbs</tt> helper.
|
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>untitled</title>
|
65
|
-
</head>
|
66
|
-
|
67
|
-
<body>
|
68
|
-
<%= render_breadcrumbs %>
|
69
|
-
</body>
|
70
|
-
</html>
|
71
|
-
|
72
|
-
<tt>render_breadcrumbs</tt> understands a limited set of options. For example, you can pass change the default separator with the <tt>:separator</tt> option.
|
73
|
-
|
74
|
-
<body>
|
75
|
-
<%= render_breadcrumbs :separator => ' / ' %>
|
76
|
-
</body>
|
77
|
-
|
78
|
-
More complex customizations require a custom Builder (documentation yet to come).
|
79
|
-
|
80
|
-
=== Breadcrumb Element
|
81
|
-
|
82
|
-
A breadcrumbs menu is composed by a number of <tt>Element</tt> objects. Each object contains two attributes: the name of the breadcrumb and the target path.
|
83
|
-
|
84
|
-
When you call <tt>add_breadcrumb</tt>, the method automatically creates a new <tt>Element</tt> object for you and append it to the breadcrumbs stack. <tt>Element</tt> name and path can be one of the following Ruby types:
|
85
|
-
|
86
|
-
* Symbol
|
87
|
-
* Proc
|
88
|
-
* String
|
89
|
-
|
90
|
-
==== Symbol
|
91
|
-
|
92
|
-
If the value is a Symbol, the library calls the corresponding method defined in the same context the and sets the <tt>Element</tt> attribute to the returned value.
|
93
|
-
|
94
|
-
class MyController
|
95
|
-
|
96
|
-
# The Name is set to the value returned by
|
97
|
-
# the :root_name method.
|
98
|
-
add_breadcrumb :root_name, "/"
|
99
|
-
|
100
|
-
protected
|
101
|
-
|
102
|
-
def root_name
|
103
|
-
"the name"
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
==== Proc
|
109
|
-
|
110
|
-
If the value is a Proc, the library calls the proc passing the current view context as argument and sets the <tt>Element</tt> attribute to the returned value. This is useful if you want to postpone the execution to get access to some special methods/variables created in your controller action.
|
111
|
-
|
112
|
-
class MyController
|
113
|
-
|
114
|
-
# The Name is set to the value returned by
|
115
|
-
# the :root_name method.
|
116
|
-
add_breadcrumb Proc.new { |c| c.my_helper_method },
|
117
|
-
"/"
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
==== String
|
122
|
-
|
123
|
-
If the value is a String, the library sets the <tt>Element</tt> attribute to the string value.
|
124
|
-
|
125
|
-
class MyController
|
126
|
-
|
127
|
-
# The Name is set to the value returned by
|
128
|
-
# the :root_name method.
|
129
|
-
add_breadcrumb "homepage", "/"
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
=== Restricting breadcrumb scope
|
135
|
-
|
136
|
-
The <tt>add_breadcrumb</tt> method understands all options you are used to pass to a Rails controller filter.
|
137
|
-
In fact, behind the scenes this method uses a <tt>before_filter</tt> to store the tab in the <tt>@breadcrumbs</tt> variable.
|
138
|
-
|
139
|
-
Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.
|
140
|
-
|
141
|
-
class PostsController < ApplicationController
|
142
|
-
add_breadcrumb "admin", :admin_path
|
143
|
-
add_breadcrumb "posts", :posts_path, :only => %w(index show)
|
144
|
-
end
|
145
|
-
|
146
|
-
class ApplicationController < ActionController::Base
|
147
|
-
add_breadcrumb "admin", :admin_path, :if => :admin_controller?
|
148
|
-
|
149
|
-
def admin_controller?
|
150
|
-
self.class.name =~ /^Admin(::|Controller)/
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
=== Internationalization and Localization
|
155
|
-
|
156
|
-
BreadcrumbsOnRails is compatible with the standard Rails internationalization framework.
|
157
|
-
|
158
|
-
For example, if you want to localize your menu, define a new breadcrumbs node in your .yml file with all the keys for your elements.
|
159
|
-
|
160
|
-
# config/locales/en.yml
|
161
|
-
en:
|
162
|
-
breadcrumbs:
|
163
|
-
homepage: Homepage
|
164
|
-
first: First
|
165
|
-
second: Second
|
166
|
-
third: Third
|
167
|
-
|
168
|
-
# config/locales/it.yml
|
169
|
-
it:
|
170
|
-
breadcrumbs:
|
171
|
-
homepage: Homepage
|
172
|
-
first: Primo
|
173
|
-
second: Secondo
|
174
|
-
third: Terzo
|
175
|
-
|
176
|
-
In your controller, use the <tt>I18n.t</tt> method.
|
177
|
-
|
178
|
-
class PostsController < ApplicationController
|
179
|
-
add_breadcrumb I18n.t("breadcrumbs.first"), :first_path
|
180
|
-
add_breadcrumb I18n.t("breadcrumbs.second"), :second_path, :only => %w(second)
|
181
|
-
add_breadcrumb I18n.t("breadcrumbs.third"), :third_path, :only => %w(third)
|
182
|
-
end
|
183
|
-
|
184
|
-
class ApplicationController < ActionController::Base
|
185
|
-
add_breadcrumb I18n.t("breadcrumbs.homepage"), :root_path
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
== Author
|
190
|
-
|
191
|
-
* {Simone Carletti}[http://www.simonecarletti.com] <weppos@weppos.net>
|
192
|
-
|
193
|
-
|
194
|
-
== Resources
|
195
|
-
|
196
|
-
* {Homepage}[http://www.simonecarletti.com/code/breadcrumbs_on_rails]
|
197
|
-
* {Source}[http://github.com/weppos/breadcrumbs_on_rails]
|
198
|
-
* {API Documentation}[http://rubydoc.info/gems/breadcrumbs_on_rails]
|
199
|
-
* {Bugs & Features}[http://github.com/weppos/breadcrumbs_on_rails/issues]
|
200
|
-
|
201
|
-
|
202
|
-
== License
|
203
|
-
|
204
|
-
BreadCrumbsOnRails is Copyright (c) 2009-2011 Simone Carletti.
|
205
|
-
This is Free Software distributed under the MIT license.
|