-
Paying Attention to Detail
- robert
- June 5th, 2008
- 04:57:41 PM
Creating websites is easy, especially with Ruby on Rails because of all the plugins out there to make coding easy. The hard part about making websites is creating a user experience that is enjoyable for the user and content that is useful for the user.
These prime objectives are what we have been focusing on for the Feisty Piranha Project. We are not looking to create a “stupid” website that displays a bunch of irrelevant information and fluff, requiring the user to click 7 times to get where they really want to be; our site’s interface needs to be seamless and flow.
Lots of websites out there fail at this whole usability thing, and over the past week I have been dealing with a few of them very closely.
This gets me to my next Ruby on Rails rant!
I have been working with Mechanize for Ruby. Mechanize allows for a “smart” way to have a Ruby program visit websites. It keeps session information, cookies, fills out forms, does pretty much everything you would ever want to do. Despite how smart it is, I ran into a website that broke Mechanize’s cleverness.
This website used a bunch of javascript to hide the “true” URL to make it look pretty in the address bar, which is fine. All of the links on this site, once clicked on, triggered a javascript function to be called, which encoded the target URL with a bunch of QueryString parameters before initiating a post. Ah, URL hackery. The creators of this site had clearly spent a lot of time mucking around with their URLs. Perhaps they should have spent more time managing their lackluster website content. After all, your site is only as good as your content.
Nonetheless, Mechanize was created to handle links like these with ease, which is why I used it over net/http. (Allyn and myself used net/http on another project, which we’ll blog about later - Stay tuned!)
Mechanize simulates “clicks” instead of just requesting links directly. This way it usually works when traversing terrible websites that have hacked up URLs. Well, mechanize couldn’t figure out how to visit this site’s links.
In the end, Dusty, Kevin, and myself were up at 1AM (I’m not usually up at 1AM coding… But I could not sleep so I decided to code… I cannot explain why Dusty and Kevin were up that late) and we chatted away for a few hours trying to figure out how to get Mechanize to visit links on this site.
We ended up using Tamper Data with Firefox to determine and duplicate the exact structure of the request being generated. Even with Mechanize executing the exact same request, it still didn’t work.
It turned out that the cause of all of this trouble was the links that Mechanize was trying to follow needed to be decoded again before posting. An easy fix!
So, with a quick and forceful decode of the URL, Mechanize was able to cross the link-traversing-barrier on this terribly coded website.
Comments
FYI, Dusty and I frequently hack on stuff late into the night; it comes with being an owner.
Now if only we could make Mechanize hack ruby code FOR us… think of the possibilities!
[...] those of you that read every word I say, you might have noticed that I hinted at another project that Allyn and I were working on in our free time. Well, the time has come to unveil our mini [...]