crummy 1.7.0 → 1.7.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/.gitignore +1 -1
- data/.rvmrc +48 -0
- data/.travis.yml +13 -0
- data/CHANGELOG +3 -0
- data/README.md +78 -55
- data/example/.gitignore +5 -0
- data/example/.rspec +1 -0
- data/example/.rvmrc +48 -0
- data/example/Gemfile +30 -0
- data/example/README.md +40 -0
- data/example/Rakefile +7 -0
- data/example/app/assets/images/rails.png +0 -0
- data/example/app/assets/javascripts/application.js +9 -0
- data/example/app/assets/javascripts/pages.js.coffee +3 -0
- data/example/app/assets/javascripts/post.js.coffee +3 -0
- data/example/app/assets/stylesheets/application.css +7 -0
- data/example/app/assets/stylesheets/layout.css.sass +26 -0
- data/example/app/assets/stylesheets/post.css.scss +3 -0
- data/example/app/controllers/application_controller.rb +6 -0
- data/example/app/controllers/pages_controller.rb +5 -0
- data/example/app/controllers/posts_controller.rb +19 -0
- data/example/app/helpers/application_helper.rb +9 -0
- data/example/app/helpers/pages_helper.rb +2 -0
- data/example/app/helpers/post_helper.rb +2 -0
- data/example/app/mailers/.gitkeep +0 -0
- data/example/app/models/.gitkeep +0 -0
- data/example/app/models/category.rb +6 -0
- data/example/app/models/post.rb +19 -0
- data/example/app/views/layouts/application.html.haml +16 -0
- data/example/app/views/pages/index.html.haml +4 -0
- data/example/app/views/posts/index.html.haml +5 -0
- data/example/app/views/posts/new.html.haml +1 -0
- data/example/app/views/posts/show.html.haml +3 -0
- data/example/config.ru +4 -0
- data/example/config/application.rb +48 -0
- data/example/config/boot.rb +6 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +30 -0
- data/example/config/environments/production.rb +60 -0
- data/example/config/environments/test.rb +39 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/inflections.rb +10 -0
- data/example/config/initializers/mime_types.rb +5 -0
- data/example/config/initializers/secret_token.rb +7 -0
- data/example/config/initializers/session_store.rb +8 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +5 -0
- data/example/config/routes.rb +5 -0
- data/example/db/migrate/20111104103150_create_posts.rb +10 -0
- data/example/db/migrate/20111104103738_create_categories.rb +12 -0
- data/example/db/migrate/20111104104040_add_category_id_to_posts.rb +5 -0
- data/example/db/schema.rb +32 -0
- data/example/db/seeds.rb +15 -0
- data/example/doc/README_FOR_APP +2 -0
- data/example/lib/assets/.gitkeep +0 -0
- data/example/lib/tasks/.gitkeep +0 -0
- data/example/log/.gitkeep +0 -0
- data/example/public/404.html +26 -0
- data/example/public/422.html +26 -0
- data/example/public/500.html +26 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/robots.txt +5 -0
- data/example/script/rails +6 -0
- data/example/spec/controllers/posts_controller_spec.rb +7 -0
- data/example/spec/spec_helper.rb +38 -0
- data/example/vendor/assets/stylesheets/.gitkeep +0 -0
- data/example/vendor/plugins/.gitkeep +0 -0
- data/gemfiles/rails3_2/Gemfile +6 -0
- data/gemfiles/rails4_0/Gemfile +6 -0
- data/lib/crummy.rb +10 -2
- data/lib/crummy/standard_renderer.rb +14 -13
- data/lib/crummy/version.rb +1 -1
- data/test/standard_renderer_test.rb +33 -3
- metadata +78 -10
data/.gitignore
CHANGED
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
|
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Crummy
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/crummy)
|
4
|
-
[](http://travis-ci.org/zachinglis/crummy)
|
5
5
|
[](https://codeclimate.com/github/zachinglis/crummy)
|
6
6
|
|
7
7
|
Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
|
@@ -10,38 +10,44 @@ Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
|
|
10
10
|
|
11
11
|
Simply add the dependency to your Gemfile:
|
12
12
|
|
13
|
-
|
13
|
+
```ruby
|
14
|
+
gem "crummy", "~> 1.7.1"
|
15
|
+
```
|
14
16
|
|
15
17
|
# Example
|
16
18
|
|
17
19
|
In your controllers you may add\_crumb either like a before\_filter or
|
18
20
|
within a method (It is also available to views).
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
```ruby
|
23
|
+
class ApplicationController
|
24
|
+
add_crumb "Home", '/'
|
25
|
+
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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"
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
# Example for nested routes:
|
34
|
+
add_crumb(:document) { [:account, :document] }
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
def show
|
37
|
+
add_crumb @business.display_name, @business
|
38
|
+
end
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
def load_comment
|
41
|
+
@comment = Comment.find(params[:id])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
41
45
|
|
42
46
|
Then in your view:
|
43
47
|
|
44
|
-
|
48
|
+
```erb
|
49
|
+
<%= render_crumbs %>
|
50
|
+
```
|
45
51
|
|
46
52
|
## Options for render\_crumbs
|
47
53
|
|
@@ -52,42 +58,57 @@ It takes 3 options
|
|
52
58
|
The output format. Can either be :xml or :html or :html\_list. Defaults
|
53
59
|
to :html
|
54
60
|
|
55
|
-
|
61
|
+
```ruby
|
62
|
+
format: (:html|:html_list|:xml)
|
63
|
+
```
|
56
64
|
|
57
65
|
The separator text. It does not assume you want spaces on either side so
|
58
66
|
you must specify. Defaults to `»` for :html and
|
59
67
|
`<crumb>` for :xml
|
60
68
|
|
61
|
-
|
69
|
+
```ruby
|
70
|
+
separator: string
|
71
|
+
```
|
62
72
|
|
63
73
|
Render links in the output. Defaults to *true*
|
64
74
|
|
65
|
-
|
75
|
+
```ruby
|
76
|
+
links: boolean
|
66
77
|
|
67
|
-
|
78
|
+
skip_if_blank: true
|
79
|
+
```
|
68
80
|
|
69
81
|
Render
|
70
82
|
[Richsnipet](http:/support.google.com/webmasters/bin/answer.py?hl=en&answer=99170&topic=1088472&ctx=topic/)
|
71
83
|
Default to *false*
|
72
84
|
|
73
|
-
|
85
|
+
```
|
86
|
+
last_crumb_linked: false
|
87
|
+
```
|
88
|
+
|
89
|
+
Optionally disable linking of the last crumb, Defaults to *true*
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
microdata: true
|
93
|
+
```
|
74
94
|
|
75
95
|
With this option, output will be blank if there are no breadcrumbs.
|
76
96
|
|
77
97
|
### Examples
|
78
98
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
```ruby
|
100
|
+
render_crumbs #=> <a href="/">Home</a> » <a href="/businesses">Businesses</a>
|
101
|
+
render_crumbs separator: ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
|
102
|
+
render_crumbs format: :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
|
103
|
+
render_crumbs format: :html_list #=> <ul class="" id=""><li class=""><a href="/">Home</a></li><li class=""><a href="/">Businesses</a></li></ul>
|
104
|
+
render_crumbs format: :html_list, :microdata => true
|
105
|
+
#=> <ul class="" id=""><li class="" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
106
|
+
# <a href="/" itemprop="url"><span itemprop="title">Home</span></a></li></ul>
|
107
|
+
```
|
86
108
|
|
87
109
|
A crumb with a nil argument for the link will output an unlinked crumb.
|
88
110
|
|
89
|
-
With
|
90
|
-
:active_li_class, :li_class, :ul_class, :ul_id`
|
111
|
+
With `format: :html_list` you can specify additional `params: :li_class, :ul_class, :ul_id`
|
91
112
|
|
92
113
|
### App-wide configuration
|
93
114
|
|
@@ -102,31 +123,34 @@ overridden in the view.
|
|
102
123
|
|
103
124
|
Insert the following in a file named `config/initializers/crummy.rb`:
|
104
125
|
|
105
|
-
|
106
|
-
|
107
|
-
|
126
|
+
```ruby
|
127
|
+
Crummy.configure do |config|
|
128
|
+
config.format = :xml
|
129
|
+
end
|
130
|
+
```
|
108
131
|
|
109
132
|
Possible parameters for configuration are:
|
110
133
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
134
|
+
```ruby
|
135
|
+
:format
|
136
|
+
:links
|
137
|
+
:skip_if_blank
|
138
|
+
:html_separator
|
139
|
+
:xml_separator
|
140
|
+
:html_list_separator
|
141
|
+
:first_class
|
142
|
+
:last_class
|
143
|
+
:ul_id
|
144
|
+
:ul_class
|
145
|
+
:li_class
|
146
|
+
:microdata
|
147
|
+
```
|
124
148
|
|
125
149
|
See `lib/crummy.rb` for a list of these parameters and their defaults.
|
126
150
|
|
127
|
-
##
|
151
|
+
## Live example application
|
128
152
|
|
129
|
-
|
153
|
+
An example application is available right inside this gem. That application is documented, see `example/README` for details about usage.
|
130
154
|
|
131
155
|
## Todo
|
132
156
|
|
@@ -138,8 +162,8 @@ Test library is at [Crummy Test](https://github.com/zachinglis/crummy-test)
|
|
138
162
|
|
139
163
|
## Credits
|
140
164
|
|
141
|
-
- [Zach Inglis](http://zachinglis.com) of [
|
142
|
-
|
165
|
+
- [Zach Inglis](http://zachinglis.com) of [Superhero Studios](http://superhero-studios.com)
|
166
|
+
- [Andrew Nesbitt](http://github.com/andrew)
|
143
167
|
- [Rein Henrichs](http://reinh.com)
|
144
168
|
- [Les Hill](http://blog.leshill.org/)
|
145
169
|
- [Sandro Turriate](http://turriate.com/)
|
@@ -157,6 +181,5 @@ Test library is at [Crummy Test](https://github.com/zachinglis/crummy-test)
|
|
157
181
|
- [Jan Szumiec](http://github.com/jasiek)
|
158
182
|
- [Jeff Browning](http://github.com/jbrowning)
|
159
183
|
- [Bill Turner](http://github.com/billturner)
|
160
|
-
- [Andrew Nesbitt](http://github.com/andrew)
|
161
184
|
|
162
185
|
**Copyright 2008-2013 Zach Inglis, released under the MIT license**
|
data/example/.gitignore
ADDED
data/example/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format documentation
|
data/example/.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-test"
|
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
|
data/example/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.1.1'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
|
10
|
+
# Gems used only for assets and not required
|
11
|
+
# in production environments by default.
|
12
|
+
group :assets do
|
13
|
+
gem 'sass-rails', '~> 3.1.4'
|
14
|
+
gem 'coffee-rails', '~> 3.1.1'
|
15
|
+
gem 'uglifier', '>= 1.0.3'
|
16
|
+
end
|
17
|
+
|
18
|
+
gem 'jquery-rails'
|
19
|
+
|
20
|
+
gem 'haml'
|
21
|
+
gem 'crummy', :path => '../'
|
22
|
+
|
23
|
+
group :test do
|
24
|
+
# Pretty printed test output
|
25
|
+
gem 'turn', :require => false
|
26
|
+
end
|
27
|
+
|
28
|
+
group :test, :development do
|
29
|
+
gem "rspec-rails", "~> 2.0"
|
30
|
+
end
|
data/example/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Crummy Test
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
This is a test application for [Crummy][crummy], and also a good place where you can see it in action.
|
6
|
+
|
7
|
+
[crummy]: http://github.com/zachinglis/crummy
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
I recommend you to use [RVM][rvm] in order to keep this application gemset distinct from the gem one. Here we use a full Rails stack, which is not true when developping the gem. I you only want to see Crummy in action, you might not care about that. Anyways RVM is not required, but if you use it you'll find an `.rvmrc` file for each context: `example/.rvmrc` and `.rvmrc` respectively for the example app and the gem. Using them is easy and only requires to take care of the directory from where you `bundle install`: if from `example`, you'll update the app bundle, else the gem bundle.
|
12
|
+
|
13
|
+
[rvm]: https://rvm.io
|
14
|
+
|
15
|
+
To quickly start the example app:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
# Enter the example directory and trust the .rvmrc file
|
19
|
+
cd crummy/example
|
20
|
+
|
21
|
+
# Install the bundle
|
22
|
+
bundle install
|
23
|
+
# Create the database
|
24
|
+
bundle exec rake db:schema:load
|
25
|
+
bundle exec rake db:seed
|
26
|
+
# Create the test database
|
27
|
+
bundle exec rake db:test:clone
|
28
|
+
|
29
|
+
# Get the tests green
|
30
|
+
bundle exec rake
|
31
|
+
|
32
|
+
# Start the server
|
33
|
+
rails server
|
34
|
+
```
|
35
|
+
|
36
|
+
Your app waits for you at [http://localhost:3000](http://localhost:3000).
|
37
|
+
|
38
|
+
* * *
|
39
|
+
|
40
|
+
I hope this makes the example application a better place to test the gem.
|
data/example/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
CrummyTest::Application.load_tasks
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|