bootstrap-sass-extras 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/Gemfile +4 -1
  4. data/Gemfile.lock +18 -4
  5. data/README.md +91 -37
  6. data/app/helpers/badge_helper.rb +13 -0
  7. data/app/helpers/bootstrap_flash_helper.rb +17 -15
  8. data/app/helpers/glyph_helper.rb +10 -7
  9. data/app/helpers/modal_helper.rb +19 -15
  10. data/app/helpers/twitter_breadcrumbs_helper.rb +3 -2
  11. data/app/views/bootstrap_sass_extras/_breadcrumbs.html.erb +6 -0
  12. data/bootstrap-sass-extras.gemspec +1 -0
  13. data/lib/bootstrap-sass-extras/breadcrumbs.rb +26 -9
  14. data/lib/bootstrap-sass-extras/engine.rb +1 -0
  15. data/lib/bootstrap-sass-extras/version.rb +1 -1
  16. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +1 -0
  17. data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
  18. data/lib/generators/bootstrap/layout/templates/layout.html.erb +32 -50
  19. data/lib/generators/bootstrap/layout/templates/layout.html.haml +20 -38
  20. data/lib/generators/bootstrap/layout/templates/layout.html.slim +20 -39
  21. data/lib/generators/bootstrap/themed/templates/_form.html.erb +10 -8
  22. data/lib/generators/bootstrap/themed/templates/_form.html.haml +8 -7
  23. data/lib/generators/bootstrap/themed/templates/_form.html.slim +8 -8
  24. data/lib/generators/bootstrap/themed/templates/index.html.erb +12 -10
  25. data/lib/generators/bootstrap/themed/templates/index.html.haml +8 -4
  26. data/lib/generators/bootstrap/themed/templates/index.html.slim +11 -9
  27. data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
  28. data/lib/generators/bootstrap/themed/templates/show.html.erb +12 -10
  29. data/lib/generators/bootstrap/themed/templates/show.html.haml +13 -12
  30. data/lib/generators/bootstrap/themed/templates/show.html.slim +11 -10
  31. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +9 -7
  32. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +5 -4
  33. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +5 -5
  34. data/spec/dummy/db/schema.rb +16 -0
  35. data/spec/helpers/badge_helper_spec.rb +16 -0
  36. data/spec/helpers/bootstrap_flash_helper_spec.rb +54 -39
  37. data/spec/helpers/glyph_helper_spec.rb +15 -0
  38. data/spec/helpers/twitter_breadcrumbs_helper_spec.rb +153 -0
  39. metadata +13 -5
  40. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +0 -14
@@ -1,6 +1,7 @@
1
1
  module TwitterBreadcrumbsHelper
2
- def render_breadcrumbs(divider = '/', &block)
3
- content = render :partial => 'twitter-bootstrap/breadcrumbs', :layout => false, :locals => { :divider => divider }
2
+ def render_breadcrumbs(&block)
3
+ return unless breadcrumbs?
4
+ content = render 'bootstrap_sass_extras/breadcrumbs'
4
5
  if block_given?
5
6
  capture(content, &block)
6
7
  else
@@ -0,0 +1,6 @@
1
+ <ol class="breadcrumb">
2
+ <% @breadcrumbs[0..-2].each do |crumb| %>
3
+ <li><%= link_to crumb[:name], crumb[:url], crumb[:options] %></li>
4
+ <% end %>
5
+ <li class="active"><%= last_breadcrumb_name %></li>
6
+ </ol>
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
19
20
  gem.add_dependency "rails", ">= 3.1.0"
20
21
 
21
22
  gem.add_development_dependency "rspec-rails"
@@ -2,13 +2,18 @@ module BootstrapSassExtras
2
2
  module BreadCrumbs
3
3
  def self.included(base)
4
4
  base.extend(ClassMethods)
5
+ base.helper_method :breadcrumbs?,
6
+ :breadcrumb_names,
7
+ :last_breadcrumb_name
5
8
  end
6
9
 
7
10
  module ClassMethods
8
11
  def add_breadcrumb(name, url, options = {})
9
12
  class_name = self.name
