Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tvw/twitter-bootstrap-rails
base: 6a8eec931a
...
head fork: tvw/twitter-bootstrap-rails
compare: 5a2437815d
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
4 README.md
@@ -34,7 +34,7 @@ Usage:
rails g bootstrap:install
-Layout (generates Twitter Bootstrap compatible layout.) - (Slim supported)
+Layout (generates Twitter Bootstrap compatible layout.) - (Haml and Slim supported)
Usage:
@@ -49,7 +49,7 @@ Example:
rails g bootstrap:layout application fixed
-Themed (generates Twitter Bootstrap compatible scaffold views.)
+Themed (generates Twitter Bootstrap compatible scaffold views.) - (Haml supported)
Usage:
View
41 lib/generators/bootstrap/layout/templates/layout.html.haml
@@ -0,0 +1,41 @@
+!!! 5
+%html{:lang => "en"}
+ %head
+ %meta{:charset => "utf-8"}
+ %title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
+ = javascript_include_tag "application"
+ = stylesheet_link_tag "application"
+ = csrf_meta_tags
+
+ %body
+ .navbar
+ .navbar-inner
+ .<%= container_class %>
+ %h3= link_to "<%= app_name %>", root_path, :class => "brand"
+ %ul.nav
+ %li= link_to "Link 1", "/path1"
+ %li= link_to "Link 2", "/path2"
+ %li= link_to "Link 3", "/path3"
+
+ .<%= container_class %>
+ <%- if layout_type == "fluid" -%>
+ .sidebar
+ .well
+ %h5 Sidebar
+ %ul
+ %li= link_to "Link 1", "/path1"
+ %li= link_to "Link 2", "/path2"
+ %li= link_to "Link 3", "/path3"
+ .content= yield
+ <% else %>
+ .content
+ .row
+ .span11= yield
+ .span1 &nbsp;
+ .span4
+ %h3 Sidebar
+ %ul
+ %li= link_to "Link 1", "/path1"
+ %li= link_to "Link 2", "/path2"
+ %li= link_to "Link 3", "/path3"
+ <% end %>
View
12 lib/generators/bootstrap/themed/templates/_form.html.haml
@@ -0,0 +1,12 @@
+<%- columns.each do |column| -%>
+.clearfix
+ = f.label :<%= column.name %>, t("activerecord.attributes.<%= model_name.underscore %>.<%= column.name %>", :default => "<%= column.name.humanize %>"), :class => :label
+ .input
+ = f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
+<%- end -%>
+
+.actions
+ %button{:class => "btn primary", :type => "submit"} Save
+ or
+ = link_to "Cancel", <%= controller_routing_path %>_path
+
View
3  lib/generators/bootstrap/themed/templates/edit.html.haml
@@ -0,0 +1,3 @@
+= form_for @<%= model_name.underscore %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => "edit_<%= model_name.underscore %>", :id => "edit_<%= model_name.underscore %>" } do |f|
+ %input{:name => "_method", :type => "hidden", :value =>"put"}
+ = render :partial => "form", :locals => {:f => f}
View
25 lib/generators/bootstrap/themed/templates/index.html.haml
@@ -0,0 +1,25 @@
+%h1 <%= resource_name.titleize %>s
+%table{:class => "zebra-striped"}
+ %thead
+ %tr
+ %th ID
+ <%- unless columns.empty? -%>
+ %th
+ = t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= columns.first.name %>", :default => t("activerecord.labels.<%= columns.first.name %>", :default => "<%= columns.first.name.capitalize %>"))
+ <%- end -%>
+ %th Created at
+ %th Actions
+ %tbody
+ - @<%= plural_resource_name %>.each do |<%= resource_name %>|
+ %tr
+ %td= <%= resource_name %>.id
+ <%- unless columns.empty? -%>
+ %td= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
+ <%- end -%>
+ %td= <%= resource_name %>.created_at
+ %td
+ = link_to "Show", <%= singular_controller_routing_path %>_path(<%= resource_name %>)
+ = link_to "Edit", edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>)
+ = link_to "Destroy", <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}"
+
+= link_to "New", new_<%= singular_controller_routing_path %>_path, :class => 'btn primary'
View
2  lib/generators/bootstrap/themed/templates/new.html.haml
@@ -0,0 +1,2 @@
+= form_for @<%= model_name.underscore %>, :url => <%= controller_routing_path %>_path, :html => { :class => :form } do |f|
+ = render :partial => "form", :locals => {:f => f}
View
9 lib/generators/bootstrap/themed/templates/show.html.haml
@@ -0,0 +1,9 @@
+<%- columns.each do |column| -%>
+%label{:class => "label"}= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= column.name %>", :default => t("activerecord.labels.<%= column.name %>", :default => "<%= column.name.humanize %>")) + ":"
+%p= @<%= resource_name %>.<%= column.name %>
+<%- end -%>
+
+.actions
+ = link_to "Back", <%= controller_routing_path %>_path, :class => 'btn primary'
+ = link_to "Edit", edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn primary'
+ = link_to "Delete", <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}", :class => 'btn primary'
View
22 lib/generators/bootstrap/themed/themed_generator.rb
@@ -15,12 +15,14 @@ def initialize(args, *options)
initialize_views_variables
end
- def copy_views
+ def copy_views
generate_views
- gsub_file(File.join('app/views/layouts', "#{layout}.html.erb"), /\<ul\s+class=\"nav\">.*\<\/ul\>/mi) do |match|
- match.gsub!(/\<\/ul\>/, "")
+ if ext == :erb
+ gsub_file(File.join('app/views/layouts', "#{layout}.html.erb"), /\<ul\s+class=\"nav\">.*\<\/ul\>/mi) do |match|
+ match.gsub!(/\<\/ul\>/, "")
%|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>|
end
+ end
end
protected
@@ -76,11 +78,11 @@ def extract_modules(name)
def generate_views
views = {
- 'index.html.erb' => File.join('app/views', @controller_file_path, "index.html.erb"),
- 'new.html.erb' => File.join('app/views', @controller_file_path, "new.html.erb"),
- 'edit.html.erb' => File.join('app/views', @controller_file_path, "edit.html.erb"),
- '_form.html.erb' => File.join('app/views', @controller_file_path, "_form.html.erb"),
- 'show.html.erb' => File.join('app/views', @controller_file_path, "show.html.erb")}
+ "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
+ "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
+ "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
+ "_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
+ "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")}
selected_views = views
options.engine == generate_erb(selected_views)
end
@@ -91,6 +93,10 @@ def generate_erb(views)
end
end
+ def ext
+ Rails.application.config.generators.options[:rails][:template_engine] || :erb
+ end
+
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.