bootstrap-generators 2.3.1.2 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -623
  3. data/Rakefile +106 -0
  4. data/lib/bootstrap/generators/version.rb +1 -1
  5. data/lib/generators/bootstrap/install/install_generator.rb +5 -2
  6. data/lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.css.scss +3 -3
  7. data/lib/generators/bootstrap/install/templates/lib/templates/erb/scaffold/index.html.erb +1 -1
  8. data/lib/generators/bootstrap/install/templates/lib/templates/haml/scaffold/index.html.haml +1 -1
  9. data/readme-template.md.erb +179 -0
  10. data/test/lib/generators/bootstrap/install_generator_test.rb +9 -1
  11. data/vendor/assets/javascripts/bootstrap-affix.js +3 -3
  12. data/vendor/assets/javascripts/bootstrap-alert.js +3 -3
  13. data/vendor/assets/javascripts/bootstrap-button.js +3 -3
  14. data/vendor/assets/javascripts/bootstrap-carousel.js +3 -3
  15. data/vendor/assets/javascripts/bootstrap-collapse.js +3 -3
  16. data/vendor/assets/javascripts/bootstrap-dropdown.js +8 -4
  17. data/vendor/assets/javascripts/bootstrap-modal.js +3 -3
  18. data/vendor/assets/javascripts/bootstrap-popover.js +3 -3
  19. data/vendor/assets/javascripts/bootstrap-scrollspy.js +3 -3
  20. data/vendor/assets/javascripts/bootstrap-tab.js +3 -3
  21. data/vendor/assets/javascripts/bootstrap-tooltip.js +3 -3
  22. data/vendor/assets/javascripts/bootstrap-transition.js +3 -3
  23. data/vendor/assets/javascripts/bootstrap-typeahead.js +3 -3
  24. data/vendor/assets/javascripts/bootstrap.js +6 -6
  25. data/vendor/assets/stylesheets/bootstrap-responsive.css +1 -1
  26. data/vendor/assets/stylesheets/bootstrap.css +12 -3
  27. data/vendor/twitter/bootstrap/less/bootstrap.less +3 -3
  28. data/vendor/twitter/bootstrap/less/dropdowns.less +11 -0
  29. data/vendor/twitter/bootstrap/less/mixins.less +2 -2
  30. data/vendor/twitter/bootstrap/less/responsive.less +3 -3
  31. data/vendor/twitter/bootstrap/less/type.less +1 -1
  32. data/vendor/twitter/bootstrap/less/variables.less +2 -2
  33. data/vendor/twitter/bootstrap/sass/_dropdowns.scss +11 -0
  34. data/vendor/twitter/bootstrap/sass/_mixins.scss +25 -19
  35. data/vendor/twitter/bootstrap/sass/_variables.scss +5 -5
  36. data/vendor/twitter/bootstrap/sass/bootstrap.scss +1 -1
  37. data/vendor/twitter/bootstrap/sass/responsive.scss +1 -1
  38. metadata +3 -2
data/Rakefile CHANGED
@@ -8,3 +8,109 @@ Rake::TestTask.new do |t|
8
8
  end
9
9
 
10
10
  task :default => :test
