lib/sinatra/assetpack/class_methods.rb
# Add the routes for the individual files.
Add the routes for the individual files.
Add the routes for the individual files .
def add_individual_routes!
        assets.served.each do |path, from|
          get %r{#{"^/#{path}/".squeeze('/')}(.*)$} do |file|
            fmt = File.extname(file)[1..-1]
            pass unless AssetPack.supported_formats.include?(fmt)
            fn = asset_path_for(file, from)  or pass
            pass  if settings.assets.ignored?("#{path}/#{file}")
            content_type fmt.to_sym
            last_modified File.mtime(fn).to_i
            expires 86400*30, :public
            format = File.extname(fn)[1..-1]
            if AssetPack.supported_formats.include?(format)
              not_found  unless format == fmt
              if fmt == 'css'
                @template_cache.fetch(fn) { asset_filter_css File.read(fn) }
              else
                send_file fn
              end
            else
              not_found unless AssetPack.tilt_formats[format] == fmt
              @template_cache.fetch(fn) {
                out = render format.to_sym, File.read(fn)
                out = asset_filter_css(out)  if fmt == 'css'
                out
              }
            end
          end
        end
      end
def add_individual_routes! assets . served . each do | path , from | get %r{ #{ "^/#{path}/" . squeeze ( '/' ) } (.*)$ } do | file | fmt = File . extname ( file ) [ 1 .. - 1 ] pass unless AssetPack . supported_formats . include? ( fmt ) fn = asset_path_for ( file , from ) or pass pass if settings . assets . ignored? ( "#{path}/#{file}" ) content_type fmt . to_sym last_modified File . mtime ( fn ) . to_i expires 86400 * 30 , :public format = File . extname ( fn ) [ 1 .. - 1 ] if AssetPack . supported_formats . include? ( format ) not_found unless format == fmt if fmt == 'css' @template_cache . fetch ( fn ) { asset_filter_css File . read ( fn ) } else send_file fn end else not_found unless AssetPack . tilt_formats [ format ] == fmt @template_cache . fetch ( fn ) { out = render format . to_sym , File . read ( fn ) out = asset_filter_css ( out ) if fmt == 'css' out } end end end end
Add the routes for the individual files.
Add the routes for the individual files .
# Sanity checks # Send headers # It's a raw file, just send it # Dynamic file