Giter Club home page Giter Club logo

hassle's Introduction

What is this?

A fork of Hassle with a couple fixes backported from the jasoncodes branch.

Run hassle even in development mode: https://github.com/jasoncodes/hassle/commit/971f2db580871602f93ce47b5ae1f53898a7fb0d
Only normalize template_location once: https://github.com/jasoncodes/hassle/commit/b6a359e198c90adf944c39c5f659685235cd46f1


h1. Hassle

Making SASS less of a hassle on read only filesystems like Heroku.

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" />

You can also set your template location as a hash. This is recommended if you store your sass outside of public/stylesheets/sass:

Sass::Plugin.options[:template_location] = {'app/sass' => 'public/stylesheets', 'app/sass/print' => 'public/stylesheets/dead_trees'}

And after Hassle runs…

$ tree
.
|-- config.ru
|-- app
|   `-- sass
|       `-- main
|           `-- screen.sass
|       `-- print
|           `__ black_and_white.sass
`-- tmp
    `-- hassle
        `-- main
            `-- screen.css
        `-- dead_trees
            `__ black_and_white.sass

Include this in your views with:

<link href="/main/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. 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.

hassle's People

Contributors

qrush avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.