forked from twbs/bootstrap-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
182 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,50 @@ | ||
require 'sass' | ||
require 'bootstrap-sass' | ||
|
||
module Sass::Script::Functions | ||
def twbs_font_path(source) | ||
twbs_asset_path source, :font | ||
end | ||
declare :twbs_font_path, [:source] | ||
|
||
def twbs_image_path(source) | ||
twbs_asset_path source, :image | ||
end | ||
declare :twbs_image_path, [:source] | ||
|
||
def twbs_asset_path(source, type) | ||
url = if Bootstrap.asset_pipeline? && (context = sprockets_context) | ||
context.send(:"#{type}_path", source.value) | ||
elsif Bootstrap.compass? | ||
send(:"#{type}_url", source, Sass::Script::Bool.new(true)).value | ||
end | ||
|
||
# sass-only | ||
url ||= source.value.gsub('"', '') | ||
Sass::Script::String.new(url, :string) | ||
end | ||
declare :twbs_asset_path, [:source] | ||
|
||
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9 | ||
# returns an IE hex string for a color with an alpha channel | ||
# suitable for passing to IE filters. | ||
def ie_hex_str(color) | ||
def twbs_ie_hex_str(color) | ||
assert_type color, :Color | ||
alpha = (color.alpha * 255).round | ||
alphastr = alpha.to_s(16).rjust(2, '0') | ||
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase) | ||
end | ||
declare :ie_hex_str, [:color] | ||
declare :twbs_ie_hex_str, [:color] | ||
|
||
protected | ||
|
||
def sprockets_context | ||
# Modern way to get context: | ||
if options.key?(:sprockets) | ||
options[:sprockets][:context] | ||
# Compatibility with sprockets pre 2.10.0: | ||
elsif (importer = options[:importer]) && importer.respond_to?(:context) | ||
importer.context | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Bootstrap | ||
VERSION = '3.0.2.1' | ||
BOOTSTRAP_SHA = '4cbc8d49b10f707029019aaa5eba50e56390a3c5' | ||
BOOTSTRAP_SHA = '27b62d39e2ba62e2d70ef2f5322edd584adc726e' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'sass', '~> 3.2' | ||
gem 'bootstrap-sass', path: '../..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'sass' | ||
require 'bootstrap-sass' | ||
|
||
css = Sass.compile( | ||
File.read(File.expand_path('./import_all.sass', File.dirname(__FILE__))), | ||
:syntax => 'sass' | ||
) | ||
|
||
if ARGV[0] | ||
File.open(ARGV[0], 'w') { |f| f.write css } | ||
else | ||
puts css | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import 'bootstrap' | ||
@import 'bootstrap/theme' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'test_helper' | ||
|
||
class SassTest < Test::Unit::TestCase | ||
DUMMY_PATH = 'test/dummy_sass_only' | ||
|
||
def test_font_helper | ||
assert_match %r(url\(['"]?.*eot['"]?\)), @css | ||
end | ||
|
||
def setup | ||
Dir.chdir DUMMY_PATH do | ||
%x[bundle] | ||
end | ||
css_path = File.join Bootstrap.gem_path, 'tmp/bootstrap-sass-only.css' | ||
command = "bundle exec ruby compile.rb #{css_path}" | ||
Dir.chdir DUMMY_PATH do | ||
assert silence_stream(STDOUT) { | ||
system(command) | ||
}, 'Sass-only compilation failed' | ||
end | ||
@css = File.read(css_path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.