breadcrumbs_rails 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 +7 -0
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +143 -0
- data/badges/license.svg +1 -0
- data/badges/ruby.svg +1 -0
- data/breadcrumbs_rails.gemspec +26 -0
- data/lib/breadcrumbs_rails.rb +8 -0
- data/lib/breadcrumbs_rails/action_controller.rb +158 -0
- data/lib/breadcrumbs_rails/railtie.rb +11 -0
- data/lib/breadcrumbs_rails/version.rb +3 -0
- data/readme.md +82 -0
- metadata +98 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 481a041e6639cb0a33b985322c02c98dcc60a496fd528f2cf647406b479057a7
|
|
4
|
+
data.tar.gz: 368657c68d3be4bfd57105a8c6764a7dbad3f13831207c6a4840d0298194663c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b7828dc371a46f67aacda7a74d93854603791f4afec2f6ce6ac1270003b9e34ddc5491439530fa7fbe899b58f3307b5bc275ce97c9fc01cea0f17835e07af20c
|
|
7
|
+
data.tar.gz: 19553a7b9208d91ee61a86a77097ede252c3e9e843c43f089e2f86ce7ba4a8a25cb0812ad397efef1279e4fa90f421d81dbe7e3b8747daaaeceec87accf07671
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
breadcrumbs_rails (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
actioncable (6.0.3.4)
|
|
10
|
+
actionpack (= 6.0.3.4)
|
|
11
|
+
nio4r (~> 2.0)
|
|
12
|
+
websocket-driver (>= 0.6.1)
|
|
13
|
+
actionmailbox (6.0.3.4)
|
|
14
|
+
actionpack (= 6.0.3.4)
|
|
15
|
+
activejob (= 6.0.3.4)
|
|
16
|
+
activerecord (= 6.0.3.4)
|
|
17
|
+
activestorage (= 6.0.3.4)
|
|
18
|
+
activesupport (= 6.0.3.4)
|
|
19
|
+
mail (>= 2.7.1)
|
|
20
|
+
actionmailer (6.0.3.4)
|
|
21
|
+
actionpack (= 6.0.3.4)
|
|
22
|
+
actionview (= 6.0.3.4)
|
|
23
|
+
activejob (= 6.0.3.4)
|
|
24
|
+
mail (~> 2.5, >= 2.5.4)
|
|
25
|
+
rails-dom-testing (~> 2.0)
|
|
26
|
+
actionpack (6.0.3.4)
|
|
27
|
+
actionview (= 6.0.3.4)
|
|
28
|
+
activesupport (= 6.0.3.4)
|
|
29
|
+
rack (~> 2.0, >= 2.0.8)
|
|
30
|
+
rack-test (>= 0.6.3)
|
|
31
|
+
rails-dom-testing (~> 2.0)
|
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
33
|
+
actiontext (6.0.3.4)
|
|
34
|
+
actionpack (= 6.0.3.4)
|
|
35
|
+
activerecord (= 6.0.3.4)
|
|
36
|
+
activestorage (= 6.0.3.4)
|
|
37
|
+
activesupport (= 6.0.3.4)
|
|
38
|
+
nokogiri (>= 1.8.5)
|
|
39
|
+
actionview (6.0.3.4)
|
|
40
|
+
activesupport (= 6.0.3.4)
|
|
41
|
+
builder (~> 3.1)
|
|
42
|
+
erubi (~> 1.4)
|
|
43
|
+
rails-dom-testing (~> 2.0)
|
|
44
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
45
|
+
activejob (6.0.3.4)
|
|
46
|
+
activesupport (= 6.0.3.4)
|
|
47
|
+
globalid (>= 0.3.6)
|
|
48
|
+
activemodel (6.0.3.4)
|
|
49
|
+
activesupport (= 6.0.3.4)
|
|
50
|
+
activerecord (6.0.3.4)
|
|
51
|
+
activemodel (= 6.0.3.4)
|
|
52
|
+
activesupport (= 6.0.3.4)
|
|
53
|
+
activestorage (6.0.3.4)
|
|
54
|
+
actionpack (= 6.0.3.4)
|
|
55
|
+
activejob (= 6.0.3.4)
|
|
56
|
+
activerecord (= 6.0.3.4)
|
|
57
|
+
marcel (~> 0.3.1)
|
|
58
|
+
activesupport (6.0.3.4)
|
|
59
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
60
|
+
i18n (>= 0.7, < 2)
|
|
61
|
+
minitest (~> 5.1)
|
|
62
|
+
tzinfo (~> 1.1)
|
|
63
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
|
64
|
+
builder (3.2.4)
|
|
65
|
+
concurrent-ruby (1.1.7)
|
|
66
|
+
crass (1.0.6)
|
|
67
|
+
erubi (1.10.0)
|
|
68
|
+
globalid (0.4.2)
|
|
69
|
+
activesupport (>= 4.2.0)
|
|
70
|
+
i18n (1.8.5)
|
|
71
|
+
concurrent-ruby (~> 1.0)
|
|
72
|
+
loofah (2.8.0)
|
|
73
|
+
crass (~> 1.0.2)
|
|
74
|
+
nokogiri (>= 1.5.9)
|
|
75
|
+
mail (2.7.1)
|
|
76
|
+
mini_mime (>= 0.1.1)
|
|
77
|
+
marcel (0.3.3)
|
|
78
|
+
mimemagic (~> 0.3.2)
|
|
79
|
+
method_source (1.0.0)
|
|
80
|
+
mimemagic (0.3.5)
|
|
81
|
+
mini_mime (1.0.2)
|
|
82
|
+
mini_portile2 (2.4.0)
|
|
83
|
+
minitest (5.14.2)
|
|
84
|
+
nio4r (2.5.4)
|
|
85
|
+
nokogiri (1.10.10)
|
|
86
|
+
mini_portile2 (~> 2.4.0)
|
|
87
|
+
rack (2.2.3)
|
|
88
|
+
rack-test (1.1.0)
|
|
89
|
+
rack (>= 1.0, < 3)
|
|
90
|
+
rails (6.0.3.4)
|
|
91
|
+
actioncable (= 6.0.3.4)
|
|
92
|
+
actionmailbox (= 6.0.3.4)
|
|
93
|
+
actionmailer (= 6.0.3.4)
|
|
94
|
+
actionpack (= 6.0.3.4)
|
|
95
|
+
actiontext (= 6.0.3.4)
|
|
96
|
+
actionview (= 6.0.3.4)
|
|
97
|
+
activejob (= 6.0.3.4)
|
|
98
|
+
activemodel (= 6.0.3.4)
|
|
99
|
+
activerecord (= 6.0.3.4)
|
|
100
|
+
activestorage (= 6.0.3.4)
|
|
101
|
+
activesupport (= 6.0.3.4)
|
|
102
|
+
bundler (>= 1.3.0)
|
|
103
|
+
railties (= 6.0.3.4)
|
|
104
|
+
sprockets-rails (>= 2.0.0)
|
|
105
|
+
rails-dom-testing (2.0.3)
|
|
106
|
+
activesupport (>= 4.2.0)
|
|
107
|
+
nokogiri (>= 1.6)
|
|
108
|
+
rails-html-sanitizer (1.3.0)
|
|
109
|
+
loofah (~> 2.3)
|
|
110
|
+
railties (6.0.3.4)
|
|
111
|
+
actionpack (= 6.0.3.4)
|
|
112
|
+
activesupport (= 6.0.3.4)
|
|
113
|
+
method_source
|
|
114
|
+
rake (>= 0.8.7)
|
|
115
|
+
thor (>= 0.20.3, < 2.0)
|
|
116
|
+
rake (13.0.1)
|
|
117
|
+
sprockets (4.0.2)
|
|
118
|
+
concurrent-ruby (~> 1.0)
|
|
119
|
+
rack (> 1, < 3)
|
|
120
|
+
sprockets-rails (3.2.2)
|
|
121
|
+
actionpack (>= 4.0)
|
|
122
|
+
activesupport (>= 4.0)
|
|
123
|
+
sprockets (>= 3.0.0)
|
|
124
|
+
thor (1.0.1)
|
|
125
|
+
thread_safe (0.3.6)
|
|
126
|
+
tzinfo (1.2.8)
|
|
127
|
+
thread_safe (~> 0.1)
|
|
128
|
+
websocket-driver (0.7.3)
|
|
129
|
+
websocket-extensions (>= 0.1.0)
|
|
130
|
+
websocket-extensions (0.1.5)
|
|
131
|
+
zeitwerk (2.4.1)
|
|
132
|
+
|
|
133
|
+
PLATFORMS
|
|
134
|
+
ruby
|
|
135
|
+
|
|
136
|
+
DEPENDENCIES
|
|
137
|
+
breadcrumbs_rails!
|
|
138
|
+
bundler
|
|
139
|
+
rails (>= 3.0)
|
|
140
|
+
rake
|
|
141
|
+
|
|
142
|
+
BUNDLED WITH
|
|
143
|
+
2.1.2
|
data/badges/license.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="112" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="112" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h47v20H0z"/><path fill="#4c1" d="M47 0h65v20H47z"/><path fill="url(#b)" d="M0 0h112v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="245" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="370">license</text><text x="245" y="140" transform="scale(.1)" textLength="370">license</text><text x="785" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="550">CC BY 4.0</text><text x="785" y="140" transform="scale(.1)" textLength="550">CC BY 4.0</text></g> </svg>
|
data/badges/ruby.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="84" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="84" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h37v20H0z"/><path fill="#007ec6" d="M37 0h47v20H37z"/><path fill="url(#b)" d="M0 0h84v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">Ruby</text><text x="195" y="140" transform="scale(.1)" textLength="270">Ruby</text><text x="595" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="370">1.9.3+</text><text x="595" y="140" transform="scale(.1)" textLength="370">1.9.3+</text></g> </svg>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
2
|
+
require 'breadcrumbs_rails/version'
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = 'breadcrumbs_rails'
|
|
6
|
+
s.version = BreadcrumbsRails::VERSION.dup
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.authors = 'EdCordata'
|
|
9
|
+
s.description = 'Rails breadcrumbs gem'
|
|
10
|
+
s.summary = 'Rails breadcrumbs gem'
|
|
11
|
+
s.licenses = ['CC BY 4.0']
|
|
12
|
+
s.require_paths = %w(lib)
|
|
13
|
+
s.files = `git ls-files`.split("\n")
|
|
14
|
+
s.homepage = 'https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails'
|
|
15
|
+
s.require_paths = ['lib']
|
|
16
|
+
s.required_ruby_version = '>= 1.9.3'
|
|
17
|
+
s.rubygems_version = '1.6.2'
|
|
18
|
+
s.metadata = {
|
|
19
|
+
'documentation_uri' => 'https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails/blob/master/readme.md',
|
|
20
|
+
'source_code_uri' => 'https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails',
|
|
21
|
+
'bug_tracker_uri' => 'https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails/issues'
|
|
22
|
+
}
|
|
23
|
+
s.add_development_dependency 'rake'
|
|
24
|
+
s.add_development_dependency 'bundler'
|
|
25
|
+
s.add_development_dependency 'rails', '>= 3.0'
|
|
26
|
+
end
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
module BreadcrumbsRails
|
|
2
|
+
module ActionController
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# -----------------------------------------------------------
|
|
7
|
+
included do |base|
|
|
8
|
+
extend ClassMethods
|
|
9
|
+
helper HelperMethods
|
|
10
|
+
|
|
11
|
+
helper_method :add_breadcrumb, :breadcrumbs_gem
|
|
12
|
+
|
|
13
|
+
unless base.respond_to?(:before_action)
|
|
14
|
+
base.alias_method :before_action, :before_filter
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
# -----------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# -----------------------------------------------------------
|
|
24
|
+
def add_breadcrumb(name, options = {})
|
|
25
|
+
url_helpers = Rails.application.routes.url_helpers
|
|
26
|
+
|
|
27
|
+
if options[:path]
|
|
28
|
+
options[:path] = if url_helpers.methods.include?(options[:path])
|
|
29
|
+
url_helpers.send(options[:path])
|
|
30
|
+
else
|
|
31
|
+
options[:path]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
self.breadcrumbs_gem[:breadcrumbs] << {
|
|
36
|
+
name: name,
|
|
37
|
+
path: options[:path].to_s,
|
|
38
|
+
params: options[:params] || {},
|
|
39
|
+
title: options[:title],
|
|
40
|
+
html_safe: options[:html_safe] == true
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
self.breadcrumbs_gem[:localize] = options[:localize] == true unless options[:localize].nil?
|
|
44
|
+
self.breadcrumbs_gem[:html_safe] = options[:html_safe] == true unless options[:html_safe].nil?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def breadcrumbs_gem
|
|
48
|
+
@breadcrumbs_gem ||= { breadcrumbs: [], scope: nil, localize: false }
|
|
49
|
+
end
|
|
50
|
+
# -----------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Class Methods
|
|
54
|
+
# -----------------------------------------------------------
|
|
55
|
+
module ClassMethods
|
|
56
|
+
|
|
57
|
+
def add_breadcrumb(name, options = {})
|
|
58
|
+
before_action(options) do |controller|
|
|
59
|
+
controller.send(:add_breadcrumb, name, options)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
# -----------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# Helper Methods
|
|
68
|
+
# -----------------------------------------------------------
|
|
69
|
+
module HelperMethods
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def render_breadcrumbs_title(default = nil)
|
|
73
|
+
return default if breadcrumbs_gem[:breadcrumbs].last[:title].nil?
|
|
74
|
+
return '' if breadcrumbs_gem[:breadcrumbs].last[:title].to_s.blank?
|
|
75
|
+
|
|
76
|
+
if breadcrumbs_gem[:localize]
|
|
77
|
+
I18n.t(breadcrumbs_gem[:breadcrumbs].last[:title])
|
|
78
|
+
else
|
|
79
|
+
breadcrumbs_gem[:breadcrumbs].last[:title]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def render_breadcrumbs(options = {}, &block)
|
|
85
|
+
format = (options[:format] || :html).to_sym
|
|
86
|
+
|
|
87
|
+
if block_given?
|
|
88
|
+
yield(breadcrumbs_gem)
|
|
89
|
+
else
|
|
90
|
+
|
|
91
|
+
case format
|
|
92
|
+
|
|
93
|
+
when :html
|
|
94
|
+
content_tag(:ul) do
|
|
95
|
+
breadcrumbs_gem[:breadcrumbs].map do |breadcrumb|
|
|
96
|
+
concat content_tag(:li, breadcrumbs_name_or_link(breadcrumbs_gem, breadcrumb))
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
when :bootstrap
|
|
101
|
+
content_tag(:ul, class: 'pagination') do
|
|
102
|
+
breadcrumbs_gem[:breadcrumbs].map do |breadcrumb|
|
|
103
|
+
concat content_tag(:li, breadcrumbs_name_or_link(breadcrumbs_gem, breadcrumb))
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
when :inspinia
|
|
108
|
+
html = ''
|
|
109
|
+
html << '<div class="row wrapper border-bottom white-bg page-heading">'
|
|
110
|
+
html << ' <div class="col-lg-9">'
|
|
111
|
+
html << (render_breadcrumbs_title ? "<h2>#{render_breadcrumbs_title}</h2>" : '<br/>')
|
|
112
|
+
html << ' <ol class="breadcrumb">'
|
|
113
|
+
|
|
114
|
+
breadcrumbs_gem[:breadcrumbs].each_with_index do |breadcrumb, index|
|
|
115
|
+
if (index + 1) == breadcrumbs_gem[:breadcrumbs].length
|
|
116
|
+
html << "<li class='active'><strong>#{breadcrumbs_name_or_link(breadcrumbs_gem, breadcrumb)}</strong></li>"
|
|
117
|
+
else
|
|
118
|
+
html << "<li>#{breadcrumbs_name_or_link(breadcrumbs_gem, breadcrumb)}</li>"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
html << ' </ol>'
|
|
123
|
+
html << ' </div>'
|
|
124
|
+
html << '</div>'
|
|
125
|
+
html.html_safe
|
|
126
|
+
|
|
127
|
+
else
|
|
128
|
+
raise "Breadcrumbs-rails: unknown format '#{format.to_s}'"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
private
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def breadcrumbs_name_or_link(breadcrumbs_gem, breadcrumb)
|
|
139
|
+
return '' if breadcrumb[:name].to_s.blank?
|
|
140
|
+
|
|
141
|
+
name = (breadcrumbs_gem[:localize] ? I18n.t(breadcrumb[:name]) : breadcrumb[:name])
|
|
142
|
+
name = CGI::escapeHTML(name) unless breadcrumb[:html_safe] # escape name as we call html_safe
|
|
143
|
+
|
|
144
|
+
if breadcrumb[:path].to_s.blank?
|
|
145
|
+
name.html_safe
|
|
146
|
+
else
|
|
147
|
+
url = Rails.application.routes.url_helpers.send(breadcrumb[:path].to_s, breadcrumb[:params])
|
|
148
|
+
link_to(name.html_safe, url)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
end
|
|
154
|
+
# -----------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module BreadcrumbsRails
|
|
2
|
+
class Railtie < Rails::Railtie
|
|
3
|
+
|
|
4
|
+
ActiveSupport.on_load(:action_controller) do
|
|
5
|
+
::ActionController::Base.send(:include, BreadcrumbsRails::ActionController)
|
|
6
|
+
views_path = "#{File.dirname(__FILE__)}/../generators/breadcrumbs/templates/app/views/breadcrumbs"
|
|
7
|
+
::ActionController::Base.prepend_view_path(views_path)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
end
|
data/readme.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Breadcrumbs Rails
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://creativecommons.org/licenses/by/4.0/)
|
|
5
|
+
|
|
6
|
+
Breadcrumbs rails is easy way to create breadcrumbs from controllers and render them in view. This gem also
|
|
7
|
+
includes functionality to easily change title.
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
As usual, add to Gemfile:
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'breadcrumbs_rails'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
and run:
|
|
17
|
+
```bash
|
|
18
|
+
$ bundle install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Introduction
|
|
23
|
+
|
|
24
|
+
Syntax is `add_breadcrumb(name, options)`
|
|
25
|
+
Available options:
|
|
26
|
+
* `html_safe` - (type: boolean, default: false) - specifies if title is html safe and shouldn't be escaped
|
|
27
|
+
* `:path` - (type: string, default: nil) - link path as string. It must be a string, not symbol
|
|
28
|
+
* `:params` - (type: hash, default: {}) - params to pass to `:path`
|
|
29
|
+
* `:title` - (type: string, default: nil) - title for `:render_breadcrumbs_title` method
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Usage
|
|
34
|
+
|
|
35
|
+
In controllers
|
|
36
|
+
```ruby
|
|
37
|
+
class ApplicationController < ActionController::Base
|
|
38
|
+
add_breadcrumb 'Home', path: 'root_path', params: { locale: 'en' }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class UsersController < ApplicationController
|
|
42
|
+
add_breadcrumb 'Users', path: 'users_path', params: { locale: 'en' }, title: 'Users'
|
|
43
|
+
|
|
44
|
+
def edit
|
|
45
|
+
add_breadcrumb('User')
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you want to use translations, do it like so:
|
|
51
|
+
```ruby
|
|
52
|
+
class ApplicationController < ActionController::Base
|
|
53
|
+
add_breadcrumb 'links.home', path: 'root_path', params: { locale: 'en' }, title: '', localize: true # Only name is required
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class UsersController < ApplicationController
|
|
57
|
+
add_breadcrumb 'links.users', path: 'users_path', params: { locale: 'en' }, title: 'Users'
|
|
58
|
+
|
|
59
|
+
def edit
|
|
60
|
+
add_breadcrumb('links.user')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Rendering breadcrumbs
|
|
66
|
+
Default format is `:html`. Available: `:html`, `:bootstrap`, `:inspinia`.
|
|
67
|
+
```haml
|
|
68
|
+
= render_breadcrumbs(format: :html)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or by using block:
|
|
72
|
+
```haml
|
|
73
|
+
- render_breadcrumbs do |renderer|
|
|
74
|
+
- renderer[:breadcrumbs].each do |breadcrumb|
|
|
75
|
+
%li= link_to_if breadcrumb[:path], breadcrumb[:name], breadcrumb[:path]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### To use `title` functionality:
|
|
79
|
+
```haml
|
|
80
|
+
%html
|
|
81
|
+
%title= render_breadcrumbs_title
|
|
82
|
+
```
|
metadata
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: breadcrumbs_rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- EdCordata
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rails
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: Rails breadcrumbs gem
|
|
56
|
+
email:
|
|
57
|
+
executables: []
|
|
58
|
+
extensions: []
|
|
59
|
+
extra_rdoc_files: []
|
|
60
|
+
files:
|
|
61
|
+
- ".gitignore"
|
|
62
|
+
- Gemfile
|
|
63
|
+
- Gemfile.lock
|
|
64
|
+
- badges/license.svg
|
|
65
|
+
- badges/ruby.svg
|
|
66
|
+
- breadcrumbs_rails.gemspec
|
|
67
|
+
- lib/breadcrumbs_rails.rb
|
|
68
|
+
- lib/breadcrumbs_rails/action_controller.rb
|
|
69
|
+
- lib/breadcrumbs_rails/railtie.rb
|
|
70
|
+
- lib/breadcrumbs_rails/version.rb
|
|
71
|
+
- readme.md
|
|
72
|
+
homepage: https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails
|
|
73
|
+
licenses:
|
|
74
|
+
- CC BY 4.0
|
|
75
|
+
metadata:
|
|
76
|
+
documentation_uri: https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails/blob/master/readme.md
|
|
77
|
+
source_code_uri: https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails
|
|
78
|
+
bug_tracker_uri: https://github.com/EdCordata-Ruby-Gems/breadcrumbs_rails/issues
|
|
79
|
+
post_install_message:
|
|
80
|
+
rdoc_options: []
|
|
81
|
+
require_paths:
|
|
82
|
+
- lib
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: 1.9.3
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
requirements: []
|
|
94
|
+
rubygems_version: 3.1.2
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: Rails breadcrumbs gem
|
|
98
|
+
test_files: []
|