devbootsrap 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +414 -0
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/twitter/bootstrap.js +13 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +117 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +99 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-button.js +105 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +207 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +167 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +169 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +247 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +114 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +162 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +144 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +361 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +60 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +335 -0
- data/app/assets/javascripts/twitter/bootstrap_ujs.js +11 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +892 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +1338 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +146 -0
- data/app/helpers/badge_label_helper.rb +16 -0
- data/app/helpers/bootstrap_flash_helper.rb +24 -0
- data/app/helpers/flash_block_helper.rb +17 -0
- data/app/helpers/glyph_helper.rb +17 -0
- data/app/helpers/modal_helper.rb +55 -0
- data/app/helpers/navbar_helper.rb +202 -0
- data/app/helpers/twitter_breadcrumbs_helper.rb +10 -0
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +14 -0
- data/lib/devbootsrap.rb +17 -0
- data/lib/devbootsrap/version.rb +1 -1
- data/lib/generators/bootstrap/install/install_generator.rb +85 -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 +3 -0
- data/lib/generators/bootstrap/install/templates/bootstrap.js +4 -0
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.css +7 -0
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +30 -0
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +23 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +23 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +106 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +65 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +67 -0
- data/lib/generators/bootstrap/partial/partial_generator.rb +20 -0
- data/lib/generators/bootstrap/partial/templates/_login.html.erb +29 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +16 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +10 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.erb +5 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +4 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +4 -0
- data/lib/generators/bootstrap/themed/templates/index.html.erb +40 -0
- data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
- data/lib/generators/bootstrap/themed/templates/index.html.slim +27 -0
- data/lib/generators/bootstrap/themed/templates/new.html.erb +5 -0
- data/lib/generators/bootstrap/themed/templates/new.html.haml +4 -0
- data/lib/generators/bootstrap/themed/templates/new.html.slim +4 -0
- data/lib/generators/bootstrap/themed/templates/show.html.erb +23 -0
- data/lib/generators/bootstrap/themed/templates/show.html.haml +15 -0
- data/lib/generators/bootstrap/themed/templates/show.html.slim +17 -0
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +14 -0
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +11 -0
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +12 -0
- data/lib/generators/bootstrap/themed/themed_generator.rb +148 -0
- data/lib/twitter-bootstrap-rails.rb +10 -0
- data/lib/twitter/bootstrap/rails/bootstrap.rb +2 -0
- data/lib/twitter/bootstrap/rails/breadcrumbs.rb +58 -0
- data/lib/twitter/bootstrap/rails/engine.rb +35 -0
- data/lib/twitter/bootstrap/rails/version.rb +7 -0
- data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +889 -0
- data/vendor/static-source/bootstrap.less +2 -0
- data/vendor/static-source/fontawesome.less +8 -0
- data/vendor/static-source/sprites.less +6 -0
- data/vendor/toolkit/fontawesome/bordered-pulled.less +16 -0
- data/vendor/toolkit/fontawesome/core.less +12 -0
- data/vendor/toolkit/fontawesome/fixed-width.less +6 -0
- data/vendor/toolkit/fontawesome/font-awesome.less +17 -0
- data/vendor/toolkit/fontawesome/icons.less +412 -0
- data/vendor/toolkit/fontawesome/larger.less +13 -0
- data/vendor/toolkit/fontawesome/list.less +19 -0
- data/vendor/toolkit/fontawesome/mixins.less +20 -0
- data/vendor/toolkit/fontawesome/path.less +14 -0
- data/vendor/toolkit/fontawesome/rotated-flipped.less +9 -0
- data/vendor/toolkit/fontawesome/spinning.less +30 -0
- data/vendor/toolkit/fontawesome/stacked.less +20 -0
- data/vendor/toolkit/fontawesome/variables.less +381 -0
- data/vendor/toolkit/twitter/bootstrap/accordion.less +34 -0
- data/vendor/toolkit/twitter/bootstrap/alerts.less +79 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +62 -0
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +24 -0
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +229 -0
- data/vendor/toolkit/twitter/bootstrap/buttons.less +228 -0
- data/vendor/toolkit/twitter/bootstrap/carousel.less +158 -0
- data/vendor/toolkit/twitter/bootstrap/close.less +32 -0
- data/vendor/toolkit/twitter/bootstrap/code.less +61 -0
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +248 -0
- data/vendor/toolkit/twitter/bootstrap/forms.less +690 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +21 -0
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +25 -0
- data/vendor/toolkit/twitter/bootstrap/labels-badges.less +84 -0
- data/vendor/toolkit/twitter/bootstrap/layouts.less +16 -0
- data/vendor/toolkit/twitter/bootstrap/media.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +702 -0
- data/vendor/toolkit/twitter/bootstrap/modals.less +95 -0
- data/vendor/toolkit/twitter/bootstrap/navbar.less +497 -0
- data/vendor/toolkit/twitter/bootstrap/navs.less +409 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +43 -0
- data/vendor/toolkit/twitter/bootstrap/pagination.less +123 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +133 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +122 -0
- data/vendor/toolkit/twitter/bootstrap/reset.less +216 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-1200px-min.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +193 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-768px-979px.less +19 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +189 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +59 -0
- data/vendor/toolkit/twitter/bootstrap/responsive.less +48 -0
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +53 -0
- data/vendor/toolkit/twitter/bootstrap/sprites.less +197 -0
- data/vendor/toolkit/twitter/bootstrap/tables.less +244 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +53 -0
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +70 -0
- data/vendor/toolkit/twitter/bootstrap/type.less +247 -0
- data/vendor/toolkit/twitter/bootstrap/utilities.less +30 -0
- data/vendor/toolkit/twitter/bootstrap/variables.less +301 -0
- data/vendor/toolkit/twitter/bootstrap/wells.less +29 -0
- data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
- metadata +130 -1
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrap
|
4
|
+
module Generators
|
5
|
+
class PartialGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
desc "This generator generates bootstrap HTML partials"
|
8
|
+
argument :component_name, :type => :string, :default => "application",
|
9
|
+
:banner => "navbar, navbar-devise, carousel"
|
10
|
+
|
11
|
+
attr_reader :app_name
|
12
|
+
|
13
|
+
def generate_partial
|
14
|
+
app = ::Rails.application
|
15
|
+
ext = app.config.generators.options[:rails][:template_engine] || :erb
|
16
|
+
copy_file "_#{component_name}.html.#{ext}", "app/views/shared/_#{component_name}.html.#{ext}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<h2>Sign in</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => 'form-horizontal' }) do |f| %>
|
4
|
+
<div class="control-group">
|
5
|
+
<%= f.label :email, :class => 'control-label' %>
|
6
|
+
<div class="controls">
|
7
|
+
<%= f.email_field :email %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="control-group">
|
11
|
+
<%= f.label :password, :class => 'control-label' %>
|
12
|
+
<div class="controls">
|
13
|
+
<%= f.password_field :password %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<% if devise_mapping.rememberable? -%>
|
18
|
+
<div class='control-group' >
|
19
|
+
<%= f.label :remember_me, :class => 'control-label' %>
|
20
|
+
<%= f.check_box :remember_me %>
|
21
|
+
</div>
|
22
|
+
<% end -%>
|
23
|
+
|
24
|
+
<div class="form-actions">
|
25
|
+
<%= f.submit "Sign in", :class => 'btn' %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<%= render :partial => "devise/shared/links" %>
|
@@ -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
|
+
<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' %>
|
15
|
+
</div>
|
16
|
+
<%% end %>
|
@@ -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
|
+
.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'
|
@@ -0,0 +1,11 @@
|
|
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
|
+
.form-actions
|
9
|
+
= f.submit nil, :class => 'btn btn-primary'
|
10
|
+
'
|
11
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
|
@@ -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-mini' %>
|
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-mini 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-mini'
|
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-mini 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-mini'
|
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-mini 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,23 @@
|
|
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
|
+
<div class="form-actions">
|
14
|
+
<%%= link_to t('.back', :default => t("helpers.links.back")),
|
15
|
+
<%= controller_routing_path %>_path, :class => 'btn' %>
|
16
|
+
<%%= link_to t('.edit', :default => t("helpers.links.edit")),
|
17
|
+
edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn' %>
|
18
|
+
<%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
19
|
+
<%= singular_controller_routing_path %>_path(@<%= resource_name %>),
|
20
|
+
:method => 'delete',
|
21
|
+
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
22
|
+
:class => 'btn btn-danger' %>
|
23
|
+
</div>
|
@@ -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
|
+
.form-actions
|
13
|
+
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
|
14
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
|
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,17 @@
|
|
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
|
+
.form-actions
|
13
|
+
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
|
14
|
+
'
|
15
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
|
16
|
+
'
|
17
|
+
= 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,14 @@
|
|
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
|
+
<div class="form-actions">
|
9
|
+
<%%= f.button :submit, :class => 'btn-primary' %>
|
10
|
+
<%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
11
|
+
<%= controller_routing_path %>_path, :class => 'btn' %>
|
12
|
+
</div>
|
13
|
+
<%- end -%>
|
14
|
+
<%% 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
|
+
.form-actions
|
9
|
+
= f.button :submit, :class => 'btn-primary'
|
10
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
|
11
|
+
<%- end -%>
|
@@ -0,0 +1,12 @@
|
|
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
|
+
.form-actions
|
9
|
+
= f.button :submit, :class => 'btn-primary'
|
10
|
+
'
|
11
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
|
12
|
+
<%- 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
|
+
|