crummy 1.6.0 → 1.7.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/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  rdoc
2
- pkg
3
2
  nbproject
3
+ *.gem
4
+ .bundle
5
+ Gemfile.lock
6
+ pkg/*
@@ -0,0 +1,34 @@
1
+ 1.7.0
2
+ * [ADDED] Added option for google microdata
3
+ * [REFACTORED] Cleaned up development internals
4
+
5
+ 1.6.0
6
+ * [FIXED] A fix for the escaped html problem in :html_list
7
+
8
+ 1.5
9
+ * [ADDED] Global configuration options
10
+ * [REFACTORED] HTML now uses content_tags
11
+
12
+ 1.3.6
13
+ * [FIXED] :li_class fixed in StandardRenderer#crumb_to_html_list
14
+
15
+ 1.3.5
16
+ * [FIXED] Spacing in name argument was causing errors.
17
+ * [FIXED] Bug where everything was getting parsed as an Array.
18
+
19
+ 1.3
20
+ * [FIXED] html_safe! is no longer called by default. That's the user's prerogative to do now.
21
+ * [ADDED] Allow record to respond to to_s even if you pass a url or block.
22
+ * [ADDED] Allow name to be a proc or lambda method
23
+ * [ADDED] clear crumbs as before filter
24
+
25
+ 1.2
26
+ * [ADDED] html_list format option
27
+ * [FIXED] Bug with Passenger and REE deployments
28
+
29
+ 1.1.1
30
+
31
+ * [FIXED] issue with undefined method escape_once for Rails 3.
32
+ * [FIXED] spelling of separator
33
+
34
+ 1.1.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 [name of plugin creator]
1
+ Copyright (c) 2013 Zach Inglis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,162 @@
1
+ # Crummy
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/crummy.png)](http://badge.fury.io/rb/crummy)
4
+ [![Build Status](https://secure.travis-ci.org/zachinglis/crummy.png?branch=master)](http://travis-ci.org/zachinglis/crummy)
5
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/zachinglis/crummy)
6
+
7
+ Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
8
+
9
+ ## Install
10
+
11
+ Simply add the dependency to your Gemfile:
12
+
13
+ gem "crummy", "~> 1.6.0"
14
+
15
+ # Example
16
+
17
+ In your controllers you may add\_crumb either like a before\_filter or
18
+ within a method (It is also available to views).
19
+
20
+ class ApplicationController
21
+ add_crumb "Home", '/'
22
+ end
23
+
24
+ class BusinessController < ApplicationController
25
+ add_crumb("Businesses") { |instance| instance.send :businesses_path }
26
+ add_crumb("Comments", :only => "comments") { |instance| instance.send :businesses_comments_path }
27
+ before_filter :load_comment, :only => "show"
28
+ add_crumb :comment, :only => "show"
29
+
30
+ # Example for nested routes:
31
+ add_crumb(:document) { [:account, :document] }
32
+
33
+ def show
34
+ add_crumb @business.display_name, @business
35
+ end
36
+
37
+ def load_comment
38
+ @comment = Comment.find(params[:id])
39
+ end
40
+ end
41
+
42
+ Then in your view:
43
+
44
+ <%= render_crumbs %>
45
+
46
+ ## Options for render\_crumbs
47
+
48
+ render\_crumbs renders the list of crumbs as either html or xml
49
+
50
+ It takes 3 options
51
+
52
+ The output format. Can either be :xml or :html or :html\_list. Defaults
53
+ to :html
54
+
55
+ :format => (:html|:html_list|:xml)
56
+
57
+ The separator text. It does not assume you want spaces on either side so
58
+ you must specify. Defaults to `&raquo;` for :html and
59
+ `<crumb>` for :xml
60
+
61
+ :separator => string
62
+
63
+ Render links in the output. Defaults to *true*
64
+
65
+ :links => boolean
66
+
67
+ :skip_if_blank => true
68
+
69
+ Render
70
+ [Richsnipet](http:/support.google.com/webmasters/bin/answer.py?hl=en&answer=99170&topic=1088472&ctx=topic/)
71
+ Default to *false*
72
+
73
+ :microdata => true
74
+
75
+ With this option, output will be blank if there are no breadcrumbs.
76
+
77
+ ### Examples
78
+
79
+ render_crumbs #=> <a href="/">Home</a> &raquo; <a href="/businesses">Businesses</a>
80
+ render_crumbs :separator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
81
+ render_crumbs :format => :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
82
+ render_crumbs :format => :html_list #=> <ul class="" id=""><li class=""><a href="/">Home</a></li><li class=""><a href="/">Businesses</a></li></ul>
83
+ render_crumbs :format => :html_list, :microdata => true
84
+ #=> <ul class="" id=""><li class="" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
85
+ # <a href="/" itemprop="url"><span itemprop="title">Home</span></a></li></ul>
86
+
87
+ A crumb with a nil argument for the link will output an unlinked crumb.
88
+
89
+ With `:format => :html_list` you can specify additional `params:
90
+ :active_li_class, :li_class, :ul_class, :ul_id`
91
+
92
+ ### App-wide configuration
93
+
94
+ You have the option to pre-configure any of the Crummy options in an
95
+ application-wide configuration. The options above are available to
96
+ configure, with the exception of `:separator`, as well as many others.
97
+
98
+ The biggest difference is that `:separator` is not an option. Instead,
99
+ you have format-specific configuration options: `:html_separator`,
100
+ `:xml_separator`, and `:html_list_separator`. `:separator` can still be
101
+ overridden in the view.
102
+
103
+ Insert the following in a file named `config/initializers/crummy.rb`:
104
+
105
+ Crummy.configure do |config|
106
+ config.format = :xml
107
+ end
108
+
109
+ Possible parameters for configuration are:
110
+
111
+ :format
112
+ :links
113
+ :skip_if_blank
114
+ :html_separator
115
+ :xml_separator
116
+ :html_list_separator
117
+ :first_class
118
+ :last_class
119
+ :ul_id
120
+ :ul_class
121
+ :li_class
122
+ :active_li_class
123
+ :microdata
124
+
125
+ See `lib/crummy.rb` for a list of these parameters and their defaults.
126
+
127
+ ## Notes
128
+
129
+ Test library is at [Crummy Test](https://github.com/zachinglis/crummy-test)
130
+
131
+ ## Todo
132
+
133
+ - Accept collections of models as a single argument
134
+ - Accept instances of models as a single argument
135
+ - Allow for variables in names. (The workaround is to do your own
136
+ before\_filter for that currently)
137
+ - Make a crumbs? type method
138
+
139
+ ## Credits
140
+
141
+ - [Zach Inglis](http://zachinglis.com) of [London
142
+ Made](http://londonmade.co.uk)
143
+ - [Rein Henrichs](http://reinh.com)
144
+ - [Les Hill](http://blog.leshill.org/)
145
+ - [Sandro Turriate](http://turriate.com/)
146
+ - [Przemysław
147
+ Kowalczyk](http://szeryf.wordpress.com/2008/06/13/easy-and-flexible-breadcrumbs-for-rails/)
148
+ - feature ideas
149
+ - [Sharad Jain](http://github.com/sjain)
150
+ - [Max Riveiro](http://github.com/kavu)
151
+ - [Kamil K. Lemański](http://kml.jogger.pl)
152
+ - [Brian Cobb](http://bcobb.net/)
153
+ - [Kir Shatrov](http://github.com/shatrov) ([Evrone
154
+ company](http://evrone.com))
155
+ - [sugilog](http://github.com/sugilog)
156
+ - [Trond Arve Nordheim](http://github.com/tanordheim)
157
+ - [Jan Szumiec](http://github.com/jasiek)
158
+ - [Jeff Browning](http://github.com/jbrowning)
159
+ - [Bill Turner](http://github.com/billturner)
160
+ - [Andrew Nesbitt](http://github.com/andrew)
161
+
162
+ **Copyright 2008-2013 Zach Inglis, released under the MIT license**
data/Rakefile CHANGED
@@ -1,25 +1,9 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
3
 
4
4
  desc 'Default: run unit tests.'
5
5
  task :default => :test
6
6
 
7
- begin
8
- require 'jeweler'
9
- Jeweler::Tasks.new do |gem|
10
- gem.name = "crummy"
11
- gem.summary = %Q{Tasty breadcrumbs!}
12
- gem.description = %Q{Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.}
13
- gem.email = "zach+crummy@londonmade.co.uk"
14
- gem.homepage = "http://github.com/zachinglis/crummy"
15
- gem.authors = ["Zach Inglis"]
16
- gem.files = FileList['lib/**/*.rb','tasks/*.rake','init.rb','MIT-LICENSE','Rakefile','README.textile','VERSION', '.gitignore']
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
- end
22
-
23
7
  require 'rake/testtask'
24
8
  desc 'Test the crummy plugin.'
25
9
  Rake::TestTask.new(:test) do |t|
@@ -28,12 +12,7 @@ Rake::TestTask.new(:test) do |t|
28
12
  t.verbose = true
29
13
  end
30
14
 
31
- # begin
32
- # gem 'hanna'
33
- # require 'hanna/rdoctask'
34
- # rescue LoadError
35
- require 'rdoc/task'
36
- # end
15
+ require 'rdoc/task'
37
16
 
38
17
  desc 'Generate documentation for the crummy plugin.'
39
18
  Rake::RDocTask.new(:rdoc) do |rdoc|
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "crummy/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "crummy"
7
+ s.version = Crummy::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Zach Inglis", "Andrew Nesbitt"]
12
+ s.summary = "Tasty breadcrumbs!"
13
+ s.description = "Crummy is a simple and tasty way to add breadcrumbs to your Rails applications."
14
+ s.email = "zach+crummy@londonmade.co.uk"
15
+ s.extra_rdoc_files = ["README.md"]
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+
20
+ s.homepage = "http://github.com/zachinglis/crummy"
21
+ s.require_paths = [%q{lib}]
22
+ s.rubygems_version = %q{1.8.8}
23
+
24
+ s.add_development_dependency 'rake'
25
+ s.add_development_dependency 'bundler', '~> 1.0'
26
+ s.add_development_dependency 'activesupport'
27
+ s.add_development_dependency 'actionpack'
28
+ end
@@ -21,6 +21,7 @@ module Crummy
21
21
  attr_accessor :ul_class
22
22
  attr_accessor :li_class
23
23
  attr_accessor :active_li_class
24
+ attr_accessor :microdata
24
25
 
25
26
  def initialize
26
27
  @format = :html
@@ -35,6 +36,7 @@ module Crummy
35
36
  @ul_class = ''
36
37
  @li_class = ''
37
38
  @active_li_class = ''
39
+ @microdata = false
38
40
  end
39
41
  end
40
42
 
@@ -4,6 +4,7 @@ module Crummy
4
4
  class StandardRenderer
5
5
  include ActionView::Helpers::UrlHelper
6
6
  include ActionView::Helpers::TagHelper unless self.included_modules.include?(ActionView::Helpers::TagHelper)
7
+ ActionView::Helpers::TagHelper::BOOLEAN_ATTRIBUTES.merge([:itemscope].to_set)
7
8
 
8
9
  # Render the list of crumbs as either html or xml
9
10
  #
@@ -34,11 +35,12 @@ module Crummy
34
35
  options[:links] ||= Crummy.configuration.links
35
36
  options[:first_class] ||= Crummy.configuration.first_class
36
37
  options[:last_class] ||= Crummy.configuration.last_class
38
+ options[:microdata] ||= Crummy.configuration.microdata
37
39
 
38
40
  case options[:format]
39
41
  when :html
40
42
  crumb_string = crumbs.collect do |crumb|
41
- crumb_to_html(crumb, options[:links], options[:first_class], options[:last_class], (crumb == crumbs.first), (crumb == crumbs.last))
43
+ crumb_to_html(crumb, options[:links], options[:first_class], options[:last_class], (crumb == crumbs.first), (crumb == crumbs.last), options[:microdata])
42
44
  end.reduce { |memo, obj| memo << options[:separator] << obj }
43
45
  crumb_string
44
46
  when :html_list
@@ -48,7 +50,7 @@ module Crummy
48
50
  options[:ul_class] ||= Crummy.configuration.ul_class
49
51
  options[:ul_id] ||= Crummy.configuration.ul_id
50
52
  crumb_string = crumbs.collect do |crumb|
51
- crumb_to_html_list(crumb, options[:links], options[:li_class], options[:active_li_class], options[:first_class], options[:last_class], (crumb == crumbs.first), (crumb == crumbs.last))
53
+ crumb_to_html_list(crumb, options[:links], options[:li_class], options[:active_li_class], options[:first_class], options[:last_class], (crumb == crumbs.first), (crumb == crumbs.last), options[:microdata])
52
54
  end.reduce { |memo, obj| memo << options[:separator] << obj }
53
55
  crumb_string = content_tag(:ul, crumb_string, :class => options[:ul_class], :id => options[:ul_id])
54
56
  crumb_string
@@ -63,27 +65,48 @@ module Crummy
63
65
 
64
66
  private
65
67
 
66
- def crumb_to_html(crumb, links, first_class, last_class, is_first, is_last)
68
+ def crumb_to_html(crumb, links, first_class, last_class, is_first, is_last, with_microdata)
67
69
  html_classes = []
68
70
  html_classes << first_class if is_first
69
71
  html_classes << last_class if is_last
70
72
  name, url = crumb
71
- url && links ? link_to(name, url, :class => html_classes) : name
73
+ html_content = url && links ? link_to(name, url) : content_tag(:span, name)
74
+ if with_microdata
75
+ item_title = content_tag(:span, name, :itemprop => "title")
76
+ html_options = {:itemscope => true, :itemtype => data_definition_url("Breadcrumb")}
77
+ html_content = url && links ? link_to(item_title, url, :class => html_classes, :itemprop => "url") : item_title
78
+ content_tag(:div, html_content, html_options)
79
+ else
80
+ url && links ? link_to(name, url, :class => html_classes) : name
81
+ end
72
82
  end
73
83
 
74
- def crumb_to_html_list(crumb, links, li_class, active_li_class, first_class, last_class, is_first, is_last)
84
+ def crumb_to_html_list(crumb, links, li_class, active_li_class, first_class, last_class, is_first, is_last, with_microdata)
75
85
  name, url = crumb
76
86
  html_classes = []
77
87
  html_classes << first_class if is_first
78
88
  html_classes << last_class if is_last
79
89
  html_classes << active_li_class unless url && links
80
90
  html_classes << li_class if !is_first && !is_last && url && links
81
- content_tag(:li, url && links ? link_to(name, url) : content_tag(:span, name), :class => html_classes.join(' ').strip)
91
+ html_options = {:class => html_classes.join(' ').strip}
92
+ if with_microdata
93
+ html_options[:itemscope] = true
94
+ html_options[:itemtype] = data_definition_url("Breadcrumb")
95
+ item_title = content_tag(:span, name, :itemprop => "title")
96
+ html_content = url && links ? link_to(item_title, url, :itemprop => "url") : item_title
97
+ else
98
+ html_content = url && links ? link_to(name, url) : content_tag(:span, name)
99
+ end
100
+ content_tag(:li, html_content, html_options)
82
101
  end
83
102
 
84
103
  def crumb_to_xml(crumb, links, separator, is_first, is_last)
85
104
  name, url = crumb
86
105
  content_tag(separator, name, :href => (url && links ? url : nil))
87
106
  end
107
+
108
+ def data_definition_url(type)
109
+ "http://data-vocabulary.org/#{type}"
110
+ end
88
111
  end
89
112
  end
@@ -0,0 +1,6 @@
1
+ module Crummy
2
+ MAJOR = 1
3
+ MINOR = 7
4
+ PATCH = 0
5
+ VERSION = [MAJOR, MINOR, PATCH].join('.')
6
+ end
@@ -0,0 +1,71 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require(:test)
4
+ require 'test/unit'
5
+
6
+ require 'action_controller'
7
+ require 'active_support/core_ext/string/output_safety'
8
+ require 'crummy'
9
+ require 'crummy/standard_renderer'
10
+
11
+ class StandardRendererTest < Test::Unit::TestCase
12
+ include Crummy
13
+
14
+ def test_classes
15
+ renderer = StandardRenderer.new
16
+ assert_equal('<a href="url" class="first last">name</a>',
17
+ renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html))
18
+ assert_equal('<ul class="" id=""><li class="first last"><a href="url">name</a></li></ul>',
19
+ renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html_list))
20
+ assert_equal('<crumb href="url">name</crumb>',
21
+ renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :xml))
22
+
23
+ assert_equal('<a href="url1" class="first">name1</a> &raquo; <a href="url2" class="last">name2</a>',
24
+ renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']], :first_class => 'first', :last_class => 'last', :format => :html))
25
+ assert_equal('<ul class="" id=""><li class="first"><a href="url1">name1</a></li><li class="li_class"><a href="url2">name2</a></li><li class="last"><a href="url3">name3</a></li></ul>',
26
+ renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2'], ['name3', 'url3']], :li_class => "li_class", :first_class => 'first', :last_class => 'last', :format => :html_list))
27
+ assert_equal('<ul class="" id=""><li class="first"><a href="url1">name1</a></li> / <li class="li_class"><a href="url2">name2</a></li> / <li class="last"><a href="url3">name3</a></li></ul>',
28
+ renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2'], ['name3', 'url3']], :li_class => "li_class", :first_class => 'first', :last_class => 'last', :format => :html_list, :separator => " / "))
29
+ assert_equal('<crumb href="url1">name1</crumb><crumb href="url2">name2</crumb>',
30
+ renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']], :first_class => 'first', :last_class => 'last', :format => :xml))
31
+
32
+ assert_equal('<div itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="url" class="first last" itemprop="url"><span itemprop="title">name</span></a></div>',
33
+ renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html, :microdata => true))
34
+ assert_equal('<ul class="" id=""><li class="first last" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="url" itemprop="url"><span itemprop="title">name</span></a></li></ul>',
35
+ renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html_list, :microdata => true))
36
+ end
37
+
38
+ def test_configuration
39
+ renderer = StandardRenderer.new
40
+ # check defaults
41
+ assert_equal " &raquo; ", Crummy.configuration.html_separator
42
+ # adjust configuration
43
+ Crummy.configure do |config|
44
+ config.html_separator = " / "
45
+ end
46
+ assert_equal " / ", Crummy.configuration.html_separator
47
+ end
48
+
49
+ def test_configured_renderer
50
+ renderer = StandardRenderer.new
51
+ Crummy.configure do |config|
52
+ config.html_separator = " / "
53
+ end
54
+ # using configured separator
55
+ assert_equal('<a href="url1" class="">name1</a> / <a href="url2" class="">name2</a>',
56
+ renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']]))
57
+ # overriding configured separator
58
+ assert_equal('<a href="url1" class="">name1</a> | <a href="url2" class="">name2</a>',
59
+ renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']], :separator => " | "))
60
+ end
61
+
62
+ def test_configured_renderer_with_microdata
63
+ renderer = StandardRenderer.new
64
+ Crummy.configure do |config|
65
+ config.microdata = true
66
+ end
67
+ # using configured microdata setting
68
+ assert_equal('<div itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="url" class="first last" itemprop="url"><span itemprop="title">name</span></a></div>',
69
+ renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html))
70
+ end
71
+ end
metadata CHANGED
@@ -1,35 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crummy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Zach Inglis
9
+ - Andrew Nesbitt
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000Z
13
- dependencies: []
13
+ date: 2013-02-03 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: &70334127850640 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *70334127850640
26
+ - !ruby/object:Gem::Dependency
27
+ name: bundler
28
+ requirement: &70334127848920 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *70334127848920
37
+ - !ruby/object:Gem::Dependency
38
+ name: activesupport
39
+ requirement: &70334127872360 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70334127872360
48
+ - !ruby/object:Gem::Dependency
49
+ name: actionpack
50
+ requirement: &70334127871040 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70334127871040
14
59
  description: Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
15
60
  email: zach+crummy@londonmade.co.uk
16
61
  executables: []
17
62
  extensions: []
18
63
  extra_rdoc_files:
19
- - README.textile
64
+ - README.md
20
65
  files:
21
66
  - .gitignore
67
+ - CHANGELOG
68
+ - Gemfile
22
69
  - MIT-LICENSE
23
- - README.textile
70
+ - README.md
24
71
  - Rakefile
25
- - VERSION
72
+ - crummy.gemspec
26
73
  - init.rb
27
74
  - lib/crummy.rb
28
75
  - lib/crummy/action_controller.rb
29
76
  - lib/crummy/action_view.rb
30
77
  - lib/crummy/railtie.rb
31
78
  - lib/crummy/standard_renderer.rb
32
- - tasks/crummy_tasks.rake
79
+ - lib/crummy/version.rb
80
+ - test/standard_renderer_test.rb
33
81
  homepage: http://github.com/zachinglis/crummy
34
82
  licenses: []
35
83
  post_install_message:
@@ -50,8 +98,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
98
  version: '0'
51
99
  requirements: []
52
100
  rubyforge_project:
53
- rubygems_version: 1.8.8
101
+ rubygems_version: 1.8.11
54
102
  signing_key:
55
103
  specification_version: 3
56
104
  summary: Tasty breadcrumbs!
57
- test_files: []
105
+ test_files:
106
+ - test/standard_renderer_test.rb
107
+ has_rdoc:
@@ -1,158 +0,0 @@
1
- h1. Crummy
2
-
3
- h2. Introduction
4
-
5
- Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
6
-
7
- h2. Install
8
-
9
- Simply add the dependency to your Gemfile:
10
-
11
- <pre>
12
- <code>
13
- gem "crummy", "~> 1.6.0"
14
- </code>
15
- </pre>
16
-
17
- h2. Example
18
-
19
- In your controllers you may add_crumb either like a before_filter or within a method (It is also available to views).
20
-
21
- <pre>
22
- <code>
23
- class ApplicationController
24
- add_crumb "Home", '/'
25
- end
26
-
27
- class BusinessController < ApplicationController
28
- add_crumb("Businesses") { |instance| instance.send :businesses_path }
29
- add_crumb("Comments", :only => "comments") { |instance| instance.send :businesses_comments_path }
30
- before_filter :load_comment, :only => "show"
31
- add_crumb :comment, :only => "show"
32
-
33
- # Example for nested routes:
34
- add_crumb(:document) { [:account, :document] }
35
-
36
- def show
37
- add_crumb @business.display_name, @business
38
- end
39
-
40
- def load_comment
41
- @comment = Comment.find(params[:id])
42
- end
43
- end
44
- </code>
45
- </pre>
46
-
47
- Then in your view:
48
-
49
- <pre>
50
- <code>
51
- <%= render_crumbs %>
52
- </code>
53
- </pre>
54
-
55
- h2. Options for render_crumbs
56
-
57
- render_crumbs renders the list of crumbs as either html or xml
58
-
59
- It takes 3 options
60
-
61
- The output format. Can either be :xml or :html or :html_list. Defaults to :html
62
-
63
- <code>:format => (:html|:html_list|:xml)</code>
64
-
65
- The separator text. It does not assume you want spaces on either side so you must specify. Defaults to <code>&raquo;</code> for :html and <code><crumb></code> for :xml
66
-
67
- <code>:separator => string</code>
68
-
69
- Render links in the output. Defaults to +true+
70
-
71
- <code>:links => boolean</code>
72
-
73
- <code>:skip_if_blank => true</code>
74
-
75
- With this option, output will be blank if there are no breadcrumbs.
76
-
77
- h3. Examples
78
-
79
- <pre>
80
- <code>
81
- render_crumbs #=> <a href="/">Home</a> &raquo; <a href="/businesses">Businesses</a>
82
- render_crumbs :separator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
83
- render_crumbs :format => :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
84
- render_crumbs :format => :html_list #=> <ul class="" id=""><li class=""><a href="/">Home</a></li><li class=""><a href="/">Businesses</a></li></ul>
85
- </code>
86
- </pre>
87
-
88
- A crumb with a nil argument for the link will output an unlinked crumb.
89
-
90
- With :format => :html_list you can specify additional params: :active_li_class, :li_class, :ul_class, :ul_id
91
-
92
- h3. App-wide configuration
93
-
94
- You have the option to pre-configure any of the Crummy options in an application-wide configuration. The options above are available to configure, with the exception of @:separator@, as well as many others.
95
-
96
- The biggest difference is that @:separator@ is not an option. Instead, you have format-specific configuration options: @:html_separator@, @:xml_separator@, and @:html_list_separator@. @:separator@ can still be overridden in the view.
97
-
98
- Insert the following in a file named @config/initializers/crummy.rb@:
99
-
100
- <pre>
101
- <code>
102
- Crummy.configure do |config|
103
- config.format = :xml
104
- end
105
- </code>
106
- </pre>
107
-
108
- Possible parameters for configuration are:
109
-
110
- <pre>
111
- <code>
112
- :format
113
- :links
114
- :skip_if_blank
115
- :html_separator
116
- :xml_separator
117
- :html_list_separator
118
- :first_class
119
- :last_class
120
- :ul_id
121
- :ul_class
122
- :li_class
123
- :active_li_class
124
- </code>
125
- </pre>
126
-
127
- See @lib/crummy.rb@ for a list of these parameters and their defaults.
128
-
129
- h2. Notes
130
-
131
- Test library is at "Crummy Test":https://github.com/zachinglis/crummy-test
132
-
133
- h2. Todo
134
-
135
- * Accept collections of models as a single argument
136
- * Accept instances of models as a single argument
137
- * Allow for variables in names. (The workaround is to do your own before_filter for that currently)
138
- * Make a crumbs? type method
139
-
140
- h2. Credits
141
-
142
- * "Zach Inglis":http://zachinglis.com of "London Made":http://londonmade.co.uk
143
- * "Rein Henrichs":http://reinh.com
144
- * "Les Hill":http://blog.leshill.org/
145
- * "Sandro Turriate":http://turriate.com/
146
- * "Przemysław Kowalczyk":http://szeryf.wordpress.com/2008/06/13/easy-and-flexible-breadcrumbs-for-rails/ - feature ideas
147
- * "Sharad Jain":http://github.com/sjain
148
- * "Max Riveiro":http://github.com/kavu
149
- * "Kamil K. Lemański":http://kml.jogger.pl
150
- * "Brian Cobb":http://bcobb.net/
151
- * "Kir Shatrov":http://github.com/shatrov ("Evrone company":http://evrone.com)
152
- * "sugilog":http://github.com/sugilog
153
- * "Trond Arve Nordheim":http://github.com/tanordheim
154
- * "Jan Szumiec":http://github.com/jasiek
155
- * "Jeff Browning":http://github.com/jbrowning
156
- * "Bill Turner":http://github.com/billturner
157
-
158
- *Copyright (c) 2008-2011 Zach Inglis, released under the MIT license*
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.6.0
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :crummy do
3
- # # Task goes here
4
- # end