nanoc › Articles about v2.0
  1. Articles about v3.2
  2. Articles about v3.1
  3. Articles about v3.0
  4. Articles about v2.2
  5. Articles about v2.1
  6. Articles about v2.0

Articles about v2.0

nanoc 2.0 released (December 25th, 2007)

nanoc 2.0 has arrived, right in time for christmas!

In addition to nanoc 2.0, I’m also proud to present a revamped nanoc site, featuring a much less amateurish look, and most importantly, a brand new, completely rewritten manual. There are quite a few other changes, but I’m sure you’ll find those by yourself.

To update or install, simply:

% gem install nanoc

Before upgrading, know that there have been quite a few changes, and that some of the changes may cause your site to break. Read carefully what I have to say.

New Features

In addition to defining custom filters, it is now possible to define custom layout processors. This is very similar to the new way of defining filters (see below).

Another new feature involves custom data sources. Instead of letting nanoc read the data off flat files on the hard disk, you can tell it to read from a database instead, for example. This may not sound terribly exciting, but it opens the door for writing GUI applications that manage a nanoc site. (There a no such GUI applications yet, though. Want to give it a shot?)

Quite useful are parent and children links for page objects. You can now easily get the parent of a page like @item.parent, and you can get a page’s child pages by doing @item.children. Very useful for building site maps or breadcrumb navigation, for example.

The coolest (and perhaps oddest) feature is an auto-compiler. Instead of having to manually compile your site every time you make a change, you can now let nanoc compile it whenever necessary.

Important Differences with nanoc 1.x

The way custom filters are defined has changed. You can no longer use register_filter. Instead, you can write filters by subclassing Nanoc::Filter. For example, the Markdown filter looks like this now:

class MarkdownFilter < Nanoc::Filter
  identifiers :markdown, :bluecloth

  def run(content)
    nanoc_require 'bluecloth'
    ::BlueCloth.new(content).to_html
  end
end

The filters attribute is gone now. To define the list of filters to run before laying out a page, use the filters_pre attribute, which does exactly the same as filters.

Support for Liquid has been dropped entirely. Liquid is a nice templating system, but it’s only really useful in situations where template writers should have restricted access to variables and functions, because of security issues. Such security issues can be a problem on a live web server, but they are completely irrelevant for a nanoc-powered site.

The Erubis filter isn’t there anymore. The main reason for using Erubis is speed, but since speed is not really relevant for nanoc-powered sites, the filter has been removed.

Identical files are no longer printed which makes nanoc’s output cleaner for sites with many pages. You can use --verbose or -V (uppercase V) to let nanoc print identical files.

Templates are no longer run through ERB when creating a page. This bug feature was quite confusing, and it wasn’t really useful either.

It may not be useful to everybody, but I’d still like to mention that the nanoc source code has been completely restructured. Some parts were rewritten from scratch. The code is a lot cleaner now, so if you want to take a shot at hacking away at nanoc, now’s the time.

Compatibility with Ruby 1.9

nanoc is compatible with Ruby 1.9, which is being (or already has been) released today. (I admit I cheated a bit to make it compatible, though, but that’s not relevant.)

BlueCloth, however, does not appear to be compatible with Ruby 1.9. You’ll get a "invalid mbstring sequence" error when trying to filter a page using the markdown/bluecloth filter. To resolve this, you can use RedCloth instead of BlueCloth, since RedCloth also supports Markdown. The RedCloth filter is identified using redcloth or textile.

The nanoc site, which is available as a sample from the Mercurial repository, cannot currently be compiled because of its dependency on Hpricot, and Hpricot does not compile on Ruby 1.9.

These are only small issues, and I’m convinced that these will be fixed soon. If you rely on BlueCloth, Hpricot, or anything else that is not currently compatible with Ruby 1.9, you can still use Ruby 1.8—nanoc still works on 1.8, and it’ll stay that way for a long time.

Last Words

nanoc has been tested thorougly, but there’s always a chance that something goes wrong. If you are experiencing any issues, please do do report them. They’ll be resolved in no time. Thanks a lot!

Enjoy nanoc 2.0. Merry christmas, and a happy new year.