= disguise A simple theme system for your Rails application. == Note All disguise versions with 3.x.x will work with Rails 3 but not with Rails 2. Rails to compatible versions are labeled with 2.x.x and are available on the Rails2 branch. The disguise master branch is now focused on Rails3 development. == Installation sudo gem install disguise Add disguise to your Gemfile: gem 'disguise' == Setup Disguise comes with a couple of admin controllers to make changing your theme simple. By default they are not protected. In order to prevent unauthorized users from changing your theme you can override the admin controller like this: class Admin::ThemesController < Admin::Disguise::ThemesController before_filter :login_required layout('admin') end class Admin::DomainThemesController < Admin::Disguise::DomainThemesController before_filter :login_required layout('admin') end Also be sure to add a route to the new controller in routes.rb: Rails.application.routes.draw do namespace "admin" do resources :theme resources :domain_themes end end === Create an initializer to configure disguise Disguise can run in two modes. The first is the default which let's an administrator set the current theme via the built in admin interface. The second looks at the url of the incoming request and matches it to a theme. The default settings are fine for most uses but if you'd like to customize disguise then create an initializer in /config/initializers/disguise.rb and enter the following contents: Disguise.configure do |config| config.use_domain_for_themes = false # Changing theme per domain can be expense so it's off by default config.themes_enabled = true # Turns disguise off/on. config.theme_full_base_path = File.join(::Rails.root.to_s, 'themes') # Full path to the themes folder. The examples puts themes in a directory called 'themes' in the Rails app root. end === Rake tasks Disguise provides a rake task for syncing the required files into your application. After include disguise do this: rake disguise:sync rake db:migrate == Usage Generate a new theme for your Rails application using the built in theme generator: ./script/generate theme theme_name == Notes After installing Disguise be sure to generate a theme and set that theme as the default theme. Not setting a theme will result in the application continually resetting the current theme which can cause serious performance problems. == Copyright Copyright (c) 2009-2010 Tatemae.com. See LICENSE for details.