kube-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -0
- data/Rakefile +14 -0
- data/lib/generators/kube/install/install_generator.rb +53 -0
- data/lib/generators/kube/install/templates/application.css +7 -0
- data/lib/generators/kube/install/templates/application.js +10 -0
- data/lib/generators/kube/install/templates/bootstrap.coffee +4 -0
- data/lib/generators/kube/install/templates/bootstrap_and_overrides.less +28 -0
- data/lib/generators/kube/layout/layout_generator.rb +23 -0
- data/lib/generators/kube/layout/templates/layout.html.erb +108 -0
- data/lib/generators/kube/layout/templates/layout.html.haml +68 -0
- data/lib/generators/kube/layout/templates/layout.html.slim +68 -0
- data/lib/generators/kube/partial/partial_generator.rb +20 -0
- data/lib/generators/kube/partial/templates/_login.html.erb +29 -0
- data/lib/generators/kube/partial/templates/_navbar.html.erb +13 -0
- data/lib/generators/kube/themed/templates/_form.html.erb +16 -0
- data/lib/generators/kube/themed/templates/_form.html.haml +10 -0
- data/lib/generators/kube/themed/templates/_form.html.slim +11 -0
- data/lib/generators/kube/themed/templates/edit.html.erb +6 -0
- data/lib/generators/kube/themed/templates/edit.html.haml +4 -0
- data/lib/generators/kube/themed/templates/edit.html.slim +4 -0
- data/lib/generators/kube/themed/templates/index.html.erb +40 -0
- data/lib/generators/kube/themed/templates/index.html.haml +25 -0
- data/lib/generators/kube/themed/templates/index.html.slim +27 -0
- data/lib/generators/kube/themed/templates/new.html.erb +6 -0
- data/lib/generators/kube/themed/templates/new.html.haml +4 -0
- data/lib/generators/kube/themed/templates/new.html.slim +4 -0
- data/lib/generators/kube/themed/templates/show.html.erb +23 -0
- data/lib/generators/kube/themed/templates/show.html.haml +15 -0
- data/lib/generators/kube/themed/templates/show.html.slim +17 -0
- data/lib/generators/kube/themed/templates/simple_form/_form.html.erb +14 -0
- data/lib/generators/kube/themed/templates/simple_form/_form.html.haml +11 -0
- data/lib/generators/kube/themed/templates/simple_form/_form.html.slim +12 -0
- data/lib/generators/kube/themed/themed_generator.rb +104 -0
- data/lib/kube/rails/engine.rb +13 -0
- data/lib/kube/rails/kube.rb +2 -0
- data/lib/kube/rails/version.rb +5 -0
- data/lib/kube-rails.rb +8 -0
- data/vendor/kube/base.less +199 -0
- data/vendor/kube/blocks.less +27 -0
- data/vendor/kube/buttons.less +138 -0
- data/vendor/kube/forms.less +219 -0
- data/vendor/kube/goodies.less +119 -0
- data/vendor/kube/grid.less +149 -0
- data/vendor/kube/kube.less +18 -0
- data/vendor/kube/mixins.less +76 -0
- data/vendor/kube/responsive.less +93 -0
- data/vendor/kube/tables.less +41 -0
- data/vendor/kube/typo.less +230 -0
- data/vendor/kube/variables.less +67 -0
- metadata +174 -0
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Kube for Rails 3.1 Asset Pipeline
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
desc "Bundle the gem"
|
6
|
+
task :bundle do
|
7
|
+
sh('bundle install')
|
8
|
+
sh 'gem build *.gemspec'
|
9
|
+
sh 'gem install *.gem'
|
10
|
+
sh 'rm *.gem'
|
11
|
+
end
|
12
|
+
|
13
|
+
task(:default).clear
|
14
|
+
task :default => :bundle
|
@@ -0,0 +1,53 @@
|
|
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_assets
|
11
|
+
|
12
|
+
if File.exist?('app/assets/javascripts/application.js')
|
13
|
+
insert_into_file "app/assets/javascripts/application.js", "//= require twitter/bootstrap\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
|
+
if content.match(/require_tree\s+\.\s*$/)
|
22
|
+
# Good enough - that'll include our bootstrap_and_overrides.css.less
|
23
|
+
else
|
24
|
+
style_require_block = " *= require bootstrap_and_overrides\n"
|
25
|
+
insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
|
26
|
+
end
|
27
|
+
else
|
28
|
+
copy_file "application.css", "app/assets/stylesheets/application.css"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_bootstrap
|
34
|
+
copy_file "bootstrap.coffee", "app/assets/javascripts/bootstrap.js.coffee"
|
35
|
+
copy_file "bootstrap_and_overrides.less", "app/assets/stylesheets/bootstrap_and_overrides.css.less"
|
36
|
+
end
|
37
|
+
|
38
|
+
def cleanup_legacy
|
39
|
+
# Remove old requires (if any) that included twitter/bootstrap directly:
|
40
|
+
gsub_file("app/assets/stylesheets/application.css", %r|\s*\*=\s*twitter/bootstrap\s*\n|, "")
|
41
|
+
gsub_file("app/assets/stylesheets/application.css", %r|\s*\*=\s*twitter/bootstrap_responsive\s*\n|, "")
|
42
|
+
if File.exist?('app/assets/stylesheets/bootstrap_override.css.less')
|
43
|
+
puts <<-EOM
|
44
|
+
Warning:
|
45
|
+
app/assets/stylesheets/bootstrap_override.css.less exists
|
46
|
+
It should be removed, as it has been superceded by app/assets/stylesheets/bootstrap_and_overrides.css.less
|
47
|
+
EOM
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
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,28 @@
|
|
1
|
+
@import "twitter/bootstrap/bootstrap";
|
2
|
+
@import "twitter/bootstrap/responsive";
|
3
|
+
|
4
|
+
// Set the correct sprite paths
|
5
|
+
@iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings.png");
|
6
|
+
@iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white.png");
|
7
|
+
|
8
|
+
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
|
9
|
+
// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not
|
10
|
+
// have the proper paths. So for now we use the absolute path.
|
11
|
+
@fontAwesomeEotPath: asset-path("fontawesome-webfont.eot");
|
12
|
+
@fontAwesomeWoffPath: asset-path("fontawesome-webfont.woff");
|
13
|
+
@fontAwesomeTtfPath: asset-path("fontawesome-webfont.ttf");
|
14
|
+
@fontAwesomeSvgPath: asset-path("fontawesome-webfont.svg");
|
15
|
+
|
16
|
+
// Font Awesome
|
17
|
+
@import "fontawesome";
|
18
|
+
|
19
|
+
// Your custom LESS stylesheets goes here
|
20
|
+
//
|
21
|
+
// Since bootstrap was imported above you have access to its mixins which
|
22
|
+
// you may use and inherit here
|
23
|
+
//
|
24
|
+
// If you'd like to override bootstrap's own variables, you can do so here as well
|
25
|
+
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
|
26
|
+
//
|
27
|
+
// Example:
|
28
|
+
// @linkColor: #ff0000;
|
@@ -0,0 +1,23 @@
|
|
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
|
+
ext = app.config.generators.options[:rails][:template_engine] || :erb
|
19
|
+
template "layout.html.#{ext}", "app/views/layouts/#{layout_name}.html.#{ext}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<title><%%= content_for?(:title) ? yield(:title) : "<%= app_name %>" %></title>
|
8
|
+
<%%= csrf_meta_tags %>
|
9
|
+
|
10
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
|
11
|
+
<!--[if lt IE 9]>
|
12
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
|
13
|
+
<![endif]-->
|
14
|
+
|
15
|
+
<%%= stylesheet_link_tag "application", :media => "all" %>
|
16
|
+
|
17
|
+
<!-- For third-generation iPad with high-resolution Retina display: -->
|
18
|
+
<!-- Size should be 144 x 144 pixels -->
|
19
|
+
<%%= favicon_link_tag 'images/apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
|
20
|
+
|
21
|
+
<!-- For iPhone with high-resolution Retina display: -->
|
22
|
+
<!-- Size should be 114 x 114 pixels -->
|
23
|
+
<%%= favicon_link_tag 'images/apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
|
24
|
+
|
25
|
+
<!-- For first- and second-generation iPad: -->
|
26
|
+
<!-- Size should be 72 x 72 pixels -->
|
27
|
+
<%%= favicon_link_tag 'images/apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
|
28
|
+
|
29
|
+
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
|
30
|
+
<!-- Size should be 57 x 57 pixels -->
|
31
|
+
<%%= favicon_link_tag 'images/apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
|
32
|
+
|
33
|
+
<!-- For all other devices -->
|
34
|
+
<!-- Size should be 32 x 32 pixels -->
|
35
|
+
<%%= favicon_link_tag 'images/favicon.ico', :rel => 'shortcut icon' %>
|
36
|
+
</head>
|
37
|
+
<body>
|
38
|
+
|
39
|
+
<div class="navbar navbar-fixed-top">
|
40
|
+
<div class="navbar-inner">
|
41
|
+
<div class="<%= container_class %>">
|
42
|
+
<a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
|
43
|
+
<span class="icon-bar"></span>
|
44
|
+
<span class="icon-bar"></span>
|
45
|
+
<span class="icon-bar"></span>
|
46
|
+
</a>
|
47
|
+
<a class="brand" href="#"><%= app_name %></a>
|
48
|
+
<div class="<%= container_class %> nav-collapse">
|
49
|
+
<ul class="nav">
|
50
|
+
<li><%%= link_to "Link1", "/path1" %></li>
|
51
|
+
<li><%%= link_to "Link2", "/path2" %></li>
|
52
|
+
<li><%%= link_to "Link3", "/path3" %></li>
|
53
|
+
</ul>
|
54
|
+
</div><!--/.nav-collapse -->
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div class="<%= container_class %>">
|
60
|
+
<%- if layout_type == "fluid" -%>
|
61
|
+
<div class="row-fluid">
|
62
|
+
<div class="span3">
|
63
|
+
<div class="well sidebar-nav">
|
64
|
+
<ul class="nav nav-list">
|
65
|
+
<li class="nav-header">Sidebar</li>
|
66
|
+
<li><%%= link_to "Link1", "/path1" %></li>
|
67
|
+
<li><%%= link_to "Link2", "/path2" %></li>
|
68
|
+
<li><%%= link_to "Link3", "/path3" %></li>
|
69
|
+
</ul>
|
70
|
+
</div><!--/.well -->
|
71
|
+
</div><!--/span-->
|
72
|
+
<div class="span9">
|
73
|
+
<%%= bootstrap_flash %>
|
74
|
+
<%%= yield %>
|
75
|
+
</div>
|
76
|
+
</div><!--/row-->
|
77
|
+
<%- else -%>
|
78
|
+
<div class="row">
|
79
|
+
<div class="span9">
|
80
|
+
<%%= yield %>
|
81
|
+
</div>
|
82
|
+
<div class="span3">
|
83
|
+
<div class="well sidebar-nav">
|
84
|
+
<h3>Sidebar</h3>
|
85
|
+
<ul class="nav nav-list">
|
86
|
+
<li class="nav-header">Sidebar</li>
|
87
|
+
<li><%%= link_to "Link1", "/path1" %></li>
|
88
|
+
<li><%%= link_to "Link2", "/path2" %></li>
|
89
|
+
<li><%%= link_to "Link3", "/path3" %></li>
|
90
|
+
</ul>
|
91
|
+
</div><!--/.well -->
|
92
|
+
</div><!--/span-->
|
93
|
+
</div><!--/row-->
|
94
|
+
<%- end -%>
|
95
|
+
|
96
|
+
<footer>
|
97
|
+
<p>© Company 2012</p>
|
98
|
+
</footer>
|
99
|
+
|
100
|
+
</div> <!-- /container -->
|
101
|
+
|
102
|
+
<!-- Javascripts
|
103
|
+
================================================== -->
|
104
|
+
<!-- Placed at the end of the document so the pages load faster -->
|
105
|
+
<%%= javascript_include_tag "application" %>
|
106
|
+
|
107
|
+
</body>
|
108
|
+
</html>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html(lang="en")
|
3
|
+
%head
|
4
|
+
%meta(charset="utf-8")
|
5
|
+
%meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1")
|
6
|
+
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
|
7
|
+
%title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
|
8
|
+
= csrf_meta_tags
|
9
|
+
/ Le HTML5 shim, for IE6-8 support of HTML elements
|
10
|
+
/[if lt IE 9]
|
11
|
+
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
12
|
+
= stylesheet_link_tag "application", :media => "all"
|
13
|
+
%link(href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144")
|
14
|
+
%link(href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114")
|
15
|
+
%link(href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72")
|
16
|
+
%link(href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed")
|
17
|
+
%link(href="images/favicon.ico" rel="shortcut icon")
|
18
|
+
|
19
|
+
|
20
|
+
%body
|
21
|
+
.navbar.navbar-fixed-top
|
22
|
+
.navbar-inner
|
23
|
+
.<%= container_class %>
|
24
|
+
%a.btn.btn-navbar(data-target=".nav-collapse" data-toggle="collapse")
|
25
|
+
%span.icon-bar
|
26
|
+
%span.icon-bar
|
27
|
+
%span.icon-bar
|
28
|
+
%a.brand(href="#") <%= app_name %>
|
29
|
+
.container.nav-collapse
|
30
|
+
%ul.nav
|
31
|
+
%li= link_to "Link 1", "/path1"
|
32
|
+
%li= link_to "Link 2", "/path2"
|
33
|
+
%li= link_to "Link 3", "/path3"
|
34
|
+
|
35
|
+
.<%= container_class %>
|
36
|
+
<%- if layout_type == "fluid" -%>
|
37
|
+
|
38
|
+
.row-fluid
|
39
|
+
.span3
|
40
|
+
.well.sidebar-nav
|
41
|
+
%ul.nav.nav-list
|
42
|
+
%li.nav-header Sidebar
|
43
|
+
%li= link_to "Link 1", "/path1"
|
44
|
+
%li= link_to "Link 2", "/path2"
|
45
|
+
%li= link_to "Link 3", "/path3"
|
46
|
+
.span9
|
47
|
+
= yield
|
48
|
+
<% else %>
|
49
|
+
.row
|
50
|
+
.span9
|
51
|
+
= bootstrap_flash
|
52
|
+
= yield
|
53
|
+
.span3
|
54
|
+
.well.sidebar-nav
|
55
|
+
%h3 Sidebar
|
56
|
+
%ul.nav.nav-list
|
57
|
+
%li.nav-header Sidebar
|
58
|
+
%li= link_to "Link 1", "/path1"
|
59
|
+
%li= link_to "Link 2", "/path2"
|
60
|
+
%li= link_to "Link 3", "/path3"
|
61
|
+
<% end %>
|
62
|
+
%footer
|
63
|
+
%p © Company 2012
|
64
|
+
/
|
65
|
+
Javascripts
|
66
|
+
\==================================================
|
67
|
+
/ Placed at the end of the document so the pages load faster
|
68
|
+
= javascript_include_tag "application"
|
@@ -0,0 +1,68 @@
|
|
1
|
+
doctype html
|
2
|
+
html lang="en"
|
3
|
+
head
|
4
|
+
meta charset="utf-8"
|
5
|
+
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
6
|
+
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
7
|
+
title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
|
8
|
+
= csrf_meta_tags
|
9
|
+
|
10
|
+
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
11
|
+
/[if lt IE 9]
|
12
|
+
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
13
|
+
= stylesheet_link_tag "application", :media => "all"
|
14
|
+
link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
15
|
+
link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
16
|
+
link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
17
|
+
link href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
18
|
+
link href="images/favicon.ico" rel="shortcut icon"
|
19
|
+
|
20
|
+
body
|
21
|
+
.navbar.navbar-fixed-top
|
22
|
+
.navbar-inner
|
23
|
+
.<%= container_class %>
|
24
|
+
a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse"
|
25
|
+
span.icon-bar
|
26
|
+
span.icon-bar
|
27
|
+
span.icon-bar
|
28
|
+
a.brand href="#"<%= app_name %>
|
29
|
+
.<%=container_class%>.nav-collapse
|
30
|
+
ul.nav
|
31
|
+
li= link_to "Link 1", "/path1"
|
32
|
+
li= link_to "Link 2", "/path2"
|
33
|
+
li= link_to "Link 3", "/path3"
|
34
|
+
|
35
|
+
.<%= container_class %>
|
36
|
+
<%- if layout_type == "fluid" -%>
|
37
|
+
|
38
|
+
.row-fluid
|
39
|
+
.span3
|
40
|
+
.well.sidebar-nav
|
41
|
+
ul.nav.nav-list
|
42
|
+
li.nav-header Sidebar
|
43
|
+
li= link_to "Link 1", "/path1"
|
44
|
+
li= link_to "Link 2", "/path2"
|
45
|
+
li= link_to "Link 3", "/path3"
|
46
|
+
.span9
|
47
|
+
= yield
|
48
|
+
<% else %>
|
49
|
+
.row
|
50
|
+
.span9
|
51
|
+
= bootstrap_flash
|
52
|
+
= yield
|
53
|
+
.span3
|
54
|
+
.well.sidebar-nav
|
55
|
+
h3 Sidebar
|
56
|
+
ul.nav.nav-list
|
57
|
+
li.nav-header Sidebar
|
58
|
+
li= link_to "Link 1", "/path1"
|
59
|
+
li= link_to "Link 2", "/path2"
|
60
|
+
li= link_to "Link 3", "/path3"
|
61
|
+
<% end %>
|
62
|
+
footer
|
63
|
+
p © Company 2012
|
64
|
+
/!
|
65
|
+
Javascripts
|
66
|
+
\==================================================
|
67
|
+
/! Placed at the end of the document so the pages load faster
|
68
|
+
= javascript_include_tag "application"
|
@@ -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,6 @@
|
|
1
|
+
<%%- model_class = <%= resource_name.classify %> -%>
|
2
|
+
<div class="page-header">
|
3
|
+
<h1><%%=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human,
|
4
|
+
:default => "Edit #{model_class.model_name.human}") %></h1>
|
5
|
+
</div>
|
6
|
+
<%%= render :partial => 'form' %>
|
@@ -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 %></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
|
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
|
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,6 @@
|
|
1
|
+
<%%- model_class = <%= resource_name.classify %> -%>
|
2
|
+
<div class="page-header">
|
3
|
+
<h1><%%=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human,
|
4
|
+
:default => "New #{model_class.model_name.human}") %></h1>
|
5
|
+
</div>
|
6
|
+
<%%= render :partial => 'form' %>
|