Agile Web Development

Build it. Launch it. Love it.

Simple RCSS

This plugin provides support for RCSS templates to the rails application environment. These operate the same as standard CSS files, but also allow the addition of Erb within the file.

Installation

Add this to config/routes.rb: map.rcss ‘stylesheets/:rcss.css’, :controller => ‘stylesheets’, :action => ‘rcss’

Usage

RCSS files are placed in:

$app_root

  views/
    stylesheets/
      stylesheet_1.rcss
      stylesheet_2.rcss

When run in production mode, it will automatically cache the stylesheets so that the web-server will deliver them in subsequent requests.

It bears noting that this will mean your apache/fcgi process will need write permissions. This could be a possible security vulnerability.

With that in mind, it is best to pre-cache all of the stylesheets by using the included rake tasks:

  $ rake rcss:create_cache

The stylesheet cache generates the following file structure:

  $app_root
    public/
      stylesheets/
        stylesheet_1.css
        stylesheet_2.css

There are other rake tasks available:

  - rcss:create_cache
  - rcss:remove_cache
  - rcss:update_cache
  - rcss:from_css

**NOTE: If you have any files in public/stylesheets/ which do not originate from app/views/stylesheets, you will lose them if you use rcss_remove_cache and rcss_update_cache. The safest thing to do is manage all your stylesheets in app/views/stylesheets. You can migrate over existing stylesheets using

  $ rake rcss:from_css

There is a task to generate stylesheets for you:

  ./script/generate stylesheet Application

Which will create:

  $app_root
    app/
      views/
        stylesheets/
          application.rcss

You can also call certain stylesheets using :defaults from within the stylesheet_link_tag helper:

  stylesheet_link_tag :defaults

This will automatically include an application.rcss as well as (controller.controller_name).rcss if they exist.


Copyright © 2006 Chris Abad, based on code from Josh Susser http://blog.hasmanythrough.com/articles/2006/03/23/dirt-simple-rcss-templates released under the MIT license

Vitals

Home http://blog.integralimpressions.com/articles/2006/08/20/simplercss-plugin
Repository http://svn.integralserver.com/plugins/simple_rcss
License Rails' (MIT)
Rating (1 vote)
Owner Chris Abad
Created 21 August 2006

Comments

  • ed
    15 June 2008

    home page is not found, and the svn repo is password protected. where else can I get this plugin?

Add a comment