bootstrap-sass 3.0.3.0 → 3.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bootstrap-sass might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +1 -1
- data/LICENSE +17 -10
- data/README.md +17 -17
- data/Rakefile +7 -2
- data/bootstrap-sass.gemspec +9 -9
- data/bower.json +22 -0
- data/composer.json +35 -0
- data/lib/bootstrap-sass.rb +1 -3
- data/lib/bootstrap-sass/sass_functions.rb +4 -3
- data/lib/bootstrap-sass/version.rb +2 -2
- data/tasks/converter.rb +21 -15
- data/tasks/converter/fonts_conversion.rb +7 -3
- data/tasks/converter/js_conversion.rb +20 -3
- data/tasks/converter/less_conversion.rb +89 -60
- data/tasks/converter/logger.rb +6 -14
- data/tasks/converter/network.rb +7 -32
- data/test/compilation_test.rb +1 -1
- data/test/dummy/app/views/pages/root.html.slim +8 -2
- data/test/dummy/config/application.rb +2 -2
- data/test/gemfiles/sass_3_2.gemfile +1 -1
- data/test/gemfiles/sass_head.gemfile +2 -3
- data/test/sprockets_rails_test.rb +21 -0
- data/vendor/assets/javascripts/bootstrap/affix.js +34 -23
- data/vendor/assets/javascripts/bootstrap/alert.js +5 -15
- data/vendor/assets/javascripts/bootstrap/button.js +21 -29
- data/vendor/assets/javascripts/bootstrap/carousel.js +16 -28
- data/vendor/assets/javascripts/bootstrap/collapse.js +7 -16
- data/vendor/assets/javascripts/bootstrap/dropdown.js +19 -26
- data/vendor/assets/javascripts/bootstrap/modal.js +25 -28
- data/vendor/assets/javascripts/bootstrap/popover.js +14 -21
- data/vendor/assets/javascripts/bootstrap/scrollspy.js +16 -21
- data/vendor/assets/javascripts/bootstrap/tab.js +7 -17
- data/vendor/assets/javascripts/bootstrap/tooltip.js +52 -39
- data/vendor/assets/javascripts/bootstrap/transition.js +11 -19
- data/vendor/assets/stylesheets/bootstrap/_badges.scss +4 -0
- data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +4 -1
- data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +8 -9
- data/vendor/assets/stylesheets/bootstrap/_buttons.scss +8 -8
- data/vendor/assets/stylesheets/bootstrap/_code.scss +10 -0
- data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +28 -3
- data/vendor/assets/stylesheets/bootstrap/_forms.scss +81 -38
- data/vendor/assets/stylesheets/bootstrap/_glyphicons.scss +1 -5
- data/vendor/assets/stylesheets/bootstrap/_grid.scss +26 -5
- data/vendor/assets/stylesheets/bootstrap/_input-groups.scss +39 -18
- data/vendor/assets/stylesheets/bootstrap/_jumbotron.scss +3 -5
- data/vendor/assets/stylesheets/bootstrap/_list-group.scss +25 -3
- data/vendor/assets/stylesheets/bootstrap/_mixins.scss +124 -41
- data/vendor/assets/stylesheets/bootstrap/_modals.scss +15 -6
- data/vendor/assets/stylesheets/bootstrap/_navbar.scss +21 -17
- data/vendor/assets/stylesheets/bootstrap/_navs.scss +1 -1
- data/vendor/assets/stylesheets/bootstrap/_normalize.scss +139 -122
- data/vendor/assets/stylesheets/bootstrap/_pager.scss +4 -4
- data/vendor/assets/stylesheets/bootstrap/_pagination.scss +6 -3
- data/vendor/assets/stylesheets/bootstrap/_panels.scss +63 -15
- data/vendor/assets/stylesheets/bootstrap/_print.scss +0 -4
- data/vendor/assets/stylesheets/bootstrap/_responsive-utilities.scss +6 -124
- data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +17 -2
- data/vendor/assets/stylesheets/bootstrap/_tables.scss +3 -1
- data/vendor/assets/stylesheets/bootstrap/_theme.scss +3 -3
- data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +4 -4
- data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +1 -1
- data/vendor/assets/stylesheets/bootstrap/_type.scss +77 -62
- data/vendor/assets/stylesheets/bootstrap/_variables.scss +350 -163
- data/vendor/assets/stylesheets/bootstrap/_wells.scss +1 -1
- data/vendor/assets/stylesheets/bootstrap/bootstrap.scss +38 -38
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b33ec25bfb1e9fa8c4e1c371a263ec79c7d40baa
|
4
|
+
data.tar.gz: 37ce59e8a375cf62d7f08077e8e111a60973859b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8052230ccd4c3069920808bd2aee510a48be09adab836da007fd8a75e9844dd4f38166bc78055c6f0424c09ab46275b141211cfb3cce49282ea3d261de22a3c9
|
7
|
+
data.tar.gz: 42ae1f9fb777f628e0a4e61cc2649c0c94d63f61897dfda22db87fb0b425b39ddea2aa39fdce62deb1cc74f8d6d2cb6b84bd739909c573249e5b2d1ff1aaecde
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
## Asset Changes
|
4
4
|
|
5
5
|
Any changes to `bootstrap-sass` assets (scss, javascripts, fonts) should be checked against the `convert` rake task.
|
6
|
-
For usage instructions, see the [README](https://github.com/
|
6
|
+
For usage instructions, see the [README](https://github.com/twbs/bootstrap-sass/blob/3/README.md).
|
7
7
|
|
8
8
|
If something is broken in the converter, it's preferable to update the converter along with the asset itself.
|
9
9
|
|
@@ -50,7 +50,7 @@ Example:
|
|
50
50
|
> causing the bug, and potential solutions (and your opinions on their
|
51
51
|
> merits).
|
52
52
|
|
53
|
-
**[File a bug report](https://github.com/
|
53
|
+
**[File a bug report](https://github.com/twbs/bootstrap-sass/issues/)**
|
54
54
|
|
55
55
|
|
56
56
|
## Pull requests
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
you may not use this file except in compliance with the License.
|
5
|
-
You may obtain a copy of the License at
|
3
|
+
Copyright (c) 2013 Twitter, Inc
|
6
4
|
|
7
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
See the License for the specific language governing permissions and
|
13
|
-
limitations under the License.
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
14
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Bootstrap for Sass
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/
|
3
|
+
[![Build Status](https://secure.travis-ci.org/twbs/bootstrap-sass.png?branch=master)](http://travis-ci.org/twbs/bootstrap-sass)
|
4
4
|
|
5
5
|
`bootstrap-sass` is a Sass-powered version of [Bootstrap](http://github.com/twbs/bootstrap), ready to drop right into your Sass powered applications.
|
6
6
|
|
@@ -16,7 +16,7 @@ In your Gemfile you need to add the `bootstrap-sass` gem, and ensure that the `s
|
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2
|
19
|
-
gem 'bootstrap-sass', '~> 3.
|
19
|
+
gem 'bootstrap-sass', '~> 3.1.0'
|
20
20
|
```
|
21
21
|
|
22
22
|
`bundle install` and restart your server to make the files available through the pipeline.
|
@@ -59,13 +59,12 @@ Require the gem, and load paths and Sass helpers will be configured automaticall
|
|
59
59
|
require 'bootstrap-sass'
|
60
60
|
```
|
61
61
|
|
62
|
-
|
62
|
+
Using bootstrap-sass as a Bower package is still being tested. You can install it with:
|
63
63
|
|
64
|
-
```
|
65
|
-
|
64
|
+
```bash
|
65
|
+
bower install 'git://github.com/twbs/bootstrap-sass.git#v3.1.0'
|
66
66
|
```
|
67
67
|
|
68
|
-
|
69
68
|
#### JS and fonts
|
70
69
|
|
71
70
|
If you are using Rails or Sprockets, see Usage.
|
@@ -112,8 +111,8 @@ You can also include optional bootstrap theme:
|
|
112
111
|
@import "bootstrap/theme";
|
113
112
|
```
|
114
113
|
|
115
|
-
The full list of bootstrap variables can be found [here](http://getbootstrap.com/customize/#less-variables). You can override these by simply redefining the variable before the `@import` directive.
|
116
|
-
|
114
|
+
The full list of bootstrap variables can be found [here](http://getbootstrap.com/customize/#less-variables). You can override these by simply redefining the variable before the `@import` directive, e.g.:
|
115
|
+
|
117
116
|
```scss
|
118
117
|
$navbar-default-bg: #312312;
|
119
118
|
$light-orange: #ff8c00;
|
@@ -125,18 +124,19 @@ $navbar-default-color: $light-orange;
|
|
125
124
|
You can also import components explicitly. To start with a full list of modules copy this file from the gem:
|
126
125
|
|
127
126
|
```bash
|
128
|
-
|
129
|
-
|
127
|
+
# copy and prepend "bootstrap/" to the @import paths:
|
128
|
+
sed 's/@import "/@import "bootstrap\//' \
|
129
|
+
$(bundle show bootstrap-sass)/vendor/assets/stylesheets/bootstrap/bootstrap.scss > \
|
130
|
+
app/assets/stylesheets/bootstrap-custom.scss
|
130
131
|
```
|
132
|
+
Comment out components you do not want from `bootstrap-custom`.
|
131
133
|
|
132
|
-
In
|
134
|
+
In `application.sass`, replace `@import 'bootstrap'` with:
|
133
135
|
|
134
136
|
```scss
|
135
137
|
@import 'bootstrap-custom';
|
136
138
|
```
|
137
139
|
|
138
|
-
Comment out any modules you don't need from `bootstrap-custom`.
|
139
|
-
|
140
140
|
### Javascript
|
141
141
|
|
142
142
|
We have a helper that includes all Bootstrap javascripts. If you use Rails (or Sprockets separately),
|
@@ -207,8 +207,8 @@ bootstrap-sass is used to build some awesome projects all over the web, includin
|
|
207
207
|
Michael Hartl's [Rails Tutorial](http://railstutorial.org/), [gitlabhq](http://gitlabhq.com/) and
|
208
208
|
[kandan](http://kandanapp.com/).
|
209
209
|
|
210
|
-
[converter]: https://github.com/
|
211
|
-
[version]: https://github.com/
|
212
|
-
[contrib]: https://github.com/
|
213
|
-
[antirequire]: https://github.com/
|
210
|
+
[converter]: https://github.com/twbs/bootstrap-sass/blob/3/tasks/converter.rb
|
211
|
+
[version]: https://github.com/twbs/bootstrap-sass/blob/3/lib/bootstrap-sass/version.rb
|
212
|
+
[contrib]: https://github.com/twbs/bootstrap-sass/graphs/contributors
|
213
|
+
[antirequire]: https://github.com/twbs/bootstrap-sass/issues/79#issuecomment-4428595
|
214
214
|
[jsdocs]: http://getbootstrap.com/javascript/#transitions
|
data/Rakefile
CHANGED
@@ -19,8 +19,13 @@ end
|
|
19
19
|
desc 'Convert bootstrap to bootstrap-sass'
|
20
20
|
task :convert, :branch do |t, args|
|
21
21
|
require './tasks/converter'
|
22
|
-
branch
|
23
|
-
|
22
|
+
Converter.new(branch: args[:branch]).process_bootstrap
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'LESS to stdin -> Sass to stdout'
|
26
|
+
task :less_to_scss, :branch do |t, args|
|
27
|
+
require './tasks/converter'
|
28
|
+
puts Converter.new(branch: args[:branch]).convert_less(STDIN.read)
|
24
29
|
end
|
25
30
|
|
26
31
|
desc 'Compile bootstrap-sass to tmp/ (or first arg)'
|
data/bootstrap-sass.gemspec
CHANGED
@@ -3,25 +3,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'bootstrap-sass/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.authors
|
9
|
-
s.email
|
10
|
-
s.summary
|
11
|
-
s.homepage = "
|
12
|
-
s.license
|
6
|
+
s.name = "bootstrap-sass"
|
7
|
+
s.version = Bootstrap::VERSION
|
8
|
+
s.authors = ["Thomas McDonald"]
|
9
|
+
s.email = 'tom@conceptcoding.co.uk'
|
10
|
+
s.summary = "Twitter's Bootstrap, converted to Sass and ready to drop into Rails or Compass"
|
11
|
+
s.homepage = "https://github.com/twbs/bootstrap-sass"
|
12
|
+
s.license = 'MIT'
|
13
13
|
|
14
14
|
s.add_development_dependency 'compass'
|
15
15
|
s.add_development_dependency 'term-ansicolor'
|
16
16
|
s.add_development_dependency 'sass-rails', '>= 3.2'
|
17
|
-
s.add_runtime_dependency
|
18
|
-
|
17
|
+
s.add_runtime_dependency 'sass', '~> 3.2'
|
19
18
|
|
20
19
|
s.add_development_dependency 'capybara'
|
21
20
|
s.add_development_dependency 'poltergeist'
|
22
21
|
s.add_development_dependency 'tzinfo'
|
23
22
|
s.add_development_dependency 'jquery-rails'
|
24
23
|
s.add_development_dependency 'slim-rails'
|
24
|
+
s.add_development_dependency 'uglifier'
|
25
25
|
|
26
26
|
s.files = `git ls-files`.split("\n")
|
27
27
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
data/bower.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"name": "bootstrap-sass",
|
3
|
+
"version": "3.1.0",
|
4
|
+
"homepage": "https://github.com/twbs/bootstrap-sass",
|
5
|
+
"authors": [
|
6
|
+
"Thomas McDonald",
|
7
|
+
"Tristan Harward",
|
8
|
+
"Peter Gumeson",
|
9
|
+
"Gleb Mazovetskiy"
|
10
|
+
],
|
11
|
+
"description": "bootstrap-sass is a Sass-powered version of Bootstrap, ready to drop right into your Sass powered applications.",
|
12
|
+
"main": ["vendor/assets/stylesheets/bootstrap.scss", "vendor/assets/javascripts/bootstrap.js"],
|
13
|
+
"keywords": [
|
14
|
+
"twbs",
|
15
|
+
"bootstrap",
|
16
|
+
"sass"
|
17
|
+
],
|
18
|
+
"license": "MIT",
|
19
|
+
"ignore": [
|
20
|
+
"**/.*", "lib", "tasks", "templates", "test", "*.gemspec", "Rakefile", "Gemfile"
|
21
|
+
]
|
22
|
+
}
|
data/composer.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"name": "twbs/bootstrap-sass",
|
3
|
+
"description": "bootstrap-sass is a Sass-powered version of Bootstrap, ready to drop right into your Sass powered applications.",
|
4
|
+
"keywords": ["bootstrap", "css", "sass"],
|
5
|
+
"homepage": "http://github.com/twbs/bootstrap",
|
6
|
+
"authors": [
|
7
|
+
{
|
8
|
+
"name": "Thomas McDonald"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "Tristan Harward"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"name": "Peter Gumeson"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"name": "Gleb Mazovetskiy"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "Mark Otto"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"name": "Jacob Thornton"
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"support": {
|
27
|
+
"issues": "https://github.com/twbs/bootstrap-sass/issues"
|
28
|
+
},
|
29
|
+
"license": "MIT",
|
30
|
+
"extra": {
|
31
|
+
"branch-alias": {
|
32
|
+
"dev-master": "3.1.x-dev"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
data/lib/bootstrap-sass.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
module Bootstrap
|
2
|
-
class FrameworkNotFound < StandardError; end
|
3
|
-
|
4
2
|
class << self
|
5
3
|
# Inspired by Kaminari
|
6
4
|
def load!
|
@@ -54,7 +52,7 @@ module Bootstrap
|
|
54
52
|
def configure_sass
|
55
53
|
::Sass.load_paths << stylesheets_path
|
56
54
|
|
57
|
-
# bootstrap requires minimum precision of 10, see https://github.com/
|
55
|
+
# bootstrap requires minimum precision of 10, see https://github.com/twbs/bootstrap-sass/issues/409
|
58
56
|
::Sass::Script::Number.precision = [10, ::Sass::Script::Number.precision].max
|
59
57
|
end
|
60
58
|
|
@@ -13,17 +13,18 @@ module Sass::Script::Functions
|
|
13
13
|
declare :twbs_image_path, [:source]
|
14
14
|
|
15
15
|
def twbs_asset_path(source, type)
|
16
|
+
return Sass::Script::String.new('', :string) if source.to_s.empty?
|
16
17
|
url = if Bootstrap.asset_pipeline? && (context = sprockets_context)
|
17
18
|
context.send(:"#{type}_path", source.value)
|
18
19
|
elsif Bootstrap.compass?
|
19
|
-
send(:"#{type}_url", source, Sass::Script::Bool.new(true)).value
|
20
|
+
send(:"#{type}_url", source, Sass::Script::Bool.new(true)).value.sub /url\((.*)\)$/, '\1'
|
20
21
|
end
|
21
22
|
|
22
23
|
# sass-only
|
23
24
|
url ||= source.value.gsub('"', '')
|
24
25
|
Sass::Script::String.new(url, :string)
|
25
26
|
end
|
26
|
-
declare :twbs_asset_path, [:source]
|
27
|
+
declare :twbs_asset_path, [:source, :type]
|
27
28
|
|
28
29
|
unless Sass::Script::Functions.instance_methods.include?(:ie_hex_str)
|
29
30
|
# polyfill sass < 3.2.6 (taken from sass 3.2.12):
|
@@ -46,4 +47,4 @@ module Sass::Script::Functions
|
|
46
47
|
importer.context
|
47
48
|
end
|
48
49
|
end
|
49
|
-
end
|
50
|
+
end
|
data/tasks/converter.rb
CHANGED
@@ -34,25 +34,31 @@ class Converter
|
|
34
34
|
include JsConversion
|
35
35
|
include FontsConversion
|
36
36
|
|
37
|
-
def initialize(branch)
|
38
|
-
@
|
39
|
-
@
|
40
|
-
|
41
|
-
@repo = 'twbs/bootstrap'
|
42
|
-
@repo_url = "https://github.com/#@repo"
|
37
|
+
def initialize(repo: 'twbs/bootstrap', branch: 'master', save_to: {}, cache_path: 'tmp/converter-cache-bootstrap')
|
38
|
+
@logger = Logger.new
|
39
|
+
@repo = repo
|
43
40
|
@branch = branch || 'master'
|
44
41
|
@branch_sha = get_branch_sha
|
45
|
-
@
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
@cache_path = cache_path
|
43
|
+
@repo_url = "https://github.com/#@repo"
|
44
|
+
@save_to = {
|
45
|
+
js: 'vendor/assets/javascripts/bootstrap',
|
46
|
+
scss: 'vendor/assets/stylesheets/bootstrap',
|
47
|
+
fonts: 'vendor/assets/fonts/bootstrap'}.merge(save_to)
|
51
48
|
end
|
52
49
|
|
53
|
-
def_delegators :@logger, :log_status, :log_processing, :log_transform, :log_file_info, :log_processed, :log_http_get_file, :log_http_get_files, :silence_log
|
50
|
+
def_delegators :@logger, :log, :log_status, :log_processing, :log_transform, :log_file_info, :log_processed, :log_http_get_file, :log_http_get_files, :silence_log
|
51
|
+
|
52
|
+
def process_bootstrap
|
53
|
+
log_status "Convert Bootstrap LESS to SASS"
|
54
|
+
puts " repo : #@repo_url"
|
55
|
+
puts " branch : #@branch_sha #@repo_url/tree/#@branch"
|
56
|
+
puts " save to: #{@save_to.to_json}"
|
57
|
+
puts " twbs cache: #{@cache_path}"
|
58
|
+
puts '-' * 60
|
59
|
+
|
60
|
+
@save_to.each { |_, v| FileUtils.mkdir_p(v) }
|
54
61
|
|
55
|
-
def process
|
56
62
|
process_stylesheet_assets
|
57
63
|
process_javascript_assets
|
58
64
|
process_font_assets
|
@@ -65,7 +71,7 @@ class Converter
|
|
65
71
|
|
66
72
|
# Update version.rb file with BOOTSTRAP_SHA
|
67
73
|
def store_version
|
68
|
-
path
|
74
|
+
path = 'lib/bootstrap-sass/version.rb'
|
69
75
|
content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][\w]+['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
|
70
76
|
File.open(path, 'w') { |f| f.write(content) }
|
71
77
|
end
|
@@ -3,10 +3,14 @@ class Converter
|
|
3
3
|
def process_font_assets
|
4
4
|
log_status 'Processing fonts...'
|
5
5
|
files = read_files('fonts', bootstrap_font_files)
|
6
|
-
|
6
|
+
save_to = @save_to[:fonts]
|
7
7
|
files.each do |name, content|
|
8
|
-
save_file "#{
|
8
|
+
save_file "#{save_to}/#{name}", content
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
def bootstrap_font_files
|
13
|
+
@bootstrap_font_files ||= get_paths_by_type('fonts', /\.(eot|svg|ttf|woff)$/)
|
14
|
+
end
|
11
15
|
end
|
12
|
-
end
|
16
|
+
end
|
@@ -2,9 +2,9 @@ class Converter
|
|
2
2
|
module JsConversion
|
3
3
|
def process_javascript_assets
|
4
4
|
log_status 'Processing javascripts...'
|
5
|
-
|
5
|
+
save_to = @save_to[:js]
|
6
6
|
read_files('js', bootstrap_js_files).each do |name, file|
|
7
|
-
save_file("#{
|
7
|
+
save_file("#{save_to}/#{name}", file)
|
8
8
|
end
|
9
9
|
log_processed "#{bootstrap_js_files * ' '}"
|
10
10
|
|
@@ -18,5 +18,22 @@ class Converter
|
|
18
18
|
save_file(path, content)
|
19
19
|
log_processed path
|
20
20
|
end
|
21
|
+
|
22
|
+
def bootstrap_js_files
|
23
|
+
@bootstrap_js_files ||= begin
|
24
|
+
files = get_paths_by_type 'js', /\.js$/
|
25
|
+
files.sort_by { |f|
|
26
|
+
case f
|
27
|
+
# tooltip depends on popover and must be loaded earlier
|
28
|
+
when /tooltip/ then
|
29
|
+
1
|
30
|
+
when /popover/ then
|
31
|
+
2
|
32
|
+
else
|
33
|
+
0
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
21
38
|
end
|
22
|
-
end
|
39
|
+
end
|
@@ -9,9 +9,9 @@ require_relative 'char_string_scanner'
|
|
9
9
|
class Converter
|
10
10
|
module LessConversion
|
11
11
|
# Some regexps for matching bits of SCSS:
|
12
|
-
|
12
|
+
SELECTOR_CHAR = '\[\]$\w\-{}#,.:&>@'
|
13
13
|
# 1 selector (the part before the {)
|
14
|
-
SELECTOR_RE = /[#{
|
14
|
+
SELECTOR_RE = /[#{SELECTOR_CHAR}]+[#{SELECTOR_CHAR}\s]*/
|
15
15
|
# 1 // comment
|
16
16
|
COMMENT_RE = %r((?:^[ \t]*//[^\n]*\n))
|
17
17
|
# 1 {, except when part of @{ and #{
|
@@ -36,19 +36,30 @@ class Converter
|
|
36
36
|
transition transition-duration transition-property transition-transform box-shadow
|
37
37
|
)
|
38
38
|
|
39
|
+
# Convert a snippet of bootstrap LESS to Scss
|
40
|
+
def convert_less(less)
|
41
|
+
load_shared
|
42
|
+
less = convert_to_scss(less)
|
43
|
+
less = yield(less) if block_given?
|
44
|
+
less
|
45
|
+
end
|
46
|
+
|
47
|
+
def load_shared
|
48
|
+
@shared_mixins ||= begin
|
49
|
+
log_status ' Reading shared mixins from mixins.less'
|
50
|
+
read_mixins read_files('less', ['mixins.less'])['mixins.less'], nested: NESTED_MIXINS
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
39
54
|
def process_stylesheet_assets
|
40
|
-
log_status
|
55
|
+
log_status 'Processing stylesheets...'
|
41
56
|
files = read_files('less', bootstrap_less_files)
|
42
57
|
|
43
|
-
|
44
|
-
read_shared_mixins! files['mixins.less']
|
45
|
-
@shared_mixins << 'make-grid'
|
46
|
-
|
47
|
-
# convert each file
|
58
|
+
log_status ' Converting LESS files to Scss:'
|
48
59
|
files.each do |name, file|
|
49
60
|
log_processing name
|
50
61
|
# apply common conversions
|
51
|
-
file =
|
62
|
+
file = convert_less(file)
|
52
63
|
case name
|
53
64
|
when 'mixins.less'
|
54
65
|
NESTED_MIXINS.each do |selector, prefix|
|
@@ -56,10 +67,12 @@ class Converter
|
|
56
67
|
end
|
57
68
|
file = varargify_mixin_definitions(file, *VARARG_MIXINS)
|
58
69
|
file = deinterpolate_vararg_mixins(file)
|
59
|
-
|
60
|
-
|
70
|
+
%w(responsive-(in)?visibility input-size).each do |mixin|
|
71
|
+
file = parameterize_mixin_parent_selector file, mixin
|
72
|
+
end
|
61
73
|
file = replace_ms_filters(file)
|
62
|
-
file = replace_all file,
|
74
|
+
file = replace_all file, /(?<=[.-])\$state/, '#{$state}'
|
75
|
+
file = replace_rules(file, ' .list-group-item-') { |rule| extract_nested_rule rule, 'a&' }
|
63
76
|
file = replace_all file, /,\s*\.open \.dropdown-toggle& \{(.*?)\}/m,
|
64
77
|
" {\\1}\n .open & { &.dropdown-toggle {\\1} }"
|
65
78
|
file = convert_grid_mixins file
|
@@ -69,16 +82,19 @@ class Converter
|
|
69
82
|
file = replace_rules(file, ' @media') { |r| unindent(r, 2) }
|
70
83
|
when 'variables.less'
|
71
84
|
file = insert_default_vars(file)
|
72
|
-
file = <<-SCSS + file
|
73
|
-
//
|
74
|
-
|
85
|
+
file = unindent <<-SCSS + file, 14
|
86
|
+
// a flag to toggle asset pipeline / compass integration
|
87
|
+
// defaults to true if twbs-font-path function is present (no function => twbs-font-path('') parsed as string == right side)
|
88
|
+
// in Sass 3.3 this can be improved with: function-exists(twbs-font-path)
|
89
|
+
$bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")')) !default;
|
75
90
|
SCSS
|
76
91
|
file = replace_all file, /(\$icon-font-path:).*(!default)/, '\1 "bootstrap/" \2'
|
77
92
|
when 'close.less'
|
78
93
|
# extract .close { button& {...} } rule
|
79
94
|
file = extract_nested_rule file, 'button&'
|
80
95
|
when 'dropdowns.less'
|
81
|
-
file = replace_all file,
|
96
|
+
file = replace_all file, /@extend \.dropdown-menu-right;/, 'right: 0; left: auto;'
|
97
|
+
file = replace_all file, /@extend \.dropdown-menu-left;/, 'left: 0; right: auto;'
|
82
98
|
when 'forms.less'
|
83
99
|
file = extract_nested_rule file, 'textarea&'
|
84
100
|
file = apply_mixin_parent_selector(file, '\.input-(?:sm|lg)')
|
@@ -89,40 +105,48 @@ $bootstrap-sass-asset-helper: true !default;
|
|
89
105
|
when 'thumbnails.less'
|
90
106
|
file = extract_nested_rule file, 'a&'
|
91
107
|
when 'glyphicons.less'
|
92
|
-
file
|
108
|
+
file = replace_all file, /\#\{(url\(.*?\))}/, '\1'
|
93
109
|
file = replace_rules(file, '@font-face') { |rule|
|
94
|
-
rule = replace_all rule, /(\$icon-font
|
110
|
+
rule = replace_all rule, /(\$icon-font(?:-\w+)+)/, '#{\1}'
|
95
111
|
replace_asset_url rule, :font
|
96
112
|
}
|
97
113
|
end
|
98
114
|
|
99
115
|
name = name.sub(/\.less$/, '.scss')
|
100
|
-
|
101
|
-
path = "#{
|
116
|
+
save_to = @save_to[:scss]
|
117
|
+
path = "#{save_to}/#{'_' unless name == 'bootstrap.scss'}#{name}"
|
102
118
|
save_file(path, file)
|
103
119
|
log_processed File.basename(path)
|
104
120
|
end
|
105
121
|
end
|
106
122
|
|
123
|
+
def bootstrap_less_files
|
124
|
+
@bootstrap_less_files ||= get_paths_by_type('less', /\.less$/)
|
125
|
+
end
|
126
|
+
|
107
127
|
# apply general less to scss conversion
|
108
128
|
def convert_to_scss(file)
|
109
|
-
#
|
110
|
-
|
111
|
-
file
|
112
|
-
file
|
113
|
-
file
|
114
|
-
file
|
115
|
-
|
116
|
-
file
|
117
|
-
file
|
118
|
-
file
|
119
|
-
file
|
120
|
-
file
|
121
|
-
file
|
122
|
-
file = replace_calculation_semantics(file)
|
129
|
+
# get local mixin names before converting the definitions
|
130
|
+
mixins = @shared_mixins + read_mixins(file)
|
131
|
+
file = replace_vars(file)
|
132
|
+
file = replace_file_imports(file)
|
133
|
+
file = replace_mixin_definitions(file)
|
134
|
+
file = replace_mixins(file, mixins)
|
135
|
+
file = replace_spin(file)
|
136
|
+
file = replace_image_urls(file)
|
137
|
+
file = replace_escaping(file)
|
138
|
+
file = convert_less_ampersand(file)
|
139
|
+
file = deinterpolate_vararg_mixins(file)
|
140
|
+
file = replace_calculation_semantics(file)
|
141
|
+
file = replace_redundant_ampersands(file)
|
123
142
|
file
|
124
143
|
end
|
125
144
|
|
145
|
+
# a&:hover => a:hover
|
146
|
+
def replace_redundant_ampersands(file)
|
147
|
+
file.gsub /([\w+])&([:\w]+)/, '\1\2'
|
148
|
+
end
|
149
|
+
|
126
150
|
def replace_asset_url(rule, type)
|
127
151
|
replace_all rule, /url\((.*?)\)/, "url(if($bootstrap-sass-asset-helper, twbs-#{type}-path(\\1), \\1))"
|
128
152
|
end
|
@@ -178,23 +202,23 @@ $bootstrap-sass-asset-helper: true !default;
|
|
178
202
|
# We need to keep a list of shared mixin names in order to convert the includes correctly
|
179
203
|
# Before doing any processing we read shared mixins from a file
|
180
204
|
# If a mixin is nested, it gets prefixed in the list (e.g. #gradient > .horizontal to 'gradient-horizontal')
|
181
|
-
def
|
182
|
-
|
183
|
-
|
184
|
-
NESTED_MIXINS.each do |selector, prefix|
|
205
|
+
def read_mixins(mixins_file, nested: {})
|
206
|
+
mixins = get_mixin_names(mixins_file, silent: true)
|
207
|
+
nested.each do |selector, prefix|
|
185
208
|
# we use replace_rules without replacing anything just to use the parsing algorithm
|
186
209
|
replace_rules(mixins_file, selector) { |rule|
|
187
|
-
|
210
|
+
mixins += get_mixin_names(unindent(unwrap_rule_block(rule)), silent: true).map { |name| "#{prefix}-#{name}" }
|
188
211
|
rule
|
189
212
|
}
|
190
213
|
end
|
191
|
-
|
192
|
-
|
193
|
-
|
214
|
+
mixins.uniq!
|
215
|
+
mixins.sort!
|
216
|
+
log_file_info "mixins: #{mixins * ', '}" unless mixins.empty?
|
217
|
+
mixins
|
194
218
|
end
|
195
219
|
|
196
220
|
def get_mixin_names(file, opts = {})
|
197
|
-
names = get_css_selectors(file).join("\n" * 2).scan(/^\.([\w-]+)\(#{LESS_MIXIN_DEF_ARGS_RE}\)[ ]*\{/).map(&:first).uniq.sort
|
221
|
+
names = get_css_selectors(file).join("\n" * 2).scan(/^\.([\w-]+)\(#{LESS_MIXIN_DEF_ARGS_RE}\)(?: when.*?)?[ ]*\{/).map(&:first).uniq.sort
|
198
222
|
log_file_info "mixin defs: #{names * ', '}" unless opts[:silent] || names.empty?
|
199
223
|
names
|
200
224
|
end
|
@@ -240,7 +264,7 @@ $bootstrap-sass-asset-helper: true !default;
|
|
240
264
|
prop, vals = $1, split_prop_val.call($2)
|
241
265
|
next m unless vals.length >= 2 && vals.any? { |v| v =~ /^[\+\-]\$/ }
|
242
266
|
transformed = vals.map { |v| v.strip =~ %r(^\(.*\)$) ? v : "(#{v})" }
|
243
|
-
log_transform "property #{prop}: #{transformed * ' '}"
|
267
|
+
log_transform "property #{prop}: #{transformed * ' '}", from: 'wrap_calculation'
|
244
268
|
"#{prop}: #{transformed * ' '};"
|
245
269
|
end
|
246
270
|
end
|
@@ -248,7 +272,7 @@ $bootstrap-sass-asset-helper: true !default;
|
|
248
272
|
end
|
249
273
|
|
250
274
|
# @import "file.less" to "#{target_path}file;"
|
251
|
-
def replace_file_imports(less, target_path = '
|
275
|
+
def replace_file_imports(less, target_path = '')
|
252
276
|
less.gsub %r([@\$]import ["|']([\w-]+).less["|'];),
|
253
277
|
%Q(@import "#{target_path}\\1";)
|
254
278
|
end
|
@@ -266,7 +290,7 @@ $bootstrap-sass-asset-helper: true !default;
|
|
266
290
|
def parameterize_mixin_parent_selector(file, rule_sel)
|
267
291
|
log_transform rule_sel
|
268
292
|
param = '$parent'
|
269
|
-
replace_rules(file, '
|
293
|
+
replace_rules(file, '^\s*@mixin\s*' + rule_sel) do |mxn_css|
|
270
294
|
mxn_css.sub! /(?=@mixin)/, "// [converter] $parent hack\n"
|
271
295
|
# insert param into mixin def
|
272
296
|
mxn_css.sub!(/(@mixin [\w-]+)\(([\$\w\-,\s]*)\)/) { "#{$1}(#{param}#{', ' if $2 && !$2.empty?}#{$2})" }
|
@@ -309,7 +333,7 @@ $bootstrap-sass-asset-helper: true !default;
|
|
309
333
|
replace_rules file, '\s*' + rule_sel, comments: false do |rule, rule_pos, css|
|
310
334
|
body = unwrap_rule_block(rule.dup).strip
|
311
335
|
next rule unless body =~ /^@include \w+/m || body =~ /^@media/ && body =~ /\{\s*@include/
|
312
|
-
rule =~ /(#{COMMENT_RE}*)(#{
|
336
|
+
rule =~ /(#{COMMENT_RE}*)([#{SELECTOR_CHAR}]+?)\s*#{RULE_OPEN_BRACE_RE}/
|
313
337
|
cmt, sel = $1, $2.strip
|
314
338
|
# take one up selector chain if this is an &. selector
|
315
339
|
if sel.start_with?('&')
|
@@ -333,13 +357,14 @@ $bootstrap-sass-asset-helper: true !default;
|
|
333
357
|
end
|
334
358
|
end
|
335
359
|
|
336
|
-
#
|
337
|
-
# .mixin()
|
338
|
-
# #scope > .mixin()
|
360
|
+
# @include and @extend from LESS:
|
361
|
+
# .mixin() -> @include mixin()
|
362
|
+
# #scope > .mixin() -> @include scope-mixin()
|
363
|
+
# &:extend(.mixin all) -> @include mixin()
|
339
364
|
def replace_mixins(less, mixin_names)
|
340
365
|
mixin_pattern = /(\s+)(([#|\.][\w-]+\s*>\s*)*)\.([\w-]+\(.*\))(?!\s\{)/
|
341
366
|
|
342
|
-
less.gsub(mixin_pattern) do |match|
|
367
|
+
less = less.gsub(mixin_pattern) do |match|
|
343
368
|
matches = match.scan(mixin_pattern).flatten
|
344
369
|
scope = matches[1] || ''
|
345
370
|
if scope != ''
|
@@ -352,6 +377,17 @@ $bootstrap-sass-asset-helper: true !default;
|
|
352
377
|
"#{matches.first}@extend .#{scope}#{matches.last.gsub(/\(\)/, '')}"
|
353
378
|
end
|
354
379
|
end
|
380
|
+
|
381
|
+
less.gsub /&:extend\((#{SELECTOR_RE}) all\)/ do
|
382
|
+
selector = $1
|
383
|
+
selector =~ /\.([\w-]+)/
|
384
|
+
mixin = $1
|
385
|
+
if mixin && mixin_names.include?(mixin)
|
386
|
+
"@include #{mixin}()"
|
387
|
+
else
|
388
|
+
"@extend #{selector}"
|
389
|
+
end
|
390
|
+
end
|
355
391
|
end
|
356
392
|
|
357
393
|
# change Microsoft filters to SASS calling convention
|
@@ -389,13 +425,6 @@ $bootstrap-sass-asset-helper: true !default;
|
|
389
425
|
less
|
390
426
|
end
|
391
427
|
|
392
|
-
# #gradient > .horizontal()
|
393
|
-
# to:
|
394
|
-
# @include .horizontal-gradient()
|
395
|
-
def replace_less_extend(less)
|
396
|
-
less.gsub(/\#(\w+) \> \.([\w-]*)(\(.*\));?/, '@include \1-\2\3;')
|
397
|
-
end
|
398
|
-
|
399
428
|
def replace_spin(less)
|
400
429
|
less.gsub(/(?![\-$@.])spin(?!-)/, 'adjust-hue')
|
401
430
|
end
|
@@ -484,7 +513,7 @@ $bootstrap-sass-asset-helper: true !default;
|
|
484
513
|
options = {comments: true}.merge(options || {})
|
485
514
|
less = less.dup
|
486
515
|
s = CharStringScanner.new(less)
|
487
|
-
rule_re = /(?:#{rule_prefix}[
|
516
|
+
rule_re = /(?:#{rule_prefix}[#{SELECTOR_CHAR})=(\s]*?#{RULE_OPEN_BRACE_RE})/
|
488
517
|
if options[:comments]
|
489
518
|
rule_start_re = /(?:#{COMMENT_RE}*)^#{rule_re}/
|
490
519
|
else
|
@@ -564,7 +593,7 @@ $bootstrap-sass-asset-helper: true !default;
|
|
564
593
|
# get the pos of css def at pos (search backwards)
|
565
594
|
def css_def_pos(css, pos, depth = -1)
|
566
595
|
to = open_brace_pos(css, pos, depth)
|
567
|
-
prev_def = to - (css[0..to].reverse.index(
|
596
|
+
prev_def = to - (css[0..to].reverse.index(RULE_CLOSE_BRACE_RE_REVERSE) || to) + 1
|
568
597
|
from = prev_def + 1 + (css[prev_def + 1..-1] =~ %r(^\s*[^\s/]))
|
569
598
|
(from..to - 1)
|
570
599
|
end
|