Sha256: 0625fe0db07fdc37256d9a8ed703439fc3ac0081ab74cf90a0d501820ea7f014

Contents?: true

Size: 870 Bytes

Versions: 16

Compression:

Stored size: 870 Bytes

Contents

module Enjoy::GzipHelper
  def gzip_javascript_include_tag(*sources)
    # Grab the asset html include tag
    tag = javascript_include_tag *sources

    # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
    if Rails.env.production? && request.accept_encoding =~ /gzip/i
      tag = tag.gsub(/\.js/i, ".js.gz")
    end

    # Return the asset whether or not it was modified
    tag.html_safe
  end

  def gzip_stylesheet_link_tag(*sources)
    # Grab the asset html include tag
    tag = stylesheet_link_tag *sources

    # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
    if Rails.env.production? && request.accept_encoding =~ /gzip/i
      tag = tag.gsub(/\.css/i, ".css.gz")
    end

    # Return the asset whether or not it was modified
    tag.html_safe
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
enjoy_cms-0.3.2.1 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.2 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.1.2 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.1.1 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.1 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.0.4 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.0.3 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.3.0.2 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.1 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.0.3.2 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.0.3.1 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.0.3 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.0.2 app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.0.1.beta app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.2.0.beta app/helpers/enjoy/gzip_helper.rb
enjoy_cms-0.1.0.beta1 app/helpers/enjoy/gzip_helper.rb