Before version 0.8, Comatose had few options that you could set via the
Comatose::Options class. For everything else, it was expected that you would override methods on the
ComatoseAdminController classes. However, newer versions of Comatose support a more advanced configuration system that lets you configure just about everything in one place.
You'll configure Comatose in your
environment.rb file. Here's an example of the configuration block:
Comatose.configure do |config| # Sets the text in the Admin UI's title area config.admin_title = "Site Content" config.admin_sub_title = "Content for the rest of us..." end
See "Configuration Settings" for a complete listing of the configuration options. Following are a few of the highlights.
At the top of the comatose admin, it says 'Comatose' with a sub-title of 'The Micro CMS'. You can change these values without having to do a complete re-skin by defining these settings:
config.admin_title = "My App's CMS" config.admin_sub_title = "Because size does matter..."
You can tell Comatose what content-type to use. By default, it's set to use 'utf-8'. This should be fine for most uses, but if you are developing an application in a different charset, you can set it like this:
config.content_type = 'iso-8859-1'
Page Tree Expansion
You can also set the default level of expansion on the page tree like this:
config.default_tree_level = 3
By default, it's set to 2 -- which shows the first two levels of pages.
Some configuration settings allow you to attach a block of code to them. You can use these for returning dynamic values.
You can define modules to include in the
ComatoseController by adding to the list of
config.includes. You will have access to the module's code from within the setting blocks and the layout.
config.admin_includes for the
If you need access to certain helpers in the layout(s) Comatose uses, you can add to
Note: These do not add methods, or tags, to a page's content. Just to the layout.
You probably don't want just anybody to add, edit, or delete your comatose pages (Aw CRUD!). The
ComatoseAdminController calls an
#authorize method for every action as a
#authorize method then looks for the
config.admin_authorization block and executes it.
So by defining the
config.admin_authorization setting you can lock down access to the comatose admin.
Comatose.configure do |config| # Includes AuthenticationSystem in the ComatoseAdminController config.admin_includes << :authenticated_system # Calls :login_required as a before_filter config.admin_authorization = :login_required end
Setting the Author
Without modification, Comatose will set the page
author as the
REMOTE_ADDR sent by the browser -- usually an IP address. If you want
it to be something else, it's as simple as defining the
setting. If you've implemented authentication, it could look something
Comatose.configure do |config| # Includes AuthenticationSystem in the ComatoseAdminController config.admin_includes << :authenticated_system # Returns the author name (login, in this case) for the current user config.admin_get_author do current_user.login end end
Customizing The Administration Views
Comatose comes out-of-the-box with a serviceable administration UI. But if you want to modify it so that it will match your application's look-n-feel, it's easy to accomplish because there's a rake task available to help you get started.
$ rake comatose:admin:customize
When you run the task, it will copy the views and layouts it uses into
your application folders (
app/views/layouts/comatose_admin.rhtml) folder, giving you total
control over how it looks and behaves.
Following is a list of all the files it will copy into your application folder structure: