twitter-bootstrap3-rails 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +708 -0
  3. data/Rakefile +46 -0
  4. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  5. data/app/assets/fonts/fontawesome-webfont.svg +399 -0
  6. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  7. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  8. data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  9. data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  10. data/app/assets/javascripts/twitter/bootstrap.js +12 -0
  11. data/app/assets/javascripts/twitter/bootstrap/affix.js +126 -0
  12. data/app/assets/javascripts/twitter/bootstrap/alert.js +98 -0
  13. data/app/assets/javascripts/twitter/bootstrap/button.js +109 -0
  14. data/app/assets/javascripts/twitter/bootstrap/carousel.js +217 -0
  15. data/app/assets/javascripts/twitter/bootstrap/collapse.js +179 -0
  16. data/app/assets/javascripts/twitter/bootstrap/dropdown.js +154 -0
  17. data/app/assets/javascripts/twitter/bootstrap/modal.js +244 -0
  18. data/app/assets/javascripts/twitter/bootstrap/popover.js +117 -0
  19. data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +158 -0
  20. data/app/assets/javascripts/twitter/bootstrap/tab.js +135 -0
  21. data/app/assets/javascripts/twitter/bootstrap/tooltip.js +382 -0
  22. data/app/assets/javascripts/twitter/bootstrap/transition.js +56 -0
  23. data/app/assets/javascripts/twitter/bootstrap_ujs.js +11 -0
  24. data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5579 -0
  25. data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +787 -0
  26. data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +146 -0
  27. data/app/helpers/badge_label_helper.rb +16 -0
  28. data/app/helpers/bootstrap_flash_helper.rb +29 -0
  29. data/app/helpers/flash_block_helper.rb +17 -0
  30. data/app/helpers/glyph_helper.rb +17 -0
  31. data/app/helpers/modal_helper.rb +59 -0
  32. data/app/helpers/navbar_helper.rb +195 -0
  33. data/app/helpers/twitter_breadcrumbs_helper.rb +10 -0
  34. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +12 -0
  35. data/lib/generators/bootstrap/install/install_generator.rb +82 -0
  36. data/lib/generators/bootstrap/install/templates/application.css +7 -0
  37. data/lib/generators/bootstrap/install/templates/application.js +10 -0
  38. data/lib/generators/bootstrap/install/templates/bootstrap.coffee +3 -0
  39. data/lib/generators/bootstrap/install/templates/bootstrap.js +4 -0
  40. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.css +7 -0
  41. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +29 -0
  42. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +18 -0
  43. data/lib/generators/bootstrap/layout/layout_generator.rb +20 -0
  44. data/lib/generators/bootstrap/layout/templates/layout.html.erb +85 -0
  45. data/lib/generators/bootstrap/layout/templates/layout.html.haml +50 -0
  46. data/lib/generators/bootstrap/layout/templates/layout.html.slim +52 -0
  47. data/lib/generators/bootstrap/partial/partial_generator.rb +20 -0
  48. data/lib/generators/bootstrap/partial/templates/_login.html.erb +28 -0
  49. data/lib/generators/bootstrap/themed/templates/_form.html.erb +16 -0
  50. data/lib/generators/bootstrap/themed/templates/_form.html.haml +9 -0
  51. data/lib/generators/bootstrap/themed/templates/_form.html.slim +10 -0
  52. data/lib/generators/bootstrap/themed/templates/edit.html.erb +5 -0
  53. data/lib/generators/bootstrap/themed/templates/edit.html.haml +4 -0
  54. data/lib/generators/bootstrap/themed/templates/edit.html.slim +4 -0
  55. data/lib/generators/bootstrap/themed/templates/index.html.erb +40 -0
  56. data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
  57. data/lib/generators/bootstrap/themed/templates/index.html.slim +27 -0
  58. data/lib/generators/bootstrap/themed/templates/new.html.erb +5 -0
  59. data/lib/generators/bootstrap/themed/templates/new.html.haml +4 -0
  60. data/lib/generators/bootstrap/themed/templates/new.html.slim +4 -0
  61. data/lib/generators/bootstrap/themed/templates/show.html.erb +21 -0
  62. data/lib/generators/bootstrap/themed/templates/show.html.haml +15 -0
  63. data/lib/generators/bootstrap/themed/templates/show.html.slim +16 -0
  64. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +13 -0
  65. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +10 -0
  66. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +11 -0
  67. data/lib/generators/bootstrap/themed/themed_generator.rb +148 -0
  68. data/lib/twitter-bootstrap-rails.rb +10 -0
  69. data/lib/twitter/bootstrap/rails/bootstrap.rb +2 -0
  70. data/lib/twitter/bootstrap/rails/engine.rb +33 -0
  71. data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +42 -0
  72. data/lib/twitter/bootstrap/rails/version.rb +7 -0
  73. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +22 -0
  74. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +62 -0
  75. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +331 -0
  76. data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +47 -0
  77. data/spec/spec_helper.rb +11 -0
  78. data/test/lib/breadcrumbs_test.rb +75 -0
  79. data/test/test_helper.rb +11 -0
  80. data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5579 -0
  81. data/vendor/static-source/bootstrap.less +1 -0
  82. data/vendor/static-source/fontawesome.less +9 -0
  83. data/vendor/static-source/sprites.less +6 -0
  84. data/vendor/toolkit/fontawesome/bootstrap.less +84 -0
  85. data/vendor/toolkit/fontawesome/core.less +129 -0
  86. data/vendor/toolkit/fontawesome/extras.less +93 -0
  87. data/vendor/toolkit/fontawesome/font-awesome-ie7.less +1953 -0
  88. data/vendor/toolkit/fontawesome/font-awesome.less +33 -0
  89. data/vendor/toolkit/fontawesome/icons.less +381 -0
  90. data/vendor/toolkit/fontawesome/mixins.less +48 -0
  91. data/vendor/toolkit/fontawesome/path.less +14 -0
  92. data/vendor/toolkit/fontawesome/variables.less +735 -0
  93. data/vendor/toolkit/twitter/bootstrap/alerts.less +71 -0
  94. data/vendor/toolkit/twitter/bootstrap/badges.less +51 -0
  95. data/vendor/toolkit/twitter/bootstrap/bootstrap.less +63 -0
  96. data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +23 -0
  97. data/vendor/toolkit/twitter/bootstrap/button-groups.less +244 -0
  98. data/vendor/toolkit/twitter/bootstrap/buttons.less +159 -0
  99. data/vendor/toolkit/twitter/bootstrap/carousel.less +204 -0
  100. data/vendor/toolkit/twitter/bootstrap/close.less +33 -0
  101. data/vendor/toolkit/twitter/bootstrap/code.less +56 -0
  102. data/vendor/toolkit/twitter/bootstrap/component-animations.less +29 -0
  103. data/vendor/toolkit/twitter/bootstrap/dropdowns.less +176 -0
  104. data/vendor/toolkit/twitter/bootstrap/forms.less +332 -0
  105. data/vendor/toolkit/twitter/bootstrap/grid.less +340 -0
  106. data/vendor/toolkit/twitter/bootstrap/input-groups.less +127 -0
  107. data/vendor/toolkit/twitter/bootstrap/jumbotron.less +29 -0
  108. data/vendor/toolkit/twitter/bootstrap/labels.less +54 -0
  109. data/vendor/toolkit/twitter/bootstrap/list-group.less +88 -0
  110. data/vendor/toolkit/twitter/bootstrap/media.less +56 -0
  111. data/vendor/toolkit/twitter/bootstrap/mixins.less +693 -0
  112. data/vendor/toolkit/twitter/bootstrap/modals.less +133 -0
  113. data/vendor/toolkit/twitter/bootstrap/navbar.less +559 -0
  114. data/vendor/toolkit/twitter/bootstrap/navs.less +228 -0
  115. data/vendor/toolkit/twitter/bootstrap/normalize.less +396 -0
  116. data/vendor/toolkit/twitter/bootstrap/pager.less +55 -0
  117. data/vendor/toolkit/twitter/bootstrap/pagination.less +72 -0
  118. data/vendor/toolkit/twitter/bootstrap/panels.less +128 -0
  119. data/vendor/toolkit/twitter/bootstrap/popovers.less +133 -0
  120. data/vendor/toolkit/twitter/bootstrap/print.less +100 -0
  121. data/vendor/toolkit/twitter/bootstrap/progress-bars.less +99 -0
  122. data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +149 -0
  123. data/vendor/toolkit/twitter/bootstrap/scaffolding.less +111 -0
  124. data/vendor/toolkit/twitter/bootstrap/tables.less +211 -0
  125. data/vendor/toolkit/twitter/bootstrap/thumbnails.less +42 -0
  126. data/vendor/toolkit/twitter/bootstrap/tooltip.less +95 -0
  127. data/vendor/toolkit/twitter/bootstrap/type.less +238 -0
  128. data/vendor/toolkit/twitter/bootstrap/utilities.less +42 -0
  129. data/vendor/toolkit/twitter/bootstrap/variables.less +607 -0
  130. data/vendor/toolkit/twitter/bootstrap/wells.less +29 -0
  131. data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
  132. metadata +297 -0
