Tuesday, August 31, 2010

What I need from a Content Management System (CMS)

Yesterday I started on a new CMS project. At the beginning of each project I like to reassess the tools that I'm using to make sure I'm not stuck using just what I know. To start, I listed some basic things I want from my CMS:

  • Manages a page tree
  • Can be extended to manage structured data
  • Rich text editor
  • Image Management
  • File Management
  • Link Management
  • User Management

Image and File Management

These are the very basics. I originally had Image and File Management listed in as Asset Management. But I find that these are presented slightly different. Images are presented in a gallery, where "files" such as PDF's are listed in a "file" manager. The Image Gallery and File Manger are accessed directly to upload and organize new assets, and integrated into the Rich Text Editor.

Editor Integration

When inserting an image, this uses the image gallery to chose an image. When adding a link, this will either use the File Manager for assets, or a Page Browser to link to another page on the website. This is what I class as Link Management.

User Management

Most CMS solutions offer sufficient User Management in terms of authentication. However, granting authorization to specific areas of the website is more involved.

Advance Options

These are necessarily "advance", but to go beyond the basics, most website I work on are bi-lingual. Therefore I require some i18n for the administration interface and some method to manage translations.

Other features include search and versioning of content.


Finally, it has to be extensible. As mentioned in my post A CMS is Not Out-of-the-box Software, a CMS is not a product until you have tailored it for you client needs. A CMS is a platform. They BrowserCMS team describe this succinctly in their presentation at acts_as_conference. Their slide summarizes this concept:

CMS is not a product, it's a platform

Friday, August 27, 2010

jQuery Cycle Plugin Ghosting with Transparent PNG's in IE

Some one please stop the Internet Explorer madness. I definitely don't want to become the IE go-to-guy. Back to programming Ruby next week, but today was finally getting the jQuery Cycle Plugin working nicely with transparent PNG's.

The issue: IE's handling of transparent PNG's causing ghosting or dark artifacts when animating with the opacity property. It appears I'm not the onlyperson who has come across this problem. So to get IE to play nicely with jQuery Cycle Plugin I need to apply UnitPNGFix to all versions of IE; this hack is typically used for Internet Explorer version 6.x.

This worked well, but I was getting intermittent errors from Cufón when applying the hack:

Attribute only valid on v:image

As suggested by the guys and gals at Media Dog, placing the UnitPNGFix after the Cufón script would resolve the problem. I had no such luck until I explicitly identified which PNG's to "fix" by specifying the classes with "unitPng". Admittedly this what I should have done in the beginning. Once I specified the elements to fix, IE worked flawlessly with the jQuery Plugin.

As a side note, I've never integrated Cufón into a project before. Does it tend to mess up layout in older browsers? When I say older, I mean Internet Explorer. It certainly generates a lot of HTML, and I'm not totally sure if people are aware of the legality converting fonts and having these openly available on the 'Net. Definitely something I need to further investigate.

"Webmaster" Launch Checklist

I have a bunch of checklists that I really need to start sharing on this blog. Here's the first one, the "Webmaster" Launch Checklist. Just some basic things to check before going live with a site. If you have your own online, please link in the comments. If you think there is something I'm missing, please let me know. Admittedly a lot of this is covered by by "blank-static" project, which covers the basics like custom 404 and 500 pages. It's the little things...


  • Add Favicon
  • Add robots.txt
  • Validate HTML
  • Custom Meta data for each page: title, meta_description, meta_keywords
  • Setup FOSI Tag
  • Setup Google Account
  • Integrate Google Custom Search Engine (if required)
  • Integrate Google Analytics
  • Add site to Google Webmaster Tools (GMT)
  • Add sitemap to GMT
  • Submit to open source directory
  • Custom 404
  • Monitor 404's, broken links (I use Deep Trawl)
  • Ensure all assets under SSL are linked using https://


  • Sign blog up on Technocrati
  • Twitter Link
  • Facebook Link
  • AddThis/ShareThis

Thursday, August 26, 2010

IE7 CSS Madness

Inspired by blogs such as Pivotal Labs and Rails Test Prescriptions I am going to attempt to do a daily recap of yesterday's firsthand experiences. These are going to be short, brief posts. I was going to call it simply Standup but I thought it would be nice to tie the company name in. So here it goes:

Internet Explorer 7 CSS Madness

Yesterday I was thrown into cleaning up some front end CSS for IE7 late in the afternoon. Here's some tricks for kids:

  • The drop-down of a select element in HTML does not expand it's width to display the longest option. Fixed using a JQuery plugin ie-select-width. There is also ie-select-style that allows you to style the select element.
  • IE7 does not play nice with transparent PNG's and the  jQuery Cycle plugin. It tends to acquire the background colour of the parent element. The fix is to add "background: none !important" to the element containing the PNG image in the slideshow.

Saturday, August 21, 2010

Defining Methods in Ruby using #instance_eval

Last week I discussed the differences between class_eval and instance_eval.

I stated there were two basic rules to follow when choosing which method to use:

  1. When the object is a class use class_eval, you will typically be using the def keyword
  2. When the object is an instance use instance_eval

When we use instance_eval to define methods where are the located? The are stored in the instance’s singleton class. I will write more about Ruby’s singleton class in the future, but for now you may want to read Ola Bini’s excellent post on the subject.

Let’s look at an example:

class MyClass; end

my_instance =

