[typo] I dance the dance of happy!

Piers Cawley pdcawley at bofh.org.uk
Sun Apr 9 03:25:18 EDT 2006

Here's the commit notice from revision 1004:

  Sing, muse the joy of pdcawley as he puts the monstrosity article_url
  and all its spawn to his sure swift sword and casts the tiny pieces
  down, down, ye even unto the very depths of The Pit.

  Bear witness as Content#full_html returns to the fray, trailing clouds
  of glory, renewing the vigour of old themes left withering in the

  For, verily, I have returned the sensible API to its rightful place. 

 (Oh, and if you must use them, article_url et al. will continue to
  work for the forseeable future, but I will insist on treating them
  like red headed stepchildren.)

Which is, arguably, a little bit over the top, but I've been longing
to get rid of article_url since the very moment we introduced it. The
old 'content_object.body_html' was just so much neater.

But, once we introduced a proper blog object, we had somewhere to hang
the active controller, so that's what I did. The Blog class is now an
around_filter called by the controller, so, for the duration of a
request, Blog (and hence any of its instances) know what the
controller is. And our content objects know what the blog is. So
Content#full_html now looks roughly like this:

  def full_html
    html(blog.controller, :all)

(It raises a slightly more informative error if there's no active
controller, of course).

Also, an article (and eventually other content subclasses) can now
tell you its url by asking the blog, which asks the controller. Once
all the content types are asking the blog for their url we can start
using the blog as a place to store url policy. Why is that useful you
may ask? Well, I was chatting on IRC to someone who was converting a
large wordpress blog and he was looking at writing the thick end of
1500 redirect rules because wordpress urls look like:


But ours look like


So, instead of writing a generic route that catches all of his
articles, he has to write a redirect for each one. But wouldn't it be
cool if we could have a 'url_style' setting on the blog, so if you
want wordpress style urls you get 'em, if you want dateless
permalinks, you get those. The routing table would (obviously) have to
handle all (most) cases, but all our generated links would respect the
blog's link style.

Piers Cawley <pdcawley at bofh.org.uk>

More information about the Typo-list mailing list