After seeing the [staggering number](http://www.macrumors.com/2008/02/05/iphone-with-28-of-u-s-smartphone-marketshare-for-q4-2007/ “iPhone with 28% of U.S. Smartphone Marketshare for Q4 2007 - Mac Rumors”) of iPhones sold in the forth quarter, I decided it was time to port my [site](http://dcrails.com “DCRails.com || Making the Metrorail fun!”) to the iPhone. As of a few days ago there is an iPhone version of [DCRails](http://dcrails.com “DCRails.com || Making the Metrorail fun!”). It was a joy to build!

It was built on the back of the [brilliant work](http://code.google.com/p/iui/ “iui - Google Code”) by the amazing [Joe Hewitt](http://joehewitt.com “JoeHewitt.com”). But this brings me to my announcement, Joe also brought [firebug lite](http://www.getfirebug.com/lite.html “Firebug Lite”) to the iPhone. It is a very cool piece of code that proxies **console.log** output through a server-side proxy and displays it in a local browser. The flip (and equally cool) side is you can execute arbitrary javascript from a local browser and have it run on the iPhone. It is called [iBug](http://www.joehewitt.com/blog/firebug_for_iph.php “JoeHewitt.com”), I am not sure my description does it justice, so give that article a read.

Anyway, iBug relies on you starting a little python webserver locally. Unfortunately, this is was problematic, since it relies on iFrames having access to the **parent** window. This poses a security risk since mongrel and iBug were on different ports (XSS police are comin’ to get ya!). So, I ported his webserver over to mongrel. This was very challenging for me, it took me far out of my normal element. I had to learn the following technologies to get this to work, [mongrel handlers](http://mongrel.rubyforge.org/rdoc/index.html “Mongrel”), [comet](http://cyll.org/blog/tech/2006-08-09-themongrelcomet.html “Topher Cyll”), and a little threading in Ruby.

Anyway it isn’t completely done, it looks a little like someone ported some python to ruby, and it could use some polishing, but it does work and I would love some feedback or patches. To get started, install the plugin and read the README file (it’s shorter than this post).

script/plugin install http://svn.simpltry.com/plugins/iphone4r

There are 2 more things, you must use mongrel, and mongrel will have trouble stopping because of an intentional infinite loop (suggestions are welcome).

Post Information

Tags:

We're Reading

Feeds/Syndication

4 Responses to “[ANN] iphone4r — A Rails Plugin”

Leave a Reply