Skip to content

jasoncodes/hassle

master
Switch branches/tags
Code
This branch is 16 commits ahead, 6 commits behind koppen:master.
Contribute

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Hassle

Making Sass less of a hassle on read only filesystems. (like Heroku)

IMPORTANT: This is for rails 3. If you want hassle for rails 2, then you should use the original one

Install

Get it from Gemcutter.

gem install hassle -s http://gemcutter.org

Usage

By default, Sass compiles CSS into the public/ directory. On platforms like Heroku, this won’t work. Instead, Hassle compiles the Sass for you into tmp/ and serves it up via a Rack::Static middleware.

Hassle assumes a few basic things about your setup: There’s going to be a tmp/ directory where it can write to, and public/ is where you store your css. A simple example:

$ tree
.
|-- config.ru
|-- public
|   `-- stylesheets
|       `-- sass
|           `-- application.sass
`-- tmp
    `-- hassle
        `-- stylesheets
            `-- application.css

With a basic Sass file in public/stylesheets/sass/application.sass, you can include it in your views with:

<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />

Hassle will look at the default sass directory (public/stylesheets/sass) and other input directories given in Sass::Plugin.options[:template_location]. CSS files are then compiled into tmp/ one directory higher than where you specified. Here’s a small example of customization:

Sass::Plugin.options[:template_location] = "./public/css/templates"

And after Hassle runs…

$ tree
.
|-- config.ru
|-- public
|   `-- css
|       `-- templates
|           `-- screen.sass
`-- tmp
    `-- hassle
        `-- css
            `-- screen.css

Include this in your views with:

<link href="/css/screen.css" media="screen" rel="stylesheet" type="text/css" />

Integration

Here’s how to integrate it with your favorite web framework:

Rails

For Rails: script/plugin install git://github.com/pedro/hassle. Done. Once you’re in production mode, Hassle will kick in and prepare your Sass for all to enjoy.

Sinatra

Here’s a sample config.ru that’s up and running.

require 'sinatra'
require 'hassle'
require 'haml'

get '/' do
  haml <<EOF
%html
  %head
    %link{:rel => 'stylesheet', :href => "stylesheets/application.css"}
  %body
    %h1 Hassle!
EOF
end

use Hassle
run Sinatra::Application

And its wonderful Sass file:

$ cat public/stylesheets/sass/application.sass 
h1
  font-size: 11em
  color: purple

Bugs

Found some problems? Post ’em in Issues.

License

Hassle uses the MIT license. Please check the LICENSE file for more details.

About

HTTP Caching Sass for your leisure (?) This fork will work with rails 3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%