rails-breadcrumbs 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rails-breadcrumbs.rb +36 -0
  2. metadata +64 -0
@@ -0,0 +1,36 @@
1
+ module Rails
2
+ module Breadcrumbs
3
+
4
+ class ActionController::Base
5
+
6
+ protected
7
+
8
+ def add_breadcrumb(name, url = '')
9
+ @breadcrumbs ||= []
10
+ url = send(url) if url.is_a?(Symbol)
11
+ @breadcrumbs << [name, url]
12
+ end
13
+
14
+ def self.add_breadcrumb(name, url, options = {})
15
+ before_filter options do |controller|
16
+ controller.send(:add_breadcrumb, name, url)
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ module Helper
23
+
24
+ def breadcrumbs(separator = "&rsaquo;")
25
+ @breadcrumbs.map do |txt, path|
26
+ link_to_unless (path.blank? || current_page?(path)), h(txt), path
27
+ end.join(" #{separator} ").html_safe
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ ActionController::Base.send(:include, Rails::Breadcrumbs)
36
+ ActionView::Base.send(:include, Rails::Breadcrumbs::Helper)
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-breadcrumbs
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Francesc Esplugas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-05 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description:
27
+ email: contact@francescesplugas.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - lib/rails-breadcrumbs.rb
36
+ homepage: https://github.com/fesplugas/rails-breadcrumbs
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.5
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: Breadcrumbs for Rails Applications
63
+ test_files: []
64
+