Skip to content

Instantly share code, notes, and snippets.

@jlong
Created May 27, 2010 16:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jlong/416035 to your computer and use it in GitHub Desktop.
Save jlong/416035 to your computer and use it in GitHub Desktop.
http_path = "/"
http_stylesheets_path = "/stylesheets"
http_images_path = "/images"
http_javascripts_path = "/javascripts"
sass_dir = "sass"
css_dir = "public/stylesheets"
images_dir = "public/images"
javascripts_dir = "public/javascripts"
relative_assets = false
#\ -p 4000
gem 'activesupport', '>= 2.3.5' # version required by Serve
gem 'serve', '>= 0.11.6'
require 'serve'
require 'serve/rack'
require 'sass/plugin/rack'
require 'compass'
# The project root directory
root = ::File.dirname(__FILE__)
# Compass
Compass.add_project_configuration(root + '/compass.config')
Compass.configure_sass_plugin!
# Middleware
use Rack::ShowStatus # Nice looking 404s and other messages
use Rack::ShowExceptions # Nice looking errors
use Sass::Plugin::Rack # Compile Sass on the fly
# Rack Application
if ENV['SERVER_SOFTWARE'] =~ /passenger/i
# Passenger only needs the adapter
run Serve::RackAdapter.new(root + '/views')
else
# We use Rack::Cascade and Rack::Directory on other platforms to
# handle static assets
run Rack::Cascade.new([
Serve::RackAdapter.new(root + '/views'),
Rack::Directory.new(root + '/public')
])
end

This assumes the following directory structure:

project/
  |
  +-- config.ru
  |
  +-- compass.config
  |
  +-- public/
  |    |
  |    +-- stylesheets/
  |    |
  |    +-- images/
  |    |
  |    +-- javascripts/
  |
  +-- sass/
  |
  +-- tmp/
  |
  +-- views/
@jlong
Copy link
Author

jlong commented May 27, 2010

This assumes the following directory structure:

project/
  |
  +-- config.ru
  |
  +-- compass.config
  |
  +-- public/
  |    |
  |    +-- stylesheets/
  |         |
  |         +-- sass/
  |
  +-- tmp/
  |
  +-- views/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment