Sha256: b03a5be961b397be011a7b975604c21b2c16c3f47370cbb134b28acc519470dc

Contents?: true

Size: 1.05 KB

Versions: 31

Compression:

Stored size: 1.05 KB

Contents

# The Cache Buster extension
class Middleman::Extensions::CacheBuster < ::Middleman::Extension
  option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
  option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for bustable assets.'
  option :ignore, [], 'Regexes of filenames to skip adding query strings to'
  option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'

  def initialize(app, options_hash={}, &block)
    super

    app.rewrite_inline_urls id: :cache_buster,
                            url_extensions: options.exts || app.config[:asset_extensions],
                            source_extensions: options.sources,
                            ignore: options.ignore,
                            rewrite_ignore: options.rewrite_ignore,
                            proc: method(:rewrite_url)
  end

  Contract String, Or[String, Pathname], Any => String
  def rewrite_url(asset_path, _dirpath, _request_path)
    asset_path + '?' + Time.now.strftime('%s')
  end
end

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
middleman-core-4.5.1 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.5.0 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.4.3 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.4.2 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.4.0 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.11 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.10 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.8 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.7 lib/middleman-core/extensions/cache_buster.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-core-4.3.3/lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.6 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.5 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.4 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.3 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.2 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.1 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.0 lib/middleman-core/extensions/cache_buster.rb
middleman-core-with-external-sources-watch-fix-4.1.10 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.3.0.rc.1 lib/middleman-core/extensions/cache_buster.rb
middleman-core-4.2.1 lib/middleman-core/extensions/cache_buster.rb