Sha256: 76909eca87aa46be6b514aa35db8d00ef41e56d0e6dd7d4fd937ed7369ca0f23

Contents?: true

Size: 874 Bytes

Versions: 13

Compression:

Stored size: 874 Bytes

Contents

module Hancock::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

13 entries across 13 versions & 1 rubygems

Version Path
hancock_cms-2.0.1.3 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.2.3 app/helpers/hancock/gzip_helper.rb
hancock_cms-2.0.1.2 app/helpers/hancock/gzip_helper.rb
hancock_cms-2.0.1.1 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.2.2 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.1 app/helpers/hancock/gzip_helper.rb
hancock_cms-2.0.0.2 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.0.4 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.0.3 app/helpers/hancock/gzip_helper.rb
hancock_cms-2.0.0.1 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.0.2 app/helpers/hancock/gzip_helper.rb
hancock_cms-2.0.0 app/helpers/hancock/gzip_helper.rb
hancock_cms-1.0.0 app/helpers/hancock/gzip_helper.rb