hsc-twitter-bootstrap-rails 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +131 -0
- data/Rakefile +9 -0
- data/lib/generators/bootstrap/install/install_generator.rb +37 -0
- data/lib/generators/bootstrap/install/templates/application.css.sass +1 -0
- data/lib/generators/bootstrap/install/templates/application.css.scss +1 -0
- data/lib/generators/bootstrap/install/templates/application.js.coffee +10 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +25 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +76 -0
- data/lib/generators/bootstrap/templates/templates_generator.rb +30 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +11 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +3 -0
- data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
- data/lib/generators/bootstrap/themed/templates/new.html.haml +2 -0
- data/lib/generators/bootstrap/themed/templates/show.html.haml +9 -0
- data/lib/generators/bootstrap/themed/themed_generator.rb +99 -0
- data/lib/hsc-twitter-bootstrap-rails.rb +3 -0
- data/lib/hsc-twitter-bootstrap/rails.rb +6 -0
- data/lib/hsc-twitter-bootstrap/rails/engine.rb +6 -0
- data/lib/hsc-twitter-bootstrap/rails/version.rb +13 -0
- metadata +109 -0
data/README.rdoc
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
= Twitter Bootstrap for Rails 3.1 Asset Pipeline using Haml/Sass/Coffeescript
|
2
|
+
|
3
|
+
{Twitter Bootstrap}[http://twitter.github.com/bootstrap/] is a design toolkit
|
4
|
+
to kickstart the graphical part of webapps.
|
5
|
+
|
6
|
+
hsc-twitter-bootstrap-rails integrates the toolkit with
|
7
|
+
{Ruby on Rails}[http://rubyonrails.org/]
|
8
|
+
{Haml}[http://haml-lang.com/], {Sass}[http://sass-lang.com/] and
|
9
|
+
{Coffeescript}[http://coffeescript.org/] and adds some generators.
|
10
|
+
|
11
|
+
{<img src="https://secure.travis-ci.org/tvw/hsc-twitter-bootstrap-rails.png?branch=master" alt="Build Status" />}[http://travis-ci.org/tvw/hsc-twitter-bootstrap-rails]
|
12
|
+
|
13
|
+
|
14
|
+
== Usage in your Ruby on Rails app
|
15
|
+
|
16
|
+
|
17
|
+
=== Installing Gem
|
18
|
+
|
19
|
+
Include Bootstrap in Gemfile:
|
20
|
+
|
21
|
+
gem "hsc-twitter-bootstrap-rails"
|
22
|
+
|
23
|
+
Bundle it:
|
24
|
+
|
25
|
+
bundle install
|
26
|
+
|
27
|
+
|
28
|
+
=== Select your preferred Sass style
|
29
|
+
|
30
|
+
Select the your preferred sass-style in config/application.rb:
|
31
|
+
|
32
|
+
config.sass.preferred_syntax = :sass
|
33
|
+
|
34
|
+
or
|
35
|
+
|
36
|
+
config.sass.preferred_syntax = :scss
|
37
|
+
|
38
|
+
where the last one is the default.
|
39
|
+
|
40
|
+
|
41
|
+
=== Config Haml
|
42
|
+
|
43
|
+
Add an initializer "config/initializers/haml.rb":
|
44
|
+
|
45
|
+
Haml::Template.options[:format] = :html5
|
46
|
+
Haml::Template.options[:attr_wrapper] = '"'
|
47
|
+
|
48
|
+
|
49
|
+
=== Install the assets
|
50
|
+
|
51
|
+
Remove the following files:
|
52
|
+
|
53
|
+
app/assets/javascripts/application.js
|
54
|
+
app/assets/stylesheets/application.css
|
55
|
+
|
56
|
+
Install application.js.coffee and application.css.sass (or .scss):
|
57
|
+
|
58
|
+
rails g bootstrap:install
|
59
|
+
|
60
|
+
|
61
|
+
== The Generators
|
62
|
+
|
63
|
+
=== Layout
|
64
|
+
|
65
|
+
To create a new haml layout:
|
66
|
+
|
67
|
+
rails g bootstrap:layout [LAYOUT_NAME] [*fixed or fluid]
|
68
|
+
|
69
|
+
'LAYOUT_NAME' is the name of the layout. 'fixed' and 'fluid' is the style of
|
70
|
+
the layout.
|
71
|
+
|
72
|
+
Example:
|
73
|
+
|
74
|
+
rails g bootstrap:layout application fixed
|
75
|
+
|
76
|
+
Make sure, that you do not have erb-versions of your layouts like
|
77
|
+
'app/views/layouts/application.html.erb' since they will be preferred by
|
78
|
+
rails.
|
79
|
+
|
80
|
+
=== Themed
|
81
|
+
|
82
|
+
Themed generates Twitter Bootstrap compatible scaffold views:
|
83
|
+
|
84
|
+
rails g bootstrap:themed [RESOURCE_NAME]
|
85
|
+
|
86
|
+
Example:
|
87
|
+
|
88
|
+
rails g scaffold post title:string description:text
|
89
|
+
rake db:migrate
|
90
|
+
rails g bootstrap:themed posts
|
91
|
+
|
92
|
+
|
93
|
+
If you want to modify the themed templates, you can install
|
94
|
+
them into you local app directory:
|
95
|
+
|
96
|
+
rails g bootstrap:templates
|
97
|
+
|
98
|
+
You will find them in 'lib/generators/bootstrap/themed/templates'.
|
99
|
+
|
100
|
+
|
101
|
+
== Credits
|
102
|
+
|
103
|
+
The main part of bringing Twitter Bootstrap to Sass is done by Christopher
|
104
|
+
Cocchi-Perrier: {sass-twitter-bootstrap-rails}[https://github.com/ccocchi/sass-twitter-bootstrap-rails]
|
105
|
+
|
106
|
+
hsc-twitter-bootstrap-rails depends on the sass-twitter-bootstrap-rails gem.
|
107
|
+
|
108
|
+
|
109
|
+
== Author
|
110
|
+
|
111
|
+
Thomas Volkmar Worm <mailto:tvw@s4r.de>
|
112
|
+
|
113
|
+
|
114
|
+
== License
|
115
|
+
|
116
|
+
Copyright (c) 2012 Thomas Volkmar Worm <mailto:tvw@s4r.de>
|
117
|
+
|
118
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
119
|
+
of this software and associated documentation files (the "Software"), to deal
|
120
|
+
in the Software without restriction, including without limitation the rights
|
121
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
122
|
+
copies of the Software, and to permit persons to whom the Software is
|
123
|
+
furnished to do so, subject to the following conditions: The above copyright
|
124
|
+
notice and this permission notice shall be included in all copies or
|
125
|
+
substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS",
|
126
|
+
WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
127
|
+
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
128
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
129
|
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
130
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
131
|
+
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrap
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
desc "This generator installs Twitter Bootstrap to Asset Pipeline"
|
9
|
+
|
10
|
+
def add_stylesheets
|
11
|
+
ext = Rails.application.config.sass.preferred_syntax.to_s
|
12
|
+
if File.exist?("app/assets/stylesheets/application.css.#{ext}")
|
13
|
+
insert_into_file "app/assets/stylesheets/application.css.#{ext}", %Q{@import "twitter/bootstrap"\n}, :before => "@import"
|
14
|
+
else
|
15
|
+
copy_file "application.css.#{ext}", "app/assets/stylesheets/application.css.#{ext}"
|
16
|
+
end
|
17
|
+
|
18
|
+
if File.exist?("app/assets/stylesheets/application.css")
|
19
|
+
log "Please remove 'app/assets/stylesheets/application.css' to make #{ext}-file work."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_coffeescripts
|
24
|
+
if File.exist?("app/assets/javascripts/application.js.coffee")
|
25
|
+
insert_into_file "app/assets/javascripts/application.js.coffee", "//= require twitter/bootstrap\n", :after => "jquery_ujs\n"
|
26
|
+
else
|
27
|
+
copy_file "application.js.coffee", "app/assets/javascripts/application.js.coffee"
|
28
|
+
end
|
29
|
+
|
30
|
+
if File.exist?("app/assets/javascripts/application.js")
|
31
|
+
log "Please remove 'app/assets/javascripts/application.js' to make coffee-file work."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "twitter/bootstrap"
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "twitter/bootstrap";
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
# be included in the compiled file accessible from http:##example.com/assets/application.js
|
4
|
+
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
# the compiled file.
|
6
|
+
#
|
7
|
+
#= require jquery
|
8
|
+
#= require jquery_ujs
|
9
|
+
#= require twitter/bootstrap
|
10
|
+
#= require_tree .
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrap
|
4
|
+
module Generators
|
5
|
+
class LayoutGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
desc "This generator generates layout file with navigation."
|
8
|
+
argument :layout_name, :type => :string, :default => "application"
|
9
|
+
argument :layout_type, :type => :string, :default => "fixed",
|
10
|
+
:banner => "*fixed or fluid"
|
11
|
+
|
12
|
+
attr_reader :app_name, :container_class
|
13
|
+
|
14
|
+
def generate_layout
|
15
|
+
app = ::Rails.application
|
16
|
+
@app_name = app.class.to_s.split("::").first
|
17
|
+
@container_class = layout_type == "fluid" ? "container-fluid" : "container"
|
18
|
+
template "layout.html.haml", "app/views/layouts/#{layout_name}.html.haml"
|
19
|
+
if File.exists?("app/views/layouts/#{layout_name}.html.erb")
|
20
|
+
puts "Remove app/views/layouts/#{layout_name}.html.erb to make haml-layout work."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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
|
+
:css
|
12
|
+
body {
|
13
|
+
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
14
|
+
}
|
15
|
+
= stylesheet_link_tag "application", :media => "all"
|
16
|
+
/ Le fav and touch icons
|
17
|
+
%link{:href => "images/favicon.ico", :rel => "shortcut icon"}/
|
18
|
+
%link{:href => "images/apple-touch-icon.png", :rel => "apple-touch-icon"}/
|
19
|
+
%link{:href => "images/apple-touch-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"}/
|
20
|
+
%link{:href => "images/apple-touch-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"}/
|
21
|
+
|
22
|
+
|
23
|
+
%body
|
24
|
+
.navbar.navbar-fixed-top
|
25
|
+
.navbar-inner
|
26
|
+
<%- if layout_type == "fluid" -%>
|
27
|
+
.container-fluid
|
28
|
+
<%- else -%>
|
29
|
+
.container
|
30
|
+
<%- end -%>
|
31
|
+
%a.btn.btn-navbar{"data-target" => ".nav-collapse", "data-toggle" => "collapse"}
|
32
|
+
%span.icon-bar
|
33
|
+
%span.icon-bar
|
34
|
+
%span.icon-bar
|
35
|
+
%a.brand{:href => "#"}<%= app_name %>
|
36
|
+
.<%=container_class%>.nav-collapse
|
37
|
+
%ul.nav
|
38
|
+
%li= link_to "Link 1", "/path1"
|
39
|
+
%li= link_to "Link 2", "/path2"
|
40
|
+
%li= link_to "Link 3", "/path3"
|
41
|
+
|
42
|
+
.<%= container_class %>
|
43
|
+
<%- if layout_type == "fluid" -%>
|
44
|
+
|
45
|
+
.row-fluid
|
46
|
+
.span3
|
47
|
+
.well.sidebar-nav
|
48
|
+
%ul.nav.nav-list
|
49
|
+
%li.nav-header Sidebar
|
50
|
+
%li= link_to "Link 1", "/path1"
|
51
|
+
%li= link_to "Link 2", "/path2"
|
52
|
+
%li= link_to "Link 3", "/path3"
|
53
|
+
.span9
|
54
|
+
= yield
|
55
|
+
<% else %>
|
56
|
+
.content
|
57
|
+
.row
|
58
|
+
.span9
|
59
|
+
= yield
|
60
|
+
.span1
|
61
|
+
.span3
|
62
|
+
.well.sidebar-nav
|
63
|
+
%h3 Sidebar
|
64
|
+
%ul.nav.nav-list
|
65
|
+
%li.nav-header Sidebar
|
66
|
+
%li= link_to "Link 1", "/path1"
|
67
|
+
%li= link_to "Link 2", "/path2"
|
68
|
+
%li= link_to "Link 3", "/path3"
|
69
|
+
<% end %>
|
70
|
+
%footer
|
71
|
+
%p © Company 2012
|
72
|
+
/
|
73
|
+
Le javascript
|
74
|
+
\==================================================
|
75
|
+
/ Placed at the end of the document so the pages load faster
|
76
|
+
= javascript_include_tag "application"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrap
|
4
|
+
module Generators
|
5
|
+
class TemplatesGenerator < ::Rails::Generators::Base
|
6
|
+
|
7
|
+
def self.user_source_root
|
8
|
+
Rails.root.join("lib", "generators", "bootstrap", "themed", "templates")
|
9
|
+
end
|
10
|
+
|
11
|
+
source_root File.expand_path('../../themed/templates', __FILE__)
|
12
|
+
desc "This generator installs Twitter Bootstrap Themed templates to #{user_source_root}."
|
13
|
+
|
14
|
+
def add_templates
|
15
|
+
|
16
|
+
views = {
|
17
|
+
"index.html.haml" => File.join(self.class.user_source_root, "index.html.haml"),
|
18
|
+
"new.html.haml" => File.join(self.class.user_source_root, "new.html.haml"),
|
19
|
+
"edit.html.haml" => File.join(self.class.user_source_root, "edit.html.haml"),
|
20
|
+
"_form.html.haml" => File.join(self.class.user_source_root, "_form.html.haml"),
|
21
|
+
"show.html.haml" => File.join(self.class.user_source_root, "show.html.haml")}
|
22
|
+
|
23
|
+
views.each do |template_name, output_path|
|
24
|
+
copy_file template_name, output_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -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,3 @@
|
|
1
|
+
= 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|
|
2
|
+
%input{:name => "_method", :type => "hidden", :value =>"put"}
|
3
|
+
= render :partial => "form", :locals => {:f => f}
|
@@ -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,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,99 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/generated_attribute'
|
3
|
+
|
4
|
+
module Bootstrap
|
5
|
+
module Generators
|
6
|
+
class ThemedGenerator < ::Rails::Generators::Base
|
7
|
+
|
8
|
+
user_source_root = Rails.root.join("lib", "generators", "bootstrap", "themed", "templates")
|
9
|
+
if File.exists?(user_source_root)
|
10
|
+
source_root user_source_root
|
11
|
+
else
|
12
|
+
source_root File.expand_path('../templates', __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
argument :controller_path, :type => :string
|
16
|
+
argument :model_name, :type => :string, :required => false
|
17
|
+
argument :layout, :type => :string, :default => "application",
|
18
|
+
:banner => "Specify application layout"
|
19
|
+
|
20
|
+
def initialize(args, *options)
|
21
|
+
super(args, *options)
|
22
|
+
initialize_views_variables
|
23
|
+
end
|
24
|
+
|
25
|
+
def copy_views
|
26
|
+
generate_views
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def initialize_views_variables
|
32
|
+
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
33
|
+
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
34
|
+
@model_name = @base_name.singularize unless @model_name
|
35
|
+
@model_name = @model_name.camelize
|
36
|
+
end
|
37
|
+
|
38
|
+
def controller_routing_path
|
39
|
+
@controller_routing_path
|
40
|
+
end
|
41
|
+
|
42
|
+
def singular_controller_routing_path
|
43
|
+
@controller_routing_path.singularize
|
44
|
+
end
|
45
|
+
|
46
|
+
def model_name
|
47
|
+
@model_name
|
48
|
+
end
|
49
|
+
|
50
|
+
def plural_model_name
|
51
|
+
@model_name.pluralize
|
52
|
+
end
|
53
|
+
|
54
|
+
def resource_name
|
55
|
+
@model_name.underscore
|
56
|
+
end
|
57
|
+
|
58
|
+
def plural_resource_name
|
59
|
+
resource_name.pluralize
|
60
|
+
end
|
61
|
+
|
62
|
+
def columns
|
63
|
+
begin
|
64
|
+
excluded_column_names = %w[id created_at updated_at]
|
65
|
+
Kernel.const_get(@model_name).columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
|
66
|
+
rescue NoMethodError
|
67
|
+
Kernel.const_get(@model_name).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)}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def extract_modules(name)
|
72
|
+
modules = name.include?('/') ? name.split('/') : name.split('::')
|
73
|
+
name = modules.pop
|
74
|
+
path = modules.map { |m| m.underscore }
|
75
|
+
file_path = (path + [name.underscore]).join('/')
|
76
|
+
nesting = modules.map { |m| m.camelize }.join('::')
|
77
|
+
[name, path, file_path, nesting, modules.size]
|
78
|
+
end
|
79
|
+
|
80
|
+
def generate_views
|
81
|
+
views = {
|
82
|
+
"index.html.haml" => File.join('app/views', @controller_file_path, "index.html.haml"),
|
83
|
+
"new.html.haml" => File.join('app/views', @controller_file_path, "new.html.haml"),
|
84
|
+
"edit.html.haml" => File.join('app/views', @controller_file_path, "edit.html.haml"),
|
85
|
+
"_form.html.haml" => File.join('app/views', @controller_file_path, "_form.html.haml"),
|
86
|
+
"show.html.haml" => File.join('app/views', @controller_file_path, "show.html.haml")}
|
87
|
+
selected_views = views
|
88
|
+
options.engine == generate_erb(selected_views)
|
89
|
+
end
|
90
|
+
|
91
|
+
def generate_erb(views)
|
92
|
+
views.each do |template_name, output_path|
|
93
|
+
template template_name, output_path
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hsc-twitter-bootstrap-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Volkmar Worm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: &9865680 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *9865680
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: actionpack
|
27
|
+
requirement: &9863600 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.1'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *9863600
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: haml-rails
|
38
|
+
requirement: &9862620 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.3.4
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *9862620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sass-twitter-bootstrap-rails
|
49
|
+
requirement: &9861440 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *9861440
|
58
|
+
description: hsc-twitter-bootstrap-rails project integrates Bootstrap CSS toolkit
|
59
|
+
for Rails 3.1 Asset Pipeline using Haml, Sass and Coffeescript
|
60
|
+
email:
|
61
|
+
- tvw@s4r.de
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- lib/hsc-twitter-bootstrap/rails.rb
|
67
|
+
- lib/hsc-twitter-bootstrap/rails/engine.rb
|
68
|
+
- lib/hsc-twitter-bootstrap/rails/version.rb
|
69
|
+
- lib/generators/bootstrap/install/install_generator.rb
|
70
|
+
- lib/generators/bootstrap/install/templates/application.js.coffee
|
71
|
+
- lib/generators/bootstrap/install/templates/application.css.scss
|
72
|
+
- lib/generators/bootstrap/install/templates/application.css.sass
|
73
|
+
- lib/generators/bootstrap/layout/templates/layout.html.haml
|
74
|
+
- lib/generators/bootstrap/layout/layout_generator.rb
|
75
|
+
- lib/generators/bootstrap/templates/templates_generator.rb
|
76
|
+
- lib/generators/bootstrap/themed/templates/edit.html.haml
|
77
|
+
- lib/generators/bootstrap/themed/templates/index.html.haml
|
78
|
+
- lib/generators/bootstrap/themed/templates/show.html.haml
|
79
|
+
- lib/generators/bootstrap/themed/templates/_form.html.haml
|
80
|
+
- lib/generators/bootstrap/themed/templates/new.html.haml
|
81
|
+
- lib/generators/bootstrap/themed/themed_generator.rb
|
82
|
+
- lib/hsc-twitter-bootstrap-rails.rb
|
83
|
+
- Rakefile
|
84
|
+
- README.rdoc
|
85
|
+
homepage: https://github.com/tvw/hsc-twitter-bootstrap-rails
|
86
|
+
licenses: []
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project: hsc-twitter-bootstrap-rails
|
105
|
+
rubygems_version: 1.8.10
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: Bootstrap CSS toolkit for Rails 3.1 Asset Pipeline using Haml, Sass and Coffeescript
|
109
|
+
test_files: []
|