Creating advanced Typo plugins

2 days ago, there was a guy called Fish who joined us while I was idling on #typo. He was asking for a gallery plugin for his Typo blog. As I’m a photographer, having such a plugin had been on my TODO list for like years now, so I told him I would do a quick proof of concept during my daily train commute. A few hours later, when I went back home, the plugin was working. It was very simple, displaying files uploaded on a Typo blog with thumbnail, pagination, medium size and large size displayed in a lightbox. Indeed, it wasn’t enough, and Fish came back asking for multiple albums and picture selection, caption, so I came back to work. As a developper, Fish could probably have done it himself, but I’m more familiar with Typo internals, and even I didn’t know how far I could go with Typo plugin integration.

Tonight, during my daily commute, I extended my gallery plugin with full admin and frontend integration. The gallery is not working yet, but the biggest part is working: integrating a complexe plugin in a Typo blog. I wanted to share this with you as a HOWTO.

Before trying this, please be sure you’re using Typo HEAD as Friday April the 8th, or a Typo version above 6.0.4 (even though it’s not released yet) as you’ll need the route.rb modification I had to do.

Creating the plugin

As Typo plugins are just plain Rails plugins, creation is kinda trivial.

<typo:code> ./script/rails generate plugin typosampleplugin </typo:code>

You’re now going to create some folders to reflect a Rails application tree:

<typo:code> cd vendor/plugins/typosampleplugin mkdir -p app/controllers/admin app/models app/helpers/admin config app/views/admin </typo:code>

Good, you’re now ready to code the main stuff. Edit your new plugin, and let’s go!

Making your code accessible

Now, you’re going to make Typo access your code. Edit your init.rb file and add the following:

<typo:code lang=’ruby’> PLUGINNAME = ‘typosampleplugin’ PLUGINPATH = “#{::Rails.root.tos}/vendor/plugins/#{PLUGINNAME}” PLUGINCONTROLLERPATH = “#{PLUGINPATH}/app/controllers” PLUGINVIEWSPATH = “#{PLUGINPATH}/app/views” PLUGINHELPERPATH = “#{PLUGINPATH}/app/helpers” PLUGINMODELSPATH = “#{PLUGINPATH}/app/models”

