has_breadcrumbs 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.textile +13 -22
- data/VERSION +1 -1
- data/init.rb +0 -1
- data/lib/breadcrumb.rb +9 -12
- data/lib/has_breadcrumbs.rb +2 -6
- metadata +17 -6
- data/has_breadcrumbs.gemspec +0 -52
data/MIT-LICENSE
CHANGED
data/README.textile
CHANGED
@@ -2,53 +2,44 @@ h1. has_breadcrumbs
|
|
2
2
|
|
3
3
|
has_breadcrumbs is a simple plugin that adds a breadcrumb object into controllers and views.
|
4
4
|
|
5
|
-
h2.
|
5
|
+
h2. Installation
|
6
6
|
|
7
|
-
|
7
|
+
Rails 2.3:
|
8
8
|
|
9
|
-
<pre>
|
10
|
-
Rails::Initializer.run do |config|
|
11
|
-
config.gem 'has_breadcrumbs'
|
12
|
-
end
|
13
|
-
</pre>
|
9
|
+
<pre>config.gem 'has_breadcrumbs'</pre>
|
14
10
|
|
15
|
-
|
11
|
+
Bundler:
|
12
|
+
|
13
|
+
<pre>gem 'has_breadcumbs'</pre>
|
16
14
|
|
17
15
|
h2. Usage
|
18
16
|
|
19
17
|
On your controller:
|
20
18
|
|
21
|
-
<pre>
|
22
|
-
|
23
|
-
before_filter :add_initial_breadcrumb
|
19
|
+
<pre>class ApplicationController < ActionController::Base
|
20
|
+
before_filter :add_home_breadcrumb
|
24
21
|
|
25
22
|
protected
|
26
23
|
|
27
|
-
def
|
24
|
+
def add_home_breadcrumb
|
28
25
|
breadcrumb.add 'Home', root_path
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
29
|
class PostsController < ApplicationController
|
33
30
|
def index
|
34
|
-
# you can also use << instead of add
|
35
31
|
breadcrumb.add 'Posts', posts_path
|
36
32
|
end
|
37
|
-
end
|
38
|
-
</pre>
|
33
|
+
end</pre>
|
39
34
|
|
40
35
|
You don't need to provide an URL; in that case, a span will be generated
|
41
36
|
instead of a link:
|
42
37
|
|
43
|
-
<pre>
|
44
|
-
breadcrumb.add 'Some page'
|
45
|
-
</pre>
|
38
|
+
<pre>breadcrumb.add 'Some page'</pre>
|
46
39
|
|
47
40
|
You can set additional HTML attributes if you need to:
|
48
41
|
|
49
|
-
<pre>
|
50
|
-
breadcrumb.add 'Home', root_path, :id => 'home', :title => 'Go to the home page'
|
51
|
-
</pre>
|
42
|
+
<pre>breadcrumb.add 'Home', root_path, :id => 'home', :title => 'Go to the home page'</pre>
|
52
43
|
|
53
44
|
On your view:
|
54
45
|
|
@@ -69,4 +60,4 @@ For a good css example take a look in examples folder.
|
|
69
60
|
|
70
61
|
This work is based on "http://github.com/fnando/has_breadcrumbs":http://github.com/fnando/has_breadcrumbs by Nando Vieira.
|
71
62
|
|
72
|
-
Adaptation made by Daniel Lopes and
|
63
|
+
Adaptation made by Daniel Lopes and Gabriel Sobrinho, under the MIT license.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/init.rb
CHANGED
data/lib/breadcrumb.rb
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
class Breadcrumb
|
2
2
|
include ActionView::Helpers::TagHelper
|
3
|
-
|
4
3
|
attr_accessor :items
|
5
4
|
|
6
5
|
def initialize
|
7
|
-
|
6
|
+
self.items = []
|
8
7
|
end
|
9
|
-
|
10
|
-
def add(name, url=nil, options={})
|
11
|
-
|
8
|
+
|
9
|
+
def add(name, url = nil, options = {})
|
10
|
+
items << [name, url, options]
|
12
11
|
end
|
13
12
|
|
14
|
-
alias :<< :add
|
15
|
-
|
16
13
|
def display
|
17
|
-
size =
|
14
|
+
size = items.size
|
18
15
|
|
19
|
-
crumbs =
|
16
|
+
crumbs = items.to_enum(:each_with_index).collect do |item, index|
|
20
17
|
name, url, options = item
|
21
18
|
|
22
19
|
options[:class] ||= ""
|
@@ -24,13 +21,13 @@ class Breadcrumb
|
|
24
21
|
options[:class] << " last" if size - 1 == index
|
25
22
|
options[:class].squish!
|
26
23
|
|
27
|
-
if url.nil?
|
24
|
+
if url.nil? or size - 1 == index
|
28
25
|
content_tag(:li, name, options)
|
29
26
|
else
|
30
27
|
content_tag(:li, content_tag(:a, name, :href => url), options)
|
31
28
|
end
|
32
29
|
end.join("\n")
|
33
|
-
|
34
|
-
content_tag(:ul, "\n#{crumbs}\n", :id=>"breadcrumbs")
|
30
|
+
|
31
|
+
content_tag(:ul, "\n#{crumbs}\n".html_safe, :id => "breadcrumbs")
|
35
32
|
end
|
36
33
|
end
|
data/lib/has_breadcrumbs.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "breadcrumb"
|
2
|
-
|
3
1
|
module Breadcrumbs
|
4
2
|
module ActionController
|
5
3
|
def self.included(base)
|
@@ -8,10 +6,8 @@ module Breadcrumbs
|
|
8
6
|
|
9
7
|
def breadcrumb
|
10
8
|
@breadcrumb ||= Breadcrumb.new
|
11
|
-
end
|
9
|
+
end
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
|
-
ActionController::Base.
|
16
|
-
include Breadcrumbs::ActionController
|
17
|
-
end
|
13
|
+
ActionController::Base.__send__(:include, Breadcrumbs::ActionController)
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_breadcrumbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Gabriel Sobrinho
|
@@ -11,7 +17,7 @@ autorequire:
|
|
11
17
|
bindir: bin
|
12
18
|
cert_chain: []
|
13
19
|
|
14
|
-
date: 2010-
|
20
|
+
date: 2010-06-14 00:00:00 -03:00
|
15
21
|
default_executable:
|
16
22
|
dependencies: []
|
17
23
|
|
@@ -31,7 +37,6 @@ files:
|
|
31
37
|
- examples/images/crumbs.gif
|
32
38
|
- examples/index.html
|
33
39
|
- examples/styles.css
|
34
|
-
- has_breadcrumbs.gemspec
|
35
40
|
- init.rb
|
36
41
|
- lib/breadcrumb.rb
|
37
42
|
- lib/has_breadcrumbs.rb
|
@@ -47,21 +52,27 @@ rdoc_options:
|
|
47
52
|
require_paths:
|
48
53
|
- lib
|
49
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
53
62
|
version: "0"
|
54
|
-
version:
|
55
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
56
65
|
requirements:
|
57
66
|
- - ">="
|
58
67
|
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
59
71
|
version: "0"
|
60
|
-
version:
|
61
72
|
requirements: []
|
62
73
|
|
63
74
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.3.
|
75
|
+
rubygems_version: 1.3.7
|
65
76
|
signing_key:
|
66
77
|
specification_version: 3
|
67
78
|
summary: has_breadcrumbs is a simple plugin that adds a `breadcrumb` object into controllers and views.
|
data/has_breadcrumbs.gemspec
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{has_breadcrumbs}
|
8
|
-
s.version = "0.1.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Gabriel Sobrinho", "Daniel Lopes", "Nando Vieira"]
|
12
|
-
s.date = %q{2010-01-20}
|
13
|
-
s.email = %q{gabriel.sobrinho@gmail.com}
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
"README.textile"
|
16
|
-
]
|
17
|
-
s.files = [
|
18
|
-
"MIT-LICENSE",
|
19
|
-
"README.textile",
|
20
|
-
"Rakefile",
|
21
|
-
"VERSION",
|
22
|
-
"examples/images/crumbs.gif",
|
23
|
-
"examples/index.html",
|
24
|
-
"examples/styles.css",
|
25
|
-
"has_breadcrumbs.gemspec",
|
26
|
-
"init.rb",
|
27
|
-
"lib/breadcrumb.rb",
|
28
|
-
"lib/has_breadcrumbs.rb",
|
29
|
-
"spec/has_breadcrumbs_spec.rb",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/sobrinho/has_breadcrumbs}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.5}
|
36
|
-
s.summary = %q{has_breadcrumbs is a simple plugin that adds a `breadcrumb` object into controllers and views.}
|
37
|
-
s.test_files = [
|
38
|
-
"spec/has_breadcrumbs_spec.rb",
|
39
|
-
"spec/spec_helper.rb"
|
40
|
-
]
|
41
|
-
|
42
|
-
if s.respond_to? :specification_version then
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
-
s.specification_version = 3
|
45
|
-
|
46
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
-
else
|
48
|
-
end
|
49
|
-
else
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|