bootstrap-sass-extras 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3fb89b0dac2bdbce1b2c0b80f970f8c2f8f4b4f
4
- data.tar.gz: ff4cb7955a581564fa9f33b1e2a7d3cd20bff4a2
3
+ metadata.gz: 550a564e70192941701c65f0c2f260f9214a238e
4
+ data.tar.gz: 71be55dfd76ad3476b5fead050a3666693905160
5
5
  SHA512:
6
- metadata.gz: 991f34f1c4b0c695d9aca47d7604fe04b33e5397b807d99940d1f89384c0fe9ba44945a8b30d8e48157ef9c0c409fa6054909fb95d52ea809be7d17cc27953bb
7
- data.tar.gz: 10f5f1afbdbcb87cd455a0cceef1fc73adada250b1a6e2fca9d8e663a1889bc2c182cf3c44de3894c8e13c8591c7b8b098c4ae762da0f825d63676aa0d0c7867
6
+ metadata.gz: 3d87b9a5f91ad2dc39d345fed78f0807df9cde3f4e99da16424cd01dde79ed616bf3b05770e2bf671d30a15403c406eef52dceeb0a1ddac506784b1527a4dc28
7
+ data.tar.gz: eaf9f7312bc58f539c09b3aa4deab8b3cc96f340d124ce5487c51d1f990b6df960856334db0bb9747d72333f99cb12ebcc913bc8f920c91058e212ece3eb3cce
@@ -1,5 +1,10 @@
1
1
  module TwitterBreadcrumbsHelper
2
- def render_breadcrumbs(divider = '/')
3
- render :partial => 'twitter-bootstrap/breadcrumbs', :locals => { :divider => divider }
2
+ def render_breadcrumbs(divider = '/', &block)
3
+ content = render :partial => 'twitter-bootstrap/breadcrumbs', :layout => false, :locals => { :divider => divider }
4
+ if block_given?
5
+ capture(content, &block)
6
+ else
7
+ content
8
+ end
4
9
  end
5
10
  end
@@ -0,0 +1,40 @@
1
+ module BootstrapSassExtras
2
+ module BreadCrumbs
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def add_breadcrumb(name, url, options = {})
9
+ class_name = self.name
10
+ before_filter options do |controller|
11
+ name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol)
12
+ controller.send :add_breadcrumb, name, url
13
+ end
14
+ end
15
+ end
16
+
17
+ protected
18
+
19
+ def add_breadcrumb(name, url = '', options = {})
20
+ @breadcrumbs ||= []
21
+ name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol)
22
+ url = eval(url.to_s) if url =~ /_path|_url|@/
23
+ @breadcrumbs << {:name => name, :url => url, :options => options}
24
+ end
25
+
26
+ def translate_breadcrumb(name, class_name)
27
+ scope = [:breadcrumbs]
28
+ namespace = class_name.underscore.split('/')
29
+ namespace.last.sub!('_controller', '')
30
+ scope += namespace
31
+
32
+ I18n.t name, :scope => scope
33
+ end
34
+
35
+ def render_breadcrumbs(divider = '/')
36
+ s = render :partial => 'twitter-bootstrap/breadcrumbs', :locals => {:divider => divider}
37
+ s.first
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,4 @@
1
+ require File.dirname(__FILE__) + '/breadcrumbs.rb'
1
2
  module BootstrapSassExtras
2
3
  class Engine < ::Rails::Engine
3
4
  initializer 'bootstrap-sass-extras.setup_helpers' do |app|
@@ -6,6 +7,7 @@ module BootstrapSassExtras
6
7
  ActionController::Base.send :helper, GlyphHelper
7
8
  ActionController::Base.send :helper, ModalHelper
8
9
  ActionController::Base.send :helper, TwitterBreadcrumbsHelper
10
+ ActionController::Base.send :include, BootstrapSassExtras::BreadCrumbs
9
11
  end
10
12
  end
11
13
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapSassExtras
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-sass-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - doabit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-18 00:00:00.000000000 Z
11
+ date: 2013-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -74,6 +74,7 @@ files:
74
74
  - app/views/twitter-bootstrap/_breadcrumbs.html.erb
75
75
  - bootstrap-sass-extras.gemspec
76
76
  - lib/bootstrap-sass-extras.rb
77
+ - lib/bootstrap-sass-extras/breadcrumbs.rb
77
78
  - lib/bootstrap-sass-extras/engine.rb
78
79
  - lib/bootstrap-sass-extras/version.rb
79
80
  - lib/generators/bootstrap/install/install_generator.rb