keep cache busting in a single file

This commit is contained in:
tdreyno 2009-10-29 09:43:08 -07:00
parent 71551613c9
commit 33195c84a9
3 changed files with 31 additions and 27 deletions

View file

@ -34,7 +34,7 @@ module Middleman
end
@@afters = []
def self.after(&block)
def self.after_feature_init(&block)
@@afters << block
end

View file

@ -1,3 +1,22 @@
class Middleman::Base
include Middleman::Sass
after_feature_init do
::Compass.configuration do |config|
config.asset_cache_buster do |path, real_path|
# real_path = real_path.gsub(self.build_dir, self.public)
if File.readable?(real_path)
File.mtime(real_path).strftime("%s")
else
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
end
end
end
::Compass.configure_sass_plugin!
end
end
class << Middleman::Base
alias_method :pre_cache_buster_asset_url, :asset_url
def asset_url(path, prefix="", request=nil)

View file

@ -68,33 +68,18 @@ end
class Middleman::Base
include Middleman::Sass
after do
after_feature_init do
::Compass.configuration do |config|
config.project_path = self.root
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
config.output_style = :nested
config.css_dir = File.join(File.basename(self.public), self.css_dir)
config.images_dir = File.join(File.basename(self.public), self.images_dir)
config.add_import_path(config.sass_dir)
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix, self.images_dir)
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix, self.css_dir)
config.asset_cache_buster { false }
if self.cache_buster?
config.asset_cache_buster do |path, real_path|
# real_path = real_path.gsub(self.build_dir, self.public)
if File.readable?(real_path)
File.mtime(real_path).strftime("%s")
else
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
end
end
else
config.asset_cache_buster do
false
end
end
config.add_import_path(config.sass_dir)
end
configure :build do