we develop communication with weLaika Advertising

Camaleon: a nearly perfect mimesis

Tags: ruby on rails, ruby, wordpress, cms, camaleon
Stefano Pau -
Stefanopau

Have you ever wondered how would Wordpress be if it has been written in Ruby? Owen Peredo Diaz (owen2345) answered this question with his project Camaleon, a CMS for RubyOnRails inspired by Wordpress.

Start

We consider you have ruby on your system and mysql server up and running.

Camaleon is a gem for RubyOnRails so these are the steps to bootstrap a new project

1
2
3
4
5
6
7
8
9
rails new blog
cd blog

echo "gem 'camaleon_cms', '>=2.1.2.0'" >> Gemfile
bundle install #install the gem

rails generate camaleon_cms:install #install the CMS
rake db:migrate #create database structure
rails g camaleon_cms:theme my_theme #install a custom theme

Once it has been installed, Camaleon CMS generates a scaffold inside the project as stating point for the development (like Worpress, too).

Like any other Rails projects you’ll need to rails server to start it up, then visit http://localhost:3000 to view the result.

Feature

Camaleon CMS imitates the typical Wordpress’ data structure: every entity is son of Post, identified by a PostType. The gem makes available an entire collection of helpers inspired by Wordpress:

1
2
3
4
5
6
7
the_post #returns the current post decorated by Draper
the_breadcrumb #draw breadcrumb for this model
the_post_type(slug_or_id) #returns a post_type object
the_name #returns the user fullname
the_seo #generate all seo attributes for profile page
the_slogan #returns the slogan for this user, default: Hello World
[...]

(the whole documentation is available here: http://camaleon.tuzitio.com/docs)

Even if Camaleon, like Wordpress, is intended for writing blogs, thanks to Content Groups and Custom Fields manager it is possible to create custom entities. This feature demonstrate a high level of versatility, but not the same completeness of Wordpress plugin Advanced Custom Fields.

Users who manage CMS have a role like administrator or editor: different roles correspond to different permissions. We can also create custom permission patterns. With Camaleon it is possibile to use shortcodes for inserting code snippets inside the contents.

Camaleon is a flexible CMS thanks to the integration of plugins like MailChimp, Mandrill, E-Commerce, Contact Form (see all plugins: http://camaleon.tuzitio.com/store/plugins).

Another interesting feature is the theme manager: we can choose between different themes or create custom ones.

All that glitters ain’t gold!

What is the result of a transition from Wordpress to Camaleon?

The main difference is the container of Camaleon: RubyOnRails. ROR is a very powerfull framework for the making of a Wordpress-style site, a big avantage, but it could reveal some traps.

The harder stuff is to break the habit of an eccessive use of ActiveRecord. We have to keep in mind that it’s a Wordpress database: this kind of databases is difficult to manage, forcing the user to write wtf-omg queries!

The best thing is making a massive use of Camaleon helpers, trying not to go crazy. Like in Wordpress environment, the development is closely tied on contents created by CMS, so we need to trust in slugs for managing the application routing.

When we develop our application with Camaleon, we need to create contents similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
id: 14,
key: "stuff",
value: "{\"_theme\":\"my_theme\",\"date_notified\":\"2015-08-31\",
\"_admin_theme\":\"en\",\"has_create_account\":\"\",
\"logo\":\"http://localhost:3000/media/1/my_logo.png\",
\"icon\":\"http://localhost:3000/media/1/favicon.png\",
\"home_page\":11,\"error_404\":\"\",\"email\":\"\",
\"front_per_page\":1,\"admin_per_page\":1,\"comment_status\":\"pending\",
\"seo_description\":\"\",\"keywords\":\"\",\"seo_author\":\"\",
\"twitter_card\":\"\",\"screenshot\":\"\",\"mailer_enabled\":0,
\"refresh_cache\":true,\"save_intro\":true,
\"security_captcha_user_register\":true}",
objectid: 1,
object_class: "Site"

the problem is the content transfer from an environment to another. If we createa lot of contents in our development environment, it will be very hard to transfer them in production environment.
All the information is wrapped inside a string: if we decide to tranfer database and assets from an environment to another using capistrano-db-tasks-like gems, we will need to rename assets’ paths with the environment root path.