Sha256: 6258bf25ec39232dc15ac16b0e6b54ba87de7e74b4119b8c80eccc14a4e7b272

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Perkins
  class Assets < Sinatra::Base

    require "haml_coffee_assets"
    configure do
      set :assets, (Sprockets::Environment.new { |env|
        env.append_path(settings.root + "/assets/images")
        env.append_path(settings.root + "/assets/javascripts")
        env.append_path(settings.root + "/assets/stylesheets")
        # compress everything in production
        if ENV["RACK_ENV"] == "production"
          #require "yui/compressor"
          #env.js_compressor  = YUI::JavaScriptCompressor.new
          #env.css_compressor = YUI::CssCompressor.new
        end
      })
    end

    get "/assets/app.js" do
      content_type("application/javascript")
      settings.assets["app.js"]
    end

    get "/assets/app.css" do
      content_type("text/css")
      settings.assets["app.css"]
    end

    %w{jpg png gif}.each do |format|
      get "/assets/:image.#{format}" do |image|
        content_type("image/#{format}")
        settings.assets["#{image}.#{format}"]
      end
    end

    get "/assets/:image.svg" do |image|
      content_type("image/svg+xml")
      settings.assets["#{image}.svg"]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
perkins-0.0.5 lib/perkins/assets.rb