Wynn Netherland changelog.com/posts

comfortable-mexican-sofa: Tiny yet powerful micro CMS for Rails 3

When writing up this project, a CMS from GBH at TWG, I felt a bit like Robin Williams’ character in Good Morning Vietnam when he said.

Excuse me, sir. Seeing as how the VP is such a VIP, shouldn’t we keep the PC on the QT? ‘Cause if it leaks to the VC he could end up MIA, and then we’d all be put out in KP.

Comfortable Mexican Sofa, from Oleg Khabarov AKA @GroceryBagHead at The Working Group, is a nifty engines-based Content Management System you can drop into any Rails 3 app. What struck me the most is the clean {{ }}-style tag syntax you’re probably used to in Mustache, Tumblr, or ExpressionEngine:

{{ cms:page:content:text }}
                    
                    ‾ tag format or extra attributes
               ‾‾‾‾‾‾‾ label/slug/path for the tag, 
           ‾‾‾‾‾‾‾‾‾‾‾‾ tag type (page, field, snippet, helper, partial)
        ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ cms tag identifier

Usage

To use CMS, configure the gem in your Gemfile:

config.gem 'comfortable_mexican_sofa'

… and run bundle install.

Next, run the supplied generator to create the required database migrations and initializer, and migrate up.

rails g cms
rake db:migrate

Now you can start creating layouts, pages, snippets, and other content in the supplied admin interface:

Admin screenshot

CMS can share your existing application layouts and CMS content can even be served up inside of regular Rails views:

def show
  @help = HelpTopic.find(params[:id])
  # CMS page probably should have either helper or partial tag to display @help details
  render :cms_page => '/help'
end

Even the admin panel is extensible, just have your admin controllers inherit from CMS’s BaseController:

class Admin::CategoriesController < CmsAdmin::BaseController
  # your code goes here
end

If you simply need to extend the admin UI, try using the view hooks:

ComfortableMexicanSofa::ViewHooks.add(:navigation, '/admin/navigation')

Be sure and check the extensive Readme for advanced usage, especially for the tag syntax.

[Source on GitHub] [Discuss on Hacker News]


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00