Typo gets dynamic permalink URL

If you’ve been following our commits on Github, you must now know that, despite being quite silent here, we’ve been working hard on your favourite Rails application. Typo 5.2.1 is on its way, and even though it’s now too late to submit requests for enhancement, you can still submit bugs, and we’ll try to fix them as much as possible. You can also ask for features and improvements, but they won’t be in our next release, unless you submit a patch with tests.

Cyril has recently been working on a separate branch, to develop Typo 5.2.1 main feature: dynamic permalink URLs for posts. This is a great improvement and a great work he can really be proud of. Permalink URL were almost hard coded in typo, forcing people to use the /date/month/year/permalink scheme. You can now define your permalinks in the SEO part of your Typo install, using some reserved keywords:

  • %year%: year.
  • %month%: month.
  • %day%: day.
  • %title%: post slug

This gives fancy things like :

  • /%year%/%month%/%day%/%title% is the default option, and will generate /date/month/year/permalink.
  • /foo/%year%/bar/%day%/joker/%month%/hiphop/%title% will generate /foo/year/bar/day/joker/month/hiphop/permalink. I know, this is totally useless, but it works.
  • /%title%.html will generate /permalink.html URL.
  • And so on…

Will this break something?

Absolutely, this will break your existing theme an horrible way if you’ve been using an heavily tweaked one. Check in your themes for the /views/ directory. If you find something there, it must be brocken. Otherwise, it may still work fine.

So, what do I need to change?

Not much actually.

  • In articles/commentbox.html.erb use @article.commenturl instead of commentspath(@article)

  • all link previewnewcommentpath(@article) are change to @article.previewcomment_url

  • all link urlfor formattedarticlepath(@article, :rss) are change to @article.feedurl(:rss)

  • all link formattedarticleurl(@article, @format) are change to @article.permalinkbyformat(@format)

That’s all folks, see you soon on #typo, we always enjoy newcommers and feedback.

Published on Thu, 19 Feb 2009 20:56

RSS