Saturday, July 1, 2006

Comatose, a Micro CMS Plugin

Features:

  • Easy to install—It’s a Rails plugin
  • Light-weight—It only adds one table to your schema (and has a generator to create the migration for you)
  • Runs entirely from the plugin folder by default
  • Intelligent page caching
  • Easy to leverage throughout your application
  • Full administration UI that can be re-skinned
  • Supports Textile filtering
  • Simple ‘mounting’ of the cms root path in your routes.rb file
  • Easy to wrap content in a Rails layout
  • It’s not meant to be a feature-complete CMS system. If this bugs you… Well, you should look into something like Radiant
  • No versioning support
  • No page status, all pages are ‘live’

Lately, I’ve had a recurring issue arise on my projects: They generally require a few content pages. Nothing fancy. Just a privacy policy, terms & conditions, an FAQ, that kind of thing.

I don’t really want to make these static HTML pages. They are likely to change at some point, especially the FAQ. Plus, I’d like to have them leverage Rails’ layout support. At the very least, I’d like to have them easy to re-skin.

That said, I don’t want to spend the time integrating an actual CMS system into the application. And really, for just a few pages, it’s too much.

I wanted an easier way. Something that was tiny, simple, and lightweight. Something I could drop into existing applications. In short; a micro CMS plugin.

They say necessity is the mother of invention, although I’ve often thought laziness is… But that’s a different post altogether. The point is, I wound up building something to suit my needs—perhaps it’ll suit yours as well.

I call it Comatose.

Comatose? What a Horrible Name!

Yeah, probably so. I just wanted something unique with the letters CMS in it. Comatose is the first one I thought of.

Features

  • Easy to install—It’s a Rails plugin
  • Light-weight—It only adds one table to your schema (and has a generator to create the migration for you)
  • Runs entirely from the plugin folder by default
  • Intelligent page caching
  • Easy to leverage throughout your application
  • Full administration UI that can be re-skinned
  • Supports Textile filtering
  • Simple ‘mounting’ of the cms root path in your routes.rb file
  • Easy to wrap content in a Rails layout
  • It’s not meant to be a feature-complete CMS system. If this bugs you… Well, you should look into something like Radiant
  • No versioning support
  • No page status, all pages are ‘live’

Installation  

Quite simple. Just run the following in your console, at your application’s root folder:

./script/plugin source http://mattmccray.com/svn/rails/plugins
./script/plugin install comatose
./script/generate comatose_migration
rake migrate

Comatose is now installed and setup.

Usage

To enable it in to your application, just add a line to your config/routes.rb file:

map.comatose_root '/pages'

That’s it! Now, whenever you visit http://your-app-url/pages it will render your cms pages.

Have a look at the README for more.

Feedback

Feel free to use Comatose. I’ve released it, at this point, under the MIT license. Which basically means you can use it however you want.

If you like it, hate it, or have some ideas for new features, let me know! ( darthapo at gmail dot com )

10 comments:

  1. This looks really nice (and really lightweight -- in the best possible way!). I'll try it out tomorrow. Thank you for sharing it. - Scott

    ReplyDelete
  2. Nice & Light!!! I will try out out during the week. Do you mind posting screenshots of the admin page?

    ReplyDelete
  3. I've written something similar that I use on several sites. Has almost the exact same feature set. Call the CMS Simplist. I'll have to consider turning it into a plugin.

    ReplyDelete
  4. Scott, Muyiwa: Thanks, I look forward to hearing what you think about it.
    Larry: It's funny, I was surprised there wasn't already a plugin like this out there -- it's a pretty common problem. It was pretty straight-forward to plugin-ize.

    ReplyDelete
  5. [...] If you’re not sure what Comatose is, you can read my last post on it for the background. [...]

    ReplyDelete
  6. Uh... Yeah, as the bizarre self-pingback (ping-back-back?) implies, there's an update to Comatose. You might wanna check it out.

    ReplyDelete
  7. After installing when I go to:http://localhost:3000/comatose
    I get:
    You have a nil object when you didn't expect it!
    The error occured while evaluating nil.updated_on
    2: # - page (Page Node)
    3: # - level (integer indicating current tree depth)
    4: # Called From:
    5: # - index
    6: # Description:
    7: # This partial is used recursively. Render it with the root node, and it will recurse
    8: # down all of the child nodes to build a list with proper indentation to indicate
    Trace of template inclusion: /vendor/plugins/comatose/views/comatose/index.rhtml

    ReplyDelete
  8. Hmmm... Did the migration run successfully? Did it say it created the Home Page for you?

    ReplyDelete
  9. I did see the message. I checked the database and there were no rows in the table. So I took the create call and pasted into the Rails console and I got a RedCloth error. I installed RedCloth via the gem and re-ran the create call in the console. Everything is happy now.
    Can you put a check in the migration to display an error if RedCloth is not installed?

    ReplyDelete
  10. You know, I wondered about that -- But I had a hard time imagining anyone who didn't have RedCloth installed! jk ;-)
    Thanks for the heads-up. I checked in a version that includes RedCloth, so this shouldn't be an issue any longer.

    ReplyDelete