Sha256: c2e5f6cd022e3635ac0764930a292d04d0b9709c5c6ca2b99b2a005571c67d47
Contents?: true
Size: 1014 Bytes
Versions: 1
Compression:
Stored size: 1014 Bytes
Contents
module RhetButler module Web class AssetsApp def initialize(file_manager) @template_handler = file_manager.base_assets end attr_reader :template_handler class AssetsContext def render(path, locals = nil) template = @template_handler.find(path).contents if template.respond_to? :render template.render(self, locals) else template end end end def assets_context @context ||= begin context = AssetsContext.new context.instance_variable_set("@template_handler", template_handler) context end end def call(env) asset_path = env["PATH_INFO"] asset_path.sub!(/^\//,"") extension = asset_path.sub(/.*[.]/, ".") mime_type = Rack::Mime.mime_type(extension, "text/plain") [200, {'Content-Type' => mime_type}, [assets_context.render(asset_path)]] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rhet-butler-0.5.0 | lib/rhet-butler/web/assets-app.rb |