@@ -0,0 +1,16 @@
1
+ <%%= form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
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 %>' %>
7
+ </div>
8
+ </div>
9
+ <%- end -%>
10
+
11
+
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 btn-default' %>
15
+
16
+ <%% end %>
@@ -0,0 +1,9 @@
1
+ = form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
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 %>'
7
+ <%- end -%>
8
+ = f.submit nil, :class => 'btn btn-primary'
9
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
@@ -0,0 +1,10 @@
1
+ = form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
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 %>'
7
+ <%- end -%>
8
+ = f.submit nil, :class => 'btn btn-primary'
9
+ '
10
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
@@ -0,0 +1,5 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header">
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize %></h1>
4
+ </div>
5
+ <%%= render :partial => 'form' %>
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ div class="page-header"
3
+ h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,40 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header">
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
4
+ </div>
5
+ <table class="table table-striped">
6
+ <thead>
7
+ <tr>
8
+ <th><%%= model_class.human_attribute_name(:id) %></th>
9
+ <%- columns.each do |column| -%>
10
+ <th><%%= model_class.human_attribute_name(:<%= column.name %>) %></th>
11
+ <%- end -%>
12
+ <th><%%= model_class.human_attribute_name(:created_at) %></th>
13
+ <th><%%=t '.actions', :default => t("helpers.actions") %></th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <%% @<%= plural_resource_name %>.each do |<%= resource_name %>| %>
18
+ <tr>
19
+ <td><%%= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %></td>
20
+ <%- columns.each do |column| -%>
21
+ <td><%%= <%= resource_name %>.<%= column.name %> %></td>
22
+ <%- end -%>
23
+ <td><%%=l <%= resource_name %>.created_at %></td>
24
+ <td>
25
+ <%%= link_to t('.edit', :default => t("helpers.links.edit")),
26
+ edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs' %>
27
+ <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
28
+ <%= singular_controller_routing_path %>_path(<%= resource_name %>),
29
+ :method => :delete,
30
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
31
+ :class => 'btn btn-xs btn-danger' %>
32
+ </td>
33
+ </tr>
34
+ <%% end %>
35
+ </tbody>
36
+ </table>
37
+
38
+ <%%= link_to t('.new', :default => t("helpers.links.new")),
39
+ new_<%= singular_controller_routing_path %>_path,
40
+ :class => 'btn btn-primary' %>
@@ -0,0 +1,25 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
+ %table.table.table-striped
5
+ %thead
6
+ %tr
7
+ %th= model_class.human_attribute_name(:id)
8
+ <%- columns.each do |column| -%>
9
+ %th= model_class.human_attribute_name(:<%= column.name %>)
10
+ <%- end -%>
11
+ %th= model_class.human_attribute_name(:created_at)
12
+ %th=t '.actions', :default => t("helpers.actions")
13
+ %tbody
14
+ - @<%= plural_resource_name %>.each do |<%= resource_name %>|
15
+ %tr
16
+ %td= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
17
+ <%- columns.each do |column| -%>
18
+ %td= <%= resource_name %>.<%= column.name %>
19
+ <%- end -%>
20
+ %td=l <%= resource_name %>.created_at
21
+ %td
22
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
23
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger'
24
+
25
+ = link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
@@ -0,0 +1,27 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ div class="page-header"
3
+ h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
+ table class="table table-striped"
5
+ thead
6
+ tr
7
+ th= model_class.human_attribute_name(:id)
8
+ <%- columns.each do |column| -%>
9
+ th= model_class.human_attribute_name(:<%= column.name %>)
10
+ <%- end -%>
11
+ th= model_class.human_attribute_name(:created_at)
12
+ th=t '.actions', :default => t("helpers.actions")
13
+ tbody
14
+ - @<%= plural_resource_name %>.each do |<%= resource_name %>|
15
+ tr
16
+ td= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
17
+ <%- columns.each do |column| -%>
18
+ td= <%= resource_name %>.<%= column.name %>
19
+ <%- end -%>
20
+ td=l <%= resource_name %>.created_at
21
+ td
22
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
23
+ '
24
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger'
25
+
26
+ = link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
27
+
@@ -0,0 +1,5 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header">
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize %></h1>
4
+ </div>
5
+ <%%= render :partial => 'form' %>
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ div class="page-header"
3
+ h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,21 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header">
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.titleize %></h1>
4
+ </div>
5
+
6
+ <dl class="dl-horizontal">
7
+ <%- columns.each do |column| -%>
8
+ <dt><strong><%%= model_class.human_attribute_name(:<%= column.name %>) %>:</strong></dt>
9
+ <dd><%%= @<%= resource_name %>.<%= column.name %> %></dd>
10
+ <%- end -%>
11
+ </dl>
12
+
13
+ <%%= link_to t('.back', :default => t("helpers.links.back")),
14
+ <%= controller_routing_path %>_path, :class => 'btn btn-default' %>
15
+ <%%= link_to t('.edit', :default => t("helpers.links.edit")),
16
+ edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default' %>
17
+ <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
18
+ <%= singular_controller_routing_path %>_path(@<%= resource_name %>),
19
+ :method => 'delete',
20
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
21
+ :class => 'btn btn-danger' %>
@@ -0,0 +1,15 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => model_class.model_name.human.titleize
4
+
5
+ <%- columns.each do |column| -%>
6
+ %p
7
+ %strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
+ %br
9
+ = @<%= resource_name %>.<%= column.name %>
10
+ <%- end -%>
11
+
12
+
13
+ = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
14
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
15
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -0,0 +1,16 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ div class="page-header"
3
+ h1=t '.title', :default => model_class.model_name.human.titleize
4
+
5
+ <%- columns.each do |column| -%>
6
+ p
7
+ strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
+ br
9
+ = @<%= resource_name %>.<%= column.name %>
10
+ <%- end -%>
11
+
12
+ = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
13
+ '
14
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
15
+ '
16
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -0,0 +1,13 @@
1
+ <%%= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
2
+ <%- columns.each do |column| -%>
3
+ <%%= f.input :<%= column.name %> %>
4
+ <%- end -%>
5
+ <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6
+ <%%= f.button :wrapped, :cancel => <%= controller_routing_path %>_path %>
7
+ <%- else -%>
8
+
9
+ <%%= f.button :submit, :class => 'btn-primary' %>
10
+ <%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
11
+ <%= controller_routing_path %>_path, :class => 'btn btn-default' %>
12
+ <%- end -%>
13
+ <%% end %>
@@ -0,0 +1,10 @@
1
+ = simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
2
+ <%- columns.each do |column| -%>
3
+ = f.input :<%= column.name %>
4
+ <%- end -%>
5
+ <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6
+ = f.button :wrapped, :cancel => <%= controller_routing_path %>_path
7
+ <%- else -%>
8
+ = f.button :submit, :class => 'btn-primary'
9
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
10
+ <%- end -%>
@@ -0,0 +1,11 @@
1
+ = simple_form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
2
+ <%- columns.each do |column| -%>
3
+ = f.input :<%= column.name %>
4
+ <%- end -%>
5
+ <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6
+ = f.button :wrapped, :cancel => <%= controller_routing_path %>_path
7
+ <%- else -%>
8
+ = f.button :submit, :class => 'btn-primary'
9
+ '
10
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
11
+ <%- end -%>
@@ -0,0 +1,148 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/generated_attribute'
3
+
4
+ module Bootstrap
5
+ module Generators
6
+ class ThemedGenerator < ::Rails::Generators::Base
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ argument :controller_path, :type => :string
9
+ argument :model_name, :type => :string, :required => false
10
+ argument :layout, :type => :string, :default => "application",
11
+ :banner => "Specify application layout"
12
+
13
+ class_option :excluded_columns, :type => :array, :required => false
14
+
15
+ def initialize(args, *options)
16
+ super(args, *options)
17
+ initialize_views_variables
18
+ end
19
+
20
+ def copy_views
21
+ generate_views
22
+ end
23
+
24
+ protected
25
+
26
+ def initialize_views_variables
27
+ @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
28
+ @controller_routing_path = @controller_file_path.gsub(/\//, '_')
29
+ @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
30
+ @model_name = @model_name.camelize
31
+ end
32
+
33
+ def controller_routing_path
34
+ @controller_routing_path
35
+ end
36
+
37
+ def singular_controller_routing_path
38
+ @controller_routing_path.singularize
39
+ end
40
+
41
+ def model_name
42
+ @model_name
43
+ end
44
+
45
+ def plural_model_name
46
+ @model_name.pluralize
47
+ end
48
+
49
+ def resource_name
50
+ @model_name.demodulize.underscore
51
+ end
52
+
53
+ def plural_resource_name
54
+ resource_name.pluralize
55
+ end
56
+
57
+ def columns
58
+ retrieve_columns.reject {|c| excluded?(c.name) }.map do |c|
59
+ new_attribute(c.name, c.type.to_s)
60
+ end
61
+ end
62
+
63
+ def excluded_columns_names
64
+ %w[_id _type id created_at updated_at]
65
+ end
66
+
67
+ def excluded_columns_pattern
68
+ [
69
+ /.*_checksum/,
70
+ /.*_count/,
71
+ ]
72
+ end
73
+
74
+ def excluded_columns
75
+ options['excluded_columns']||[]
76
+ end
77
+
78
+ def excluded?(name)
79
+ excluded_columns_names.include?(name) ||
80
+ excluded_columns_pattern.any? {|p| name =~ p } ||
81
+ excluded_columns.include?(name)
82
+ end
83
+
84
+ def retrieve_columns
85
+ if defined?(ActiveRecord) == "constant" && ActiveRecord.class == Module
86
+ rescue_block ActiveRecord::StatementInvalid do
87
+ @model_name.constantize.columns
88
+ end
89
+ else
90
+ rescue_block do
91
+ @model_name.constantize.fields.map {|c| c[1] }
92
+ end
93
+ end
94
+ end
95
+
96
+ def new_attribute(name, type)
97
+ ::Rails::Generators::GeneratedAttribute.new(name, type)
98
+ end
99
+
100
+ def rescue_block(exception=Exception)
101
+ yield if block_given?
102
+ rescue exception => e
103
+ say e.message, :red
104
+ exit
105
+ end
106
+
107
+ def extract_modules(name)
108
+ modules = name.include?('/') ? name.split('/') : name.split('::')
109
+ name = modules.pop
110
+ path = modules.map { |m| m.underscore }
111
+ file_path = (path + [name.underscore]).join('/')
112
+ nesting = modules.map { |m| m.camelize }.join('::')
113
+ [name, path, file_path, nesting, modules.size]
114
+ end
115
+
116
+ def generate_views
117
+ options.engine == generate_erb(selected_views)
118
+ end
119
+
120
+ def selected_views
121
+ {
122
+ "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
123
+ "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
124
+ "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
125
+ "#{form_builder}_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
126
+ "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")
127
+ }
128
+ end
129
+
130
+ def generate_erb(views)
131
+ views.each do |template_name, output_path|
132
+ template template_name, output_path
133
+ end
134
+ end
135
+
136
+ def ext
137
+ ::Rails.application.config.generators.options[:rails][:template_engine] || :erb
138
+ end
139
+
140
+ def form_builder
141
+ defined?(::SimpleForm) ? 'simple_form/' : ''
142
+ end
143
+ end
144
+ end
145
+ end
146
+
147
+
148
+
@@ -0,0 +1,10 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module Rails
4
+ require 'twitter/bootstrap/rails/engine' if defined?(Rails)
5
+ end
6
+ end
7
+ end
8
+
9
+ #require 'less-rails'
10
+ require 'twitter/bootstrap/rails/bootstrap' if defined?(Rails)
@@ -0,0 +1,2 @@
1
+ require "twitter/bootstrap/rails/engine"
2
+ require "twitter/bootstrap/rails/version"
@@ -0,0 +1,33 @@
1
+ require 'rails'
2
+
3
+ require File.dirname(__FILE__) + '/twitter-bootstrap-breadcrumbs.rb'
4
+ require File.dirname(__FILE__) + '/../../../../app/helpers/flash_block_helper.rb'
5
+ require File.dirname(__FILE__) + '/../../../../app/helpers/modal_helper.rb'
6
+ require File.dirname(__FILE__) + '/../../../../app/helpers/navbar_helper.rb'
7
+
8
+ module Twitter
9
+ module Bootstrap
10
+ module Rails
11
+ class Engine < ::Rails::Engine
12
+ initializer 'twitter-bootstrap-rails.setup',
13
+ :after => 'less-rails.after.load_config_initializers',
14
+ :group => :all do |app|
15
+ if defined?(Less)
16
+ app.config.less.paths << File.join(config.root, 'vendor', 'toolkit')
17
+ end
18
+ end
19
+
20
+ initializer 'twitter-bootstrap-rails.setup_helpers' do |app|
21
+ app.config.to_prepare do
22
+ ActionController::Base.send :include, BreadCrumbs
23
+ ActionController::Base.send :helper, FlashBlockHelper
24
+ ActionController::Base.send :helper, ModalHelper
25
+ ActionController::Base.send :helper, NavbarHelper
26
+ ActionController::Base.send :helper, BadgeLabelHelper
27
+ #ActionController::Base.send :helper_method, :render_breadcrumbs
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end