bootstrap-generators 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/bootstrap-generators.gemspec +4 -2
- data/lib/bootstrap-generators.rb +31 -3
- data/lib/bootstrap-generators/engine.rb +6 -0
- data/lib/bootstrap-generators/version.rb +1 -1
- data/lib/generators/erubis.rb +10 -0
- data/lib/generators/{erb → erubis}/controller/controller_generator.rb +3 -3
- data/lib/generators/erubis/controller/templates/view.html.erb +3 -0
- data/lib/generators/{erb → erubis}/scaffold/scaffold_generator.rb +3 -4
- data/lib/generators/erubis/scaffold/templates/_form.html.erb +24 -0
- data/lib/generators/erubis/scaffold/templates/edit.html.erb +9 -0
- data/lib/generators/erubis/scaffold/templates/index.html.erb +31 -0
- data/lib/generators/erubis/scaffold/templates/new.html.erb +8 -0
- data/lib/generators/erubis/scaffold/templates/show.html.erb +13 -0
- data/lib/generators/layout/application.html.erb +42 -0
- data/lib/generators/layout/bootstrap-layout.css +3 -0
- data/test/lib/generators/{erb → erubis}/controller_generator_test.rb +2 -2
- data/test/lib/generators/{erb → erubis}/scaffold_generator_test.rb +3 -3
- data/test/test_helper.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-alerts.js +111 -0
- data/vendor/assets/javascripts/bootstrap-dropdown.js +53 -0
- data/vendor/assets/javascripts/bootstrap-modal.js +244 -0
- data/vendor/assets/javascripts/bootstrap-popover.js +77 -0
- data/vendor/assets/javascripts/bootstrap-scrollspy.js +105 -0
- data/vendor/assets/javascripts/bootstrap-tabs.js +77 -0
- data/vendor/assets/javascripts/bootstrap-twipsy.js +303 -0
- data/vendor/assets/stylesheets/bootstrap.css +2363 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +330 -0
- metadata +56 -22
- data/lib/generators/erb.rb +0 -10
- data/lib/generators/erb/controller/templates/view.html.erb +0 -1
- data/lib/generators/erb/scaffold/templates/_form.html.erb +0 -1
- data/lib/generators/erb/scaffold/templates/edit.html.erb +0 -1
- data/lib/generators/erb/scaffold/templates/index.html.erb +0 -1
- data/lib/generators/erb/scaffold/templates/new.html.erb +0 -1
- data/lib/generators/erb/scaffold/templates/show.html.erb +0 -1
data/.gitignore
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
# s.add_development_dependency "rspec"
|
23
23
|
# s.add_runtime_dependency "rest-client"
|
24
24
|
|
25
|
-
s.add_dependency
|
26
|
-
s.add_development_dependency
|
25
|
+
s.add_dependency "railties", ">= 3.0.0"
|
26
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
27
|
+
s.add_development_dependency "test-unit"
|
28
|
+
s.add_development_dependency "rails", ">= 3.0.0"
|
27
29
|
end
|
data/lib/bootstrap-generators.rb
CHANGED
@@ -1,9 +1,37 @@
|
|
1
|
+
require 'rails'
|
1
2
|
require 'rails/generators'
|
2
3
|
|
3
|
-
module
|
4
|
-
module
|
4
|
+
module BootstrapGenerators
|
5
|
+
module Rails
|
6
|
+
class Railtie < ::Rails::Railtie
|
7
|
+
if ::Rails.version.to_f >= 3.1
|
8
|
+
# Erubis has the default template engine
|
9
|
+
config.app_generators.template_engine :erubis
|
10
|
+
config.app_generators.stylesheets false
|
11
|
+
require 'bootstrap-generators/engine'
|
12
|
+
else
|
13
|
+
# Erubis has the default template engine
|
14
|
+
config.generators.template_engine :erubis
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class LayoutGenerator < ::Rails::Generators::Base
|
20
|
+
desc "This generator installs Twitter Bootstrap Layout"
|
21
|
+
source_root File.expand_path('../generators/layout', __FILE__)
|
22
|
+
|
23
|
+
def copy_layout
|
24
|
+
say_status("copying", "layout", :green)
|
25
|
+
copy_file "application.html.erb", "app/views/layouts/application.html.erb"
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_stylesheet
|
29
|
+
say_status("copying", "layout stylesheet", :green)
|
30
|
+
copy_file "bootstrap-layout.css", "app/assets/stylesheets/bootstrap-layout.css"
|
31
|
+
end
|
32
|
+
end
|
5
33
|
end
|
6
34
|
|
7
35
|
Rails::Generators.hidden_namespaces << 'rails'
|
8
36
|
Rails::Generators.hidden_namespaces << 'erb:controller' << 'erb:scaffold'
|
9
|
-
|
37
|
+
Rails::Generators.hidden_namespaces << 'erubis:controller' << 'erubis:scaffold'
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'generators/
|
1
|
+
require 'generators/erubis'
|
2
2
|
require 'rails/generators/erb/controller/controller_generator'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Erubis
|
5
5
|
module Generators
|
6
|
-
class ControllerGenerator
|
6
|
+
class ControllerGenerator < Erb::Generators::ControllerGenerator
|
7
7
|
extend TemplatePath
|
8
8
|
end
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'generators/
|
1
|
+
require 'generators/erubis'
|
2
2
|
require 'rails/generators/erb/scaffold/scaffold_generator'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Erubis
|
5
5
|
module Generators
|
6
|
-
class ScaffoldGenerator
|
6
|
+
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
7
7
|
extend TemplatePath
|
8
8
|
|
9
9
|
hook_for :form_builder, :as => :scaffold
|
@@ -22,4 +22,3 @@ module Erb
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%%= form_for(@<%= singular_table_name %>) do |f| %>
|
2
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%%= msg %></li>
|
9
|
+
<%% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<%% end %>
|
13
|
+
|
14
|
+
<% attributes.each do |attribute| -%>
|
15
|
+
<div class="field">
|
16
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
17
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
18
|
+
</div>
|
19
|
+
<% end -%>
|
20
|
+
<div class="actions">
|
21
|
+
<%%= f.submit %>
|
22
|
+
</div>
|
23
|
+
<%% end %>
|
24
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, :class => 'btn' %>
|
3
|
+
<h1>Listing <%= plural_table_name %></h1>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<table class="zebra-striped">
|
7
|
+
<thead>
|
8
|
+
<tr>
|
9
|
+
<% attributes.each do |attribute| -%>
|
10
|
+
<th><%= attribute.human_name %></th>
|
11
|
+
<% end -%>
|
12
|
+
<th></th>
|
13
|
+
<th></th>
|
14
|
+
<th></th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
|
18
|
+
<tbody>
|
19
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
20
|
+
<tr>
|
21
|
+
<% attributes.each do |attribute| -%>
|
22
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
23
|
+
<% end -%>
|
24
|
+
<td><%%= link_to 'Show', <%= singular_table_name %> %></td>
|
25
|
+
<td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
|
26
|
+
<td><%%= link_to 'Destroy', <%= singular_table_name %>, <%= key_value :confirm, "'Are you sure?'" %>, <%= key_value :method, ":delete" %> %></td>
|
27
|
+
</tr>
|
28
|
+
<%% end %>
|
29
|
+
</tbody>
|
30
|
+
</table>
|
31
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<p id="notice"><%%= notice %></p>
|
2
|
+
|
3
|
+
<% attributes.each do |attribute| -%>
|
4
|
+
<p>
|
5
|
+
<b><%= attribute.human_name %>:</b>
|
6
|
+
<%%= @<%= singular_table_name %>.<%= attribute.name %> %>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
|
12
|
+
<%%= link_to 'Back', <%= index_helper %>_path %>
|
13
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Bootstrap, from Twitter</title>
|
6
|
+
<meta name="description" content="">
|
7
|
+
<meta name="author" content="">
|
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"></script>
|
12
|
+
<![endif]-->
|
13
|
+
|
14
|
+
<%= stylesheet_link_tag "application" %>
|
15
|
+
<%= javascript_include_tag "application" %>
|
16
|
+
<%= csrf_meta_tags %>
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div class="topbar">
|
20
|
+
<div class="fill">
|
21
|
+
<div class="container">
|
22
|
+
<a class="brand" href="#">Project name</a>
|
23
|
+
<ul class="nav">
|
24
|
+
<li class="active"><a href="#">Home</a></li>
|
25
|
+
<li><a href="#about">About</a></li>
|
26
|
+
<li><a href="#contact">Contact</a></li>
|
27
|
+
</ul>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<div class="container">
|
32
|
+
<div class="row">
|
33
|
+
<div class="span16">
|
34
|
+
<%= yield %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<footer>
|
38
|
+
<p>© Company 2011</p>
|
39
|
+
</footer>
|
40
|
+
</div>
|
41
|
+
</body>
|
42
|
+
</html>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class Erubis::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
|
4
4
|
destination File.join(Rails.root)
|
5
5
|
tests Rails::Generators::ControllerGenerator
|
6
|
-
arguments %w(Account foo bar --template-engine
|
6
|
+
arguments %w(Account foo bar --template-engine erubis)
|
7
7
|
|
8
8
|
setup :prepare_destination
|
9
9
|
setup :copy_routes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class Erubis::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
|
4
4
|
destination File.join(Rails.root)
|
5
5
|
tests Rails::Generators::ScaffoldGenerator
|
6
|
-
arguments %w(product_line title:string price:integer --template-engine
|
6
|
+
arguments %w(product_line title:string price:integer --template-engine erubis)
|
7
7
|
|
8
8
|
setup :prepare_destination
|
9
9
|
setup :copy_routes
|
@@ -24,7 +24,7 @@ class Erb::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
test "should invoke form builder" do
|
27
|
-
run_generator %w(product_line title:string price:integer --template-engine
|
27
|
+
run_generator %w(product_line title:string price:integer --template-engine erubis --form-builder some-form-builder)
|
28
28
|
assert_no_file "app/views/product_lines/_form.html.erb"
|
29
29
|
end
|
30
30
|
end
|
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,111 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-alerts.js v1.3.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
4
|
+
* ==========================================================
|
5
|
+
* Copyright 2011 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================== */
|
19
|
+
|
20
|
+
|
21
|
+
!function( $ ){
|
22
|
+
|
23
|
+
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
|
24
|
+
* ======================================================= */
|
25
|
+
|
26
|
+
var transitionEnd
|
27
|
+
|
28
|
+
$(document).ready(function () {
|
29
|
+
|
30
|
+
$.support.transition = (function () {
|
31
|
+
var thisBody = document.body || document.documentElement
|
32
|
+
, thisStyle = thisBody.style
|
33
|
+
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
|
34
|
+
return support
|
35
|
+
})()
|
36
|
+
|
37
|
+
// set CSS transition event type
|
38
|
+
if ( $.support.transition ) {
|
39
|
+
transitionEnd = "TransitionEnd"
|
40
|
+
if ( $.browser.webkit ) {
|
41
|
+
transitionEnd = "webkitTransitionEnd"
|
42
|
+
} else if ( $.browser.mozilla ) {
|
43
|
+
transitionEnd = "transitionend"
|
44
|
+
} else if ( $.browser.opera ) {
|
45
|
+
transitionEnd = "oTransitionEnd"
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
})
|
50
|
+
|
51
|
+
/* ALERT CLASS DEFINITION
|
52
|
+
* ====================== */
|
53
|
+
|
54
|
+
var Alert = function ( content, options ) {
|
55
|
+
this.settings = $.extend({}, $.fn.alert.defaults, options)
|
56
|
+
this.$element = $(content)
|
57
|
+
.delegate(this.settings.selector, 'click', this.close)
|
58
|
+
}
|
59
|
+
|
60
|
+
Alert.prototype = {
|
61
|
+
|
62
|
+
close: function (e) {
|
63
|
+
var $element = $(this).parent('.alert-message')
|
64
|
+
|
65
|
+
e && e.preventDefault()
|
66
|
+
$element.removeClass('in')
|
67
|
+
|
68
|
+
function removeElement () {
|
69
|
+
$element.remove()
|
70
|
+
}
|
71
|
+
|
72
|
+
$.support.transition && $element.hasClass('fade') ?
|
73
|
+
$element.bind(transitionEnd, removeElement) :
|
74
|
+
removeElement()
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
/* ALERT PLUGIN DEFINITION
|
81
|
+
* ======================= */
|
82
|
+
|
83
|
+
$.fn.alert = function ( options ) {
|
84
|
+
|
85
|
+
if ( options === true ) {
|
86
|
+
return this.data('alert')
|
87
|
+
}
|
88
|
+
|
89
|
+
return this.each(function () {
|
90
|
+
var $this = $(this)
|
91
|
+
|
92
|
+
if ( typeof options == 'string' ) {
|
93
|
+
return $this.data('alert')[options]()
|
94
|
+
}
|
95
|
+
|
96
|
+
$(this).data('alert', new Alert( this, options ))
|
97
|
+
|
98
|
+
})
|
99
|
+
}
|
100
|
+
|
101
|
+
$.fn.alert.defaults = {
|
102
|
+
selector: '.close'
|
103
|
+
}
|
104
|
+
|
105
|
+
$(document).ready(function () {
|
106
|
+
new Alert($('body'), {
|
107
|
+
selector: '.alert-message[data-alert] .close'
|
108
|
+
})
|
109
|
+
})
|
110
|
+
|
111
|
+
}( window.jQuery || window.ender );
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/* ============================================================
|
2
|
+
* bootstrap-dropdown.js v1.3.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#dropdown
|
4
|
+
* ============================================================
|
5
|
+
* Copyright 2011 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ============================================================ */
|
19
|
+
|
20
|
+
|
21
|
+
!function( $ ){
|
22
|
+
|
23
|
+
/* DROPDOWN PLUGIN DEFINITION
|
24
|
+
* ========================== */
|
25
|
+
|
26
|
+
$.fn.dropdown = function ( selector ) {
|
27
|
+
return this.each(function () {
|
28
|
+
$(this).delegate(selector || d, 'click', function (e) {
|
29
|
+
var li = $(this).parent('li')
|
30
|
+
, isActive = li.hasClass('open')
|
31
|
+
|
32
|
+
clearMenus()
|
33
|
+
!isActive && li.toggleClass('open')
|
34
|
+
return false
|
35
|
+
})
|
36
|
+
})
|
37
|
+
}
|
38
|
+
|
39
|
+
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
40
|
+
* =================================== */
|
41
|
+
|
42
|
+
var d = 'a.menu, .dropdown-toggle'
|
43
|
+
|
44
|
+
function clearMenus() {
|
45
|
+
$(d).parent('li').removeClass('open')
|
46
|
+
}
|
47
|
+
|
48
|
+
$(function () {
|
49
|
+
$('html').bind("click", clearMenus)
|
50
|
+
$('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' )
|
51
|
+
})
|
52
|
+
|
53
|
+
}( window.jQuery || window.ender );
|