Sha256: 9bc1df109c62994dbd6edbe53b39c712ea05b91ede38832ec241990dc0f803ee

Contents?: true

Size: 1009 Bytes

Versions: 2

Compression:

Stored size: 1009 Bytes

Contents

module RailsAppcache
  module ApplicationHelper
    def appcache_manifest_path(path)
      "/#{path}.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?
        Time.now.to_i.to_s
      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

2 entries across 2 versions & 1 rubygems

Version Path
rails_appcache-0.0.2 lib/rails_appcache/application_helper.rb
rails_appcache-0.0.1 lib/rails_appcache/application_helper.rb