Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Misc optimizations to run on a pure ruby server

  • Loading branch information...
commit 38c6d2e09aae84ef1b829ad43104d3e4e53a390b 1 parent d3d7161
@oz authored
Showing with 17 additions and 11 deletions.
  1. +2 −2 app/actions/home.rb
  2. +4 −0 application.rb
  3. +11 −9 config.ru
View
4 app/actions/home.rb
@@ -10,8 +10,8 @@ def start
def haml(template)
# Template paths
- tpl_path = Printer::Application.root + "/app/views/#{ template }.haml"
- layout_path = Printer::Application.root + "/app/views/layout.haml"
+ tpl_path = Printer::Application.views + "/#{ template }.haml"
+ layout_path = Printer::Application.views + "/layout.haml"
# Read files
tpl_data = File.read(tpl_path)
View
4 application.rb
@@ -8,6 +8,10 @@ def self.root(path = nil)
path ? File.join(@_root, path.to_s) : @_root
end
+ def self.views
+ self.root 'app/views'
+ end
+
def self.env
@_env ||= ENV['RACK_ENV'] || 'development'
end
View
20 config.ru
@@ -8,17 +8,19 @@ if Printer::Application.env == 'development'
# Enable code reloading on every request
use Rack::Reloader, 0
+end
- # Serve assets from /public
- use Rack::Static,
- :urls => ["/js", "/css"],
- :root => Printer::Application.root(:public)
+if Printer::Application.env == 'production'
+ use Rack::Cache,
+ :verbose => ENV['RACK_ENV'] == 'development',
+ :metastore => "file:#{Printer::Application.root}/tmp/cache/rack/meta",
+ :entitystore => "file:#{Printer::Application.root}/tmp/cache/rack/body"
end
-#require 'rack/cache'
-#use Rack::Cache,
-# :verbose => ENV['RACK_ENV'] == 'development',
-# :metastore => "file:#{PRINTER_ROOT}/tmp/cache/rack/meta",
-# :entitystore => "file:#{PRINTER_ROOT}/tmp/cache/rack/body"
+# Serve assets from /public
+# XXX not using a proxy to serve these is kinda bad y'know.
+use Rack::Static,
+ :urls => ['/js', '/css'],
+ :root => Printer::Application.root(:public)
run Printer::Application.routes
Please sign in to comment.
Something went wrong with that request. Please try again.