Sha256: 594107eb0323d04d2166fc91f0a3b8bb5d0d85279a26f4709444e5aad8276e55
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
MyApp.class_eval do set :sprockets, Sprockets::Environment.new(root) set :assets_prefix, '/assets' set :assets_digest, true configure do sprockets.append_path File.join(root, 'app', 'assets', 'stylesheets') sprockets.append_path File.join(root, 'app', 'assets', 'javascripts') #sample config for compression #sprockets.js_compressor = Uglifier.new #sprockets.css_compressor = YUI::CssCompressor.new end helpers do def javascript_path(path) path << ".js" if File.extname(path).empty? asset_path(path) end def stylesheet_path(path) path << ".css" if File.extname(path).empty? asset_path(path) end def asset_path(path) return path if path.match %r!^(?:https?:)//! asset = settings.sprockets.find_asset(path) raise "asset not found for '#{path}'" unless asset basename = settings.assets_digest ? asset.digest_path : asset.logical_path File.join(settings.assets_prefix, basename) end end get "#{settings.assets_prefix}/*" do path = params[:splat].last.sub(%r!^/!, "") if digest = path[/-[0-9a-f]+\./] path.sub!(digest, ".") expires 8640000, :public end asset = settings.sprockets.index.find_asset path halt 404, "asset not found '#{path}'" unless asset content_type File.extname(path) asset end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hisyo-0.2.0 | data/generators/assistance/sprockets/app/sprockets.rb |