vinted-crummy 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rvmrc +48 -0
  4. data/.travis.yml +7 -0
  5. data/Appraisals +9 -0
  6. data/CHANGELOG +47 -0
  7. data/Gemfile +3 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +220 -0
  10. data/Rakefile +25 -0
  11. data/crummy.gemspec +30 -0
  12. data/example/.gitignore +5 -0
  13. data/example/.rspec +1 -0
  14. data/example/.rvmrc +48 -0
  15. data/example/Gemfile +30 -0
  16. data/example/README.md +40 -0
  17. data/example/Rakefile +7 -0
  18. data/example/app/assets/images/rails.png +0 -0
  19. data/example/app/assets/javascripts/application.js +9 -0
  20. data/example/app/assets/javascripts/pages.js.coffee +3 -0
  21. data/example/app/assets/javascripts/post.js.coffee +3 -0
  22. data/example/app/assets/stylesheets/application.css +7 -0
  23. data/example/app/assets/stylesheets/layout.css.sass +26 -0
  24. data/example/app/assets/stylesheets/post.css.scss +3 -0
  25. data/example/app/controllers/application_controller.rb +6 -0
  26. data/example/app/controllers/pages_controller.rb +5 -0
  27. data/example/app/controllers/posts_controller.rb +19 -0
  28. data/example/app/helpers/application_helper.rb +9 -0
  29. data/example/app/helpers/pages_helper.rb +2 -0
  30. data/example/app/helpers/post_helper.rb +2 -0
  31. data/example/app/mailers/.gitkeep +0 -0
  32. data/example/app/models/.gitkeep +0 -0
  33. data/example/app/models/category.rb +6 -0
  34. data/example/app/models/post.rb +19 -0
  35. data/example/app/views/layouts/application.html.haml +16 -0
  36. data/example/app/views/pages/index.html.haml +4 -0
  37. data/example/app/views/posts/index.html.haml +5 -0
  38. data/example/app/views/posts/new.html.haml +1 -0
  39. data/example/app/views/posts/show.html.haml +3 -0
  40. data/example/config.ru +4 -0
  41. data/example/config/application.rb +48 -0
  42. data/example/config/boot.rb +6 -0
  43. data/example/config/database.yml +25 -0
  44. data/example/config/environment.rb +5 -0
  45. data/example/config/environments/development.rb +30 -0
  46. data/example/config/environments/production.rb +60 -0
  47. data/example/config/environments/test.rb +39 -0
  48. data/example/config/initializers/backtrace_silencers.rb +7 -0
  49. data/example/config/initializers/inflections.rb +10 -0
  50. data/example/config/initializers/mime_types.rb +5 -0
  51. data/example/config/initializers/secret_token.rb +7 -0
  52. data/example/config/initializers/session_store.rb +8 -0
  53. data/example/config/initializers/wrap_parameters.rb +14 -0
  54. data/example/config/locales/en.yml +5 -0
  55. data/example/config/routes.rb +5 -0
  56. data/example/db/migrate/20111104103150_create_posts.rb +10 -0
  57. data/example/db/migrate/20111104103738_create_categories.rb +12 -0
  58. data/example/db/migrate/20111104104040_add_category_id_to_posts.rb +5 -0
  59. data/example/db/schema.rb +32 -0
  60. data/example/db/seeds.rb +15 -0
  61. data/example/doc/README_FOR_APP +2 -0
  62. data/example/lib/assets/.gitkeep +0 -0
  63. data/example/lib/tasks/.gitkeep +0 -0
  64. data/example/log/.gitkeep +0 -0
  65. data/example/public/404.html +26 -0
  66. data/example/public/422.html +26 -0
  67. data/example/public/500.html +26 -0
  68. data/example/public/favicon.ico +0 -0
  69. data/example/public/robots.txt +5 -0
  70. data/example/script/rails +6 -0
  71. data/example/spec/controllers/posts_controller_spec.rb +7 -0
  72. data/example/spec/spec_helper.rb +38 -0
  73. data/example/vendor/assets/stylesheets/.gitkeep +0 -0
  74. data/example/vendor/plugins/.gitkeep +0 -0
  75. data/gemfiles/rails3_2.gemfile +8 -0
  76. data/gemfiles/rails4_0.gemfile +8 -0
  77. data/init.rb +1 -0
  78. data/lib/crummy.rb +69 -0
  79. data/lib/crummy/action_controller.rb +83 -0
  80. data/lib/crummy/action_view.rb +29 -0
  81. data/lib/crummy/railtie.rb +20 -0
  82. data/lib/crummy/standard_renderer.rb +170 -0
  83. data/lib/crummy/version.rb +6 -0
  84. data/test/standard_renderer_test.rb +182 -0
  85. metadata +200 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 65f3e4a86d3ec1d1b30df795dbbf43a45df0feb41ec3eeca050a9f0a9bbfa472
