public
Description: Cheap Themes adds dead easy theming support for Rails views and also a way of customizing controller actions on per-theme basis.
Homepage: http://hubertlepicki.com/pages/cheap-themes
Clone URL: git://github.com/hubertlepicki/cheap-themes.git
name age message
file .gitignore Sat Dec 06 07:20:08 -0800 2008 Added .DS_Store entry to ignoring [hubertlepicki]
file MIT-LICENSE Mon Dec 01 06:20:01 -0800 2008 First version of theme support added [hubertlepicki]
file README Sat Apr 04 10:10:28 -0700 2009 Readme updated, thanks vdbit [hubertlepicki]
file init.rb Mon Dec 01 06:20:01 -0800 2008 First version of theme support added [hubertlepicki]
file install.rb Mon Dec 01 06:20:01 -0800 2008 First version of theme support added [hubertlepicki]
directory lib/ Sun Apr 05 03:28:26 -0700 2009 One more regexp fix [hubertlepicki]
directory spec/ Sat Apr 04 11:10:02 -0700 2009 Regexp changed to allow numbers as theme names [hubertlepicki]
directory tasks/ Mon Dec 01 06:20:01 -0800 2008 First version of theme support added [hubertlepicki]
file uninstall.rb Mon Dec 01 06:20:01 -0800 2008 First version of theme support added [hubertlepicki]
README
CheapThemes
===========

This plugin provides easy view themes support and customizable controller actions for Rails applications.

Installation
------------

First, grab a copy of plugin from repository:

    ./script/plugin install git://github.com/hubertlepicki/cheap-themes.git

Usage
-----

### Theming views

To allow theming of views, include following line in your controller:

    class ExampleController
      has_themable_views :find_view_theme
      ....
    end

and define "find_view_theme" method in the same controller or any of parent ones that returns a String which is a theme 
name:
    
    class ExampleController
      has_themable_views :find_view_theme
     
      ....
 
      private 
      def find_view_theme
        "green"
      end
    end

Of course, instead of "find_view_theme" you can use your own name.

Now, if you want to customize index.html.erb view file, create file 
"RAILS_ROOT/themes/green/views/example/index.html.erb". It's content will be used instead of standard 
"RAILS_ROOT/app/views/example/index.html.erb".

This also works with layouts, so if you want to customize "default.html.erb" layout, just create file 
"RAILS_ROOT/themes/green/views/layouts/default.html.erb".

### Customizing actions

If you want to customize ExampleController::index action, create file 
"RAILS_ROOT"/themes/green/controllers/example/index.rb" with customized code, for example:

render :text => "This is customized action"

And add in your controller:

    class ExampleController
      has_customizable_actions :find_action_theme
     
      ....
 
      private 
      def find_action_theme
        "green"
      end
    end

General notes
-------------

Of course you can have multiple multiple themes.

In development mode, customized controller actions are reloaded on every request. In production mode, customized 
controller actions are loaded only once (at first request) and then cached methods are used.

Bugs and requests
=================

Please use Github to fork and submit merge requests or email me and patches.

Please also feel free to send me a message over Github or email at hubert.lepicki at gmail.com with questions, comments 
or criticism ;).


Copyright (c) 2008 Hubert Lepicki, released under the MIT license