11
+
12
+ namespace :bootstrap do
13
+ desc "Update to a new version of Twitter Bootstrap"
14
+ task :update do
15
+ bootstrap_version = "2.3.2"
16
+ striped_bootstrap_generators_version = "2.3"
17
+
18
+ twitter_latest_dist_zip_url = "https://github.com/twbs/bootstrap/archive/v#{bootstrap_version}.zip"
19
+ twitter_sass_lastest_dist_zip_url = "https://github.com/jlong/sass-bootstrap/archive/v#{bootstrap_version}.zip"
20
+ twitter_bootstrap_dir = "tmp/bootstrap-#{bootstrap_version}"
21
+ twitter_sass_bootstrap_dir = "tmp/sass-bootstrap-#{bootstrap_version}"
22
+
23
+ # Make sure tmp/ dir exists
24
+ Dir.mkdir('tmp') unless File.exists?('tmp')
25
+
26
+ if File.exists?(twitter_bootstrap_dir)
27
+ puts "Twitter Bootstrap already downloaded."
28
+ else
29
+ # Download the latest version of Twitter Bootstrap
30
+ `wget -O tmp/bootstrap.zip #{twitter_latest_dist_zip_url}`
31
+
32
+ # Extract Twitter Bootstrap
33
+ `unzip -d tmp tmp/bootstrap.zip`
34
+ end
35
+
36
+ if File.exists?(twitter_sass_bootstrap_dir)
37
+ puts "Twitter Bootstrap Sass already downloaded."
38
+ else
39
+ # Download the latest version of Twitter Bootstrap Sass
40
+ `wget -O tmp/sass-bootstrap.zip #{twitter_sass_lastest_dist_zip_url}`
41
+
42
+ # Extract Twitter Bootstrap
43
+ `unzip -d tmp tmp/sass-bootstrap.zip`
44
+ end
45
+
46
+ # Reset Twitter Bootstrap JS files
47
+ bootstrap_javascript_dir = 'vendor/assets/javascripts'
48
+ bootstrap_main_javascript = 'vendor/assets/javascripts/bootstrap.js'
49
+
50
+ FileUtils.rm Dir.glob("#{bootstrap_javascript_dir}/*.js")
51
+ FileUtils.cp Dir.glob("#{twitter_bootstrap_dir}/js/*.js"), bootstrap_javascript_dir
52
+
53
+ # Rewrite base bootstrap.js
54
+ require_files = []
55
+ Dir.glob("#{bootstrap_javascript_dir}/*.js") do |js_file|
56
+ require_files << File.basename(js_file, '.*')
57
+ end
58
+
59
+ # Make sure that tooltip.js is before popover.js (Popover requires tooltip.js)
60
+ tooltip_position = require_files.index('bootstrap-tooltip')
61
+ popover_position = require_files.index('bootstrap-popover')
62
+ require_files.insert(popover_position, require_files.delete_at(tooltip_position))
63
+
64
+ File.open(bootstrap_main_javascript, 'w') do |file|
65
+ require_files.each do |require_file|
66
+ file.write("//= require #{require_file}\n")
67
+ end
68
+ end
69
+
70
+ # Reset Twitter Bootstrap Images
71
+ bootstrap_images_dir = 'vendor/assets/images'
72
+
73
+ FileUtils.rm Dir.glob("#{bootstrap_images_dir}/*")
74
+ FileUtils.cp Dir.glob("#{twitter_bootstrap_dir}/img/*"), bootstrap_images_dir
75
+
76
+ # Reset Twitter Bootstrap CSS file
77
+ FileUtils.cp "#{twitter_bootstrap_dir}/docs/assets/css/bootstrap.css", "vendor/assets/stylesheets/bootstrap.css"
78
+ FileUtils.cp "#{twitter_bootstrap_dir}/docs/assets/css/bootstrap-responsive.css", "vendor/assets/stylesheets/bootstrap-responsive.css"
79
+
80
+ # Reset Twitter Bootstrap LESS files
81
+ bootstrap_less_dir = 'vendor/twitter/bootstrap/less'
82
+
83
+ FileUtils.rm Dir.glob("#{bootstrap_less_dir}/*.less")
84
+ FileUtils.cp Dir.glob("#{twitter_bootstrap_dir}/less/*.less"), bootstrap_less_dir
85
+
86
+ # Reset Twitter Bootstrap SASS files
87
+ bootstrap_sass_dir = 'vendor/twitter/bootstrap/sass'
88
+
89
+ FileUtils.rm Dir.glob("#{bootstrap_sass_dir}/*.scss")
90
+ FileUtils.cp Dir.glob("#{twitter_sass_bootstrap_dir}/lib/*.scss"), bootstrap_sass_dir
91
+
92
+ # Copy bootstrap variables
93
+ FileUtils.cp "#{bootstrap_less_dir}/variables.less", "lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.less"
94
+ FileUtils.cp "#{bootstrap_sass_dir}/_variables.scss", "lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.css.scss"
95
+
96
+ # Change icon-font-path
97
+ ["vendor/assets/stylesheets/bootstrap.css", "lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.less", "lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.css.scss"].each do |filepath|
98
+ file_content = File.read(filepath).gsub("../img/", "")
99
+ File.open(filepath, 'w') { |file| file.puts file_content }
100
+ end
101
+
102
+ # Generate README.md
103
+ require 'erb'
104
+
105
+ javascript_bootstrap_content_code = ""
106
+ File.open(bootstrap_main_javascript, 'r').each_line do |line|
107
+ javascript_bootstrap_content_code += " #{line}"
108
+ end
109
+
110
+ template = ERB.new File.read("readme-template.md.erb")
111
+
112
+ File.open('README.md', 'w') do |file|
113
+ file.write(template.result(binding))
114
+ end
115
+ end
116
+ end
@@ -1,5 +1,5 @@
1
1
  module Bootstrap
