Sha256: 2ff6c8460a1829e2e6c80aeb03ae8fbb44dd575516f7b5210b483baa281298cd
Contents?: true
Size: 872 Bytes
Versions: 2
Compression:
Stored size: 872 Bytes
Contents
# Serves theme files from the theme directory without touching Rails. 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-1.0.1 | lib/refinery/theme_server.rb |
refinerycms-theming-1.0.0 | lib/refinery/theme_server.rb |