10
13
  before_filter options do |controller|
11
- name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol)
14
+ if name.is_a?(Symbol)
15
+ name = controller.send :translate_breadcrumb, name, class_name
16
+ end
12
17
  controller.send :add_breadcrumb, name, url
13
18
  end
14
19
  end
@@ -19,22 +24,34 @@ module BootstrapSassExtras
19
24
  def add_breadcrumb(name, url = '', options = {})
20
25
  @breadcrumbs ||= []
21
26
  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}
27
+ url = send(url.to_s) if url =~ /_path|_url|@/
28
+ @breadcrumbs << { name: name, url: url, options: options }
24
29
  end
25
30
 
26
31
  def translate_breadcrumb(name, class_name)
27
32
  scope = [:breadcrumbs]
28
33
  namespace = class_name.underscore.split('/')
29
34
  namespace.last.sub!('_controller', '')
30
- scope += namespace
35
+ scope << namespace
31
36
 
32
- I18n.t name, :scope => scope
37
+ I18n.t name, scope: scope
33
38
  end
34
39
 
35
- def render_breadcrumbs(divider = '/')
36
- s = render :partial => 'twitter-bootstrap/breadcrumbs', :locals => {:divider => divider}
37
- s.first
40
+ def clear_breadcrumbs
41
+ @breadcrumbs = nil
42
+ end
43
+
44
+ def breadcrumbs?
45
+ Array(@breadcrumbs).any?
46
+ end
47
+
48
+ def breadcrumb_names
49
+ Array(@breadcrumbs).map { |breadcrumb| breadcrumb[:name] }
50
+ end
51
+
52
+ def last_breadcrumb_name
53
+ return unless crumb = Array(@breadcrumbs).last
54
+ crumb[:name]
38
55
  end
39
56
  end
40
- end
57
+ end
@@ -6,6 +6,7 @@ module BootstrapSassExtras
6
6
  ActionController::Base.send :helper, BootstrapFlashHelper
7
7
  ActionController::Base.send :helper, BootstrapViewportMetaHelper
8
8
  ActionController::Base.send :helper, GlyphHelper
9
+ ActionController::Base.send :helper, BadgeHelper
9
10
  ActionController::Base.send :helper, ModalHelper
10
11
  ActionController::Base.send :helper, TwitterBreadcrumbsHelper
11
12
  ActionController::Base.send :include, BootstrapSassExtras::BreadCrumbs
@@ -1,3 +1,3 @@
1
1
  module BootstrapSassExtras
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -11,6 +11,7 @@ en:
11
11
  destroy: "Delete"
12
12
  new: "New"
13
13
  edit: "Edit"
14
+ show: "Show"
14
15
  titles:
15
16
  edit: "Edit"
16
17
  save: "Save"
@@ -6,15 +6,12 @@ module Bootstrap
6
6
  source_root File.expand_path("../templates", __FILE__)
7
7
  desc "This generator generates layout file with navigation."
8
8
  argument :layout_name, :type => :string, :default => "application"
9
- argument :layout_type, :type => :string, :default => "fixed",
10
- :banner => "*fixed or fluid"
11
9
 
12
- attr_reader :app_name, :container_class
10
+ attr_reader :app_name
13
11
 
14
12
  def generate_layout
15
13
  app = ::Rails.application
16
14
  @app_name = app.class.to_s.split("::").first
17
- @container_class = layout_type == "fluid" ? "container-fluid" : "container"
18
15
  ext = app.config.generators.options[:rails][:template_engine] || :erb
19
16
  template "layout.html.#{ext}", "app/views/layouts/#{layout_name}.html.#{ext}"
20
17
  end
@@ -10,6 +10,7 @@
10
10
  <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
11
11
  <!--[if lt IE 9]>
12
12
  <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
13
+ <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js" type="text/javascript"></script>
13
14
  <![endif]-->
14
15
 
15
16
  <%%= stylesheet_link_tag "application", :media => "all" %>
@@ -33,77 +34,58 @@
33
34
  <!-- For all other devices -->
34
35
  <!-- Size should be 32 x 32 pixels -->