2
2
  module Generators
3
- VERSION = "2.3.1.2"
3
+ VERSION = "2.3.2"
4
4
  end
5
5
  end
@@ -48,8 +48,11 @@ module Bootstrap
48
48
  end
49
49
 
50
50
  def inject_backbone
51
- inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
52
- "//= require bootstrap\n"
51
+ application_js_path = "app/assets/javascripts/application.js"
52
+ if File.exists?(File.join(destination_root, application_js_path))
53
+ inject_into_file application_js_path, :before => "//= require_tree" do
54
+ "//= require bootstrap\n"
55
+ end
53
56
  end
54
57
  end
55
58
  end
@@ -62,9 +62,9 @@ $headingsColor: inherit !default; // empty to use BS default, $textColor
62
62
  // -------------------------
63
63
  // Based on 14px font-size and 20px line-height
64
64
 
65
- $fontSizeLarge: $baseFontSize * 1.25; // ~18px
66
- $fontSizeSmall: $baseFontSize * 0.85; // ~12px
67
- $fontSizeMini: $baseFontSize * 0.75; // ~11px
65
+ $fontSizeLarge: $baseFontSize * 1.25 !default; // ~18px
66
+ $fontSizeSmall: $baseFontSize * 0.85 !default; // ~12px
67
+ $fontSizeMini: $baseFontSize * 0.75 !default; // ~11px
68
68
 
69
69
  $paddingLarge: 11px 19px !default; // 44px
70
70
  $paddingSmall: 2px 10px !default; // 26px
@@ -26,7 +26,7 @@
26
26
  <% end -%>
27
27
  <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
28
28
  <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
29
- <td><%%= link_to 'Destroy', <%= singular_table_name %>, confirm: 'Are you sure?', method: :delete %></td>
29
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, data: { confirm: 'Are you sure?' }, method: :delete %></td>
30
30
  </tr>
31
31
  <%% end %>
32
32
  </tbody>
@@ -22,4 +22,4 @@
22
22
  <% end -%>
23
23
  %td= link_to 'Show', <%= singular_table_name %>
24
24
  %td= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
