loaf 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.rvmrc +28 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +132 -0
- data/LICENSE.txt +20 -0
- data/README.md +128 -0
- data/Rakefile +2 -45
- data/init.rb +3 -0
- data/lib/loaf.rb +14 -8
- data/lib/loaf/configuration.rb +2 -0
- data/lib/loaf/{filters.rb → controller_extensions.rb} +13 -12
- data/lib/loaf/crumb.rb +6 -0
- data/lib/loaf/crumb_formatter.rb +20 -0
- data/lib/loaf/railtie.rb +15 -6
- data/lib/loaf/translation.rb +18 -9
- data/lib/loaf/version.rb +4 -2
- data/lib/loaf/view_extensions.rb +43 -0
- data/loaf.gemspec +28 -0
- data/spec/integration/configuration_spec.rb +13 -0
- data/spec/integration/crumbs_routing_spec.rb +33 -0
- data/spec/integration/nested_crumbs_spec.rb +5 -0
- data/spec/loaf/crumb_formatter_spec.rb +33 -0
- data/spec/loaf/translation_spec.rb +23 -0
- data/spec/loaf_spec.rb +5 -0
- data/spec/rails_app/.gitignore +5 -0
- data/spec/rails_app/Rakefile +8 -0
- data/spec/rails_app/app/assets/images/rails.png +0 -0
- data/spec/rails_app/app/assets/javascripts/application.js +9 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +7 -0
- data/spec/rails_app/app/controllers/application_controller.rb +5 -0
- data/spec/rails_app/app/controllers/comments_controller.rb +4 -0
- data/spec/rails_app/app/controllers/home_controller.rb +4 -0
- data/spec/rails_app/app/controllers/posts_controller.rb +12 -0
- data/spec/rails_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails_app/app/mailers/.gitkeep +0 -0
- data/spec/rails_app/app/models/.gitkeep +0 -0
- data/spec/rails_app/app/views/home/index.html.erb +1 -0
- data/spec/rails_app/app/views/layouts/_breadcrumbs.html.erb +8 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +16 -0
- data/spec/rails_app/app/views/posts/index.html.erb +1 -0
- data/spec/rails_app/app/views/posts/new.html.erb +1 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +48 -0
- data/spec/rails_app/config/boot.rb +10 -0
- data/spec/rails_app/config/database.yml +25 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +30 -0
- data/spec/rails_app/config/environments/production.rb +60 -0
- data/spec/rails_app/config/environments/test.rb +42 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/inflections.rb +10 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/rails_app/config/initializers/session_store.rb +8 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/en.yml +5 -0
- data/spec/rails_app/config/routes.rb +9 -0
- data/spec/rails_app/db/seeds.rb +7 -0
- data/spec/rails_app/lib/assets/.gitkeep +0 -0
- data/spec/rails_app/lib/tasks/.gitkeep +0 -0
- data/spec/rails_app/public/404.html +26 -0
- data/spec/rails_app/public/422.html +26 -0
- data/spec/rails_app/public/500.html +26 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/robots.txt +5 -0
- data/spec/rails_app/script/rails +6 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/capybara.rb +10 -0
- data/spec/support/load_routes.rb +6 -0
- metadata +202 -119
- data/README.rdoc +0 -71
- data/lib/loaf/helpers.rb +0 -49
data/lib/loaf/helpers.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'loaf/configuration'
|
2
|
-
|
3
|
-
module Loaf
|
4
|
-
module Helpers
|
5
|
-
|
6
|
-
class_eval do
|
7
|
-
define_method :config do |options|
|
8
|
-
Loaf.config
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# Adds breadcrumbs in a view
|
13
|
-
def add_breadcrumb(name, url=nil)
|
14
|
-
_breadcrumbs.push(name, url)
|
15
|
-
end
|
16
|
-
|
17
|
-
def breadcrumbs(options={}, &block)
|
18
|
-
#builder = Loaf::Builder.new(options)
|
19
|
-
options = config.merge(options)
|
20
|
-
|
21
|
-
_breadcrumbs.each do |crumb|
|
22
|
-
|
23
|
-
name = if crumb.name
|
24
|
-
formatted = options[:capitalize] ? crumb.name.capitalize : crumb.name
|
25
|
-
truncate(formatted, :length => options[:crumb_length])
|
26
|
-
else
|
27
|
-
'[name-error]'
|
28
|
-
end
|
29
|
-
|
30
|
-
url = url_for _process_url_for(crumb.url)
|
31
|
-
|
32
|
-
styles = ( request.request_uri.split('?')[0] == url ? "#{options[:style_classes]}" : '' )
|
33
|
-
|
34
|
-
block.call(name, url, styles)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def _process_url_for(url)
|
41
|
-
if url.is_a?(String) || url.is_a?(Symbol)
|
42
|
-
return send url
|
43
|
-
else
|
44
|
-
return url
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end # Helpers
|
49
|
-
end # Loaf
|