crummy 1.1.0 → 1.1.1
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/README.textile +10 -8
- data/VERSION +1 -1
- data/lib/crummy/standard_renderer.rb +12 -11
- metadata +6 -6
data/README.textile
CHANGED
@@ -41,17 +41,17 @@ In your controllers you may add_crumb either like a before_filter or within a me
|
|
41
41
|
class ApplicationController
|
42
42
|
add_crumb "Home", '/'
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
class BusinessController < ApplicationController
|
46
46
|
add_crumb("Businesses") { |instance| instance.send :businesses_path }
|
47
47
|
add_crumb("Comments", :only => "comments") { |instance| instance.send :businesses_comments_path }
|
48
48
|
before_filter :load_comment, :only => "show"
|
49
49
|
add_crumb :comment, :only => "show"
|
50
|
-
|
50
|
+
|
51
51
|
def show
|
52
52
|
add_crumb @business.display_name, @business
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def load_comment
|
56
56
|
@comment = Comment.find(params[:id])
|
57
57
|
end
|
@@ -77,20 +77,20 @@ The output format. Can either be :xml or :html. Defaults to :html
|
|
77
77
|
|
78
78
|
<code>:format => (:html|:xml)</code>
|
79
79
|
|
80
|
-
The
|
80
|
+
The separator text. It does not assume you want spaces on either side so you must specify. Defaults to <code>»</code> for :html and <code><crumb></code> for :xml
|
81
81
|
|
82
|
-
<code>:
|
82
|
+
<code>:separator => string</code>
|
83
83
|
|
84
84
|
Render links in the output. Defaults to +true+
|
85
85
|
|
86
|
-
<code>:links => boolean</code>
|
86
|
+
<code>:links => boolean</code>
|
87
87
|
|
88
88
|
h3. Examples
|
89
89
|
|
90
90
|
<pre>
|
91
91
|
<code>
|
92
92
|
render_crumbs #=> <a href="/">Home</a> » <a href="/businesses">Businesses</a>
|
93
|
-
render_crumbs :
|
93
|
+
render_crumbs :separator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
|
94
94
|
render_crumbs :format => :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
|
95
95
|
</code>
|
96
96
|
</pre>
|
@@ -115,5 +115,7 @@ h2. Credits
|
|
115
115
|
* "Przemysław Kowalczyk":http://szeryf.wordpress.com/2008/06/13/easy-and-flexible-breadcrumbs-for-rails/ - feature ideas
|
116
116
|
* "Sharad Jain":http://github.com/sjain
|
117
117
|
* "Max Riveiro":http://github.com/kavu
|
118
|
+
* "Kamil K. Lemański":http://kml.jogger.pl
|
119
|
+
* "Brian Cobb":http://bcobb.net/
|
118
120
|
|
119
|
-
*Copyright (c)
|
121
|
+
*Copyright (c) 2011 Zach Inglis, released under the MIT license*
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
@@ -3,43 +3,44 @@
|
|
3
3
|
module Crummy
|
4
4
|
class StandardRenderer
|
5
5
|
include ActionView::Helpers::UrlHelper
|
6
|
+
include ActionView::Helpers::TagHelper unless self.included_modules.include?(ActionView::Helpers::TagHelper)
|
6
7
|
|
7
8
|
# Render the list of crumbs as either html or xml
|
8
9
|
#
|
9
10
|
# Takes 3 options:
|
10
11
|
# The output format. Can either be xml or html. Default :html
|
11
12
|
# :format => (:html|:xml)
|
12
|
-
# The
|
13
|
-
# :
|
13
|
+
# The separator text. It does not assume you want spaces on either side so you must specify. Default +»+ for :html and +crumb+ for xml
|
14
|
+
# :separator => string
|
14
15
|
# Render links in the output. Default +true+
|
15
16
|
# :link => boolean
|
16
17
|
#
|
17
18
|
# Examples:
|
18
19
|
# render_crumbs #=> <a href="/">Home</a> » <a href="/businesses">Businesses</a>
|
19
|
-
# render_crumbs :
|
20
|
+
# render_crumbs :separator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
|
20
21
|
# render_crumbs :format => :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
|
21
22
|
#
|
22
|
-
# The only argument is for the
|
23
|
+
# The only argument is for the separator text. It does not assume you want spaces on either side so you must specify. Defaults to +»+
|
23
24
|
#
|
24
25
|
# render_crumbs(" . ") #=> <a href="/">Home</a> . <a href="/businesses">Businesses</a>
|
25
26
|
#
|
26
27
|
def render_crumbs(crumbs, options = {})
|
27
28
|
options[:format] = :html if options[:format] == nil
|
28
|
-
if options[:
|
29
|
-
options[:
|
30
|
-
options[:
|
29
|
+
if options[:separator] == nil
|
30
|
+
options[:separator] = " » " if options[:format] == :html
|
31
|
+
options[:separator] = "crumb" if options[:format] == :xml
|
31
32
|
end
|
32
33
|
options[:links] = true if options[:links] == nil
|
33
34
|
case options[:format]
|
34
35
|
when :html
|
35
36
|
crumb_string = crumbs.collect do |crumb|
|
36
37
|
crumb_to_html crumb, options[:links]
|
37
|
-
end * options[:
|
38
|
+
end * options[:separator]
|
38
39
|
crumb_string = crumb_string.html_safe if crumb_string.respond_to?(:html_safe)
|
39
40
|
crumb_string
|
40
41
|
when :xml
|
41
42
|
crumbs.collect do |crumb|
|
42
|
-
crumb_to_xml crumb, options[:links], options[:
|
43
|
+
crumb_to_xml crumb, options[:links], options[:separator]
|
43
44
|
end * ''
|
44
45
|
else
|
45
46
|
raise ArgumentError, "Unknown breadcrumb output format"
|
@@ -53,9 +54,9 @@ module Crummy
|
|
53
54
|
url && links ? link_to(name, url) : name
|
54
55
|
end
|
55
56
|
|
56
|
-
def crumb_to_xml(crumb, links,
|
57
|
+
def crumb_to_xml(crumb, links, separator)
|
57
58
|
name, url = crumb
|
58
|
-
url && links ? "<#{
|
59
|
+
url && links ? "<#{separator} href=\"#{url}\">#{name}</#{separator}>" : "<#{separator}>#{name}</#{separator}>"
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crummy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zach Inglis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-03 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements: []
|
71
71
|
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.5.0
|
74
74
|
signing_key:
|
75
75
|
specification_version: 3
|
76
76
|
summary: Tasty breadcrumbs!
|