bootstrapped-rails 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/.DS_Store +0 -0
- data/lib/bootstrapped-rails/version.rb +1 -1
- data/lib/generators/bootstrapped/install/install_generator.rb +49 -0
- data/lib/generators/bootstrapped/install/templates/application.css +7 -0
- data/lib/generators/bootstrapped/install/templates/application.js +10 -0
- data/lib/generators/bootstrapped/install/templates/bootstrap.coffee +4 -0
- data/lib/generators/bootstrapped/layout/layout_generator.rb +32 -0
- data/lib/generators/bootstrapped/layout/templates/_bootstrapped-navigation.html.erb +22 -0
- data/lib/generators/bootstrapped/layout/templates/layout.html.erb +79 -0
- data/lib/generators/bootstrapped/layout/templates/layout.html.haml +71 -0
- data/lib/generators/bootstrapped/layout/templates/layout.html.slim +72 -0
- data/lib/generators/bootstrapped/themed/templates/_form.html.erb +19 -0
- data/lib/generators/bootstrapped/themed/templates/_form.html.haml +13 -0
- data/lib/generators/bootstrapped/themed/templates/_form.html.slim +11 -0
- data/lib/generators/bootstrapped/themed/templates/edit.html.erb +1 -0
- data/lib/generators/bootstrapped/themed/templates/edit.html.haml +2 -0
- data/lib/generators/bootstrapped/themed/templates/edit.html.slim +3 -0
- data/lib/generators/bootstrapped/themed/templates/index.html.erb +30 -0
- data/lib/generators/bootstrapped/themed/templates/index.html.haml +25 -0
- data/lib/generators/bootstrapped/themed/templates/index.html.slim +25 -0
- data/lib/generators/bootstrapped/themed/templates/new.html.erb +1 -0
- data/lib/generators/bootstrapped/themed/templates/new.html.haml +2 -0
- data/lib/generators/bootstrapped/themed/templates/new.html.slim +2 -0
- data/lib/generators/bootstrapped/themed/templates/show.html.erb +14 -0
- data/lib/generators/bootstrapped/themed/templates/show.html.haml +9 -0
- data/lib/generators/bootstrapped/themed/templates/show.html.slim +9 -0
- data/lib/generators/bootstrapped/themed/themed_generator.rb +96 -0
- data/readme.md +66 -1
- metadata +32 -7
data/.gitignore
CHANGED
data/lib/.DS_Store
CHANGED
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrapped
|
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_assets
|
11
|
+
|
12
|
+
if File.exist?('app/assets/javascripts/application.js')
|
13
|
+
insert_into_file "app/assets/javascripts/application.js", "//= require bootstrapped\n", :after => "jquery_ujs\n"
|
14
|
+
else
|
15
|
+
copy_file "application.js", "app/assets/javascripts/application.js"
|
16
|
+
end
|
17
|
+
|
18
|
+
if File.exist?('app/assets/stylesheets/application.css')
|
19
|
+
# Add our own require:
|
20
|
+
content = File.read("app/assets/stylesheets/application.css")
|
21
|
+
style_require_block = " *= require bootstrapped\n"
|
22
|
+
insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
|
23
|
+
else
|
24
|
+
copy_file "application.css", "app/assets/stylesheets/application.css"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# def add_bootstrap
|
30
|
+
# copy_file "bootstrap.coffee", "app/assets/javascripts/bootstrap.js.coffee"
|
31
|
+
# copy_file "bootstrap_and_overrides.less", "app/assets/stylesheets/bootstrap_and_overrides.css.less"
|
32
|
+
# end
|
33
|
+
|
34
|
+
# def cleanup_legacy
|
35
|
+
# # Remove old requires (if any) that included twitter/bootstrap directly:
|
36
|
+
# gsub_file("app/assets/stylesheets/application.css", %r|\s*\*=\s*twitter/bootstrap\s*\n|, "")
|
37
|
+
# gsub_file("app/assets/stylesheets/application.css", %r|\s*\*=\s*twitter/bootstrap_responsive\s*\n|, "")
|
38
|
+
# if File.exist?('app/assets/stylesheets/bootstrap_override.css.less')
|
39
|
+
# puts <<-EOM
|
40
|
+
# Warning:
|
41
|
+
# app/assets/stylesheets/bootstrap_override.css.less exists
|
42
|
+
# It should be removed, as it has been superceded by app/assets/stylesheets/bootstrap_and_overrides.css.less
|
43
|
+
# EOM
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -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,32 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrapped
|
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
|
+
ext = app.config.generators.options[:rails][:template_engine] || :erb
|
19
|
+
template "layout.html.#{ext}", "app/views/layouts/#{layout_name}.html.#{ext}"
|
20
|
+
template "_bootstrapped-navigation.html.#{ext}", "app/views/layouts/_bootstrapped-navigation.html.#{ext}"
|
21
|
+
# Add our own require:
|
22
|
+
|
23
|
+
end
|
24
|
+
def application_controller_should_default_use_newly_generated_layout
|
25
|
+
layout_name_here = %Q{ layout \'#{layout_name}\'\n}
|
26
|
+
insert_into_file('app/controllers/application_controller.rb', after: "protect_from_forgery\n") do
|
27
|
+
layout_name_here
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="navbar navbar-fixed-top">
|
2
|
+
<div class="navbar-inner">
|
3
|
+
<%- if layout_type == "fluid" -%>
|
4
|
+
<div class="container-fluid">
|
5
|
+
<%- else -%>
|
6
|
+
<div class="container">
|
7
|
+
<%- end -%>
|
8
|
+
<a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
|
9
|
+
<span class="icon-bar"></span>
|
10
|
+
<span class="icon-bar"></span>
|
11
|
+
<span class="icon-bar"></span>
|
12
|
+
</a>
|
13
|
+
<a class="brand" href="#"><%= app_name %></a>
|
14
|
+
<div class="<%= container_class %> nav-collapse">
|
15
|
+
<ul class="nav">
|
16
|
+
<%- (1..3).each do |i| -%>
|
17
|
+
<li><%%= link_to "Link<%= i %>", "#" %></li>
|
18
|
+
<%- end -%>
|
19
|
+
</ul>
|
20
|
+
</div><!--/.nav-collapse -->
|
21
|
+
</div>
|
22
|
+
</div>
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title><%= app_name %></title>
|
7
|
+
<%%= csrf_meta_tags %>
|
8
|
+
|
9
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
|
10
|
+
<!--[if lt IE 9]>
|
11
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
|
12
|
+
<![endif]-->
|
13
|
+
|
14
|
+
<!-- Le styles -->
|
15
|
+
<%%= stylesheet_link_tag "application", :media => "all" %>
|
16
|
+
|
17
|
+
<!-- Le fav and touch icons -->
|
18
|
+
<link href="images/favicon.ico" rel="shortcut icon">
|
19
|
+
<link href="images/apple-touch-icon.png" rel="apple-touch-icon">
|
20
|
+
<link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon" sizes="72x72">
|
21
|
+
<link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon" sizes="114x114">
|
22
|
+
<style type="text/css">body { margin-top: 100px; }</style>
|
23
|
+
</head>
|
24
|
+
<body>
|
25
|
+
|
26
|
+
<%%= render partial: "layouts/bootstrapped-navigation" %>
|
27
|
+
|
28
|
+
|
29
|
+
<div class="<%= container_class %>">
|
30
|
+
<%- if layout_type == "fluid" -%>
|
31
|
+
<div class="row-fluid">
|
32
|
+
<div class="span3">
|
33
|
+
<div class="well sidebar-nav">
|
34
|
+
<ul class="nav nav-list">
|
35
|
+
<li class="nav-header">Sidebar</li>
|
36
|
+
<%- (1..3).each do |i| -%>
|
37
|
+
<li><%%= link_to "Link<%= i %>", "#" %></li>
|
38
|
+
<%- end -%>
|
39
|
+
</ul>
|
40
|
+
</div><!--/.well -->
|
41
|
+
</div><!--/span-->
|
42
|
+
<div class="span9">
|
43
|
+
<%%= yield %>
|
44
|
+
</div>
|
45
|
+
</div><!--/row-->
|
46
|
+
<%- else -%>
|
47
|
+
<div class="content">
|
48
|
+
<div class="row">
|
49
|
+
<div class="span9">
|
50
|
+
<%%= yield %>
|
51
|
+
</div>
|
52
|
+
<div class="span3">
|
53
|
+
<div class="well sidebar-nav">
|
54
|
+
<h3>Sidebar</h3>
|
55
|
+
<ul class="nav nav-list">
|
56
|
+
<li class="nav-header">Sidebar</li>
|
57
|
+
<%- (1..3).each do |i| -%>
|
58
|
+
<li><%%= link_to "Link<%= i %>", "#" %></li>
|
59
|
+
<%- end -%>
|
60
|
+
</ul>
|
61
|
+
</div><!--/.well -->
|
62
|
+
</div><!--/span-->
|
63
|
+
</div><!--/row-->
|
64
|
+
</div><!--/content-->
|
65
|
+
<%- end -%>
|
66
|
+
|
67
|
+
<footer class='well'>
|
68
|
+
<p>© Company 2012</p>
|
69
|
+
</footer>
|
70
|
+
|
71
|
+
</div> <!-- /container -->
|
72
|
+
|
73
|
+
<!-- Le javascript
|
74
|
+
================================================== -->
|
75
|
+
<!-- Placed at the end of the document so the pages load faster -->
|
76
|
+
<%%= javascript_include_tag "application" %>
|
77
|
+
|
78
|
+
</body>
|
79
|
+
</html>
|
@@ -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.well
|
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.well
|
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 Bootstrapped
|
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
|
+
::Rails.application.config.generators.options[:rails][:template_engine] || :erb
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/readme.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
# This is a
|
1
|
+
# This is a hacked-together version of the gem 'bootstrap-rails', with the generators from 'twitter-bootstrap-rails', has also replaced the Glyphicons icons with [Font Awesome](http://fortawesome.github.com/Font-Awesome/), since svg icons are resizable and colorable and such. There are also some custom scss helpers in a folder called 'custom_partials', which are just a byproduct of trying not to hate css. Feel free to muck around with this as you please.
|
2
2
|
|
3
3
|
As specified below, the license is being included.
|
4
4
|
Feel free to fork and mess around with this.
|
5
5
|
(uses bootstrap v2)
|
6
6
|
|
7
|
+
|
8
|
+
|
7
9
|
## License
|
8
10
|
Copyright (c) 2011 AnjLab
|
9
11
|
|
@@ -11,6 +13,69 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
11
13
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
12
14
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
13
15
|
|
16
|
+
## License
|
17
|
+
Copyright (c) 2011 Seyhun Akyürek
|
18
|
+
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
20
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
## Installing Gem
|
24
|
+
|
25
|
+
Include Bootstrap in Gemfile;
|
26
|
+
|
27
|
+
gem "bootstrapped-rails"
|
28
|
+
|
29
|
+
You can run bundle from command line
|
30
|
+
|
31
|
+
bundle install
|
32
|
+
|
33
|
+
|
34
|
+
## Installing to App (using Generators)
|
35
|
+
|
36
|
+
You can run following generators to get started with Twitter Bootstrap quickly.
|
37
|
+
|
38
|
+
|
39
|
+
Install (requires directives to Asset pipeline.)
|
40
|
+
|
41
|
+
|
42
|
+
Usage:
|
43
|
+
|
44
|
+
|
45
|
+
rails g bootstrapped:install
|
46
|
+
|
47
|
+
|
48
|
+
Layout (generates Twitter Bootstrap compatible layout) - (Haml and Slim supported)
|
49
|
+
|
50
|
+
|
51
|
+
Usage:
|
52
|
+
|
53
|
+
|
54
|
+
rails g bootstrapped:layout [LAYOUT_NAME] [*fixed or fluid]
|
55
|
+
|
56
|
+
|
57
|
+
Example:
|
58
|
+
|
59
|
+
|
60
|
+
rails g bootstrapped:layout application fixed
|
61
|
+
|
62
|
+
|
63
|
+
Themed (generates Twitter Bootstrap compatible scaffold views.)
|
64
|
+
|
65
|
+
|
66
|
+
Usage:
|
67
|
+
|
68
|
+
|
69
|
+
rails g bootstrapped:themed [RESOURCE_NAME]
|
70
|
+
|
71
|
+
|
72
|
+
Example:
|
73
|
+
|
74
|
+
|
75
|
+
rails g scaffold post title:string description:text
|
76
|
+
rake db:migrate
|
77
|
+
rails g bootstrapped:themed posts
|
78
|
+
|
14
79
|
## Custom Modules
|
15
80
|
Can be imported with the following import commands at the top of your scss file.
|
16
81
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrapped-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-07 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|
16
|
-
requirement: &
|
16
|
+
requirement: &70236412489760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70236412489760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70236412489260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70236412489260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70236412488740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.1'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70236412488740
|
47
47
|
description: ! ' please see summary '
|
48
48
|
email:
|
49
49
|
- han@logicalprep.com
|
@@ -62,6 +62,31 @@ files:
|
|
62
62
|
- lib/bootstrapped-rails/ie_hex_str.rb
|
63
63
|
- lib/bootstrapped-rails/railtie.rb
|
64
64
|
- lib/bootstrapped-rails/version.rb
|
65
|
+
- lib/generators/bootstrapped/install/install_generator.rb
|
66
|
+
- lib/generators/bootstrapped/install/templates/application.css
|
67
|
+
- lib/generators/bootstrapped/install/templates/application.js
|
68
|
+
- lib/generators/bootstrapped/install/templates/bootstrap.coffee
|
69
|
+
- lib/generators/bootstrapped/layout/layout_generator.rb
|
70
|
+
- lib/generators/bootstrapped/layout/templates/_bootstrapped-navigation.html.erb
|
71
|
+
- lib/generators/bootstrapped/layout/templates/layout.html.erb
|
72
|
+
- lib/generators/bootstrapped/layout/templates/layout.html.haml
|
73
|
+
- lib/generators/bootstrapped/layout/templates/layout.html.slim
|
74
|
+
- lib/generators/bootstrapped/themed/templates/_form.html.erb
|
75
|
+
- lib/generators/bootstrapped/themed/templates/_form.html.haml
|
76
|
+
- lib/generators/bootstrapped/themed/templates/_form.html.slim
|
77
|
+
- lib/generators/bootstrapped/themed/templates/edit.html.erb
|
78
|
+
- lib/generators/bootstrapped/themed/templates/edit.html.haml
|
79
|
+
- lib/generators/bootstrapped/themed/templates/edit.html.slim
|
80
|
+
- lib/generators/bootstrapped/themed/templates/index.html.erb
|
81
|
+
- lib/generators/bootstrapped/themed/templates/index.html.haml
|
82
|
+
- lib/generators/bootstrapped/themed/templates/index.html.slim
|
83
|
+
- lib/generators/bootstrapped/themed/templates/new.html.erb
|
84
|
+
- lib/generators/bootstrapped/themed/templates/new.html.haml
|
85
|
+
- lib/generators/bootstrapped/themed/templates/new.html.slim
|
86
|
+
- lib/generators/bootstrapped/themed/templates/show.html.erb
|
87
|
+
- lib/generators/bootstrapped/themed/templates/show.html.haml
|
88
|
+
- lib/generators/bootstrapped/themed/templates/show.html.slim
|
89
|
+
- lib/generators/bootstrapped/themed/themed_generator.rb
|
65
90
|
- readme.md
|
66
91
|
- vendor/assets/fonts/.DS_Store
|
67
92
|
- vendor/assets/fonts/iconic_stroke.eot
|