one-button mouse

November 17th, 2007

So I launched Twitterrific on Thursday morning, and saw this tweet by Dan Cederholm:

wishes he could view source in iSafari.

Obviously, this was a hole in the market that needed filling, and it sounded like it would make for a fun, relatively simple project. So with some technical advice and code tweakage from Chief Typist Craig Hockenberry, I created a web app called iSource - give it a URL and it will show you the source code for that URL right there in your browser.

Of course, things move fast on the Internet, and so by Friday afternoon iSource’s functionality had been surpassed by ViewS, a similar app created by Shaun Inman that was geared towards improving upon certain areas of iSource.

The original version of iSource only accepted URLs through the form field on the page. ViewS improved on this by allowing URLs to be submitted through query strings, which enables you to create a bookmarklet for the site.

Bookmarklets make a web app like this even more useful, allowing you to avoid a lot of unnecessary typing on your iPhone by letting you jump from any web page straight to its rendered source code. So Friday evening I reworked iSource to allow query strings, and bookmarklets.

Here’s the JavaScript code for the iSource bookmarklet:

javascript:location='http://onebuttonmouse.com/tools/isource/?url='+escape(location)

If you’re not on an iPhone at the moment, you could drag the following link into your bookmarks bar: iSource Bookmarklet. Then you should be able to sync it to your iPhone.

If you want to get the bookmarklet directly on your iPhone, the best way is probably to bookmark this link, then edit the bookmark to add javascript:location=' before the url and '+escape(location) after it (hat tip to Shaun for this method of saving the bookmarklet).

While I was at it, I implemented some of the other improvements Shaun mentioned, such as adopting the browser’s user agent to ensure that you’re viewing the same source code that was used to render the page in the browser. I have a few other improvements in mind for iSource, so I’ll be working on them as time allows.

[Update (11/18/07): iSource now plays nicely with various character encodings.]

Illustration and other random pixelry by Anthony Piraino

About »

My Flickr Photostream