Sha256: bb9f850705c5be4de95267e9f5e661f5cde5c8897b74c5d82ec19158dff34d63

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

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)
    http_path = pre_cache_buster_asset_url(path, prefix, request)
    
    if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path))
      http_path
    else
      begin
        prefix = self.images_dir if prefix == self.http_images_path
      rescue
      end
      
      real_path = File.join(self.public, prefix, path)
      http_path << "?" + File.mtime(real_path).strftime("%s") if File.readable?(real_path)
      http_path
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
middleman-0.10.12 lib/middleman/features/cache_buster.rb
middleman-0.10.11 lib/middleman/features/cache_buster.rb
middleman-0.10.10 lib/middleman/features/cache_buster.rb
middleman-0.10.9 lib/middleman/features/cache_buster.rb
middleman-0.10.8 lib/middleman/features/cache_buster.rb
middleman-0.10.7 lib/middleman/features/cache_buster.rb
middleman-0.10.6 lib/middleman/features/cache_buster.rb
middleman-0.10.5 lib/middleman/features/cache_buster.rb
middleman-0.10.4 lib/middleman/features/cache_buster.rb
middleman-0.10.3 lib/middleman/features/cache_buster.rb
middleman-0.10.2 lib/middleman/features/cache_buster.rb
middleman-0.10.1 lib/middleman/features/cache_buster.rb