Sha256: 5d3aa6a15f0f303adb1a56f83ce84b14d13f584fcb86a81d737153994b17a6a0

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module RailsAppcache
  module ApplicationHelper
    def appcache_manifest_path(path)
      return "" unless RailsAppcache.config.perform_caching?

      "/#{path}-#{appcache_version_string}.appcache"
    end

    # In development, serve up a new manifest every time
    # In production, serve the current Git revision
    def appcache_version_string

      if Rails.env.development?
        Rails.application.config.assets.version
      else
        # Use the REVISION file left in root from capistrano
        if File.exists?(Rails.root.join('REVISION'))
          File.read(Rails.root.join('REVISION'))
        else
          `git rev-parse HEAD`
        end
      end
    end

    def stylesheet_cache_path(*paths)
      tags = stylesheet_link_tag(*paths)
      tags.scan(/href="(.*?)"/).map do |match|
        match[0].html_safe
      end.join("\n")
    end

    def javascript_cache_path(*paths)
      tags = javascript_include_tag(*paths)
      tags.scan(/src="(.*?)"/).map do |match|
        match[0].html_safe
      end.join("\n")
    end

    def asset_cache_path(path)
      asset_path(path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_appcache-0.0.4 lib/rails_appcache/application_helper.rb