config.autoloadpaths += %W(#{TypoSamplePlugin::PLUGINCONTROLLER_PATH} \

                        #{TypoSamplePlugin::PLUGIN_HELPER_PATH}      \
                        #{TypoSamplePlugin::PLUGIN_VIEWS_PATH}       \

ActionView::Base.send(:include, TypoSamplePlugin::Helper) </typo:code>

The routing

Unless Rails generators, your plugin won’t be allowed to change routes.rb. We want our end users to remove them if they don’t want them anymore. So we’re going to create our own config/routes.rb. It’s going to look like this:

<typo:code lang=’ruby’> ActionController::Routing::Routes.draw do |map| map.connect ‘sampleplugin/:action’, :controller => ‘typosample’, :action => ‘index’

%w{ sample_plugin }.each do |i|

map.connect "/admin/#{i}", :controller => "admin/#{i}", :action => 'index'
map.connect "/admin/#{i}/:action/:id", :controller => "admin/#{i}", :action => nil, :id => nil

end end </typo:code>

I know, we’re still using Rails 2 routing DSL. It’s bad but Rails 3 can’t handle everything we do.

The first block is for your frontend controllers, the second one for the admin. Easy as pie isn’t it?

The models

She’s a model and she’s looking good. I’d like to take her home that’s understood.

Add your models files in app/models exactly like on any Rails application. You can use any Active Record relations you want and access or extend existing Typo models.

To create your database schema, edit your init.rb file, and add the following code:

<typo:code lang=’ruby’> unless ::TypoSamplePlugin.tableexists? ActiveRecord::Schema.createtable(TypoSamplePlugin.table_name) do |t|

t.column :name,  :string
t.column :description,  :text

end end </typo:code>

Couldn’t be easy heh? Now let’s switch to the front and back office thing.

The front thing


To be able to display your content within your Typo blog layout, every front end controller will need the following code:

<typo:code lang=’ruby’> class TypoSamplePluginController < ActionController::Base unloadable layout :themelayout beforefilter :template_root

def template_root

self.class.view_paths = ::ActionController::Base.view_paths.dup.unshift(TypoSamplePlugin::PLUGIN_VIEWS_PATH)


def theme_layout

File.join("#{::Rails.root.to_s}/themes/#{Blog.default.theme}/views", Blog.default.current_theme.layout(self.action_name))


end </typo:code>

There’s certainly a cleaner way to do it by not repeating the code, but I’ll dig it later.


Nothing special here. Really.

The backend thing

OK, now you want to give your plugin a fancy back office? Let’s go.

Adding your module to the admin

Edit your init.rb. In your model creation block, add the following:

<typo:code lang=’ruby’> admin = Profile.findbylabel(‘admin’) admin.modules << :typosampleplugin

publisher = Profile.findbylabel(‘publisher’) publisher.modules << :typosampleplugin

This will update both admin and publisher profiles giving them the rights to access your plugin admin.

Now, let’s add them to the access control list (and the menu as well). This is still in init.rb

<typo:code lang=’ruby’> :require => [ :admin, :publisher, :contributor ] do |map| map.project_module :typosampleplugin, nil do |project|    "My plugin meny",  { :controller => "admin/typo_sample_plugin" }
project.submenu "My submenu", {:controller => "admin/typo_sample_plugin_other" }

end end </typo:code>

Edit your lib/typosampleplugin.rb and add the following:

<typo:code lang=’ruby’> module Helper def classtyposampleplugin return classselectedtab if controller.controllername =~ /typosampleplugin/ class_tab
end end </typo:code>

This will allow you to manage the tabs highligh in the admin.


Your controllers will go to app/controllers/admin and will all look like this, pretty like normal admin controller:

<typo:code lang=’ruby’> module Admin; end

class Admin::TypoSamplePluginController < Admin::BaseController layout ‘administration’ unloadable


end </typo:code>


Typo plugins admin views look like normal admin views. Minimum code is:

<typo:code lang=’ruby’> <% @pageheading = (‘Sample plugin’) %> <% subtabs_for(:typosampleplugin) %> </typo:code>

You can access any admin helper like saveorcancel or linktonew.

Here we are (born to be kings). I’ll release Typo Gallery when I finish it, which could happen very soon as I’m thinking about quiting Flickr to host my photos somewhere like I used to do with Wordpress + Gallery2 in the past, many, many cycles ago.

Published on 08/04/2011 at 17h08 by Frédéric de Villamil, tags , , , ,

Moving to a new server... and to Ruby 1.9.2

If you can read this… I love starting a blog post with that sentence, it always teases something great, exciting, or just new. So, if you can read this, then, we’ve successfully moved to our new ass kicking server: Quad Core Xeon, 16GB RAM, 2*2TB hard drive on a Gigabit port with as much trafic as the machine can handle.

But that’s not the point.

This blog is running on a yet experimental but apparently working Ruby 1.9.2 compliant version. If you’ve been running 6.0.4 lately, then you can also try running Typo on a Ruby 1.9.2 environment.

This does not work out of the box though. You will need an UTF-8 aware Ruby 1.9 compliant database driver, just like sam-mysql-ruby. To do so, just edit Typo Gemfile and replace the gem 'mysql' line by gem 'sam-mysql-ruby'. If you’re using a custom theme, you’ll probably have to fix your theme encoding too.

As I’ve said, this is very experimental. However, if you’re willing to test this, we’ll be glad to hear your feedback. Just one thing though: don’t complain because you’re using a database driver that’s not UTF-8 compliant: we can’t do anything about it.

Published on 06/03/2011 at 17h43 by Frédéric de Villamil, tags , ,

Release of Typo 6.0.4 : lots of bug fixes and cosmetic improvement

It’s been 3 weeks since we last released a Typo version, and we want to thank all our users who provided great feedback – mostly bug reports, nobody’s perfect. We’ve had a hard time fixing them as these bugs were mostly due to the upgrade to Rails 3.0, but tonight we’re happy to release Typo 6.0.4, fourth of both the Irving Penn series and 2011.

General Improvement

Integrated version checker

When displaying the dashboard, typo will check for the latest release and will display a message accordingly:

  • A notice if Typo’s just a minor version behind.
  • A warning if Typo’s a sub version behind.
  • An error message if Typo’s a major version behind

Our dashboard was almost completely redesigned, making information easier to get and prettier.

Utility Sidebar Widget

A utility sidebar widget was added, displaying various links to Login page, RSS, Typo documentation. This Widget is enabled by default when creating a new blog making the sidebar prettier.

Editable RSS description

RSS description is now editable from the admin. You can add as much HTML as you want to make nice RSS footers.

French Translation

Having 3 Typo commiters out of 4 being French while having an incomplete French translation full of mistakes was a shame. This is now fixed thanks to great work by Ollivier Robert and Sylvain Abelard.

Bug fixes

Invalid publishing time when using a non UTC timezone.
With Rails 2, Active Record used to store contents using local time for timestamps. Rails 3 uses UTC instead, creating a gap between the publishing time and the user’s time. Typo 6.0.4 fixes this making Active Record behave like it should on Rails 3.

Broken theme editor.
A change in the way should be called between Ruby 1.8.6 and Ruby 1.8.7 broke theme file loading. Also theme editor did not raise an error when trying to load non existing files.

Broken migrations when creating a new blog.
Rails 3 upgrade broke initial migration as it was trying to use a non loaded model.

Broken sidebar save button
Upgrade to Rails 3 with use of prototypelegacyhelper plugin broke many AJAX saving feature. This caused sidebars not to be saved anymore.

Broken image links in administration style.
Background images would not load when using Typo in a sub URI.

Broken cache system.
The way caching used to work caused a stale file descriptor bug having the cache not being generated anymore after a sweep.

Broken cache system with sub URIs.
Cache could not be accessed when using a site deployed in a sub URI, making it useless.

Broken sites with https.
Blogs using https would break because Typo was only expecting URLs to start with http only.

Broken Flickr and Lightbox macro filters.
By escaping macro tags, BlueCloth was breaking Flickr and Lightbox macros. This would happen when using Markdown, Textile or Markdown + Smartypants.

Published on 23/02/2011 at 11h30 by Frédéric de Villamil, tags

Release of Typo 6.0.3 – Important bugfix

If you’re using any of the Typo 6.0 series, you really should upgrade to 6.0.3 as it fixes a lot of AJAX related bugs. Having a good unit tests coverage is not always enough, and human test are always worth spending the time we didn’t have. Hopefully, Fabiano Francesconi has been doing a great work reporting bugs he was falling on tonight while I was fixing them.

The culprit is an outdated, buggy Rails Prototype Legacy Helper plugin. This plugin gathers all the fancy AJAX helpers that were removed from Rails 3. We probably should have done some unobtrusive Javascript instead of using that one, but… Typo 6.0 would probably had never been released at all.

As usual, you can download Typo at or

A few things fixed by Typo 6.0.3:

  • Sidebar settings being saved since nothing seemed to happen and the sidebar form would eventually look dead afterwards.
  • Comments preview breaking on most legacy themes, including built in Typographic, Scribbish, Dirtylicious and Standard Issue.
  • Category drag and drop reorder would not do anything.
  • Admin content filtering would render an error.

Published on 01/02/2011 at 20h42 by Frédéric de Villamil, tags

Release of Typo 6.0.2 Irving Penn

Coming only 11 days after Typo 6.0, Typo 6.0.2 is the third release of the Irving Penn series. This is both another bug fixing release, and the beggining of a new feature oriented one, and despite the minor version number and the very little time between releases, it’s an important one as it makes Typo 6.0 series stable enough to be production ready.

Many thanks to Ollivier Robert for improving the French translation. and Luuk Hendriks for various bug reporting.

What’s new in Typo 6.0.2?

Typo is now Thread safe enabled by default. If you wonder what thread safe is about, you should read this question and answer post.

Typo was lacking a recent dark background theme. This error is now fixed with True Red, a brown and red port of default theme True Blue (now in use on our blog). This is also the starting point of a deep thoughts about themes framework.

True Red

Typo now comes with various ways to display date and time on your blog posts. This will allow European and American users to display dates the way they want without having to hack their templates. Existing themes will automatically profit from that improvement.

As usual, French translation was improved. This is not perfect, but we’re still working on it.

Squashed bugs

Made bundle install work from inside subdirectories.

Added a missing .html_safe in the Scribbish theme

Removed deceptive “pointer” cursors in admin accordion-headers.

Made save as draft keep a published article published.

Fixed Flickr and Lightbox plugins

Fixed google sitemap.

Fixed RSS trackbacks feeds.

Published on 29/01/2011 at 10h21 by Frédéric de Villamil, tags

6 years and 2973 commits later

It may sound like a coincidence, but while we were releasing Typo 6.0 Irving Penn for Ruby On Rails 3.0, the blogging engine was officially celebrating his sixth birthday. Tobias did his first commit January the 20th 2005 at 2:08 AM. 6 years and 2973 commits later, Typo has seen 5 major releases (Typo 3 never existed), 8 official maintainers, and was said dead countless times. At that time, Typo had no UI, and articles were written using MarsEdit and the MetaWeblog API.

Relaunch of too-biased

Yesterday I had some time so i decided to tackle a little project I was contemplating for a while.

Welcome typo. Typo is the smallest possible weblog. It doesn’t have an admin interface at all and its based on sqlite. It took about 6 hours to write and most of the work was put into the XMLRPC backend.

So Marsedit is the only way to get any content onto this site now and thats plenty.

As always my code is free under MIT licence and you can fetch it from my svn server at svn://

Typo had its 15 minutes of fame, eventually powering and becoming one of the sample application for people starting Ruby On Rails. Typo theme contest was a great success, giving it a huge amount of nice templates. Then, for some reason, it turned into a giant bloatware. Its main contributors started another project called Mephisto, and most users switched to Wordpress. Typo was left for dead.

I started using Typo mid 2006 after spending 2 years being a happy and proud contributor of the growing Wordpress community. My first patch was integrated December the 29th 2006, after something like 3 weeks waiting in the limbo. It was the second patch I was submitting, the first one being a complete admin revamping that was too big to be reviewed. After a few times on #typo IRC channel, I understood that the remaining maintainers had something else to do. I had the possibility to migrate my blog to Mephisto, but I had became quite familiar with Typo code, and I wanted a blogware I could hack.

I asked for the project keys, and was eventually given them, Piers Cawley keeping the project lead. My first commit was February the 8th 2007. 4 years later, Typo is still alive, running with 4 cool maintainers, 3 of them being French. The idea of a widely used Rails blogware is no more while Rails became less and less visible, and was more widely used in enterprise projects. I still do think there’s a place on the Web for a Ruby On Rails blogging engine that would be supported by a small community of users and contributors. Typo 6.0.1 now looks mature enough to start building that community. After trying to make Typo more user friendly, I hope we’ll make it actually used, and that’s what I plan to do in the next months.

Published on 23/01/2011 at 14h42 by Frédéric de Villamil, tags

Release of Typo 6.0.1 Irving Penn for Ruby on Rails 3.0

Only 2 days after releasing the long awaited Typo 6.0 Irving Penn for Ruby on Rails 3.0, we’re back with a new version fixing some nasty leftovers bugs and bringing you some improvement. Thank you to Luuk Hendriks for testing this version and submitting patches.

Here’s the list of what we improved…

The dashboard was improved, getting some more figures about spam and content.

Dashboard internationalization was completed.

French translation was improved.

Merged both files and resources view in the admin, first step to a (much) better file upload thing

Made information blocks look different from confirmation ones.

Improved forms help lisibility

and a comprehensive list of what has been fixed.

Bug #192: multi-byte permalinks. - Do not escape the title upon conversion to permalink slug. - Escape permalink sluk upon creation of permalink url. - Search article by permalink and by escaped permalink to support legacy permalink slugs.

Fixed some sidebars using old deprecated code silently dying.

Fixed a bug in the HTML editor inserting image tag even when cancel was clicked.

Fixed a 404 in the administration CSS that was polluting your log files.

Fixed themes not displaying categories correctly (Luuk Hendriks)

Published on 21/01/2011 at 17h31 by Frédéric de Villamil, tags

Release of Typo 6.0 Irving Penn for Ruby on Rails 3.0

Almost 7 months after Typo 5.5, we’re proud to announce the release of Typo 6.0 Irving Penn for Ruby on Rails 3.0. This major version of our application is mostly about upgrading to Rails 3, but it also provides a bunch of new feature.

You can download Typo 6.0 as a zip archive or as a tarball.

Upgrade to Rails 3

Upgrading to Rails 3 was a long and painful path. Typo was born when Rails was very very young, and the framework took some path while we chose another path to fix its lacks. Typo 6.0 is only a first compatible version, and we’re still planning to ditch the remaining piece of antiquities we still carry.

Bye bye Typo installer

Typo installer has been around for 6 years now, and what seemed a really great idea at Rails 1.0 era rapidely became an unmaintained burden. There are now lots of easy ways to deploy a Rails application, while Bundler handles all the dependencies issues. Installing Typo is now easy as, let’s say, installing any other mainstream blogging engine: fill in your database credential, run bundle and you’re done.

Finally a real plugin API

Thomas Lecavelier did a wonderful job working on what’s going to be the real plugin API we’ve dreamt of for a while now. He started with making avatar provider pluggable and knows how much he still has to be done. Good news as he’s the latest addition to Typo core team. We’re really glad to welcome him onboard.

Theme changes

Theme structure has been change to be compliant with Rails views structure. If you’re using a custom template, you’ll have to move the layouts folder into the views one. Nothing you can’t handle.

Admin, SEO and usability

We’ve made some SEO improvement, adding a bit more options, and making tags URL really SEO friendly. Admin usability has been improved to, but we’ve many other things we want to make better as well.

That’s all for now. We’ll be glad to hear your feedback if you’ve got some. For now, we’re going to celebrate this release by working on the next one.

Published on 18/01/2011 at 21h48 by Frédéric de Villamil, tags , ,

Setting up a new plugins repository

Typo and Ruby on Rails both provide a powerful plugin interface, making extending your Typo blog easy. We wanted to make finding such an extension easy as well. Most plugins were hosted on Frédéric’s Github account, amongst many other projects, and the only way to know what is Typo related and what isn’t is to browse Typo Plugins Catalogue.

With its “fork and update” process, Github provides a fantastic opportunity to bring together a plugin repository from original code, tracking plugins evolution and updating as they come. That’s the reason why we have built the new Typo Plugin Repository, dedicated to hosting every Typo plugins available on Github. Typo plugins Catalogue will remain as a… catalogue, but browsing code will be made easier.

Just as a reminder, Typo plugins come in 3 flavour:

Typo sidebars plugins

You will recognise them easily because their name finish with _sidebar. You can enable from the admin interface and display using:

<typo:code lang=’ruby’> <%= render_sidebars %> </typo:code>


<typo:code lang=’ruby’> <%= rendersidebar(‘somesidebar’) %> </typo:code>

Typo text filters plugins

Their name start with typo_textfilter. Like the typo:code text filter or typo:flickr, they allow you to insert almost anything in your blog posts.

Other plugins

They are just basic Rails plugins being able to interact with your Typo blog. You will usually need to edit your template to make them work.

If you have created a Typo plugin and want it to be listed in our repository, just drop us a line at, we’ll be glad to review it and eventually add it.

Published on 03/10/2010 at 00h47 by Frédéric de Villamil, tags

Rails 3 Typo is coming soon

I’m thrilled to tell you that, since tonight September the 26th 22:22 GMT, Typo official blog and my own blog are now running our Rails 3 development branch. This was made possible by Matijs great work – and a bit of mine as well.

The past weeks were quite exciting, and I really had great fun working on this branch, making specs pass one at a time, getting excited because Matijs had pushed something new, and I had to push more as well, fixing this and that in the train on my way to work.

Typo is a very old application, almost as old as Rails is, and it has seen many major releases: 1.0, 1.2, 2.0 and now 3.0. Some code is very old as well, and Rails often took the opposite path as how we did things. Rails 3 is probably the biggest evolution I’ve seen since I started, and migrating Typo is a long and painful process. It was only made possible because we had a good – thus insufficient – test coverage.

What’s next?

In the next days, we’re going to polish the few remaining details. Typo installer needs to be changed to match Bundler evolution. Oh, and we also want to add some feature we had in mind for a while. So stay tuned.

Published on 26/09/2010 at 20h22 by Frédéric de Villamil, tags

Powered by Publify | Photo Startup stock photos