breadcrumbs_on_rails 1.0.1 → 2.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.
- data/CHANGELOG.rdoc +7 -0
- data/{LICENSE.rdoc → LICENSE} +3 -1
- data/README.rdoc +29 -64
- data/Rakefile +80 -31
- data/breadcrumbs_on_rails.gemspec +22 -19
- data/init.rb +1 -1
- data/lib/breadcrumbs_on_rails.rb +2 -2
- data/lib/breadcrumbs_on_rails/breadcrumbs.rb +11 -19
- data/lib/breadcrumbs_on_rails/controller_mixin.rb +18 -20
- data/lib/breadcrumbs_on_rails/railtie.rb +28 -0
- data/lib/breadcrumbs_on_rails/version.rb +3 -3
- data/test/test_helper.rb +15 -18
- data/test/{breadcrumbs_on_rails_test.rb → unit/breadcrumbs_on_rails_test.rb} +0 -0
- data/test/{builder_test.rb → unit/builder_test.rb} +2 -5
- data/test/{element_test.rb → unit/element_test.rb} +0 -0
- data/test/{simple_builder_test.rb → unit/simple_builder_test.rb} +2 -4
- metadata +53 -60
- data/Manifest +0 -16
- data/rails/init.rb +0 -5
data/CHANGELOG.rdoc
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
3
|
|
4
|
+
== Release 2.0.0
|
5
|
+
|
6
|
+
* FIXED: Invalid documentation for Element target in the controller class context (closes #2)
|
7
|
+
|
8
|
+
* CHANGED: Upgraded to Rails 3
|
9
|
+
|
10
|
+
|
4
11
|
== Release 1.0.1
|
5
12
|
|
6
13
|
* FIXED: Since the removal of rails/init.rb in 7278376ab77651e540e39552384ad9677e32ff7e, Rails fails to load the helpers.
|
data/{LICENSE.rdoc → LICENSE}
RENAMED
data/README.rdoc
CHANGED
@@ -1,61 +1,42 @@
|
|
1
1
|
= Breadcrumbs On Rails
|
2
2
|
|
3
|
-
BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.
|
3
|
+
*BreadcrumbsOnRails* is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.
|
4
4
|
It provides helpers for creating navigation elements with a flexible interface.
|
5
5
|
|
6
6
|
|
7
7
|
== Requirements
|
8
8
|
|
9
|
-
*
|
10
|
-
* Rails 2.2.x, 2.3.x or 3.0 (see section Rails 3 below)
|
9
|
+
* Rails 3
|
11
10
|
|
11
|
+
Please note
|
12
12
|
|
13
|
-
|
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.
|
14
15
|
|
15
|
-
=== As a Gem
|
16
16
|
|
17
|
-
|
18
|
-
The GEM is hosted on {RubyGems}[http://rubygems.org/gems/breadcrumbs_on_rails].
|
17
|
+
== Installation
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
==== Rails 2.2.x and 2.3.x
|
23
|
-
|
24
|
-
With Rails 2.2.x and 2.3.x, you need to specify the GEM dependency in your <tt>environment.rb</tt> file so that Rails will automatically include the library on startup.
|
19
|
+
"RubyGems":http://rubygems.org is the preferred way to install *BreadcrumbsOnRails* and the best way if you want install a stable version.
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
# other configurations
|
29
|
-
# ...
|
30
|
-
|
31
|
-
config.gem "breadcrumbs_on_rails"
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
==== Rails 3
|
21
|
+
$ gem install breadcrumbs_on_rails
|
36
22
|
|
37
|
-
|
23
|
+
Specify the Gem dependency in the "Bundler":http://gembundler.com Gemfile.
|
38
24
|
|
39
25
|
gem "breadcrumbs_on_rails"
|
40
26
|
|
41
|
-
|
42
|
-
=== As a Plugin
|
43
|
-
|
44
|
-
This is the preferred way if you want to live on the edge and install a development version.
|
45
|
-
|
46
|
-
$ script/plugin install git://github.com/weppos/breadcrumbs_on_rails.git
|
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.
|
47
28
|
|
48
29
|
|
49
30
|
== Usage
|
50
31
|
|
51
32
|
Creating a breadcrumb navigation menu in your Rails app using BreadcrumbsOnRails is really straightforward.
|
52
33
|
|
53
|
-
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.
|
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.
|
54
35
|
|
55
36
|
class MyController
|
56
37
|
|
57
|
-
add_breadcrumb "home", root_path
|
58
|
-
add_breadcrumb "my", my_path
|
38
|
+
add_breadcrumb "home", :root_path
|
39
|
+
add_breadcrumb "my", :my_path
|
59
40
|
|
60
41
|
def index
|
61
42
|
# ...
|
@@ -98,7 +79,6 @@ When you call <tt>add_breadcrumb</tt>, the method automatically creates a new <t
|
|
98
79
|
* Proc
|
99
80
|
* String
|
100
81
|
|
101
|
-
|
102
82
|
==== Symbol
|
103
83
|
|
104
84
|
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.
|
@@ -107,7 +87,7 @@ If the value is a Symbol, the library calls the corresponding method defined in
|
|
107
87
|
|
108
88
|
# The Name is set to the value returned by
|
109
89
|
# the :root_name method.
|
110
|
-
add_breadcrumb :root_name,
|
90
|
+
add_breadcrumb :root_name, "/"
|
111
91
|
|
112
92
|
protected
|
113
93
|
|
@@ -126,19 +106,19 @@ If the value is a Proc, the library calls the proc passing the current view cont
|
|
126
106
|
# The Name is set to the value returned by
|
127
107
|
# the :root_name method.
|
128
108
|
add_breadcrumb Proc.new { |c| c.my_helper_method },
|
129
|
-
|
109
|
+
"/"
|
130
110
|
|
131
111
|
end
|
132
112
|
|
133
113
|
==== String
|
134
114
|
|
135
|
-
If the value is a
|
115
|
+
If the value is a String, the library sets the <tt>Element</tt> attribute to the string value.
|
136
116
|
|
137
117
|
class MyController
|
138
118
|
|
139
119
|
# The Name is set to the value returned by
|
140
120
|
# the :root_name method.
|
141
|
-
add_breadcrumb "homepage", "
|
121
|
+
add_breadcrumb "homepage", "/"
|
142
122
|
|
143
123
|
end
|
144
124
|
|
@@ -151,12 +131,12 @@ In fact, behind the scenes this method uses a <tt>before_filter</tt> to store th
|
|
151
131
|
Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.
|
152
132
|
|
153
133
|
class PostsController < ApplicationController
|
154
|
-
add_breadcrumb "admin", admin_path
|
155
|
-
add_breadcrumb "posts, posts_path, :only => %w(index show)
|
134
|
+
add_breadcrumb "admin", :admin_path
|
135
|
+
add_breadcrumb "posts", :posts_path, :only => %w(index show)
|
156
136
|
end
|
157
137
|
|
158
138
|
class ApplicationController < ActionController::Base
|
159
|
-
add_breadcrumb "admin", admin_path, :if => :admin_controller?
|
139
|
+
add_breadcrumb "admin", :admin_path, :if => :admin_controller?
|
160
140
|
|
161
141
|
def admin_controller?
|
162
142
|
self.class.name =~ /^Admin(::|Controller)/
|
@@ -188,32 +168,15 @@ For example, if you want to localize your menu, define a new breadcrumbs node in
|
|
188
168
|
In your controller, use the <tt>I18n.t</tt> method.
|
189
169
|
|
190
170
|
class PostsController < ApplicationController
|
191
|
-
add_breadcrumb I18n.t("breadcrumbs.first"),
|
192
|
-
add_breadcrumb I18n.t("breadcrumbs.second"), second_path, :only => %w(second)
|
193
|
-
add_breadcrumb I18n.t("breadcrumbs.third"),
|
171
|
+
add_breadcrumb I18n.t("breadcrumbs.first"), :first_path
|
172
|
+
add_breadcrumb I18n.t("breadcrumbs.second"), :second_path, :only => %w(second)
|
173
|
+
add_breadcrumb I18n.t("breadcrumbs.third"), :third_path, :only => %w(third)
|
194
174
|
end
|
195
175
|
|
196
176
|
class ApplicationController < ActionController::Base
|
197
|
-
add_breadcrumb I18n.t("breadcrumbs.homepage"), root_path
|
198
|
-
end
|
199
|
-
|
200
|
-
=== Rails 3
|
201
|
-
|
202
|
-
This plugin is "partially" compatible with Rails 3.
|
203
|
-
The first attempt to create an unique release compatible with both Rails 2.x and Rails 3 failed
|
204
|
-
due to some Rails 3 internal changes
|
205
|
-
(see http://github.com/weppos/breadcrumbs_on_rails/commit/b25885ceb293193b6b264177769f003985df3bff).
|
206
|
-
|
207
|
-
This version is specifically packaged and tested against Rails 2.3.x,
|
208
|
-
but you can use it in a Rails 3 application by manually including the
|
209
|
-
<tt>BreadcrumbsOnRails::ControllerMixin</tt> mixin in your <tt>ApplicationController</tt>.
|
210
|
-
|
211
|
-
class ApplicationController < ActionController::Base
|
212
|
-
include BreadcrumbsOnRails::ControllerMixin
|
177
|
+
add_breadcrumb I18n.t("breadcrumbs.homepage"), :root_path
|
213
178
|
end
|
214
179
|
|
215
|
-
A Rails 3 version will be available very soon.
|
216
|
-
|
217
180
|
|
218
181
|
== Author
|
219
182
|
|
@@ -222,11 +185,13 @@ A Rails 3 version will be available very soon.
|
|
222
185
|
|
223
186
|
== Resources
|
224
187
|
|
225
|
-
* {Homepage}[http://
|
188
|
+
* {Homepage}[http://www.simonecarletti.com/code/breadcrumbs_on_rails]
|
189
|
+
* {Source}[http://github.com/weppos/breadcrumbs_on_rails]
|
190
|
+
* {API Documentation}[http://www.simonecarletti.com/code/breadcrumbs_on_rails/api/]
|
226
191
|
* {Bugs & Features}[http://github.com/weppos/breadcrumbs_on_rails/issues]
|
227
192
|
|
228
193
|
|
229
194
|
== License
|
230
195
|
|
231
|
-
Copyright (c) 2009-
|
232
|
-
|
196
|
+
BreadCrumbsOnRails is Copyright (c) 2009-2011 Simone Carletti.
|
197
|
+
This is Free Software distributed under the MIT license.
|
data/Rakefile
CHANGED
@@ -1,48 +1,97 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__) + "/lib")
|
2
|
-
|
3
1
|
require 'rubygems'
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
2
|
+
require 'bundler'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'hanna/rdoctask'
|
7
6
|
|
7
|
+
$:.unshift(File.dirname(__FILE__) + "/lib")
|
8
|
+
require 'breadcrumbs_on_rails/version'
|
8
9
|
|
9
|
-
|
10
|
+
|
11
|
+
PKG_NAME = ENV['PKG_NAME'] || "breadcrumbs_on_rails"
|
10
12
|
PKG_VERSION = ENV['PKG_VERSION'] || BreadcrumbsOnRails::VERSION
|
11
|
-
RUBYFORGE_PROJECT = nil
|
12
13
|
|
13
14
|
if ENV['SNAPSHOT'].to_i == 1
|
14
15
|
PKG_VERSION << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
|
15
16
|
end
|
16
17
|
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
# Run test by default.
|
20
|
+
task :default => :test
|
21
|
+
|
22
|
+
# This builds the actual gem. For details of what all these options
|
23
|
+
# mean, and other ones you can add, check the documentation here:
|
24
|
+
#
|
25
|
+
# http://rubygems.org/read/chapter/20
|
26
|
+
#
|
27
|
+
spec = Gem::Specification.new do |s|
|
28
|
+
s.name = PKG_NAME
|
29
|
+
s.version = PKG_VERSION
|
30
|
+
s.summary = "A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation."
|
31
|
+
s.description = "BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project."
|
29
32
|
|
30
|
-
|
33
|
+
s.author = "Simone Carletti"
|
34
|
+
s.email = "weppos@weppos.net"
|
35
|
+
s.homepage = "http://www.simonecarletti.com/code/breadcrumbs_on_rails"
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
# You should probably have a README of some kind. Change the filename
|
38
|
+
# as appropriate
|
39
|
+
s.extra_rdoc_files = Dir.glob("*.rdoc")
|
40
|
+
s.rdoc_options = %w( --main README.rdoc )
|
41
|
+
|
42
|
+
# Add any extra files to include in the gem (like your README)
|
43
|
+
s.files = %w( Rakefile LICENSE init.rb ) + Dir.glob("*.{rdoc,gemspec}") + Dir.glob("{lib,test,rails}/**/*")
|
44
|
+
s.require_paths = %w( lib )
|
45
|
+
|
46
|
+
s.add_development_dependency("bundler")
|
47
|
+
s.add_development_dependency("hanna")
|
48
|
+
s.add_development_dependency("rails", "~> 3.0.0")
|
49
|
+
s.add_development_dependency("mocha", "~> 0.9.10")
|
50
|
+
end
|
51
|
+
|
52
|
+
# This task actually builds the gem. We also regenerate a static
|
53
|
+
# .gemspec file, which is useful if something (i.e. GitHub) will
|
54
|
+
# be automatically building a gem for this project. If you're not
|
55
|
+
# using GitHub, edit as appropriate.
|
56
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
57
|
+
pkg.gem_spec = spec
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Build the gemspec file #{spec.name}.gemspec"
|
61
|
+
task :gemspec do
|
62
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
63
|
+
File.open(file, "w") {|f| f << spec.to_ruby }
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Remove any temporary products, including gemspec."
|
67
|
+
task :clean => [:clobber] do
|
68
|
+
rm "#{spec.name}.gemspec"
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Remove any generated file"
|
72
|
+
task :clobber => [:clobber_rdoc, :clobber_rcov, :clobber_package]
|
73
|
+
|
74
|
+
desc "Package the library and generates the gemspec"
|
75
|
+
task :package => [:gemspec]
|
76
|
+
|
77
|
+
|
78
|
+
# Run all the tests in the /test folder
|
79
|
+
Rake::TestTask.new do |t|
|
80
|
+
t.libs << "test"
|
81
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
82
|
+
t.verbose = true
|
83
|
+
end
|
34
84
|
|
35
|
-
|
85
|
+
# Generate documentation
|
86
|
+
Rake::RDocTask.new do |rd|
|
87
|
+
rd.main = "README.rdoc"
|
88
|
+
rd.rdoc_files.include("*.rdoc", "lib/**/*.rb")
|
89
|
+
rd.rdoc_dir = "rdoc"
|
36
90
|
end
|
37
91
|
|
38
92
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
CodeStatistics.new(["BreadcrumbsOnRails", "lib"],
|
44
|
-
["Tests", "test"]).to_s
|
45
|
-
end
|
46
|
-
rescue LoadError
|
47
|
-
puts "CodeStatistics (Rails) is not available"
|
93
|
+
desc "Publish documentation to the site"
|
94
|
+
task :publish_rdoc => [:clobber_rdoc, :rdoc] do
|
95
|
+
ENV["username"] || raise(ArgumentError, "Missing ssh username")
|
96
|
+
sh "rsync -avz --delete rdoc/ #{ENV["username"]}@code:/var/www/apps/code/#{PKG_NAME}/api"
|
48
97
|
end
|
@@ -2,36 +2,39 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{breadcrumbs_on_rails}
|
5
|
-
s.version = "
|
5
|
+
s.version = "2.0.0"
|
6
6
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">=
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = %q{
|
10
|
-
s.description = %q{
|
11
|
-
}
|
9
|
+
s.date = %q{2011-04-30}
|
10
|
+
s.description = %q{BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.}
|
12
11
|
s.email = %q{weppos@weppos.net}
|
13
|
-
s.extra_rdoc_files = ["CHANGELOG.rdoc", "
|
14
|
-
s.files = ["
|
15
|
-
s.homepage = %q{http://
|
16
|
-
s.rdoc_options = ["--
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
|
13
|
+
s.files = ["Rakefile", "LICENSE", "init.rb", "CHANGELOG.rdoc", "README.rdoc", "breadcrumbs_on_rails.gemspec", "lib/breadcrumbs_on_rails", "lib/breadcrumbs_on_rails/breadcrumbs.rb", "lib/breadcrumbs_on_rails/controller_mixin.rb", "lib/breadcrumbs_on_rails/railtie.rb", "lib/breadcrumbs_on_rails/version.rb", "lib/breadcrumbs_on_rails.rb", "test/test_helper.rb", "test/unit", "test/unit/breadcrumbs_on_rails_test.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb"]
|
14
|
+
s.homepage = %q{http://www.simonecarletti.com/code/breadcrumbs_on_rails}
|
15
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
16
|
s.require_paths = ["lib"]
|
18
|
-
s.rubygems_version = %q{1.
|
17
|
+
s.rubygems_version = %q{1.7.2}
|
19
18
|
s.summary = %q{A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.}
|
20
|
-
s.test_files = ["test/breadcrumbs_on_rails_test.rb", "test/builder_test.rb", "test/element_test.rb", "test/simple_builder_test.rb", "test/test_helper.rb"]
|
21
19
|
|
22
20
|
if s.respond_to? :specification_version then
|
23
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
21
|
s.specification_version = 3
|
25
22
|
|
26
|
-
if Gem::Version.new(Gem::
|
27
|
-
s.add_development_dependency(%q<
|
28
|
-
s.add_development_dependency(%q<
|
23
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
25
|
+
s.add_development_dependency(%q<hanna>, [">= 0"])
|
26
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.0"])
|
27
|
+
s.add_development_dependency(%q<mocha>, ["~> 0.9.10"])
|
29
28
|
else
|
30
|
-
s.add_dependency(%q<
|
31
|
-
s.add_dependency(%q<
|
29
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
30
|
+
s.add_dependency(%q<hanna>, [">= 0"])
|
31
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
32
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.10"])
|
32
33
|
end
|
33
34
|
else
|
34
|
-
s.add_dependency(%q<
|
35
|
-
s.add_dependency(%q<
|
35
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
36
|
+
s.add_dependency(%q<hanna>, [">= 0"])
|
37
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
38
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.10"])
|
36
39
|
end
|
37
40
|
end
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'breadcrumbs_on_rails'
|
data/lib/breadcrumbs_on_rails.rb
CHANGED
@@ -10,19 +10,19 @@
|
|
10
10
|
# License:: MIT License
|
11
11
|
#
|
12
12
|
#--
|
13
|
-
#
|
13
|
+
#
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
17
17
|
require 'breadcrumbs_on_rails/controller_mixin'
|
18
18
|
require 'breadcrumbs_on_rails/breadcrumbs'
|
19
19
|
require 'breadcrumbs_on_rails/version'
|
20
|
+
require 'breadcrumbs_on_rails/railtie'
|
20
21
|
|
21
22
|
|
22
23
|
module BreadcrumbsOnRails
|
23
24
|
|
24
25
|
NAME = 'Breadcrumbs on Rails'
|
25
26
|
GEM = 'breadcrumbs_on_rails'
|
26
|
-
AUTHORS = ['Simone Carletti <weppos@weppos.net>']
|
27
27
|
|
28
28
|
end
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# License:: MIT License
|
11
11
|
#
|
12
12
|
#--
|
13
|
-
#
|
13
|
+
#
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
@@ -26,20 +26,16 @@ module BreadcrumbsOnRails
|
|
26
26
|
# To create a custom Builder, just extend this class
|
27
27
|
# and implement the following abstract methods:
|
28
28
|
#
|
29
|
-
# render
|
30
|
-
# Renders and returns the collection of navigation elements
|
29
|
+
# * <tt>#render</tt>: Renders and returns the collection of navigation elements
|
31
30
|
#
|
32
31
|
class Builder
|
33
32
|
|
34
33
|
# Initializes a new Builder with <tt>context</tt>,
|
35
34
|
# <tt>element</tt> and <tt>options</tt>.
|
36
35
|
#
|
37
|
-
# context
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# The collection of Elements
|
41
|
-
# options::
|
42
|
-
# Hash with optional prefereces or settings to customize the rendering behavior
|
36
|
+
# * <tt>context</tt>: The view context, that is current Rails Template instance
|
37
|
+
# * <tt>elements</tt>: The collection of Elements
|
38
|
+
# * <tt>options</tt>: Hash with optional prefereces or settings to customize the rendering behavior
|
43
39
|
#
|
44
40
|
def initialize(context, elements, options = {})
|
45
41
|
@context = context
|
@@ -49,10 +45,7 @@ module BreadcrumbsOnRails
|
|
49
45
|
|
50
46
|
# Renders Elements and returns the Breadcrumb navigation for the view.
|
51
47
|
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# NotImplemented:: you should implement this method in your custom Builder.
|
55
|
-
#
|
48
|
+
# Raises <tt>NotImplemented</tt>: you should implement this method in your custom Builder.
|
56
49
|
def render
|
57
50
|
raise NotImplementedError
|
58
51
|
end
|
@@ -96,7 +89,7 @@ module BreadcrumbsOnRails
|
|
96
89
|
#
|
97
90
|
# The SimpleBuilder accepts a limited set of options.
|
98
91
|
# If you need more flexibility, create a custom Builder and
|
99
|
-
# pass the option :builder => BuilderClass to the render_breadcrumbs helper method.
|
92
|
+
# pass the option :builder => BuilderClass to the <tt>render_breadcrumbs</tt> helper method.
|
100
93
|
#
|
101
94
|
class SimpleBuilder < Builder
|
102
95
|
|
@@ -120,8 +113,7 @@ module BreadcrumbsOnRails
|
|
120
113
|
|
121
114
|
# = Element
|
122
115
|
#
|
123
|
-
# Represents a navigation element
|
124
|
-
# in the breadcrumb collection.
|
116
|
+
# Represents a navigation element in the breadcrumb collection.
|
125
117
|
#
|
126
118
|
class Element
|
127
119
|
|
@@ -133,7 +125,7 @@ module BreadcrumbsOnRails
|
|
133
125
|
end
|
134
126
|
|
135
127
|
end
|
136
|
-
|
128
|
+
|
137
129
|
end
|
138
|
-
|
139
|
-
end
|
130
|
+
|
131
|
+
end
|
@@ -10,22 +10,20 @@
|
|
10
10
|
# License:: MIT License
|
11
11
|
#
|
12
12
|
#--
|
13
|
-
#
|
13
|
+
#
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
17
17
|
module BreadcrumbsOnRails
|
18
18
|
|
19
19
|
module ControllerMixin
|
20
|
+
extend ActiveSupport::Concern
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
helper HelperMethods
|
27
|
-
helper_method :add_breadcrumb, :breadcrumbs
|
28
|
-
end
|
22
|
+
included do
|
23
|
+
extend ClassMethods
|
24
|
+
include InstanceMethods
|
25
|
+
helper HelperMethods
|
26
|
+
helper_method :add_breadcrumb, :breadcrumbs
|
29
27
|
end
|
30
28
|
|
31
29
|
module Utils
|
@@ -40,14 +38,14 @@ module BreadcrumbsOnRails
|
|
40
38
|
|
41
39
|
# This is an horrible method with an horrible name.
|
42
40
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
41
|
+
# convert_to_set_of_strings(nil, [:foo, :bar])
|
42
|
+
# # => nil
|
43
|
+
# convert_to_set_of_strings(true, [:foo, :bar])
|
44
|
+
# # => ["foo", "bar"]
|
45
|
+
# convert_to_set_of_strings(:foo, [:foo, :bar])
|
46
|
+
# # => ["foo"]
|
47
|
+
# convert_to_set_of_strings([:foo, :bar, :baz], [:foo, :bar])
|
48
|
+
# # => ["foo", "bar", "baz"]
|
51
49
|
#
|
52
50
|
def self.convert_to_set_of_strings(value, keys)
|
53
51
|
if value == true
|
@@ -92,9 +90,9 @@ module BreadcrumbsOnRails
|
|
92
90
|
|
93
91
|
def render_breadcrumbs(options = {}, &block)
|
94
92
|
builder = (options.delete(:builder) || Breadcrumbs::SimpleBuilder).new(self, breadcrumbs, options)
|
95
|
-
content = builder.render
|
93
|
+
content = builder.render.html_safe
|
96
94
|
if block_given?
|
97
|
-
|
95
|
+
capture(content, &block)
|
98
96
|
else
|
99
97
|
content
|
100
98
|
end
|
@@ -103,5 +101,5 @@ module BreadcrumbsOnRails
|
|
103
101
|
end
|
104
102
|
|
105
103
|
end
|
106
|
-
|
104
|
+
|
107
105
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# = Breadcrumbs On Rails
|
3
|
+
#
|
4
|
+
# A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Category:: Rails
|
8
|
+
# Package:: BreadcrumbsOnRails
|
9
|
+
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
+
# License:: MIT License
|
11
|
+
#
|
12
|
+
#--
|
13
|
+
#
|
14
|
+
#++
|
15
|
+
|
16
|
+
|
17
|
+
module BreadcrumbsOnRails
|
18
|
+
|
19
|
+
class Railtie < Rails::Railtie
|
20
|
+
initializer "breadcrumbs_on_rails.initialize" do
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
ActiveSupport.on_load(:action_controller) do
|
27
|
+
include BreadcrumbsOnRails::ControllerMixin
|
28
|
+
end
|
@@ -10,16 +10,16 @@
|
|
10
10
|
# License:: MIT License
|
11
11
|
#
|
12
12
|
#--
|
13
|
-
#
|
13
|
+
#
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
17
17
|
module BreadcrumbsOnRails
|
18
18
|
|
19
19
|
module Version
|
20
|
-
MAJOR =
|
20
|
+
MAJOR = 2
|
21
21
|
MINOR = 0
|
22
|
-
PATCH =
|
22
|
+
PATCH = 0
|
23
23
|
BUILD = nil
|
24
24
|
|
25
25
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
data/test/test_helper.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
gem 'mocha', '~>0.9.7'
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha'
|
4
3
|
|
5
|
-
|
6
|
-
# Rails 2.2.x requires Mocha 0.9.5 and
|
7
|
-
# Rails 2.3.x requires Mocha 0.9.7
|
8
|
-
# gem 'rails', '2.2.2'
|
9
|
-
# gem 'mocha', '0.9.5'
|
4
|
+
ENV["RAILS_ENV"] = "test"
|
10
5
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
|
6
|
+
require "active_support"
|
7
|
+
require "action_controller"
|
8
|
+
require "rails/railtie"
|
9
|
+
|
10
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
11
|
+
require 'breadcrumbs_on_rails'
|
15
12
|
|
16
|
-
|
17
|
-
require File.dirname(__FILE__) + '/../init.rb'
|
13
|
+
ActionController::Base.view_paths = File.join(File.dirname(__FILE__), 'views')
|
18
14
|
|
19
|
-
|
20
|
-
|
15
|
+
BreadcrumbsOnRails::Routes = ActionDispatch::Routing::RouteSet.new
|
16
|
+
BreadcrumbsOnRails::Routes.draw do
|
17
|
+
match ':controller(/:action(/:id))'
|
18
|
+
end
|
21
19
|
|
22
|
-
ActionController::Base.
|
23
|
-
ActionController::Routing::Routes.reload rescue nil
|
20
|
+
ActionController::Base.send :include, BreadcrumbsOnRails::Routes.url_helpers
|
File without changes
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
3
|
class BuilderTest < ActiveSupport::TestCase
|
5
4
|
|
6
|
-
|
5
|
+
Template = Class.new do
|
7
6
|
include ActionView::Helpers::TagHelper
|
8
7
|
include ActionView::Helpers::UrlHelper
|
9
8
|
|
@@ -28,12 +27,10 @@ class BuilderTest < ActiveSupport::TestCase
|
|
28
27
|
def proc_for_path
|
29
28
|
"http://localhost/#proc"
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
33
|
-
|
34
31
|
|
35
32
|
def setup
|
36
|
-
@template =
|
33
|
+
@template = Template.new
|
37
34
|
@element = BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, nil)
|
38
35
|
end
|
39
36
|
|
File without changes
|
@@ -3,14 +3,13 @@ require 'test_helper'
|
|
3
3
|
|
4
4
|
class SimpleBuilderTest < ActionView::TestCase
|
5
5
|
|
6
|
-
|
6
|
+
Template = Class.new do
|
7
7
|
include ActionView::Helpers::TagHelper
|
8
8
|
include ActionView::Helpers::UrlHelper
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
11
|
def setup
|
13
|
-
@template =
|
12
|
+
@template = Template.new
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_render_should_be_implemented
|
@@ -71,5 +70,4 @@ class SimpleBuilderTest < ActionView::TestCase
|
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
|
-
|
75
73
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadcrumbs_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 1.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 2.0.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Simone Carletti
|
@@ -14,38 +10,53 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
13
|
+
date: 2011-04-30 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
-
prerelease: false
|
16
|
+
name: bundler
|
23
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
24
19
|
requirements:
|
25
|
-
- -
|
20
|
+
- - ">="
|
26
21
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
- 8
|
30
|
-
- 7
|
31
|
-
version: 0.8.7
|
22
|
+
version: "0"
|
32
23
|
type: :development
|
24
|
+
prerelease: false
|
33
25
|
version_requirements: *id001
|
34
26
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
36
|
-
prerelease: false
|
27
|
+
name: hanna
|
37
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
38
30
|
requirements:
|
39
|
-
- -
|
31
|
+
- - ">="
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 3
|
43
|
-
- 2
|
44
|
-
- 0
|
45
|
-
version: 3.2.0
|
33
|
+
version: "0"
|
46
34
|
type: :development
|
35
|
+
prerelease: false
|
47
36
|
version_requirements: *id002
|
48
|
-
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rails
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 3.0.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mocha
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.9.10
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id004
|
59
|
+
description: BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.
|
49
60
|
email: weppos@weppos.net
|
50
61
|
executables: []
|
51
62
|
|
@@ -53,69 +64,51 @@ extensions: []
|
|
53
64
|
|
54
65
|
extra_rdoc_files:
|
55
66
|
- CHANGELOG.rdoc
|
56
|
-
- LICENSE.rdoc
|
57
67
|
- README.rdoc
|
58
|
-
- lib/breadcrumbs_on_rails.rb
|
59
|
-
- lib/breadcrumbs_on_rails/breadcrumbs.rb
|
60
|
-
- lib/breadcrumbs_on_rails/controller_mixin.rb
|
61
|
-
- lib/breadcrumbs_on_rails/version.rb
|
62
68
|
files:
|
63
|
-
- CHANGELOG.rdoc
|
64
|
-
- LICENSE.rdoc
|
65
|
-
- Manifest
|
66
|
-
- README.rdoc
|
67
69
|
- Rakefile
|
70
|
+
- LICENSE
|
68
71
|
- init.rb
|
69
|
-
-
|
72
|
+
- CHANGELOG.rdoc
|
73
|
+
- README.rdoc
|
74
|
+
- breadcrumbs_on_rails.gemspec
|
70
75
|
- lib/breadcrumbs_on_rails/breadcrumbs.rb
|
71
76
|
- lib/breadcrumbs_on_rails/controller_mixin.rb
|
77
|
+
- lib/breadcrumbs_on_rails/railtie.rb
|
72
78
|
- lib/breadcrumbs_on_rails/version.rb
|
73
|
-
-
|
74
|
-
- test/breadcrumbs_on_rails_test.rb
|
75
|
-
- test/builder_test.rb
|
76
|
-
- test/element_test.rb
|
77
|
-
- test/simple_builder_test.rb
|
79
|
+
- lib/breadcrumbs_on_rails.rb
|
78
80
|
- test/test_helper.rb
|
79
|
-
-
|
80
|
-
|
81
|
-
|
81
|
+
- test/unit/breadcrumbs_on_rails_test.rb
|
82
|
+
- test/unit/builder_test.rb
|
83
|
+
- test/unit/element_test.rb
|
84
|
+
- test/unit/simple_builder_test.rb
|
85
|
+
homepage: http://www.simonecarletti.com/code/breadcrumbs_on_rails
|
82
86
|
licenses: []
|
83
87
|
|
84
88
|
post_install_message:
|
85
89
|
rdoc_options:
|
86
|
-
- --line-numbers
|
87
|
-
- --inline-source
|
88
|
-
- --title
|
89
|
-
- Breadcrumbs_on_rails
|
90
90
|
- --main
|
91
91
|
- README.rdoc
|
92
92
|
require_paths:
|
93
93
|
- lib
|
94
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
95
96
|
requirements:
|
96
97
|
- - ">="
|
97
98
|
- !ruby/object:Gem::Version
|
98
|
-
segments:
|
99
|
-
- 0
|
100
99
|
version: "0"
|
101
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
102
|
requirements:
|
103
103
|
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
- 1
|
107
|
-
- 2
|
108
|
-
version: "1.2"
|
105
|
+
version: "0"
|
109
106
|
requirements: []
|
110
107
|
|
111
108
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.7.2
|
113
110
|
signing_key:
|
114
111
|
specification_version: 3
|
115
112
|
summary: A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
|
116
|
-
test_files:
|
117
|
-
|
118
|
-
- test/builder_test.rb
|
119
|
-
- test/element_test.rb
|
120
|
-
- test/simple_builder_test.rb
|
121
|
-
- test/test_helper.rb
|
113
|
+
test_files: []
|
114
|
+
|
data/Manifest
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
CHANGELOG.rdoc
|
2
|
-
LICENSE.rdoc
|
3
|
-
Manifest
|
4
|
-
README.rdoc
|
5
|
-
Rakefile
|
6
|
-
init.rb
|
7
|
-
lib/breadcrumbs_on_rails.rb
|
8
|
-
lib/breadcrumbs_on_rails/breadcrumbs.rb
|
9
|
-
lib/breadcrumbs_on_rails/controller_mixin.rb
|
10
|
-
lib/breadcrumbs_on_rails/version.rb
|
11
|
-
rails/init.rb
|
12
|
-
test/breadcrumbs_on_rails_test.rb
|
13
|
-
test/builder_test.rb
|
14
|
-
test/element_test.rb
|
15
|
-
test/simple_builder_test.rb
|
16
|
-
test/test_helper.rb
|