Sword 1.0b5 · A simple and friendly weblogging tool for academic environments created by Fingertips design & development.

 
 
 
 
 

Routing

TrackBack link: http://blog.markjuh.net/markjuh/trackback/2005/5/13/routing

Published on 13 May 2005 at 08:34.

I’ve been diving into routing the last two weeks. It’s a great concept, but the code is hard to get through.

One thing that had me puzzled for several hours was that I wasn’t able to break the routing tests, no matter what I did. It turned out there was an error in the filename of the file that contains the routing tests.

After fixing this simple problem, I added support for domains and subdomains to vendor/rails/actionpack/lib/action_controller/routing.rb. The Route::items= method now sets an optional part in array that contains the routing information.

[[domain_info], path_info], where if domain_info is empty, it reduces to [path_info], which is just the regular case it used to be without any domain/subdomain additions.

This makes sure that I did not break existing behaviour, yet provides a way to identify the new items.

Unfortunately, also changes to the test-functions are needed, since currently verify_recognize and verify_generate do not accept / as a prefix for the path. And the possibility to use this prefix is essential in our extension of routing, since we would like to use the following scheme in our application:

//:weblog.ourdomain.org/:year/:month/:day/:post

(the nice Route::items= method would give us [[:weblog, "ourdomain", "org"], :year, :month, :day, :post] here)

Furthermore, the flow of information through the UrlRewrite::rewrite method would need to change. The following implementation would not work anymore:

rewrite_url(rewrite_path(options), options)

But instead rewrite_path should also update the options in a smart way.

Since this is too much of a hassle at the moment, we decided to drop this for a bit and go ahead with the implementation of the pilot version and use URIs of the form /:weblog/:year/:month/:day/:post/.

New comments are disabled for this post