35
36
  <%%= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' %>
37
+ <%%= javascript_include_tag "application" %>
36
38
  </head>
37
39
  <body>
38
40
 
39
- <div class="navbar navbar-<%= layout_type %>-top">
40
- <div class="navbar-inner">
41
- <div class="<%= container_class %>">
42
- <a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
41
+ <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
42
+ <div class="container">
43
+ <!-- Brand and toggle get grouped for better mobile display -->
44
+ <div class="navbar-header">
45
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
46
+ <span class="sr-only">Toggle navigation</span>
43
47
  <span class="icon-bar"></span>
44
48
  <span class="icon-bar"></span>
45
49
  <span class="icon-bar"></span>
46
- </a>
47
- <a class="brand" href="#"><%= app_name %></a>
48
- <div class="<%= container_class %> nav-collapse">
49
- <ul class="nav">
50
- <li><%%= link_to "Link1", "/path1" %></li>
51
- <li><%%= link_to "Link2", "/path2" %></li>
52
- <li><%%= link_to "Link3", "/path3" %></li>
53
- </ul>
54
- </div><!--/.nav-collapse -->
50
+ </button>
51
+ <a class="navbar-brand" href="#"><%= app_name%></a>
55
52
  </div>
53
+
54
+ <!-- Collect the nav links, forms, and other content for toggling -->
55
+ <div class="navbar-collapse collapse navbar-responsive-collapse">
56
+ <ul class="nav navbar-nav">
57
+ <li class="active"><%%= link_to "Link1", '#' %></li>
58
+ <li><%%= link_to "Link2", '#' %></li>
59
+ <li><%%= link_to "Link3", '#' %></li>
60
+ </ul>
61
+ </div><!-- /.navbar-collapse -->
56
62
  </div>
57
- </div>
63
+ </nav>
58
64
 
59
- <div class="<%= container_class %>">
60
- <%- if layout_type == "fluid" -%>
61
- <div class="row-fluid">
62
- <div class="span3">
65
+ <div class="container">
66
+ <div class="row">
67
+ <div class="col-md-9">
68
+ <%%= bootstrap_flash %>
69
+ <%%= yield %>
70
+ </div>
71
+ <div class="col-md-3">
63
72
  <div class="well sidebar-nav">
73
+ <h3>Sidebar</h3>
64
74
  <ul class="nav nav-list">
65
75
  <li class="nav-header">Sidebar</li>
66
- <li><%%= link_to "Link1", "/path1" %></li>
67
- <li><%%= link_to "Link2", "/path2" %></li>
68
- <li><%%= link_to "Link3", "/path3" %></li>
76
+ <li><%%= link_to "Link1", "#" %></li>
77
+ <li><%%= link_to "Link2", "#" %></li>
78
+ <li><%%= link_to "Link3", "#" %></li>
69
79
  </ul>
70
80
  </div><!--/.well -->
71
81
  </div><!--/span-->
72
- <div class="span9">
73
- <%%= bootstrap_flash %>
74
- <%%= yield %>
75
- </div>
76
82
  </div><!--/row-->
77
- <%- else -%>
78
- <div class="row">
79
- <div class="span9">
80
- <%%= bootstrap_flash %>
81
- <%%= yield %>
82
- </div>
83
- <div class="span3">
84
- <div class="well sidebar-nav">
85
- <h3>Sidebar</h3>
86
- <ul class="nav nav-list">
87
- <li class="nav-header">Sidebar</li>
88
- <li><%%= link_to "Link1", "/path1" %></li>
89
- <li><%%= link_to "Link2", "/path2" %></li>
90
- <li><%%= link_to "Link3", "/path3" %></li>
91
- </ul>
92
- </div><!--/.well -->
93
- </div><!--/span-->
94
- </div><!--/row-->
95
- <%- end -%>
96
83
 
97
84
  <footer>
98
- <p>&copy; Company 2013</p>
85
+ <p>&copy; Company <%= Date.today.year %></p>
99
86
  </footer>
100
87
 
101
88
  </div> <!-- /container -->
102
89
 
