Sha256: f239ce4c95122f92d7b06a9e18b1a9754516848fb54153665df5a964abf5bd33
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
# Allow the metal piece to run in isolation require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) # Serves theme files from the theme directory without touching Rails too much class ThemeServer def initialize(app) @app = app end def call(env) theme = Theme.current_theme(env) if env["PATH_INFO"] =~ /^\/theme/ env["PATH_INFO"].gsub!(/^\/theme\//, '') if (file_path = (dir = Rails.root.join("themes", theme)).join(env["PATH_INFO"])).exist? etag = Digest::MD5.hexdigest("#{file_path.to_s}#{file_path.mtime}") unless (etag == env["HTTP_IF_NONE_MATCH"]) status, headers, body = Rack::File.new(dir).call(env) [status, headers.update({"ETag" => etag}), body] else [304, {"ETag" => etag}, []] end else [404, {}, []] end else @app.call(env) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-0.9.6.21 | vendor/plugins/themes/lib/theme_server.rb |