lib/asset_compiler.rb in vitrine-0.0.24 vs lib/asset_compiler.rb in vitrine-0.0.25

- old
+ new

@@ -40,18 +40,19 @@ content_type 'text/css', :charset => 'utf-8' Vitrine.compile_sass(scss_source_path, get_public) 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 + cache_bust! + # 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 | @@ -94,18 +95,22 @@ rescue Errno::ENOENT # Missing CoffeeScript forward_or_halt "No such JS file and could not find a .coffee replacement" rescue Exception => e # CS syntax error or something alike # Ensure the response with the exception gets reloaded on next request - response.headers['Cache-Control'] = 'private' - response.headers['Pragma'] = 'no-cache' - response.headers.delete('ETag') + cache_bust! # Inject the syntax error into the browser console console_message = 'console.error(%s)' % [e.class, "\n", "--> ", e.message].join.inspect # Avoid 500 because it plays bad with LiveReload halt 200, console_message end + end + + def cache_bust! + response.headers['Cache-Control'] = 'private' + response.headers['Pragma'] = 'no-cache' + response.headers.delete('ETag') end def mtime_cache(path) # Mix in the request URL into the cache key so that we can hash # .map sourcemaps and .js compiles based off of the same file path