my_instance.instance_eval do
  # add the method to the instance's singleton class
  def foo

puts # => "bar" 

another_instance =

  # since the method exists only on the my_instance singleton class, calling
  # it on another_instance will raise a NoMethodError exception

  puts another_instance.greeting
rescue NoMethodError
  puts "The foo method does not exist" 

What happens when we call instance_eval on Class?
MyClass.instance_eval do
  def baz

puts MyClass.baz # => "qux" 

As you can see it defines a class method. I would argue that you should never use instance_eval on a class (although my last post regarding the subject suggested you could). I feel for a beginner in Ruby it may confuse. Stick to class_eval for class objects, and instance_eval for instances. If you need to dynamically define a class method then use this technique:

MyClass.class_eval do

  class << self

    # define .quux as a class method
    def quux

  def grault

puts MyClass.quux # => "corge" 
puts my_instance.grault # => "garply" 

A CMS is Not Out-of-the-box Software

This morning I was doing a "Saturday" clean out of some old files and came across this snippet from Namahn regarding Content Management Systems (CMS). I originally came across this around mid-2009:

"Moreover a CMS is almost never a piece of software that comes out-of-the-box. Rather it is a platform/framework for building a custom content application based on an organisation’s needs."

Only for the simplest websites, is a CMS going to work out of the box. I have yet to be involved in a CMS project where there's not some customization required.

"To define the architecture of a CMS and the features it has to offer, you need to figure out how corporate content is created, how it travels through its lifespan, and the uses to which it is put. And because corporate content is created, maintained and used by humans, it is mandatory to define the different interactions people have with documents."

Most of the open source CMS platforms don't address the life cycle of the content. They are good at publishing the content, but never the workflow. Really they should be called Website Publishing Systems (WPS), not Content Management Systems. It would be nice to see more work in this area in the open source realm.

The "white paper" is worth a read if you're trying to get beyond the basics of content management.

Saturday, August 14, 2010

When to use Ruby's class_eval vs. instance_eval

When to use class_eval vs instance_eval? Here are some basic rules to follow:

  1. When the object is a class use class_eval, you will typically be using the def keyword
  2. When the object is an instance use instance_eval

There is an important subtle difference between the two.

  • class_eval changes self and the current class
  • instance_eval only changes self

If you don't need to use def then what should use use? Well you could use MyClass.instance_eval. But as Paolo Perrotta states from Metaprogramming Ruby:

"…pick the method that best communicates our intentions."
class Book
  # define a class instance variable
  @books_published = 0

  # define the attr_accessor as a class method
  class << self
    attr_accessor :books_published
  def initialize(title)
    @title = title
    Book.books_published =+ 1

b ="Metaprogramming Ruby")

Book.class_eval do
  def introduction
    "Thank you for reading #{@title}"
  def units_sold

b.instance_eval do
  puts @title # access an instance variable => Metaprogramming Ruby
  puts units_sold # send a message to a private method => 100000

puts b.introduction # => Thank you for reading Metaprogramming Ruby

# I don't care if this is a class or an instance
Book.instance_eval do
  puts @books_published # => 1

Wednesday, August 11, 2010

User Story Format

Something I am constantly looking up is a format for user stories. While reading The RSpec Book tonight it remind me to write this down. I thought my blog would be a good place for it.

Connextra Format (named after the company)

As a [stakeholder], I want [feature] so that [benefit].

Popular Variant

In order to [benefit], a [stakeholder] wants to [feature].

Friday, August 6, 2010

Questions asked in a Ruby on Rails Job Interview

Here are some real life Ruby and Rails questions that you maybe asked in a job interview. These are based on my experience in applying for contract positions. I have not provided the answers, I will leave that as an exercise to the reader (as they say).

General Object-Oriented and Programming Questions

  1. What is polymorphism?
  2. What is overriding and oveloading?
  3. What does a test suite contain? (e.g. setup, fixtures, assertions)

Ruby Theory Questions

  1. What is a Singleton Method?
  2. What is the difference between a block, lamda and proc?
  3. What is the super class of Class?
  4. What is the super class of Module?
  5. What is a class variable vs. a constant?
  6. What do you like about Ruby?

Ruby Practical Questions

  1. Print the numbers 1 to 10 in the console
  2. Create a custom method to iterate over an array contain negative and positive numbers and only print the positive numbers

General Algorithm Questions

  1. Reverse an interger, e.g. 12345 => 54321, without converting to a string
  2. Perform a Binary Search on an array of numbers to find a target number

Rails Questions

  1. What is the difference between #destroy and #delete?
  2. What modules make up Rails? (e.g. ActiveRecord)
  3. What is ActiveSupport?
  4. What two extension methods does ActiveSupport contains?
  5. What association methods does ActiveRecord provide?
  6. Which table is the foreign key related in a belongs_to association?
  7. What annoys you about Rails?
  8. Describe a situation where you had to work outside of the Rails stack or customize Rails  to make it meet project requirements?

Database Questions

  1. What is an index?
  2. How is an index implemented?
  3. When would you use an index?
  4. What are the first things to look at with a slow query containing a join?
  5. What is an outer right join?

These questions are ones that I have been asked personally. Please add questions you have been asked in the comments. I'm sure there are some I am missing so I will update this post as they come to mind.


Please note this blog is no longer maintained. Please visit CivilCode Inc - Custom Software Development.