bootstrap-sass-backport 3.2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +19 -0
- data/CHANGELOG.md +146 -0
- data/CONTRIBUTING.md +79 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/README.md +320 -0
- data/Rakefile +54 -0
- data/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +229 -0
- data/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/assets/images/.keep +0 -0
- data/assets/javascripts/bootstrap-sprockets.js +12 -0
- data/assets/javascripts/bootstrap.js +2107 -0
- data/assets/javascripts/bootstrap/affix.js +142 -0
- data/assets/javascripts/bootstrap/alert.js +92 -0
- data/assets/javascripts/bootstrap/button.js +110 -0
- data/assets/javascripts/bootstrap/carousel.js +223 -0
- data/assets/javascripts/bootstrap/collapse.js +170 -0
- data/assets/javascripts/bootstrap/dropdown.js +151 -0
- data/assets/javascripts/bootstrap/modal.js +280 -0
- data/assets/javascripts/bootstrap/popover.js +113 -0
- data/assets/javascripts/bootstrap/scrollspy.js +170 -0
- data/assets/javascripts/bootstrap/tab.js +128 -0
- data/assets/javascripts/bootstrap/tooltip.js +457 -0
- data/assets/javascripts/bootstrap/transition.js +59 -0
- data/assets/stylesheets/_bootstrap-compass.scss +7 -0
- data/assets/stylesheets/_bootstrap-mincer.scss +17 -0
- data/assets/stylesheets/_bootstrap-sprockets.scss +7 -0
- data/assets/stylesheets/_bootstrap.scss +50 -0
- data/assets/stylesheets/bootstrap/_alerts.scss +68 -0
- data/assets/stylesheets/bootstrap/_badges.scss +57 -0
- data/assets/stylesheets/bootstrap/_breadcrumbs.scss +26 -0
- data/assets/stylesheets/bootstrap/_button-groups.scss +240 -0
- data/assets/stylesheets/bootstrap/_buttons.scss +157 -0
- data/assets/stylesheets/bootstrap/_carousel.scss +243 -0
- data/assets/stylesheets/bootstrap/_close.scss +35 -0
- data/assets/stylesheets/bootstrap/_code.scss +68 -0
- data/assets/stylesheets/bootstrap/_component-animations.scss +35 -0
- data/assets/stylesheets/bootstrap/_dropdowns.scss +215 -0
- data/assets/stylesheets/bootstrap/_forms.scss +538 -0
- data/assets/stylesheets/bootstrap/_glyphicons.scss +237 -0
- data/assets/stylesheets/bootstrap/_grid.scss +84 -0
- data/assets/stylesheets/bootstrap/_input-groups.scss +166 -0
- data/assets/stylesheets/bootstrap/_jumbotron.scss +48 -0
- data/assets/stylesheets/bootstrap/_labels.scss +66 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +131 -0
- data/assets/stylesheets/bootstrap/_media.scss +56 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +39 -0
- data/assets/stylesheets/bootstrap/_modals.scss +150 -0
- data/assets/stylesheets/bootstrap/_navbar.scss +659 -0
- data/assets/stylesheets/bootstrap/_navs.scss +242 -0
- data/assets/stylesheets/bootstrap/_normalize.scss +425 -0
- data/assets/stylesheets/bootstrap/_pager.scss +55 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +88 -0
- data/assets/stylesheets/bootstrap/_panels.scss +243 -0
- data/assets/stylesheets/bootstrap/_popovers.scss +133 -0
- data/assets/stylesheets/bootstrap/_print.scss +101 -0
- data/assets/stylesheets/bootstrap/_progress-bars.scss +105 -0
- data/assets/stylesheets/bootstrap/_responsive-embed.scss +34 -0
- data/assets/stylesheets/bootstrap/_responsive-utilities.scss +174 -0
- data/assets/stylesheets/bootstrap/_scaffolding.scss +150 -0
- data/assets/stylesheets/bootstrap/_tables.scss +233 -0
- data/assets/stylesheets/bootstrap/_theme.scss +258 -0
- data/assets/stylesheets/bootstrap/_thumbnails.scss +38 -0
- data/assets/stylesheets/bootstrap/_tooltip.scss +95 -0
- data/assets/stylesheets/bootstrap/_type.scss +304 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +57 -0
- data/assets/stylesheets/bootstrap/_variables.scss +854 -0
- data/assets/stylesheets/bootstrap/_wells.scss +29 -0
- data/assets/stylesheets/bootstrap/mixins/_alerts.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +50 -0
- data/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +84 -0
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +58 -0
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
- data/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_image.scss +34 -0
- data/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +31 -0
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
- data/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_opacity.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +23 -0
- data/assets/stylesheets/bootstrap/mixins/_panels.scss +24 -0
- data/assets/stylesheets/bootstrap/mixins/_progress-bar.scss +10 -0
- data/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
- data/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
- data/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +219 -0
- data/bootstrap-sass-backport.gemspec +36 -0
- data/bower.json +50 -0
- data/composer.json +35 -0
- data/lib/bootstrap-sass-backport.rb +71 -0
- data/lib/bootstrap-sass/engine.rb +12 -0
- data/lib/bootstrap-sass/version.rb +4 -0
- data/package.json +30 -0
- data/sache.json +5 -0
- data/tasks/bower.rake +34 -0
- data/tasks/converter.rb +80 -0
- data/tasks/converter/char_string_scanner.rb +38 -0
- data/tasks/converter/fonts_conversion.rb +16 -0
- data/tasks/converter/js_conversion.rb +45 -0
- data/tasks/converter/less_conversion.rb +670 -0
- data/tasks/converter/logger.rb +57 -0
- data/tasks/converter/network.rb +86 -0
- data/templates/project/_bootstrap-variables.sass.erb +4 -0
- data/templates/project/manifest.rb +26 -0
- data/templates/project/styles.sass +3 -0
- data/test/compass_test.rb +9 -0
- data/test/compilation_test.rb +18 -0
- data/test/dummy_node_mincer/apple-touch-icon-144-precomposed.png +0 -0
- data/test/dummy_node_mincer/application.css.ejs.scss +6 -0
- data/test/dummy_node_mincer/manifest.js +87 -0
- data/test/dummy_rails/README.rdoc +3 -0
- data/test/dummy_rails/Rakefile +6 -0
- data/test/dummy_rails/app/assets/images/.keep +0 -0
- data/test/dummy_rails/app/assets/javascripts/application.js +2 -0
- data/test/dummy_rails/app/assets/stylesheets/application.css.sass +2 -0
- data/test/dummy_rails/app/controllers/application_controller.rb +5 -0
- data/test/dummy_rails/app/controllers/pages_controller.rb +4 -0
- data/test/dummy_rails/app/helpers/application_helper.rb +2 -0
- data/test/dummy_rails/app/views/layouts/application.html.erb +14 -0
- data/test/dummy_rails/app/views/pages/root.html.slim +41 -0
- data/test/dummy_rails/bin/bundle +3 -0
- data/test/dummy_rails/bin/rails +4 -0
- data/test/dummy_rails/bin/rake +4 -0
- data/test/dummy_rails/config.ru +4 -0
- data/test/dummy_rails/config/application.rb +30 -0
- data/test/dummy_rails/config/boot.rb +5 -0
- data/test/dummy_rails/config/environment.rb +5 -0
- data/test/dummy_rails/config/environments/development.rb +26 -0
- data/test/dummy_rails/config/environments/production.rb +76 -0
- data/test/dummy_rails/config/environments/test.rb +30 -0
- data/test/dummy_rails/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy_rails/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy_rails/config/initializers/inflections.rb +16 -0
- data/test/dummy_rails/config/initializers/mime_types.rb +5 -0
- data/test/dummy_rails/config/initializers/secret_token.rb +18 -0
- data/test/dummy_rails/config/initializers/session_store.rb +3 -0
- data/test/dummy_rails/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy_rails/config/locales/en.yml +3 -0
- data/test/dummy_rails/config/locales/es.yml +3 -0
- data/test/dummy_rails/config/routes.rb +3 -0
- data/test/dummy_rails/db/test.sqlite3 +0 -0
- data/test/dummy_rails/lib/assets/.keep +0 -0
- data/test/dummy_rails/log/.keep +0 -0
- data/test/dummy_rails/public/404.html +58 -0
- data/test/dummy_rails/public/422.html +58 -0
- data/test/dummy_rails/public/500.html +57 -0
- data/test/dummy_rails/public/favicon.ico +0 -0
- data/test/dummy_sass_only/Gemfile +4 -0
- data/test/dummy_sass_only/compile.rb +13 -0
- data/test/dummy_sass_only/import_all.sass +2 -0
- data/test/gemfiles/sass_3_2.gemfile +6 -0
- data/test/gemfiles/sass_3_3.gemfile +6 -0
- data/test/gemfiles/sass_3_4.gemfile +7 -0
- data/test/gemfiles/sass_head.gemfile +6 -0
- data/test/node_mincer_test.rb +36 -0
- data/test/node_sass_test.rb +16 -0
- data/test/pages_test.rb +14 -0
- data/test/sass_test.rb +26 -0
- data/test/sprockets_rails_test.rb +27 -0
- data/test/support/dummy_rails_integration.rb +22 -0
- data/test/support/integration_test.rb +22 -0
- data/test/support/reporting.rb +17 -0
- data/test/test_helper.rb +35 -0
- data/test/test_helper_rails.rb +6 -0
- metadata +484 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'bootstrap-sass/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "bootstrap-sass-backport"
|
7
|
+
s.version = Bootstrap::VERSION
|
8
|
+
s.authors = ["Thomas McDonald", 'Michael Deering']
|
9
|
+
s.email = ['tom@conceptcoding.co.uk', 'mdeering@mdeering.com']
|
10
|
+
s.summary = "Backport to Rails 3 Twitter's Bootstrap, converted to Sass and ready to drop into Rails or Compass"
|
11
|
+
s.homepage = "https://github.com/mdeering/bootstrap-sass"
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.add_runtime_dependency 'sass', '~> 3.2'
|
15
|
+
|
16
|
+
# Testing dependencies
|
17
|
+
s.add_development_dependency 'minitest', '~> 5.4.0'
|
18
|
+
s.add_development_dependency 'minitest-reporters', '~> 1.0.5'
|
19
|
+
# Integration testing
|
20
|
+
s.add_development_dependency 'capybara'
|
21
|
+
s.add_development_dependency 'poltergeist'
|
22
|
+
# Dummy Rails app dependencies
|
23
|
+
s.add_development_dependency 'actionpack', '>= 4.1.5'
|
24
|
+
s.add_development_dependency 'activesupport', '>= 4.1.5'
|
25
|
+
s.add_development_dependency 'json', '>= 1.8.1'
|
26
|
+
s.add_development_dependency 'sprockets-rails', '>= 2.1.3'
|
27
|
+
s.add_development_dependency 'autoprefixer-rails', '~> 1.1'
|
28
|
+
s.add_development_dependency 'jquery-rails', '>= 3.1.0'
|
29
|
+
s.add_development_dependency 'slim-rails'
|
30
|
+
s.add_development_dependency 'uglifier'
|
31
|
+
# Converter
|
32
|
+
s.add_development_dependency 'term-ansicolor'
|
33
|
+
|
34
|
+
s.files = `git ls-files`.split("\n")
|
35
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
36
|
+
end
|
data/bower.json
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"name": "bootstrap-sass",
|
3
|
+
"version": "3.2.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": [
|
13
|
+
"assets/stylesheets/_bootstrap.scss",
|
14
|
+
"assets/fonts/bootstrap/glyphicons-halflings-regular.eot",
|
15
|
+
"assets/fonts/bootstrap/glyphicons-halflings-regular.svg",
|
16
|
+
"assets/fonts/bootstrap/glyphicons-halflings-regular.ttf",
|
17
|
+
"assets/fonts/bootstrap/glyphicons-halflings-regular.woff",
|
18
|
+
"assets/javascripts/bootstrap/affix.js",
|
19
|
+
"assets/javascripts/bootstrap/alert.js",
|
20
|
+
"assets/javascripts/bootstrap/button.js",
|
21
|
+
"assets/javascripts/bootstrap/carousel.js",
|
22
|
+
"assets/javascripts/bootstrap/collapse.js",
|
23
|
+
"assets/javascripts/bootstrap/dropdown.js",
|
24
|
+
"assets/javascripts/bootstrap/tab.js",
|
25
|
+
"assets/javascripts/bootstrap/transition.js",
|
26
|
+
"assets/javascripts/bootstrap/scrollspy.js",
|
27
|
+
"assets/javascripts/bootstrap/modal.js",
|
28
|
+
"assets/javascripts/bootstrap/tooltip.js",
|
29
|
+
"assets/javascripts/bootstrap/popover.js"
|
30
|
+
],
|
31
|
+
"keywords": [
|
32
|
+
"twbs",
|
33
|
+
"bootstrap",
|
34
|
+
"sass"
|
35
|
+
],
|
36
|
+
"license": "MIT",
|
37
|
+
"ignore": [
|
38
|
+
"**/.*",
|
39
|
+
"lib",
|
40
|
+
"tasks",
|
41
|
+
"templates",
|
42
|
+
"test",
|
43
|
+
"*.gemspec",
|
44
|
+
"Rakefile",
|
45
|
+
"Gemfile"
|
46
|
+
],
|
47
|
+
"dependencies": {
|
48
|
+
"jquery": ">= 1.9.0"
|
49
|
+
}
|
50
|
+
}
|
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-sass",
|
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.2.x-dev"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Bootstrap
|
2
|
+
class << self
|
3
|
+
# Inspired by Kaminari
|
4
|
+
def load!
|
5
|
+
register_compass_extension if compass?
|
6
|
+
register_rails_engine if rails?
|
7
|
+
|
8
|
+
configure_sass
|
9
|
+
end
|
10
|
+
|
11
|
+
# Paths
|
12
|
+
def gem_path
|
13
|
+
@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def stylesheets_path
|
17
|
+
File.join assets_path, 'stylesheets'
|
18
|
+
end
|
19
|
+
|
20
|
+
def fonts_path
|
21
|
+
File.join assets_path, 'fonts'
|
22
|
+
end
|
23
|
+
|
24
|
+
def javascripts_path
|
25
|
+
File.join assets_path, 'javascripts'
|
26
|
+
end
|
27
|
+
|
28
|
+
def assets_path
|
29
|
+
@assets_path ||= File.join gem_path, 'assets'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Environment detection helpers
|
33
|
+
def asset_pipeline?
|
34
|
+
defined?(::Sprockets)
|
35
|
+
end
|
36
|
+
|
37
|
+
def compass?
|
38
|
+
defined?(::Compass)
|
39
|
+
end
|
40
|
+
|
41
|
+
def rails?
|
42
|
+
defined?(::Rails)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def configure_sass
|
48
|
+
require 'sass'
|
49
|
+
|
50
|
+
::Sass.load_paths << stylesheets_path
|
51
|
+
|
52
|
+
# bootstrap requires minimum precision of 10, see https://github.com/twbs/bootstrap-sass/issues/409
|
53
|
+
::Sass::Script::Number.precision = [10, ::Sass::Script::Number.precision].max
|
54
|
+
end
|
55
|
+
|
56
|
+
def register_compass_extension
|
57
|
+
::Compass::Frameworks.register(
|
58
|
+
'bootstrap',
|
59
|
+
:path => gem_path,
|
60
|
+
:stylesheets_directory => stylesheets_path,
|
61
|
+
:templates_directory => File.join(gem_path, 'templates')
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def register_rails_engine
|
66
|
+
require 'bootstrap-sass/engine'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Bootstrap.load!
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Bootstrap
|
2
|
+
module Rails
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
initializer 'bootstrap-sass.assets.precompile' do |app|
|
5
|
+
%w(stylesheets javascripts fonts images).each do |sub|
|
6
|
+
app.config.assets.paths << root.join('assets', sub)
|
7
|
+
end
|
8
|
+
app.config.assets.precompile << %r(bootstrap/glyphicons-halflings-regular\.(?:eot|svg|ttf|woff)$)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"name": "bootstrap-sass",
|
3
|
+
"version": "3.2.0",
|
4
|
+
"description": "bootstrap-sass is a Sass-powered version of Bootstrap, ready to drop right into your Sass powered applications.",
|
5
|
+
"main": "index.js",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "git://github.com/twbs/bootstrap-sass"
|
9
|
+
},
|
10
|
+
"keywords": [
|
11
|
+
"bootstrap",
|
12
|
+
"sass",
|
13
|
+
"css"
|
14
|
+
],
|
15
|
+
"contributors": [
|
16
|
+
"Thomas McDonald",
|
17
|
+
"Tristan Harward",
|
18
|
+
"Peter Gumeson",
|
19
|
+
"Gleb Mazovetskiy"
|
20
|
+
],
|
21
|
+
"license": "MIT",
|
22
|
+
"bugs": {
|
23
|
+
"url": "https://github.com/twbs/bootstrap-sass/issues"
|
24
|
+
},
|
25
|
+
"devDependencies": {
|
26
|
+
"node-sass": "*",
|
27
|
+
"mincer": "*",
|
28
|
+
"ejs": "*"
|
29
|
+
}
|
30
|
+
}
|
data/sache.json
ADDED
data/tasks/bower.rake
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'find'
|
2
|
+
require 'json'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
namespace :bower do
|
6
|
+
|
7
|
+
find_files = ->(path) {
|
8
|
+
Find.find(Pathname.new(path).relative_path_from(Pathname.new Dir.pwd).to_s).map do |path|
|
9
|
+
path if File.file?(path)
|
10
|
+
end.compact
|
11
|
+
}
|
12
|
+
|
13
|
+
desc 'update main and version in bower.json'
|
14
|
+
task :generate do
|
15
|
+
require 'bootstrap-sass'
|
16
|
+
Dir.chdir Bootstrap.gem_path do
|
17
|
+
spec = JSON.parse(File.read 'bower.json')
|
18
|
+
js_paths = File.read(File.join Bootstrap.javascripts_path, 'bootstrap-sprockets.js').lines.map do |line|
|
19
|
+
line.strip if line.sub!(%r(//\s*=\s*require\s*(?:./)?(.*)\s*), 'assets/javascripts/\1.js')
|
20
|
+
end.compact
|
21
|
+
|
22
|
+
spec['main'] =
|
23
|
+
find_files.(File.join(Bootstrap.stylesheets_path, '_bootstrap.scss')) +
|
24
|
+
find_files.(Bootstrap.fonts_path) +
|
25
|
+
js_paths
|
26
|
+
|
27
|
+
spec['version'] = Bootstrap::VERSION[0..-3]
|
28
|
+
|
29
|
+
File.open('bower.json', 'w') do |f|
|
30
|
+
f.puts JSON.pretty_generate(spec)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/tasks/converter.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Based on convert script from vwall/compass-twitter-bootstrap gem.
|
3
|
+
# https://github.com/vwall/compass-twitter-bootstrap/blob/master/build/convert.rb
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this work except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License in the LICENSE file, or at:
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'open-uri'
|
18
|
+
require 'json'
|
19
|
+
require 'strscan'
|
20
|
+
require 'forwardable'
|
21
|
+
require 'term/ansicolor'
|
22
|
+
require 'fileutils'
|
23
|
+
|
24
|
+
require_relative 'converter/fonts_conversion'
|
25
|
+
require_relative 'converter/less_conversion'
|
26
|
+
require_relative 'converter/js_conversion'
|
27
|
+
require_relative 'converter/logger'
|
28
|
+
require_relative 'converter/network'
|
29
|
+
|
30
|
+
class Converter
|
31
|
+
extend Forwardable
|
32
|
+
include Network
|
33
|
+
include LessConversion
|
34
|
+
include JsConversion
|
35
|
+
include FontsConversion
|
36
|
+
|
37
|
+
def initialize(repo: 'twbs/bootstrap', branch: 'master', save_to: {}, cache_path: 'tmp/converter-cache-bootstrap')
|
38
|
+
@logger = Logger.new
|
39
|
+
@repo = repo
|
40
|
+
@branch = branch || 'master'
|
41
|
+
@branch_sha = get_branch_sha
|
42
|
+
@cache_path = cache_path
|
43
|
+
@repo_url = "https://github.com/#@repo"
|
44
|
+
@save_to = {
|
45
|
+
js: 'assets/javascripts/bootstrap',
|
46
|
+
scss: 'assets/stylesheets/bootstrap',
|
47
|
+
fonts: 'assets/fonts/bootstrap'}.merge(save_to)
|
48
|
+
end
|
49
|
+
|
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) }
|
61
|
+
|
62
|
+
process_font_assets
|
63
|
+
process_stylesheet_assets
|
64
|
+
process_javascript_assets
|
65
|
+
store_version
|
66
|
+
end
|
67
|
+
|
68
|
+
def save_file(path, content, mode='w')
|
69
|
+
dir = File.dirname(path)
|
70
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
71
|
+
File.open(path, mode) { |file| file.write(content) }
|
72
|
+
end
|
73
|
+
|
74
|
+
# Update version.rb file with BOOTSTRAP_SHA
|
75
|
+
def store_version
|
76
|
+
path = 'lib/bootstrap-sass/version.rb'
|
77
|
+
content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][\w]+['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
|
78
|
+
File.open(path, 'w') { |f| f.write(content) }
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# regular string scanner works with bytes
|
2
|
+
# this one works with chars and provides #scan_next
|
3
|
+
class Converter
|
4
|
+
class CharStringScanner
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
@s = StringScanner.new(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def_delegators :@s, :scan_until, :skip_until, :string
|
12
|
+
|
13
|
+
# advance scanner to pos after the next match of pattern and return the match
|
14
|
+
def scan_next(pattern)
|
15
|
+
return unless @s.scan_until(pattern)
|
16
|
+
@s.matched
|
17
|
+
end
|
18
|
+
|
19
|
+
def pos
|
20
|
+
byte_to_str_pos @s.pos
|
21
|
+
end
|
22
|
+
|
23
|
+
def pos=(i)
|
24
|
+
@s.pos = str_to_byte_pos i
|
25
|
+
i
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def byte_to_str_pos(pos)
|
31
|
+
@s.string.byteslice(0, pos).length
|
32
|
+
end
|
33
|
+
|
34
|
+
def str_to_byte_pos(pos)
|
35
|
+
@s.string.slice(0, pos).bytesize
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Converter
|
2
|
+
module FontsConversion
|
3
|
+
def process_font_assets
|
4
|
+
log_status 'Processing fonts...'
|
5
|
+
files = read_files('fonts', bootstrap_font_files)
|
6
|
+
save_to = @save_to[:fonts]
|
7
|
+
files.each do |name, content|
|
8
|
+
save_file "#{save_to}/#{name}", content
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def bootstrap_font_files
|
13
|
+
@bootstrap_font_files ||= get_paths_by_type('fonts', /\.(eot|svg|ttf|woff)$/)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Converter
|
2
|
+
module JsConversion
|
3
|
+
def process_javascript_assets
|
4
|
+
log_status 'Processing javascripts...'
|
5
|
+
save_to = @save_to[:js]
|
6
|
+
contents = {}
|
7
|
+
read_files('js', bootstrap_js_files).each do |name, file|
|
8
|
+
contents[name] = file
|
9
|
+
save_file("#{save_to}/#{name}", file)
|
10
|
+
end
|
11
|
+
log_processed "#{bootstrap_js_files * ' '}"
|
12
|
+
|
13
|
+
log_status 'Updating javascript manifest'
|
14
|
+
manifest = ''
|
15
|
+
cat = ''
|
16
|
+
bootstrap_js_files.each do |name|
|
17
|
+
cat << contents[name] + "\n"
|
18
|
+
name = name.gsub(/\.js$/, '')
|
19
|
+
manifest << "//= require ./bootstrap/#{name}\n"
|
20
|
+
end
|
21
|
+
{'assets/javascripts/bootstrap-sprockets.js' => manifest,
|
22
|
+
'assets/javascripts/bootstrap.js' => cat}.each do |path, content|
|
23
|
+
save_file path, content
|
24
|
+
log_processed path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def bootstrap_js_files
|
29
|
+
@bootstrap_js_files ||= begin
|
30
|
+
files = get_paths_by_type 'js', /\.js$/
|
31
|
+
files.sort_by { |f|
|
32
|
+
case f
|
33
|
+
# tooltip depends on popover and must be loaded earlier
|
34
|
+
when /tooltip/ then
|
35
|
+
1
|
36
|
+
when /popover/ then
|
37
|
+
2
|
38
|
+
else
|
39
|
+
0
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|