Sha256: 8f5a7887510e606d6fa8321eb747554421568cb38aaab3b070a56141a089b2fb
Contents?: true
Size: 1014 Bytes
Versions: 2
Compression:
Stored size: 1014 Bytes
Contents
# Allow the metal piece to run in isolation require File.expand_path('../../../config/environment', __FILE__) unless defined?(Rails) # Serves theme files from the theme directory without touching Rails too much module Refinery class ThemeServer def initialize(app) @app = app end def call(env) if env["PATH_INFO"] =~ /^\/theme\/(stylesheets|javascripts|images)/ and (theme = Theme.current_theme(env)).present? env["PATH_INFO"].gsub!(/^\/theme\//, '') if (file_path = (dir = Theme.current_theme_dir).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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-theming-0.9.9 | lib/theme_server.rb |
refinerycms-theming-0.9.8.2 | lib/theme_server.rb |