Sha256: 82668f3c796e2fa1c44cb2d7e9be0cdb64df1b79b77570c2b98dd503d110623a
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
module Middleman::Features::CacheBuster class << self def registered(app) app.register_asset_handler :cache_buster do |path, prefix, request| http_path = app.before_asset_handler(:cache_buster, path, prefix, request) if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path)) http_path else begin prefix = app.images_dir if prefix == app.http_images_path rescue end real_path_static = File.join(app.views, prefix, path) if File.readable?(real_path_static) http_path << "?" + File.mtime(real_path_static).strftime("%s") elsif app.environment == :build real_path_dynamic = File.join(app.root, app.build_dir, prefix, path) http_path << "?" + File.mtime(real_path_dynamic).strftime("%s") if File.readable?(real_path_dynamic) end http_path end end app.after_feature_init do ::Compass.configuration do |config| config.asset_cache_buster do |path, real_path| real_path = real_path.path if real_path.is_a? File real_path = real_path.gsub(File.join(app.root, app.build_dir), app.views) 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 end end alias :included :registered end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-2.0.0.rc1 | lib/middleman/features/cache_buster.rb |