Module: Sinatra::ZeroClipboard::Assets

Defined in:
lib/sinatra/zero_clipboard/assets.rb

Constant Summary collapse

ASSETS =
{
  development: {
    swf: { "ZeroClipboard.swf" => "2fa578220e56ec9d382e26e2dbb82ad0b9550ac2" },
    js: { "ZeroClipboard.js" => "e3f0c042f93fe9aeaa570ba09e774a308681f2ed" }
  },
  production: {
    swf: { "ZeroClipboard.swf" => "2fa578220e56ec9d382e26e2dbb82ad0b9550ac2" },
    js: { "ZeroClipboard.min.js" => "20699686261a143ba1972b18a3ef3f0b3dbcd95c" }
  }       
}

Class Method Summary collapse

Class Method Details

.generate_zero_clipboard_asset_routes(application) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sinatra/zero_clipboard/assets.rb', line 18

def generate_zero_clipboard_asset_routes(application)
  ASSETS[application.settings.environment].each do |file_type, files|
    files.each_pair do |file_name, sha1_checksum|
      application.get "/#{file_type}/#{file_name}", :provides => file_type do
        cache_control :public, :must_revalidate, :max_age => 3600
        etag sha1_checksum

        File.read(File.join(Gem.datadir("sinatra-zero_clipboard"), "assets", file_name))
      end
    end
  end
end

.registered(application) ⇒ Object



31
32
33
34
# File 'lib/sinatra/zero_clipboard/assets.rb', line 31

def registered(application)
  generate_zero_clipboard_asset_routes(application)
  application.helpers AssetsHelper
end