fix-twitter-bootstrap-rails 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +213 -0
- data/Rakefile +14 -0
- data/lib/generators/bootstrap/install/install_generator.rb +53 -0
- data/lib/generators/bootstrap/install/templates/application.css +7 -0
- data/lib/generators/bootstrap/install/templates/application.js +10 -0
- data/lib/generators/bootstrap/install/templates/bootstrap.coffee +4 -0
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +19 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +23 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +99 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +71 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +72 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +19 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +13 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +2 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +3 -0
- data/lib/generators/bootstrap/themed/templates/index.html.erb +30 -0
- data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
- data/lib/generators/bootstrap/themed/templates/index.html.slim +25 -0
- data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -0
- data/lib/generators/bootstrap/themed/templates/new.html.haml +2 -0
- data/lib/generators/bootstrap/themed/templates/new.html.slim +2 -0
- data/lib/generators/bootstrap/themed/templates/show.html.erb +14 -0
- data/lib/generators/bootstrap/themed/templates/show.html.haml +9 -0
- data/lib/generators/bootstrap/themed/templates/show.html.slim +9 -0
- data/lib/generators/bootstrap/themed/themed_generator.rb +96 -0
- data/lib/twitter-bootstrap-rails.rb +10 -0
- data/lib/twitter/bootstrap/rails/bootstrap.rb +2 -0
- data/lib/twitter/bootstrap/rails/engine.rb +17 -0
- data/lib/twitter/bootstrap/rails/version.rb +7 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +94 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +100 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +157 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +136 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +92 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +210 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +95 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +125 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +130 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +270 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +51 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +271 -0
- data/vendor/toolkit/twitter/bootstrap/accordion.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/alerts.less +70 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +62 -0
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +148 -0
- data/vendor/toolkit/twitter/bootstrap/buttons.less +183 -0
- data/vendor/toolkit/twitter/bootstrap/carousel.less +121 -0
- data/vendor/toolkit/twitter/bootstrap/close.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/code.less +57 -0
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +130 -0
- data/vendor/toolkit/twitter/bootstrap/forms.less +522 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +20 -0
- data/vendor/toolkit/twitter/bootstrap/labels.less +32 -0
- data/vendor/toolkit/twitter/bootstrap/layouts.less +17 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +590 -0
- data/vendor/toolkit/twitter/bootstrap/modals.less +83 -0
- data/vendor/toolkit/twitter/bootstrap/navbar.less +299 -0
- data/vendor/toolkit/twitter/bootstrap/navs.less +353 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +30 -0
- data/vendor/toolkit/twitter/bootstrap/pagination.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +49 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +95 -0
- data/vendor/toolkit/twitter/bootstrap/reset.less +126 -0
- data/vendor/toolkit/twitter/bootstrap/responsive.less +327 -0
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +29 -0
- data/vendor/toolkit/twitter/bootstrap/sprites.less +158 -0
- data/vendor/toolkit/twitter/bootstrap/tables.less +150 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +35 -0
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +35 -0
- data/vendor/toolkit/twitter/bootstrap/type.less +218 -0
- data/vendor/toolkit/twitter/bootstrap/utilities.less +23 -0
- data/vendor/toolkit/twitter/bootstrap/variables.less +107 -0
- data/vendor/toolkit/twitter/bootstrap/wells.less +17 -0
- data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
- metadata +172 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html{:lang => "en"}
|
3
|
+
%head
|
4
|
+
%meta{:charset => "utf-8"}/
|
5
|
+
%title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
|
6
|
+
= csrf_meta_tags
|
7
|
+
/ Le HTML5 shim, for IE6-8 support of HTML elements
|
8
|
+
/[if lt IE 9]
|
9
|
+
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
10
|
+
/ Le styles
|
11
|
+
= stylesheet_link_tag "application", :media => "all"
|
12
|
+
/ Le fav and touch icons
|
13
|
+
%link{:href => "images/favicon.ico", :rel => "shortcut icon"}/
|
14
|
+
%link{:href => "images/apple-touch-icon.png", :rel => "apple-touch-icon"}/
|
15
|
+
%link{:href => "images/apple-touch-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"}/
|
16
|
+
%link{:href => "images/apple-touch-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"}/
|
17
|
+
|
18
|
+
|
19
|
+
%body
|
20
|
+
.navbar.navbar-fixed-top
|
21
|
+
.navbar-inner
|
22
|
+
<%- if layout_type == "fluid" -%>
|
23
|
+
.container-fluid
|
24
|
+
<%- else -%>
|
25
|
+
.container
|
26
|
+
<%- end -%>
|
27
|
+
%a.btn.btn-navbar{"data-target" => ".nav-collapse", "data-toggle" => "collapse"}
|
28
|
+
%span.icon-bar
|
29
|
+
%span.icon-bar
|
30
|
+
%span.icon-bar
|
31
|
+
%a.brand{:href => "#"}<%= app_name %>
|
32
|
+
.<%=container_class%>.nav-collapse
|
33
|
+
%ul.nav
|
34
|
+
%li= link_to "Link 1", "/path1"
|
35
|
+
%li= link_to "Link 2", "/path2"
|
36
|
+
%li= link_to "Link 3", "/path3"
|
37
|
+
|
38
|
+
.<%= container_class %>
|
39
|
+
<%- if layout_type == "fluid" -%>
|
40
|
+
|
41
|
+
.row-fluid
|
42
|
+
.span3
|
43
|
+
.well.sidebar-nav
|
44
|
+
%ul.nav.nav-list
|
45
|
+
%li.nav-header Sidebar
|
46
|
+
%li= link_to "Link 1", "/path1"
|
47
|
+
%li= link_to "Link 2", "/path2"
|
48
|
+
%li= link_to "Link 3", "/path3"
|
49
|
+
.span9
|
50
|
+
= yield
|
51
|
+
<% else %>
|
52
|
+
.content
|
53
|
+
.row
|
54
|
+
.span9
|
55
|
+
= yield
|
56
|
+
.span3
|
57
|
+
.well.sidebar-nav
|
58
|
+
%h3 Sidebar
|
59
|
+
%ul.nav.nav-list
|
60
|
+
%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 %>
|
65
|
+
%footer
|
66
|
+
%p © Company 2012
|
67
|
+
/
|
68
|
+
Le javascript
|
69
|
+
\==================================================
|
70
|
+
/ Placed at the end of the document so the pages load faster
|
71
|
+
= javascript_include_tag "application"
|
@@ -0,0 +1,72 @@
|
|
1
|
+
doctype html
|
2
|
+
html lang="en"
|
3
|
+
head
|
4
|
+
meta charset="utf-8"
|
5
|
+
title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
|
6
|
+
= csrf_meta_tags
|
7
|
+
|
8
|
+
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
9
|
+
/[if lt IE 9]
|
10
|
+
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
11
|
+
/! Le styles
|
12
|
+
= stylesheet_link_tag "application", :media => "all"
|
13
|
+
/ Le fav and touch icons
|
14
|
+
link href="images/favicon.ico" rel="shortcut icon"
|
15
|
+
link href="images/apple-touch-icon.png" rel="apple-touch-icon"
|
16
|
+
link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon" sizes="72x72"
|
17
|
+
link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon" sizes="114x114"
|
18
|
+
|
19
|
+
|
20
|
+
body
|
21
|
+
.navbar.navbar-fixed-top
|
22
|
+
.navbar-inner
|
23
|
+
<%- if layout_type == "fluid" -%>
|
24
|
+
.container-fluid
|
25
|
+
<%- else -%>
|
26
|
+
.container
|
27
|
+
<%- end -%>
|
28
|
+
a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse"
|
29
|
+
span.icon-bar
|
30
|
+
span.icon-bar
|
31
|
+
span.icon-bar
|
32
|
+
a.brand href="#"<%= app_name %>
|
33
|
+
.<%=container_class%>.nav-collapse
|
34
|
+
ul.nav
|
35
|
+
li= link_to "Link 1", "/path1"
|
36
|
+
li= link_to "Link 2", "/path2"
|
37
|
+
li= link_to "Link 3", "/path3"
|
38
|
+
|
39
|
+
.<%= container_class %>
|
40
|
+
<%- if layout_type == "fluid" -%>
|
41
|
+
|
42
|
+
.row-fluid
|
43
|
+
.span3
|
44
|
+
.well.sidebar-nav
|
45
|
+
ul.nav.nav-list
|
46
|
+
li.nav-header Sidebar
|
47
|
+
li= link_to "Link 1", "/path1"
|
48
|
+
li= link_to "Link 2", "/path2"
|
49
|
+
li= link_to "Link 3", "/path3"
|
50
|
+
.span9
|
51
|
+
= yield
|
52
|
+
<% else %>
|
53
|
+
.content
|
54
|
+
.row
|
55
|
+
.span9
|
56
|
+
= yield
|
57
|
+
.span3
|
58
|
+
.well.sidebar-nav
|
59
|
+
h3 Sidebar
|
60
|
+
ul.nav.nav-list
|
61
|
+
li.nav-header Sidebar
|
62
|
+
li= link_to "Link 1", "/path1"
|
63
|
+
li= link_to "Link 2", "/path2"
|
64
|
+
li= link_to "Link 3", "/path3"
|
65
|
+
<% end %>
|
66
|
+
footer
|
67
|
+
p © Company 2012
|
68
|
+
/!
|
69
|
+
Le javascript
|
70
|
+
\==================================================
|
71
|
+
/! Placed at the end of the document so the pages load faster
|
72
|
+
= javascript_include_tag "application"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%%= form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
|
2
|
+
<fieldset>
|
3
|
+
<legend><%%= controller.action_name.capitalize %> <%= model_name.titleize %></legend>
|
4
|
+
|
5
|
+
<%- columns.each do |column| -%>
|
6
|
+
<div class="control-group">
|
7
|
+
<%%= f.label :<%= column.name %>, :class => 'control-label' %>
|
8
|
+
<div class="controls">
|
9
|
+
<%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%- end -%>
|
14
|
+
<div class="form-actions">
|
15
|
+
<%%= f.submit nil, :class => 'btn btn-primary' %>
|
16
|
+
<%%= link_to 'Cancel', <%= controller_routing_path %>_path, :class => 'btn' %>
|
17
|
+
</div>
|
18
|
+
</fieldset>
|
19
|
+
<%% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%fieldset
|
2
|
+
%legend
|
3
|
+
= controller.action_name.capitalize
|
4
|
+
<%= model_name.titleize %>
|
5
|
+
<%- columns.each do |column| -%>
|
6
|
+
.control-group
|
7
|
+
= f.label :<%= column.name %>, :class => 'control-label'
|
8
|
+
.controls
|
9
|
+
= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
|
10
|
+
<%- end -%>
|
11
|
+
.form-actions
|
12
|
+
= f.submit nil, :class => 'btn btn-primary'
|
13
|
+
= link_to "Cancel", <%= controller_routing_path %>_path, :class => 'btn'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%- columns.each do |column| -%>
|
2
|
+
.clearfix
|
3
|
+
= f.label :<%= column.name %>, t("activerecord.attributes.<%= model_name.underscore %>.<%= column.name %>", :default => "<%= column.name.humanize %>"), :class => :label
|
4
|
+
.input
|
5
|
+
= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
|
6
|
+
<%- end -%>
|
7
|
+
|
8
|
+
.form-actions
|
9
|
+
button class="btn primary" type="submit" Save
|
10
|
+
| or
|
11
|
+
= link_to "Cancel", <%= controller_routing_path %>_path
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render :partial => 'form' %>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
= form_for @<%= resource_name %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => "edit_<%= resource_name %>", :id => "edit_<%= resource_name %>" } do |f|
|
2
|
+
input name="_method" type="hidden" value="put"
|
3
|
+
= render :partial => "form", :locals => {:f => f}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<h1><%= resource_name.titleize %>s</h1>
|
2
|
+
<table class="table table-striped">
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th>ID</th>
|
6
|
+
<%- unless columns.empty? -%>
|
7
|
+
<th><%= columns.first.name.humanize %></th>
|
8
|
+
<%- end -%>
|
9
|
+
<th>Created at</th>
|
10
|
+
<th>Actions</th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<%% @<%= plural_resource_name %>.each do |<%= resource_name %>| %>
|
15
|
+
<tr>
|
16
|
+
<td><%%= <%= resource_name %>.id %></td>
|
17
|
+
<%- unless columns.empty? -%>
|
18
|
+
<td><%%= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %></td>
|
19
|
+
<%- end -%>
|
20
|
+
<td><%%= <%= resource_name %>.created_at %></td>
|
21
|
+
<td>
|
22
|
+
<%%= link_to 'Edit', edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-mini' %>
|
23
|
+
<%%= link_to 'Destroy', <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => 'Are you sure?', :class => 'btn btn-mini btn-danger' %>
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
<%% end %>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
29
|
+
|
30
|
+
<%%= link_to 'New', new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary' %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
%h1 <%= resource_name.titleize %>s
|
2
|
+
%table{:class => "table table-striped"}
|
3
|
+
%thead
|
4
|
+
%tr
|
5
|
+
%th ID
|
6
|
+
<%- unless columns.empty? -%>
|
7
|
+
%th
|
8
|
+
= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= columns.first.name %>", :default => t("activerecord.labels.<%= columns.first.name %>", :default => "<%= columns.first.name.capitalize %>"))
|
9
|
+
<%- end -%>
|
10
|
+
%th Created at
|
11
|
+
%th Actions
|
12
|
+
%tbody
|
13
|
+
- @<%= plural_resource_name %>.each do |<%= resource_name %>|
|
14
|
+
%tr
|
15
|
+
%td= <%= resource_name %>.id
|
16
|
+
<%- unless columns.empty? -%>
|
17
|
+
%td= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
|
18
|
+
<%- end -%>
|
19
|
+
%td= <%= resource_name %>.created_at
|
20
|
+
%td
|
21
|
+
= link_to "Show", <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-mini'
|
22
|
+
= link_to "Edit", edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-mini'
|
23
|
+
= link_to "Destroy", <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}", :class => 'btn btn-mini btn-danger'
|
24
|
+
|
25
|
+
= link_to "New", new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
h1 <%= resource_name.titleize %>s
|
2
|
+
table class="table table-striped"
|
3
|
+
thead
|
4
|
+
tr
|
5
|
+
th ID
|
6
|
+
<%- unless columns.empty? -%>
|
7
|
+
th
|
8
|
+
= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= columns.first.name %>", :default => t("activerecord.labels.<%= columns.first.name %>", :default => "<%= columns.first.name.capitalize %>"))
|
9
|
+
<%- end -%>
|
10
|
+
th Created at
|
11
|
+
th Actions
|
12
|
+
tbody
|
13
|
+
- @<%= plural_resource_name %>.each do |<%= resource_name %>|
|
14
|
+
tr
|
15
|
+
td= <%= resource_name %>.id
|
16
|
+
<%- unless columns.empty? -%>
|
17
|
+
td= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
|
18
|
+
<%- end -%>
|
19
|
+
td= <%= resource_name %>.created_at
|
20
|
+
td
|
21
|
+
= link_to "Show", <%= singular_controller_routing_path %>_path(<%= resource_name %>)
|
22
|
+
= link_to "Edit", edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>)
|
23
|
+
= link_to "Destroy", <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}"
|
24
|
+
|
25
|
+
= link_to "New", new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= render :partial => 'form' %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1><%= model_name.titleize %></h1>
|
2
|
+
|
3
|
+
<%- columns.each do |column| -%>
|
4
|
+
<p>
|
5
|
+
<b><%= column.name.humanize %></b><br>
|
6
|
+
<%%= @<%= resource_name %>.<%= column.name %> %>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<%- end -%>
|
10
|
+
<div class="form-actions">
|
11
|
+
<%%= link_to 'Back', <%= controller_routing_path %>_path, :class => 'btn' %>
|
12
|
+
<%%= link_to 'Edit', edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn' %>
|
13
|
+
<%%= link_to 'Delete', <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => 'delete', :confirm => 'Are you sure?', :class => 'btn btn-danger' %>
|
14
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%- columns.each do |column| -%>
|
2
|
+
%label{:class => "label"}= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= column.name %>", :default => t("activerecord.labels.<%= column.name %>", :default => "<%= column.name.humanize %>")) + ":"
|
3
|
+
%p= @<%= resource_name %>.<%= column.name %>
|
4
|
+
<%- end -%>
|
5
|
+
|
6
|
+
.form-actions
|
7
|
+
= link_to "Back", <%= controller_routing_path %>_path, :class => 'btn'
|
8
|
+
= link_to "Edit", edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
|
9
|
+
= link_to "Delete", <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}", :class => 'btn'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%- columns.each do |column| -%>
|
2
|
+
label class="label"= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= column.name %>", :default => t("activerecord.labels.<%= column.name %>", :default => "<%= column.name.humanize %>")) + ":"
|
3
|
+
p= @<%= resource_name %>.<%= column.name %>
|
4
|
+
<%- end -%>
|
5
|
+
|
6
|
+
.form-actions
|
7
|
+
= link_to "Back", <%= controller_routing_path %>_path, :class => 'btn'
|
8
|
+
= link_to "Edit", edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
|
9
|
+
= link_to "Delete", <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}", :class => 'btn'
|
@@ -0,0 +1,96 @@
|
|
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
|
+
def initialize(args, *options)
|
14
|
+
super(args, *options)
|
15
|
+
initialize_views_variables
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_views
|
19
|
+
generate_views
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def initialize_views_variables
|
25
|
+
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
26
|
+
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
27
|
+
@model_name = @base_name.singularize unless @model_name
|
28
|
+
@model_name = @model_name.camelize
|
29
|
+
end
|
30
|
+
|
31
|
+
def controller_routing_path
|
32
|
+
@controller_routing_path
|
33
|
+
end
|
34
|
+
|
35
|
+
def singular_controller_routing_path
|
36
|
+
@controller_routing_path.singularize
|
37
|
+
end
|
38
|
+
|
39
|
+
def model_name
|
40
|
+
@model_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def plural_model_name
|
44
|
+
@model_name.pluralize
|
45
|
+
end
|
46
|
+
|
47
|
+
def resource_name
|
48
|
+
@model_name.demodulize.underscore
|
49
|
+
end
|
50
|
+
|
51
|
+
def plural_resource_name
|
52
|
+
resource_name.pluralize
|
53
|
+
end
|
54
|
+
|
55
|
+
def columns
|
56
|
+
begin
|
57
|
+
excluded_column_names = %w[id created_at updated_at]
|
58
|
+
@model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
|
59
|
+
rescue NoMethodError
|
60
|
+
@model_name.constantize.fields.collect{|c| c[1]}.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def extract_modules(name)
|
65
|
+
modules = name.include?('/') ? name.split('/') : name.split('::')
|
66
|
+
name = modules.pop
|
67
|
+
path = modules.map { |m| m.underscore }
|
68
|
+
file_path = (path + [name.underscore]).join('/')
|
69
|
+
nesting = modules.map { |m| m.camelize }.join('::')
|
70
|
+
[name, path, file_path, nesting, modules.size]
|
71
|
+
end
|
72
|
+
|
73
|
+
def generate_views
|
74
|
+
views = {
|
75
|
+
"index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
|
76
|
+
"new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
|
77
|
+
"edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
|
78
|
+
"_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
|
79
|
+
"show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")}
|
80
|
+
selected_views = views
|
81
|
+
options.engine == generate_erb(selected_views)
|
82
|
+
end
|
83
|
+
|
84
|
+
def generate_erb(views)
|
85
|
+
views.each do |template_name, output_path|
|
86
|
+
template template_name, output_path
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def ext
|
91
|
+
:haml
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|