lib/asset_compiler.rb in vitrine-0.0.18 vs lib/asset_compiler.rb in vitrine-0.0.19
- old
+ new
@@ -25,42 +25,31 @@
# An explicit override for +public_folder+ setting,
# if set will take precedence over the setting
attr_accessor :public_dir
# Try to find SCSS replacement for missing CSS
- get /(.+)\.css$/ do | basename |
- # Return vanilla CSS
- if File.exist?(File.join(get_public, basename + '.css'))
- return send_file(File.join(get_public, basename + '.css'))
- end
-
+ get /(.+)\.css/ do | basename |
begin
# TODO: handle .sass ext as well
scss_source_path = File.join(get_public, "#{basename}.scss")
mtime_cache(scss_source_path)
content_type 'text/css', :charset => 'utf-8'
- Vitrine.compile_sass(scss_source_path, get_public)
+
+ # TODO: Examine http://sass-lang.com/documentation/file.SASS_REFERENCE.html
+ # It already has provisions for error display, among other things
+ Sass.compile_file(scss_source_path, cache_location: '/tmp/vitrine/sass-cache')
rescue Errno::ENOENT # Missing SCSS
forward_or_halt "No such CSS or SCSS file found"
rescue Exception => e # CSS syntax error or something alike
- # Add a generated DOM element before <body/> to inject
- # a visible error message
- error_tpl = 'body:before {
- background: white; padding: 3px; font-family: monospaced; color: red;
- font-size: 14px; content: %s }'
- css_message = error_tpl % [e.class, "\n", "--> ", e.message].join.inspect
- # If we halt with 500 this will not be shown as CSS
- halt 200, css_message
+ # Add a generated DOM element before <body/> to inject
+ # a visible error message
+ error_tpl = 'body:before {
+ background: white; padding: 3px; font-family: monospaced; color: red;
+ font-size: 14px; content: %s }'
+ css_message = error_tpl % [e.class, "\n", "--> ", e.message].join.inspect
+ # If we halt with 500 this will not be shown as CSS
+ halt 200, css_message
end
- end
-
- # Try to find SCSS replacement for missing CSS
- get /(.+)\.css\.map$/ do | basename |
- # TODO: handle .sass ext as well
- scss_source_path = File.join(get_public, "#{basename}.scss")
- mtime_cache(scss_source_path)
- content_type 'application/json', :charset => 'utf-8'
- Vitrine.compile_sass_source_map(scss_source_path, get_public)
end
# Generate a sourcemap for CoffeeScript files
get /(.+)\.js\.map$/ do | basename |
begin