Sha256: 5550206bbf941e8726c3d9bf61e2a37d8e93f079e0b1b7b202975aa09157c13f

Contents?: true

Size: 862 Bytes

Versions: 8

Compression:

Stored size: 862 Bytes

Contents

module 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

8 entries across 8 versions & 1 rubygems

Version Path
ack_rocket_cms-0.9.2 app/helpers/gzip_helper.rb
ack_rocket_cms-0.9.1.3 app/helpers/gzip_helper.rb
ack_rocket_cms-0.9.1.2 app/helpers/gzip_helper.rb
ack_rocket_cms-0.9.1.1 app/helpers/gzip_helper.rb
ack_rocket_cms-0.9.1 app/helpers/gzip_helper.rb
ack_rocket_cms-0.9 app/helpers/gzip_helper.rb
ack_rocket_cms-0.8.2 app/helpers/gzip_helper.rb
ack_rocket_cms-0.8.0 app/helpers/gzip_helper.rb