25
- %td= link_to 'Destroy', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete
25
+ %td= link_to 'Destroy', <%= singular_table_name %>, :data => { confirm: 'Are you sure?' }, :method => :delete
@@ -0,0 +1,179 @@
1
+ # Bootstrap Generators
2
+
3
+ [![Build Status](https://travis-ci.org/decioferreira/bootstrap-generators.png?branch=master)](https://travis-ci.org/decioferreira/bootstrap-generators)
4
+
5
+ Bootstrap-generators provides [Twitter Bootstrap](http://twitter.github.com/bootstrap/) generators for Rails 4 (supported Rails >= 3.1). Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.
6
+
7
+ ## Current Twitter Bootstrap version
8
+
9
+ The current version of Twitter Bootstrap is <%= bootstrap_version %>.
10
+
11
+ ## Installing Gem
12
+
13
+ In your Gemfile, add this line:
14
+
15
+ gem 'bootstrap-generators', '~> <%= striped_bootstrap_generators_version %>'
16
+
17
+ Or you can install from latest build:
18
+
19
+ gem 'bootstrap-generators', :git => 'git://github.com/decioferreira/bootstrap-generators.git'
20
+
21
+ By default Bootstrap Generators requires [SimpleForm 2.0](https://github.com/plataformatec/simple_form). Add the dependency on your Gemfile:
22
+
23
+ gem 'simple_form'
24
+
25
+ If you don't want to use SimpleForm, just pass the `--form_builder=form_builder` option:
26
+
27
+ rails generate bootstrap:install --form_builder=form_builder
28
+
29
+ Run bundle install:
30
+
31
+ bundle install
32
+
33
+ ## Generators
34
+
35
+ Get started:
36
+
37
+ rails generate bootstrap:install -f
38
+
39
+ Once you've done that, any time you generate a controller or scaffold, you'll get [Bootstrap](http://twitter.github.com/bootstrap/) templates.
40
+
41
+ ### Give it a try
42
+
43
+ rails generate scaffold post title:string body:text published:boolean
44
+
45
+ You can easily customize colors, grid system, fonts, and much more by editing `bootstrap-variables.[less|scss]` on your application assets folder.
46
+
47
+ ## Usage
48
+
49
+ To print the options and usage run the command `rails generate bootstrap:install --help`
50
+
51
+ rails generate bootstrap:install [options]
52
+
53
+ Options:
54
+ [--layout=LAYOUT] # Bootstrap layout templates (hero or fluid)
55
+ # Default: hero
56
+ [--form-builder=FORM_BUILDER] # Select your form builder (simple_form or form_builder)
57
+ # Default: simple_form
58
+ -e, [--template-engine=TEMPLATE_ENGINE] # Indicates when to generate template engine
59
+ # Default: erb
60
+ -se, [--stylesheet-engine=STYLESHEET_ENGINE] # Indicates when to generate stylesheet engine
61
+ # Default: scss
62
+
63
+ Runtime options:
64
+ -f, [--force] # Overwrite files that already exist
65
+ -p, [--pretend] # Run but do not make any changes
66
+ -q, [--quiet] # Supress status output
67
+ -s, [--skip] # Skip files that already exist
68
+
69
+ Copy BootstrapGenerators default files
70
+
71
+ ### Options
72
+
73
+ #### Layouts
74
+
75
+ There are the two available layouts, based on Bootstrap's quick-start examples:
76
+
77
+ * [Basic marketing site](http://getbootstrap.com/<%= bootstrap_version %>/examples/hero.html) (default)
78
+ * [Fluid layout](http://getbootstrap.com/<%= bootstrap_version %>/examples/fluid.html)
79
+
80
+ To select one of these layouts just pass the option `--layout=LAYOUT` to the install generator.
81
+
82
+ #### Form builders
83
+
84
+ * SimpleForm
85
+
86
+ By default Bootstrap Generators requires SimpleForm 2.0. Add the dependency on your Gemfile:
87
+
88
+ gem 'simple_form'
89
+
90
+ And then run:
91
+
92
+ rails generate bootstrap:install --form_builder=simple_form
93
+
94
+ * Default Rails form builder
95
+
96
+ If you don't want to use SimpleForm, just pass the `--form_builder=form_builder` option:
97
+
98
+ rails generate bootstrap:install --form_builder=form_builder
99
+
100
+ #### Template engines
101
+
102
+ Supported template engines:
103
+
104
+ * ERB
105
+ * Haml
106
+
107
+ ##### Haml
108
+
109
+ Add the dependency on your Gemfile:
110
+
111
+ gem 'haml-rails'
112
+
113
+ And then run:
114
+
115
+ rails generate bootstrap:install --template-engine=haml
116
+
117
+ #### Stylesheet engines
118
+
119
+ Supported stylesheet engines:
120
+
121
+ * CSS
122
+ * SCSS
123
+ * LESS
124
+
125
+ ##### SCSS
126
+
127
+ Make sure you have `sass-rails` dependency on your Gemfile:
128
+
129
+ gem 'sass-rails'
130
+
131
+ And then run:
132
+
133
+ rails generate bootstrap:install --stylesheet-engine=scss
134
+
135
+ Now you can customize the look and feel of Bootstrap.
136
+
137
+ ##### LESS
138
+
139
+ Add the dependency on your Gemfile:
140
+
141
+ gem 'less-rails'
142
+
143
+ And then run:
144
+
145
+ rails generate bootstrap:install --stylesheet-engine=less
146
+
147
+ Now you can customize the look and feel of Bootstrap.
148
+
149
+ ## Assets
150
+
151
+ <a name="customize"></a>
152
+
153
+ ### Customize and extend Bootstrap
154
+
155
+ In Rails 3.0 and above, generators don’t just look in the source root for templates, they also search for templates in other paths. And one of them is lib/templates.
156
+
157
+ ### Javascript
158
+
159
+ Select all jQuery plugins (`app/assets/javascripts/bootstrap.js`)
160
+
161
+ //= require bootstrap
162
+
163
+ Or quickly add only the necessary javascript (Transitions: required for any animation; Popovers: requires Tooltips)
164
+
165
+ <%= javascript_bootstrap_content_code %>
166
+
167
+ ## Customizing Templates
168
+
169
+ In Rails 3.0 and above, generators don’t just look in the source root for templates, they also search for templates in other paths. And one of them is lib/templates.
170
+
171
+ Since Bootstrap Generators installs its templates under lib/templates, you can go and customize them.
172
+
173
+ ## Credits
174
+
175
+ * [Twitter Bootstrap](http://twitter.github.com/bootstrap)
176
+ * [Twitter Bootstrap - Sass Conversion](https://github.com/jlong/sass-twitter-bootstrap)
177
+ * [SimpleForm](https://github.com/plataformatec/simple_form)
178
+
179
+ [customize]: #customize
@@ -44,7 +44,15 @@ class InstallGeneratorTest < Rails::Generators::TestCase
44
44
  test "should require javascript bootstrap file" do
45
45
  run_generator
46
46
 
47
- assert_file "app/assets/javascripts/application.js", /require bootstrap/
47
+ assert_file "app/assets/javascripts/application.js", /require bootstrap/
48
+ end
49
+
50
+ test "should work when there is no application.js file" do
51
+ File.delete(File.join(destination_root, "app/assets/javascripts/application.js"))
52
+
53
+ assert_nothing_raised Errno::ENOENT do
54
+ run_generator
55
+ end
48
56
  end
49
57
 
50
58
  test "should copy css files" do
@@ -1,8 +1,8 @@
1
1
  /* ==========================================================
2
- * bootstrap-affix.js v2.3.1
3
- * http://twitter.github.com/bootstrap/javascript.html#affix
2
+ * bootstrap-affix.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#affix
4
4
  * ==========================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  /* ==========================================================
2
- * bootstrap-alert.js v2.3.1
3
- * http://twitter.github.com/bootstrap/javascript.html#alerts
2
+ * bootstrap-alert.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#alerts
4
4
  * ==========================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  /* ============================================================
2
- * bootstrap-button.js v2.3.1
3
- * http://twitter.github.com/bootstrap/javascript.html#buttons
2
+ * bootstrap-button.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#buttons
4
4
  * ============================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  /* ==========================================================
2
- * bootstrap-carousel.js v2.3.1
3
- * http://twitter.github.com/bootstrap/javascript.html#carousel
2
+ * bootstrap-carousel.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#carousel
4
4
  * ==========================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  /* =============================================================
2
- * bootstrap-collapse.js v2.3.1
3
- * http://twitter.github.com/bootstrap/javascript.html#collapse
2
+ * bootstrap-collapse.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#collapse
4
4
  * =============================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  /* ============================================================
2
- * bootstrap-dropdown.js v2.3.1
3
- * http://twitter.github.com/bootstrap/javascript.html#dropdowns
2
+ * bootstrap-dropdown.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#dropdowns
4
4
  * ============================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -52,6 +52,10 @@
52
52
  clearMenus()
53
53
 
54
54
  if (!isActive) {
55
+ if ('ontouchstart' in document.documentElement) {
56
+ // if mobile we we use a backdrop because click events don't delegate
57
+ $('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
58
+ }
55
59
  $parent.toggleClass('open')
56
60
  }
57
61
 
@@ -104,6 +108,7 @@
104
108
  }
105
109
 
106
110
  function clearMenus() {
111
+ $('.dropdown-backdrop').remove()
107
112
  $(toggle).each(function () {
108
113
  getParent($(this)).removeClass('open')
109
114
  })
@@ -158,7 +163,6 @@
158
163
  $(document)
159
164
  .on('click.dropdown.data-api', clearMenus)
160
165
  .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
161
- .on('click.dropdown-menu', function (e) { e.stopPropagation() })
162
166
  .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
163
167
  .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
164
168