4
+ data.tar.gz: 33c5a0a2e2992ad5fc17e9ee0cf01c1292862b82dfa76b08ce59f8c6c2faa0e6
5
+ SHA512:
6
+ metadata.gz: 9e6417b85048af8d57946931a0e62b0f1dfa2b69ebf34cf469053fe039b45d7add5844638693177ef65db299f9f0e3ebb57c3e7983b43bf9758420cbd564cbfb
7
+ data.tar.gz: 702f949125d96ddf93862907e8260b967a02927918441ea41e40df66a68a28e81289d10b2cb2c18d4db362e628c50112ee54a29c0e6f5bdfec79417f96816bb9
@@ -0,0 +1,8 @@
1
+ rdoc
2
+ nbproject
3
+ *.gem
4
+ .bundle
5
+ pkg/*
6
+ Gemfile.lock
7
+ *.gemfile.lock
8
+ .idea
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-head@crummy"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.17.7 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ gemfile:
6
+ - gemfiles/rails3_2.gemfile
7
+ - gemfiles/rails4_0.gemfile
@@ -0,0 +1,9 @@
1
+ appraise "rails3_2" do
2
+ gem 'activesupport', '>= 3.0', '< 4'
3
+ gem 'actionpack', '>= 3.0', '< 4'
4
+ end
5
+
6
+ appraise "rails4_0" do
7
+ gem 'activesupport', '>= 4.0.0.beta', '< 5'
8
+ gem 'actionpack', '>= 4.0.0.beta', '< 5'
9
+ end
@@ -0,0 +1,47 @@
1
+ 1.8.0
2
+ * [ADDED] You can now set each parameters individually for each crumb
3
+ * [ADDED] You can now set each crumb on right or left side
4
+ * [ADDED] You can now use a html in a crumb name
5
+ * [REFACTORED] Don't render empty html_options for tags.
6
+
7
+ 1.7.2
8
+ * [ADDED] :truncate option to shorten text in breadcrumbs
9
+ * [ADDED] Added ability to pass html link options through to renderer
10
+
11
+ 1.7.1
12
+ * [ADDED] :last_crumb_linked option to disable linking crumb on current page
13
+
14
+ 1.7.0
15
+ * [ADDED] Added option for google microdata
16
+ * [REFACTORED] Cleaned up development internals
17
+
18
+ 1.6.0
19
+ * [FIXED] A fix for the escaped html problem in :html_list
20
+
21
+ 1.5
22
+ * [ADDED] Global configuration options
23
+ * [REFACTORED] HTML now uses content_tags
24
+
25
+ 1.3.6
26
+ * [FIXED] :li_class fixed in StandardRenderer#crumb_to_html_list
27
+
28
+ 1.3.5
29
+ * [FIXED] Spacing in name argument was causing errors.
30
+ * [FIXED] Bug where everything was getting parsed as an Array.
31
+
32
+ 1.3
33
+ * [FIXED] html_safe! is no longer called by default. That's the user's prerogative to do now.
34
+ * [ADDED] Allow record to respond to to_s even if you pass a url or block.
35
+ * [ADDED] Allow name to be a proc or lambda method
36
+ * [ADDED] clear crumbs as before filter
37
+
38
+ 1.2
39
+ * [ADDED] html_list format option
40
+ * [FIXED] Bug with Passenger and REE deployments
41
+
42
+ 1.1.1
43
+
44
+ * [FIXED] issue with undefined method escape_once for Rails 3.
45
+ * [FIXED] spelling of separator
46
+
47
+ 1.1.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Zach Inglis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,220 @@
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)](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
+ ```ruby
14
+ gem "crummy", "~> 1.8.0"
15
+ ```
16
+
17
+ # Example
18
+
19
+ In your controllers you may add\_crumb either like a before\_filter or
20
+ within a method (It is also available to views).
21
+
22
+ ```ruby
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
+ ```
45
+
46
+ Then in your view:
47
+
48
+ ```erb
49
+ <%= render_crumbs %>
50
+ ```
51
+
52
+ ## Html options for breadcrumb link
53
+
54
+ You can set the html options with *link_html_options*.
55
+ These are added to the *a* tag.
56
+
57
+ ```ruby
58
+ add_crumb "Home", '/', link_html_options: {title: "my link title"}
59
+ ```
60
+
61
+ ##You can set html instead text in first parameter.
62
+ If tag <code>a</code> present in this html, tag a not be a wrapper.
63
+
64
+ ```ruby
65
+ add_crumb "<a class='glyphicons shield' href='/support'><i></i>Support</a>".html_safe, "", {}
66
+ ```
67
+
68
+ ## Options for render\_crumbs
69
+
70
+ `render_crumbs` renders the list of crumbs as either html or xml
71
+
72
+ The output format. Can either be :xml or :html or :html\_list. Defaults
73
+ to :html
74
+
75
+ ```ruby
76
+ format: (:html|:html_list|:xml)
77
+ ```
78
+
79
+ The separator text. It does not assume you want spaces on either side so
80
+ you must specify. Defaults to `&raquo;` for :html and
81
+ `<crumb>` for :xml
82
+
83
+ ```ruby
84
+ separator: string
85
+ ```
86
+
87
+ Render links in the output. Defaults to *true*
88
+
89
+ ```ruby
90
+ links: false
91
+ ```
92
+
93
+ Render
94
+ [Richsnipet](http:/support.google.com/webmasters/bin/answer.py?hl=en&answer=99170&topic=1088472&ctx=topic/)
95
+ Default to *false*
96
+
97
+ ```ruby
98
+ microdata: true
99
+ ```
100
+
101
+ Optionally disable linking of the last crumb, Defaults to *true*
102
+
103
+ ```ruby
104
+ last_crumb_linked: false
105
+ ```
106
+
107
+ With this option, output will be blank if there are no breadcrumbs.
108
+
109
+ ```ruby
110
+ skip_if_blank: true
111
+ ```
112
+
113
+ ### Examples
114
+
115
+ ```ruby
116
+ render_crumbs #=> <a href="/">Home</a> &raquo; <a href="/businesses">Businesses</a>
117
+ render_crumbs separator: ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
118
+ render_crumbs format: :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
119
+ render_crumbs format: :html_list #=> <ol class="" id=""><li class=""><a href="/">Home</a></li><li class=""><a href="/">Businesses</a></li></ol>
120
+ render_crumbs format: :html_list, :microdata => true
121
+ #=> <ol class="" id=""><li class="" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
122
+ # <a href="/" itemprop="url"><span itemprop="title">Home</span></a></li></ol>
123
+ add_crumb support_link, {:right_side => true, :links => "/support", :li_right_class => "pull-right hidden-phone"}
124
+ #=> <li class="pull-right hidden-phone">
125
+ #=> <span><a class="glyphicons shield" href="/support">
126
+ #=> <i></i>Support</a>
127
+ #=> </span>
128
+ #=> </li>
129
+ #=> <li class="divider pull-right hidden-phone"></li>
130
+ ```
131
+
132
+ A crumb with a nil argument for the link will output an unlinked crumb.
133
+
134
+ With `format: :html_list` you can specify additional `params: :li_class, :ol_class, :ol_id`
135
+
136
+ ### App-wide configuration
137
+
138
+ You have the option to pre-configure any of the Crummy options in an
139
+ application-wide configuration. The options above are available to
140
+ configure, with the exception of `:separator`, as well as many others.
141
+
142
+ The biggest difference is that `:separator` is not an option. Instead,
143
+ you have format-specific configuration options: `:html_separator`,
144
+ `:xml_separator`, and `:html_list_separator`. `:separator` can still be
145
+ overridden in the view.
146
+
147
+ Insert the following in a file named `config/initializers/crummy.rb`:
148
+
149
+ ```ruby
150
+ Crummy.configure do |config|
151
+ config.format = :xml
152
+ end
153
+ ```
154
+
155
+ Possible parameters for configuration are:
156
+
157
+ ```ruby
158
+ :format
159
+ :links
160
+ :skip_if_blank
161
+ :html_separator
162
+ :xml_separator
163
+ :html_list_separator
164
+ :html_list_right_separator
165
+ :first_class
166
+ :last_class
167
+ :ol_id
168
+ :ol_class
169
+ :li_class
170
+ :li_right_class
171
+ :microdata
172
+ :last_crumb_linked
173
+ :truncate
174
+ :right_side
175
+ ```
176
+
177
+ See `lib/crummy.rb` for a list of these parameters and their defaults.
178
+
179
+ ###Individually for each crumb configuration:
180
+ ```ruby
181
+ add_crumb support_link, {:right_side => true, :links => "/support", : li_class => "my_class", :li_right_class => "pull-right hidden-phone"}
182
+ ```
183
+ Simple add that parameter to options hash.
184
+
185
+
186
+ ## Live example application
187
+
188
+ An example application is available right inside this gem. That application is documented, see `example/README` for details about usage.
189
+
190
+ ## Todo
191
+
192
+ - Accept collections of models as a single argument
193
+ - Accept instances of models as a single argument
194
+ - Allow for variables in names. (The workaround is to do your own
195
+ before\_filter for that currently)
196
+ - Make a crumbs? type method
197
+
198
+ ## Credits
199
+
200
+ - [Zach Inglis](http://zachinglis.com) of [Superhero Studios](http://superhero-studios.com)
201
+ - [Andrew Nesbitt](http://github.com/andrew)
202
+ - [Rein Henrichs](http://reinh.com)
203
+ - [Les Hill](http://blog.leshill.org/)
204
+ - [Sandro Turriate](http://turriate.com/)
205
+ - [Przemysław
206
+ Kowalczyk](http://szeryf.wordpress.com/2008/06/13/easy-and-flexible-breadcrumbs-for-rails/)
207
+ - feature ideas
208
+ - [Sharad Jain](http://github.com/sjain)
209
+ - [Max Riveiro](http://github.com/kavu)
210
+ - [Kamil K. Lemański](http://kml.jogger.pl)
211
+ - [Brian Cobb](http://bcobb.net/)
212
+ - [Kir Shatrov](http://github.com/shatrov) ([Evrone
213
+ company](http://evrone.com))
214
+ - [sugilog](http://github.com/sugilog)
215
+ - [Trond Arve Nordheim](http://github.com/tanordheim)
216
+ - [Jan Szumiec](http://github.com/jasiek)
217
+ - [Jeff Browning](http://github.com/jbrowning)
218
+ - [Bill Turner](http://github.com/billturner)
219
+
220
+ **Copyright 2008-2013 Zach Inglis, released under the MIT license**
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'appraisal'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ require 'rake/testtask'
9
+ desc 'Test the crummy plugin.'
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'lib'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ require 'rdoc/task'
17
+
18
+ desc 'Generate documentation for the crummy plugin.'
19
+ Rake::RDocTask.new(:rdoc) do |rdoc|
20
+ rdoc.rdoc_dir = 'rdoc'
21
+ rdoc.title = 'Crummy: Tasty Breadcrumbs'
22
+ rdoc.options << '--line-numbers' << '--inline-source'
23
+ rdoc.rdoc_files.include('README.textile')
24
+ rdoc.rdoc_files.include('lib/**/*.rb')
25
+ end
@@ -0,0 +1,30 @@
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 = "vinted-crummy"
7
+ s.version = Crummy::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.licenses = ['MIT']
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Tomas Varneckas", "Zach Inglis", "Andrew Nesbitt"]
13
+ s.summary = "Tasty breadcrumbs!"
14
+ s.description = "Crummy is a simple and tasty way to add breadcrumbs to your Rails applications."
15
+ s.email = "tomas.varneckas@vinted.com"
16
+ s.extra_rdoc_files = ["README.md"]
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+
21
+ s.homepage = "http://github.com/vinted/crummy"
22
+ s.require_paths = [%q{lib}]
23
+ s.rubygems_version = %q{1.8.8}
24
+
25
+ s.add_development_dependency 'rake'
26
+ s.add_development_dependency 'activesupport'
27
+ s.add_development_dependency 'actionpack'
28
+ s.add_development_dependency 'appraisal'
29
+ s.add_development_dependency 'test-unit'
30
+ end
@@ -0,0 +1,5 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
5
+ .sass-cache/
@@ -0,0 +1 @@
1
+ --color --format documentation