chriseppstein-compass 0.6.15 → 0.7.0
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/CHANGELOG.markdown +170 -0
- data/LICENSE.markdown +29 -0
- data/README.markdown +10 -2
- data/REVISION +1 -1
- data/Rakefile +126 -0
- data/VERSION.yml +2 -2
- data/deps.rip +1 -0
- data/examples/blueprint_default/src/images/grid.png +0 -0
- data/examples/blueprint_plugins/src/images/grid.png +0 -0
- data/examples/blueprint_scoped/images/grid.png +0 -0
- data/examples/blueprint_scoped_form/images/grid.png +0 -0
- data/examples/blueprint_semantic/src/images/grid.png +0 -0
- data/examples/blueprint_semantic/src/liquid.sass +2 -2
- data/examples/blueprint_semantic/src/screen.sass +3 -3
- data/examples/compass/src/images/blue_arrow.gif +0 -0
- data/frameworks/blueprint/stylesheets/blueprint/_ie.sass +42 -0
- data/frameworks/blueprint/stylesheets/blueprint/_reset.sass +3 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass +10 -9
- data/frameworks/blueprint/stylesheets/blueprint/modules/_form.sass +35 -23
- data/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass +7 -7
- data/frameworks/blueprint/stylesheets/blueprint/modules/_reset.sass +56 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_rtl.sass +2 -2
- data/frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass +2 -1
- data/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass +3 -2
- data/frameworks/blueprint/templates/project/manifest.rb +2 -1
- data/frameworks/blueprint/templates/project/partials/_base.sass +11 -0
- data/frameworks/blueprint/templates/project/screen.sass +38 -6
- data/frameworks/compass/stylesheets/compass/_utilities.sass +1 -0
- data/frameworks/compass/stylesheets/compass/utilities/_sprites.sass +1 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_reset.sass +106 -28
- data/frameworks/compass/stylesheets/compass/utilities/general/_tag_cloud.sass +1 -1
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite_img.sass +12 -0
- data/frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass +10 -3
- data/frameworks/compass/templates/project/manifest.rb +1 -1
- data/frameworks/compass/templates/project/screen.sass +6 -0
- data/lib/compass/actions.rb +7 -0
- data/lib/compass/{merb.rb → app_integration/merb.rb} +0 -0
- data/lib/compass/app_integration/rails/action_controller.rb +15 -0
- data/lib/compass/app_integration/rails/image_url.rb +14 -0
- data/lib/compass/app_integration/rails/sass_plugin.rb +5 -0
- data/lib/compass/app_integration/rails/templates/compass-install-rails.rb +80 -0
- data/lib/compass/app_integration/rails.rb +12 -0
- data/lib/compass/app_integration.rb +5 -0
- data/lib/compass/commands/project_base.rb +12 -2
- data/lib/compass/commands/update_project.rb +13 -3
- data/lib/compass/commands/watch_project.rb +27 -28
- data/lib/compass/commands/write_configuration.rb +5 -1
- data/lib/compass/compiler.rb +14 -2
- data/lib/compass/configuration.rb +78 -2
- data/lib/compass/exec.rb +78 -37
- data/lib/compass/installers/base.rb +4 -2
- data/lib/compass/installers/rails.rb +3 -2
- data/lib/compass/installers/stand_alone.rb +3 -2
- data/lib/compass/sass_extensions/functions/display.rb +22 -0
- data/lib/compass/sass_extensions/functions/enumerate.rb +6 -0
- data/lib/compass/sass_extensions/functions/image_url.rb +88 -0
- data/lib/compass/sass_extensions/functions/inline_image.rb +35 -0
- data/lib/compass/sass_extensions/functions/selectors.rb +39 -0
- data/lib/compass/sass_extensions/functions.rb +19 -0
- data/lib/compass/sass_extensions/monkey_patches/stylesheet_updating.rb +23 -0
- data/lib/compass/sass_extensions/monkey_patches.rb +3 -0
- data/lib/compass/sass_extensions.rb +5 -0
- data/lib/compass/version.rb +2 -3
- data/lib/compass.rb +3 -18
- data/test/command_line_helper.rb +102 -0
- data/test/command_line_test.rb +2 -106
- data/test/compass_test.rb +18 -6
- data/test/configuration_test.rb +73 -0
- data/test/fixtures/stylesheets/blueprint/images/grid.png +0 -0
- data/test/fixtures/stylesheets/compass/css/reset.css +42 -46
- data/test/fixtures/stylesheets/compass/sass/reset.sass +9 -0
- data/test/fixtures/stylesheets/image_urls/config.rb +17 -0
- data/test/fixtures/stylesheets/image_urls/css/screen.css +3 -0
- data/test/fixtures/stylesheets/image_urls/images/grid.png +0 -0
- data/test/fixtures/stylesheets/image_urls/sass/screen.sass +6 -0
- data/test/rails_integration_test.rb +83 -0
- data/test/sass_extensions_test.rb +0 -1
- data/test/test_case_helper.rb +13 -0
- data/test/test_helper.rb +3 -27
- data/test/test_rails_helper.rb +20 -0
- metadata +51 -4
- data/lib/sass_extensions.rb +0 -67
@@ -7,45 +7,44 @@ module Compass
|
|
7
7
|
module Commands
|
8
8
|
class WatchProject < UpdateProject
|
9
9
|
|
10
|
-
attr_accessor :last_update_time
|
10
|
+
attr_accessor :last_update_time, :last_sass_files
|
11
11
|
|
12
12
|
def perform
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
Signal.trap("INT") do
|
14
|
+
puts ""
|
15
|
+
exit 0
|
16
|
+
end
|
17
|
+
puts ">>> Compass is watching for changes. Press Ctrl-C to Stop."
|
17
18
|
loop do
|
18
19
|
# TODO: Make this efficient by using filesystem monitoring.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
exit 0
|
24
|
-
end
|
25
|
-
file, t = should_update?
|
26
|
-
if t
|
27
|
-
begin
|
28
|
-
puts ">>> Change detected to: #{file}"
|
29
|
-
super
|
30
|
-
rescue StandardError => e
|
31
|
-
::Compass::Exec.report_error(e, options)
|
32
|
-
end
|
33
|
-
self.last_update_time = t
|
34
|
-
end
|
20
|
+
compiler = new_compiler_instance(:quiet => true)
|
21
|
+
remove_obsolete_css(compiler)
|
22
|
+
recompile(compiler)
|
23
|
+
sleep 1
|
35
24
|
end
|
36
25
|
end
|
37
26
|
|
38
|
-
def
|
39
|
-
|
27
|
+
def remove_obsolete_css(compiler)
|
28
|
+
sass_files = compiler.sass_files
|
29
|
+
deleted_sass_files = (last_sass_files || []) - sass_files
|
30
|
+
deleted_sass_files.each do |deleted_sass_file|
|
31
|
+
css_file = compiler.corresponding_css_file(deleted_sass_file)
|
32
|
+
remove(css_file) if File.exists?(css_file)
|
33
|
+
end
|
34
|
+
self.last_sass_files = sass_files
|
40
35
|
end
|
41
36
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
def recompile(compiler)
|
38
|
+
if file = compiler.out_of_date?
|
39
|
+
begin
|
40
|
+
puts ">>> Change detected to: #{file}"
|
41
|
+
compiler.run
|
42
|
+
rescue StandardError => e
|
43
|
+
::Compass::Exec.report_error(e, options)
|
44
|
+
end
|
47
45
|
end
|
48
46
|
end
|
47
|
+
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -12,13 +12,17 @@ module Compass
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
15
|
-
installer.write_configuration_files
|
15
|
+
installer.write_configuration_files(options[:configuration_file])
|
16
16
|
end
|
17
17
|
|
18
18
|
def installer_args
|
19
19
|
[nil, project_directory, options]
|
20
20
|
end
|
21
21
|
|
22
|
+
def explicit_config_file_must_be_readable?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/compass/compiler.rb
CHANGED
@@ -22,15 +22,27 @@ module Compass
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def css_files
|
25
|
-
@css_files
|
25
|
+
@css_files ||= sass_files.map{|sass_file| corresponding_css_file(sass_file)}
|
26
|
+
end
|
27
|
+
|
28
|
+
def corresponding_css_file(sass_file)
|
29
|
+
"#{to}/#{stylesheet_name(sass_file)}.css"
|
26
30
|
end
|
27
31
|
|
28
32
|
def target_directories
|
29
33
|
css_files.map{|css_file| File.dirname(css_file)}.uniq.sort.sort_by{|d| d.length }
|
30
34
|
end
|
31
35
|
|
36
|
+
def out_of_date?
|
37
|
+
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
|
38
|
+
sass_files.zip(css_files).each do |sass_filename, css_filename|
|
39
|
+
return sass_filename if Sass::Plugin.exact_stylesheet_needs_update?(css_filename, sass_filename)
|
40
|
+
end
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
32
44
|
def run
|
33
|
-
Compass.configure_sass_plugin!
|
45
|
+
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
|
34
46
|
target_directories.each do |dir|
|
35
47
|
directory dir
|
36
48
|
end
|
@@ -13,7 +13,9 @@ module Compass
|
|
13
13
|
:javascripts_dir,
|
14
14
|
:output_style,
|
15
15
|
:environment,
|
16
|
-
:http_images_path
|
16
|
+
:http_images_path,
|
17
|
+
:additional_import_paths,
|
18
|
+
:sass_options
|
17
19
|
]
|
18
20
|
|
19
21
|
attr_accessor *ATTRIBUTES
|
@@ -38,6 +40,10 @@ module Compass
|
|
38
40
|
value = eval(prop.to_s, binding) rescue nil
|
39
41
|
self.send("#{prop}=", value) if value
|
40
42
|
end
|
43
|
+
if @added_import_paths
|
44
|
+
self.additional_import_paths ||= []
|
45
|
+
self.additional_import_paths += @added_import_paths
|
46
|
+
end
|
41
47
|
end
|
42
48
|
|
43
49
|
def set_all(options)
|
@@ -117,7 +123,50 @@ module Compass
|
|
117
123
|
end
|
118
124
|
end
|
119
125
|
|
126
|
+
def add_import_path(*paths)
|
127
|
+
# The @added_import_paths variable works around an issue where
|
128
|
+
# the additional_import_paths gets overwritten during parse
|
129
|
+
@added_import_paths ||= []
|
130
|
+
@added_import_paths += paths
|
131
|
+
self.additional_import_paths ||= []
|
132
|
+
self.additional_import_paths += paths
|
133
|
+
end
|
134
|
+
|
135
|
+
# When called with a block, defines the asset host url to be used.
|
136
|
+
# The block must return a string that starts with a protocol (E.g. http).
|
137
|
+
# The block will be passed the root-relative url of the asset.
|
138
|
+
# When called without a block, returns the block that was previously set.
|
139
|
+
def asset_host(&block)
|
140
|
+
if block_given?
|
141
|
+
@asset_host = block
|
142
|
+
else
|
143
|
+
@asset_host
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# When called with a block, defines the cache buster strategy to be used.
|
148
|
+
# The block must return nil or a string that can be appended to a url as a query parameter.
|
149
|
+
# The returned string must not include the starting '?'.
|
150
|
+
# The block will be passed the root-relative url of the asset.
|
151
|
+
# If the block accepts two arguments, it will also be passed a File object
|
152
|
+
# that points to the asset on disk -- which may or may not exist.
|
153
|
+
# When called without a block, returns the block that was previously set.
|
154
|
+
def asset_cache_buster(&block)
|
155
|
+
if block_given?
|
156
|
+
@asset_cache_buster = block
|
157
|
+
else
|
158
|
+
@asset_cache_buster
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
|
120
163
|
def serialize
|
164
|
+
if asset_cache_buster
|
165
|
+
raise Compass::Error, "Cannot serialize a configuration with asset_cache_buster set."
|
166
|
+
end
|
167
|
+
if asset_host
|
168
|
+
raise Compass::Error, "Cannot serialize a configuration with asset_host set."
|
169
|
+
end
|
121
170
|
contents = ""
|
122
171
|
required_libraries.each do |lib|
|
123
172
|
contents << %Q{require '#{lib}'\n}
|
@@ -152,17 +201,31 @@ module Compass
|
|
152
201
|
Compass::Frameworks::ALL.each do |framework|
|
153
202
|
locations[framework.stylesheets_directory] = css_path || css_dir || "."
|
154
203
|
end
|
204
|
+
resolve_additional_import_paths.each do |additional_path|
|
205
|
+
locations[additional_path] = File.join(css_path || css_dir || ".", File.basename(additional_path))
|
206
|
+
end
|
155
207
|
plugin_opts = {:template_location => locations}
|
156
208
|
plugin_opts[:style] = output_style if output_style
|
157
209
|
plugin_opts[:line_comments] = default_line_comments if environment
|
210
|
+
plugin_opts.merge!(sass_options || {})
|
158
211
|
plugin_opts
|
159
212
|
end
|
160
213
|
|
214
|
+
def resolve_additional_import_paths
|
215
|
+
(additional_import_paths || []).map do |path|
|
216
|
+
if project_path && !absolute_path?(path)
|
217
|
+
File.join(project_path, path)
|
218
|
+
else
|
219
|
+
path
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
161
224
|
def to_sass_engine_options
|
162
225
|
engine_opts = {:load_paths => sass_load_paths}
|
163
226
|
engine_opts[:style] = output_style if output_style
|
164
227
|
engine_opts[:line_comments] = default_line_comments if environment
|
165
|
-
engine_opts
|
228
|
+
engine_opts.merge!(sass_options || {})
|
166
229
|
end
|
167
230
|
|
168
231
|
def sass_load_paths
|
@@ -171,6 +234,7 @@ module Compass
|
|
171
234
|
Compass::Frameworks::ALL.each do |framework|
|
172
235
|
load_paths << framework.stylesheets_directory
|
173
236
|
end
|
237
|
+
load_paths += resolve_additional_import_paths
|
174
238
|
load_paths
|
175
239
|
end
|
176
240
|
|
@@ -179,6 +243,9 @@ module Compass
|
|
179
243
|
ATTRIBUTES.each do |attr|
|
180
244
|
send("#{attr}=", nil)
|
181
245
|
end
|
246
|
+
@asset_cache_buster = nil
|
247
|
+
@asset_host = nil
|
248
|
+
@added_import_paths = nil
|
182
249
|
self.required_libraries = []
|
183
250
|
end
|
184
251
|
|
@@ -187,6 +254,10 @@ module Compass
|
|
187
254
|
super
|
188
255
|
end
|
189
256
|
|
257
|
+
def absolute_path?(path)
|
258
|
+
# This is only going to work on unix, gonna need a better implementation.
|
259
|
+
path.index(File::SEPARATOR) == 0
|
260
|
+
end
|
190
261
|
end
|
191
262
|
|
192
263
|
module ConfigHelpers
|
@@ -202,9 +273,14 @@ module Compass
|
|
202
273
|
end
|
203
274
|
|
204
275
|
def configure_sass_plugin!
|
276
|
+
@sass_plugin_configured = true
|
205
277
|
Sass::Plugin.options.merge!(sass_plugin_configuration)
|
206
278
|
end
|
207
279
|
|
280
|
+
def sass_plugin_configured?
|
281
|
+
@sass_plugin_configured
|
282
|
+
end
|
283
|
+
|
208
284
|
def sass_engine_options
|
209
285
|
configuration.to_sass_engine_options
|
210
286
|
end
|
data/lib/compass/exec.rb
CHANGED
@@ -80,14 +80,24 @@ module Compass
|
|
80
80
|
Usage: compass [options] [project]
|
81
81
|
|
82
82
|
Description:
|
83
|
-
|
84
|
-
the current directory.
|
83
|
+
The compass command line tool will help you create and manage the stylesheets for your project.
|
85
84
|
|
86
|
-
|
85
|
+
To get started on a stand-alone project based on blueprint:
|
87
86
|
|
88
|
-
|
87
|
+
compass -f blueprint my_compass_project
|
88
|
+
|
89
|
+
When you change any sass files, you must recompile your project using --update or --watch.
|
89
90
|
END
|
90
|
-
opts.
|
91
|
+
opts.separator ''
|
92
|
+
opts.separator 'Mode Options(only specify one):'
|
93
|
+
|
94
|
+
opts.on('-i', '--install', :NONE, "Create a new compass project.",
|
95
|
+
" The default mode when a project is provided.") do
|
96
|
+
self.options[:command] = :create_project
|
97
|
+
end
|
98
|
+
|
99
|
+
opts.on('-u', '--update', :NONE, 'Update the current project.',
|
100
|
+
' This is the default when no project is provided.') do
|
91
101
|
self.options[:command] = :update_project
|
92
102
|
end
|
93
103
|
|
@@ -96,19 +106,58 @@ END
|
|
96
106
|
self.options[:quiet] = true
|
97
107
|
end
|
98
108
|
|
99
|
-
opts.on('-
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
opts.on('-p', '--pattern PATTERN', 'Stamp out a pattern into the current project. Must be used in combination with -f.') do |pattern|
|
109
|
+
opts.on('-p', '--pattern PATTERN', 'Stamp out a pattern into the current project.',
|
110
|
+
' Must be used with -f.') do |pattern|
|
104
111
|
self.options[:command] = :stamp_pattern
|
105
112
|
self.options[:pattern] = pattern
|
106
113
|
end
|
107
114
|
|
108
|
-
opts.on('-
|
115
|
+
opts.on('--write-configuration', "Write the current configuration to the configuration file.") do
|
116
|
+
self.options[:command] = :write_configuration
|
117
|
+
end
|
118
|
+
|
119
|
+
opts.on('--list-frameworks', "List compass frameworks available to use.") do
|
120
|
+
self.options[:command] = :list_frameworks
|
121
|
+
end
|
122
|
+
|
123
|
+
opts.on('--validate', :NONE, 'Validate your project\'s compiled css. Requires Java.') do
|
124
|
+
self.options[:command] = :validate_project
|
125
|
+
end
|
126
|
+
|
127
|
+
opts.on('--grid-img [DIMENSIONS]', 'Generate a background image to test grid alignment.',
|
128
|
+
' Dimension is given as <column_width>+<gutter_width>.',
|
129
|
+
' Defaults to 30+10.') do |dimensions|
|
130
|
+
self.options[:grid_dimensions] = dimensions || "30+10"
|
131
|
+
unless self.options[:grid_dimensions] =~ /^\d+\+\d+$/
|
132
|
+
puts "Please enter your dimensions as <column_width>+<gutter_width>. E.g. 20+5 or 30+10."
|
133
|
+
exit
|
134
|
+
end
|
135
|
+
self.options[:command] = :generate_grid_background
|
136
|
+
end
|
137
|
+
|
138
|
+
opts.separator ''
|
139
|
+
opts.separator 'Install/Pattern Options:'
|
140
|
+
|
141
|
+
opts.on('-f FRAMEWORK', '--framework FRAMEWORK', 'Use the specified framework. Only one may be specified.') do |framework|
|
142
|
+
self.options[:framework] = framework
|
143
|
+
end
|
144
|
+
|
145
|
+
opts.on('-n', '--pattern-name NAME', 'The name to use when stamping a pattern.',
|
146
|
+
' Must be used in combination with -p.') do |name|
|
109
147
|
self.options[:pattern_name] = name
|
110
148
|
end
|
111
149
|
|
150
|
+
opts.on('--rails', "Sets the project type to a rails project.") do
|
151
|
+
self.options[:project_type] = :rails
|
152
|
+
end
|
153
|
+
|
154
|
+
opts.separator ''
|
155
|
+
opts.separator 'Configuration Options:'
|
156
|
+
|
157
|
+
opts.on('-c', '--config CONFIG_FILE', 'Specify the location of the configuration file explicitly.') do |configuration_file|
|
158
|
+
self.options[:configuration_file] = configuration_file
|
159
|
+
end
|
160
|
+
|
112
161
|
opts.on('--sass-dir SRC_DIR', "The source directory where you keep your sass stylesheets.") do |sass_dir|
|
113
162
|
self.options[:sass_dir] = sass_dir
|
114
163
|
end
|
@@ -117,30 +166,33 @@ END
|
|
117
166
|
self.options[:css_dir] = css_dir
|
118
167
|
end
|
119
168
|
|
120
|
-
opts.on('--
|
121
|
-
self.options[:
|
169
|
+
opts.on('--images-dir IMAGES_DIR', "The directory where you keep your images.") do |images_dir|
|
170
|
+
self.options[:images_dir] = images_dir
|
122
171
|
end
|
123
172
|
|
124
|
-
opts.on('-
|
125
|
-
self.options[:
|
173
|
+
opts.on('--javascripts-dir JS_DIR', "The directory where you keep your javascripts.") do |javascripts_dir|
|
174
|
+
self.options[:javascripts_dir] = javascripts_dir
|
126
175
|
end
|
127
176
|
|
128
|
-
opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment
|
177
|
+
opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment.',
|
178
|
+
' One of: development, production (default)') do |env|
|
129
179
|
self.options[:environment] = env
|
130
180
|
end
|
131
181
|
|
132
|
-
opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode
|
182
|
+
opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode.',
|
183
|
+
' One of: nested, expanded, compact, compressed') do |style|
|
133
184
|
self.options[:output_style] = style
|
134
185
|
end
|
135
186
|
|
136
|
-
opts.
|
187
|
+
opts.separator ''
|
188
|
+
opts.separator 'General Options:'
|
189
|
+
|
190
|
+
opts.on('-r LIBRARY', '--require LIBRARY', "Require the given ruby LIBRARY before running commands.",
|
191
|
+
" This is used to access compass plugins without having a",
|
192
|
+
" project configuration file.") do |library|
|
137
193
|
::Compass.configuration.require library
|
138
194
|
end
|
139
195
|
|
140
|
-
opts.on('--rails', "Sets the project type to a rails project.") do
|
141
|
-
self.options[:project_type] = :rails
|
142
|
-
end
|
143
|
-
|
144
196
|
opts.on('-q', '--quiet', :NONE, 'Quiet mode.') do
|
145
197
|
self.options[:quiet] = true
|
146
198
|
end
|
@@ -153,11 +205,13 @@ END
|
|
153
205
|
self.options[:trace] = true
|
154
206
|
end
|
155
207
|
|
156
|
-
opts.on('--force', :NONE, 'Force. Allows some commands to succeed
|
208
|
+
opts.on('--force', :NONE, 'Force. Allows some failing commands to succeed instead.') do
|
157
209
|
self.options[:force] = true
|
158
210
|
end
|
159
211
|
|
160
|
-
opts.on('--imports', :NONE, 'Emit an
|
212
|
+
opts.on('--imports', :NONE, 'Emit an imports suitable for passing to the sass command-line.',
|
213
|
+
' Example: sass `compass --imports`',
|
214
|
+
' Note: Compass\'s Sass extensions will not be available.') do
|
161
215
|
print ::Compass::Frameworks::ALL.map{|f| "-I #{f.stylesheets_directory}"}.join(' ')
|
162
216
|
exit
|
163
217
|
end
|
@@ -167,10 +221,6 @@ END
|
|
167
221
|
exit
|
168
222
|
end
|
169
223
|
|
170
|
-
opts.on('--validate', :NONE, 'Validate your project\'s compiled css. Requires Java.') do
|
171
|
-
self.options[:command] = :validate_project
|
172
|
-
end
|
173
|
-
|
174
224
|
opts.on_tail("-?", "-h", "--help", "Show this message") do
|
175
225
|
puts opts
|
176
226
|
exit
|
@@ -180,15 +230,6 @@ END
|
|
180
230
|
self.options[:command] = :print_version
|
181
231
|
end
|
182
232
|
|
183
|
-
opts.on('--grid-img [DIMENSIONS]', 'Generate a background image to test grid alignment. Dimension is given as <column_width>+<gutter_width>. Defaults to 30+10.') do |dimensions|
|
184
|
-
self.options[:grid_dimensions] = dimensions || "30+10"
|
185
|
-
unless self.options[:grid_dimensions] =~ /^\d+\+\d+$/
|
186
|
-
puts "Please enter your dimensions as <column_width>+<gutter_width>. E.g. 20+5 or 30+10."
|
187
|
-
exit
|
188
|
-
end
|
189
|
-
self.options[:command] = :generate_grid_background
|
190
|
-
end
|
191
|
-
|
192
233
|
end
|
193
234
|
|
194
235
|
def do_command(command)
|
@@ -127,12 +127,14 @@ module Compass
|
|
127
127
|
def stylesheet_links
|
128
128
|
html = "<head>\n"
|
129
129
|
manifest.each_stylesheet do |stylesheet|
|
130
|
+
# Skip partials.
|
131
|
+
next if File.basename(stylesheet.from)[0..0] == "_"
|
130
132
|
media = if stylesheet.options[:media]
|
131
133
|
%Q{ media="#{stylesheet.options[:media]}"}
|
132
134
|
end
|
133
135
|
ss_line = %Q{ <link href="/stylesheets/#{stylesheet.to.sub(/\.sass$/,'.css')}"#{media} rel="stylesheet" type="text/css" />}
|
134
|
-
if stylesheet.options[:
|
135
|
-
ss_line = " <!--[if
|
136
|
+
if stylesheet.options[:condition]
|
137
|
+
ss_line = " <!--[if #{stylesheet.options[:condition]}]>\n #{ss_line}\n <![endif]-->"
|
136
138
|
end
|
137
139
|
html << ss_line + "\n"
|
138
140
|
end
|
@@ -13,8 +13,9 @@ module Compass
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
-
def write_configuration_files
|
17
|
-
|
16
|
+
def write_configuration_files(config_file = nil)
|
17
|
+
config_file ||= targetize('config/compass.config')
|
18
|
+
write_file config_file, config_contents
|
18
19
|
write_file targetize('config/initializers/compass.rb'), initializer_contents
|
19
20
|
end
|
20
21
|
|
@@ -8,8 +8,9 @@ module Compass
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def write_configuration_files
|
12
|
-
|
11
|
+
def write_configuration_files(config_file = nil)
|
12
|
+
config_file ||= targetize('config.rb')
|
13
|
+
write_file config_file, config_contents
|
13
14
|
end
|
14
15
|
|
15
16
|
def config_files_exist?
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Compass::SassExtensions::Functions::Display
|
2
|
+
DEFAULT_DISPLAY = {
|
3
|
+
:block => %w{address blockquote center dir div dd dl dt fieldset form
|
4
|
+
frameset h1 h2 h3 h4 h5 h6 hr isindex menu noframes
|
5
|
+
noscript ol p pre ul},
|
6
|
+
:inline => %w{a abbr acronym b basefont bdo big br cite code dfn em
|
7
|
+
font i img input kbd label q s samp select small span
|
8
|
+
strike strong sub sup textarea tt u var},
|
9
|
+
:table => %w{table},
|
10
|
+
:"list-item" => %w{li},
|
11
|
+
:"table-row-group" => %w{tbody},
|
12
|
+
:"table-header-group" => %w{thead},
|
13
|
+
:"table-footer-group" => %w{tfoot},
|
14
|
+
:"table-row" => %w{tr},
|
15
|
+
:"table-cell" => %w{th td}
|
16
|
+
}
|
17
|
+
|
18
|
+
# returns a comma delimited string for all the elements according to their default css3 display value.
|
19
|
+
def elements_of_type(display)
|
20
|
+
Sass::Script::String.new(DEFAULT_DISPLAY.fetch(display.value.to_sym).join(", "))
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Compass::SassExtensions::Functions::ImageUrl
|
2
|
+
def image_url(path)
|
3
|
+
path = path.value # get to the string value of the literal.
|
4
|
+
# Short curcuit if they have provided an absolute url.
|
5
|
+
if absolute_path?(path)
|
6
|
+
puts "#{path} is absolute"
|
7
|
+
return Sass::Script::String.new("url(#{path})")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Compute the path to the image, either root relative or stylesheet relative
|
11
|
+
# or nil if the http_images_path is not set in the configuration.
|
12
|
+
http_images_path = if relative?
|
13
|
+
compute_relative_path
|
14
|
+
else
|
15
|
+
Compass.configuration.http_images_path
|
16
|
+
end
|
17
|
+
|
18
|
+
# Compute the real path to the image on the file stystem if the images_dir is set.
|
19
|
+
real_path = if Compass.configuration.images_dir
|
20
|
+
File.join(Compass.configuration.project_path, Compass.configuration.images_dir, path)
|
21
|
+
end
|
22
|
+
|
23
|
+
# prepend the path to the image if there's one
|
24
|
+
if http_images_path
|
25
|
+
http_images_path = "#{http_images_path}/" unless http_images_path[-1..-1] == "/"
|
26
|
+
path = "#{http_images_path}#{path}"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Compute the asset host unless in relative mode.
|
30
|
+
asset_host = (compute_asset_host(path) unless relative?)
|
31
|
+
|
32
|
+
# Compute and append the cache buster if there is one.
|
33
|
+
if buster = compute_cache_buster(path, real_path)
|
34
|
+
path += "?#{buster}"
|
35
|
+
end
|
36
|
+
|
37
|
+
# prepend the asset host if there is one.
|
38
|
+
path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host
|
39
|
+
|
40
|
+
Sass::Script::String.new("url(#{path})")
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def relative?
|
46
|
+
Compass.configuration.http_images_path == :relative
|
47
|
+
end
|
48
|
+
|
49
|
+
def absolute_path?(path)
|
50
|
+
path[0..0] == "/" || path[0..3] == "http"
|
51
|
+
end
|
52
|
+
|
53
|
+
def compute_relative_path
|
54
|
+
if (target_css_file = options[:css_filename])
|
55
|
+
images_path = File.join(Compass.configuration.project_path, Compass.configuration.images_dir)
|
56
|
+
Pathname.new(images_path).relative_path_from(Pathname.new(File.dirname(target_css_file))).to_s
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def compute_cache_buster(path, real_path)
|
61
|
+
if Compass.configuration.asset_cache_buster
|
62
|
+
args = [path]
|
63
|
+
if Compass.configuration.asset_cache_buster.arity > 1
|
64
|
+
args << (File.new(real_path) if real_path)
|
65
|
+
end
|
66
|
+
Compass.configuration.asset_cache_buster.call(*args)
|
67
|
+
elsif real_path
|
68
|
+
default_cache_buster(path, real_path)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def default_cache_buster(path, real_path)
|
73
|
+
if File.readable?(real_path)
|
74
|
+
File.mtime(real_path).strftime("%s")
|
75
|
+
else
|
76
|
+
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def compute_asset_host(path)
|
81
|
+
if Compass.configuration.asset_host
|
82
|
+
Compass.configuration.asset_host.call(path)
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'base64'
|
2
|
+
module Compass::SassExtensions::Functions::InlineImage
|
3
|
+
|
4
|
+
def inline_image(path, mime_type = nil)
|
5
|
+
path = path.value
|
6
|
+
real_path = File.join(Compass.configuration.project_path, Compass.configuration.images_dir, path)
|
7
|
+
url = "url('data:#{compute_mime_type(path,mime_type)};base64,#{data(real_path)}')"
|
8
|
+
Sass::Script::String.new(url)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def compute_mime_type(path, mime_type)
|
13
|
+
return mime_type if mime_type
|
14
|
+
case path
|
15
|
+
when /\.png$/i
|
16
|
+
'image/png'
|
17
|
+
when /\.jpe?g$/i
|
18
|
+
'image/jpeg'
|
19
|
+
when /\.gif$/i
|
20
|
+
'image/gif'
|
21
|
+
when /\.([a-zA-Z]+)$/
|
22
|
+
"image/#{Regexp.last_match(1).downcase}"
|
23
|
+
else
|
24
|
+
raise Compass::Error, "A mime type could not be determined for #{path}, please specify one explicitly."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def data(real_path)
|
29
|
+
if File.readable?(real_path)
|
30
|
+
Base64.encode64(File.read(real_path)).gsub("\n","")
|
31
|
+
else
|
32
|
+
raise Compass::Error, "File not found or cannot be read: #{real_path}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|