103
- <!-- Javascripts
104
- ================================================== -->
105
- <!-- Placed at the end of the document so the pages load faster -->
106
- <%%= javascript_include_tag "application" %>
107
-
108
90
  </body>
109
91
  </html>
@@ -9,61 +9,43 @@
9
9
  / Le HTML5 shim, for IE6-8 support of HTML elements
10
10
  /[if lt IE 9]
11
11
  = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js"
12
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js"
12
13
  = stylesheet_link_tag "application", :media => "all"
13
14
  = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144'
14
15
  = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114'
15
16
  = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72'
16
17
  = favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png'
17
18
  = favicon_link_tag 'favicon.ico', :rel => 'shortcut icon'
18
-
19
+ = javascript_include_tag "application"
19
20
 
20
21
  %body
21
- .navbar.navbar-<%= layout_type %>-top
22
- .navbar-inner
23
- .<%= container_class %>
24
- %a.btn.btn-navbar(data-target=".nav-collapse" data-toggle="collapse")
22
+ %nav.navbar.navbar-default.navbar-fixed-top(role="navigation")
23
+ .container
24
+ .navbar-header
25
+ %button.navbar-toggle(type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse")
25
26
  %span.icon-bar
26
27
  %span.icon-bar
27
28
  %span.icon-bar
28
- %a.brand(href="#") <%= app_name %>
29
- .container.nav-collapse
30
- %ul.nav
31
- %li= link_to "Link 1", "/path1"
32
- %li= link_to "Link 2", "/path2"
33
- %li= link_to "Link 3", "/path3"
34
-
35
- .<%= container_class %>
36
- <%- if layout_type == "fluid" -%>
29
+ %a.navbar-brand(href="#") <%= app_name %>
30
+ .navbar-collapse.collapse.navbar-responsive-collapse
31
+ %ul.nav.navbar-nav
32
+ %li.active= link_to "Link 1", "#"
33
+ %li= link_to "Link 2", "#"
34
+ %li= link_to "Link 3", "#"
35
+ %li= link_to "Link 3", "#"
37
36
 
38
- .row-fluid
39
- .span3
40
- .well.sidebar-nav
41
- %ul.nav.nav-list
42
- %li.nav-header Sidebar
43
- %li= link_to "Link 1", "/path1"
44
- %li= link_to "Link 2", "/path2"
45
- %li= link_to "Link 3", "/path3"
46
- .span9
47
- = bootstrap_flash
48
- = yield
49
- <% else %>
37
+ .container
50
38
  .row
51
- .span9
39
+ .col-md-9
52
40
  = bootstrap_flash
53
41
  = yield
54
- .span3
42
+ .col-md-3
55
43
  .well.sidebar-nav
56
44
  %h3 Sidebar
57
45
  %ul.nav.nav-list
58
46
  %li.nav-header Sidebar
59
- %li= link_to "Link 1", "/path1"
60
- %li= link_to "Link 2", "/path2"
61
- %li= link_to "Link 3", "/path3"
62
- <% end %>
47
+ %li= link_to "Link 1", "#"
48
+ %li= link_to "Link 2", "#"
49
+ %li= link_to "Link 3", "#"
63
50
  %footer
64
- %p &copy; Company 2013
65
- /
66
- Javascripts
67
- \==================================================
68
- / Placed at the end of the document so the pages load faster
69
- = javascript_include_tag "application"
51
+ %p &copy; Company <%= Date.today.year %>
@@ -10,62 +10,43 @@ html lang="en"
10
10
  /! Le HTML5 shim, for IE6-8 support of HTML elements
11
11
  /[if lt IE 9]
12
12
  = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js"
13
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js"
13
14
  = stylesheet_link_tag "application", :media => "all"
14
15
  = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144'
15
16
  = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114'
16
17
  = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72'
17
18
  = favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png'
18
19
  = favicon_link_tag 'favicon.ico', :rel => 'shortcut icon'
19
-
20
-
20
+ = javascript_include_tag "application"
21
21
 
22
22
  body
23
- .navbar.navbar-<%= layout_type %>-top
24
- .navbar-inner
25
- .<%= container_class %>
26
- a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse"
23
+ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
24
+ .container
25
+ .navbar-header
26
+ button.navbar-toggle type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse"
27
27
  span.icon-bar
28
28
  span.icon-bar
29
29
  span.icon-bar
30
- a.brand href="#"<%= app_name %>
31
- .<%=container_class%>.nav-collapse
32
- ul.nav
33
- li= link_to "Link 1", "/path1"
34
- li= link_to "Link 2", "/path2"
35
- li= link_to "Link 3", "/path3"
30
+ a.navbar-brand href="#" <%= app_name %>
31
+ .navbar-collapse.collapse.navbar-responsive-collapse
32
+ ul.nav.navbar-nav
33
+ li.active= link_to "Link 1", "#"
34
+ li= link_to "Link 2", "#"
35
+ li= link_to "Link 3", "#"
36
36
 
37
- .<%= container_class %>
38
- <%- if layout_type == "fluid" -%>
39
-
40
- .row-fluid
41
- .span3
42
- .well.sidebar-nav
43
- ul.nav.nav-list
44
- li.nav-header Sidebar
45
- li= link_to "Link 1", "/path1"
46
- li= link_to "Link 2", "/path2"
47
- li= link_to "Link 3", "/path3"
48
- .span9
49
- = bootstrap_flash
50
- = yield
51
- <% else %>
37
+ .container
52
38
  .row
53
- .span9
39
+ .col-md-9
54
40
  = bootstrap_flash
55
41
  = yield
56
- .span3
42
+ .col-md-3
57
43
  .well.sidebar-nav
58
44
  h3 Sidebar
59
45
  ul.nav.nav-list
60
46
  li.nav-header Sidebar
61
- li= link_to "Link 1", "/path1"
62
- li= link_to "Link 2", "/path2"
63
- li= link_to "Link 3", "/path3"
64
- <% end %>
47
+ li= link_to "Link 1", "#"
48
+ li= link_to "Link 2", "#"
49
+ li= link_to "Link 3", "#"
50
+
65
51
  footer
66
- p &copy; Company 2013
67
- /!
68
- Javascripts
69
- \==================================================
70
- /! Placed at the end of the document so the pages load faster
71
- = javascript_include_tag "application"
52
+ p &copy; Company <%= Date.today.year %>
@@ -1,16 +1,18 @@
1
1
  <%%= form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
2
2
  <%- columns.each do |column| -%>
3
- <div class="control-group">
4
- <%%= f.label :<%= column.name %>, :class => 'control-label' %>
5
- <div class="controls">
6
- <%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
3
+ <div class="form-group">
4
+ <%%= f.label :<%= column.name %>, :class => 'control-label col-md-2' %>
5
+ <div class="col-md-10">
6
+ <%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %> form-control' %>
7
7
  </div>
8
8
  </div>
9
9
  <%- end -%>
10
10
 
11
- <div class="form-actions">
12
- <%%= f.submit nil, :class => 'btn btn-primary' %>
13
- <%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
14
- <%= controller_routing_path %>_path, :class => 'btn' %>
11
+ <div class="form-group">
12
+ <div class='col-md-offset-2 col-md-10'>
13
+ <%%= f.submit nil, :class => 'btn btn-primary' %>
14
+ <%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
15
+ <%= controller_routing_path %>_path, :class => 'btn btn-default' %>
16
+ </div>
15
17
  </div>
16
18
  <%% end %>
@@ -1,10 +1,11 @@
1
1
  = form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
2
2
  <%- columns.each do |column| -%>
3
- .control-group
4
- = f.label :<%= column.name %>, :class => 'control-label'
5
- .controls
6
- = f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
3
+ .form-group
4
+ = f.label :<%= column.name %>, :class => 'control-label col-md-2'
5
+ .col-md-10
6
+ = f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %> form-control'
7
7
  <%- end -%>
8
- .form-actions
9
- = f.submit nil, :class => 'btn btn-primary'
10
- = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
8
+ .form-group
9
+ .col-md-offset-2.col-md-10
10
+ = f.submit nil, :class => 'btn btn-primary'
11
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'