var sourceWindow=window.open('about:blank'); var newDoc=sourceWindow.document; newDoc.open(); newDoc.write('<html><head><title>Source of' + document.location.href + '</title></head><body></body></html>'); newDoc.close(); var pre=newDoc.body.appendChild(newDoc.createElement("pre")); pre.appendChild(newDoc.createTextNode(document.documentElement.innerHTML));
The code opens a new blank window. Writes an empty html page with the title “Source of” and the url of the current page. It finishes by appending the html source of the current page into a text element of the new page. Voila! You’ve got source.
Now for the server side. I have yet to find an “app” that lets me run node.js or the Wordpress php software on the IPad. So basically I was stuck using the IPad as a terminal to a server. I needed two things to make this happen. First I needed a server on which to run Wordpress and node.js. Second I needed to be connected to said server anytime I want to do work. The latter was a bit of a pain on this trip as even though the plane said it had wifi, it didn’t, and my AT&T coverage in Georgia pretty much sucked as well as the DSL from Southern Bell. But putting aside the whole connection issue lets look at what it took to actually get up and running from a server standpoint.
There are a lot of hosting options out there these days but I wanted something I could get up and running quickly, inexpensively, and that let me at a command line interface. The last requirement was so I could install and run any software I wanted for development. The thing that fit the bill was Amazon’s EC2 instance. Amazon has a variety of levels of cloud server that you can spin up for varying prices. The cool thing is that to get people started they allow you to run a micro instance for free for up to a year. This allows you to fire up your own linux server at their expense. You can’t get crazy with it and you surely don’t want to use it for any real production but for my purposes of doing light weight development it would do the trick.
Setting up an ec2 instance is relatively painless. There are a few things you’ll need to know including you need to edit your security settings to open up some ports. They’re all closed off at first and you’re going to need to open them up for node, http, and ssh. If you don't do this it can be pretty frustrating at first trying to figure out why you can't shell in to your instance.
You’re going to need something that allows you to ssh into your ec2 instance and the thing i use is putty for windows. You’ll need to set up putty to use your private key from amazon. Once you’ve done this you can bring up a shell on your ec2 linux instance and install pretty much anything you want. I installed both Wordpress and node.js on mine, opened up the ports I needed and was ready to roll. I also installed mongodb as I needed a database for my node.js development.
There are two apps you’re going to want for working with the code on yourIPad in conjunction with your ec2 instance. These are Textastic a sweet little context sensitive code editor and Prompt by Panic. Prompt is an ssh client for the IPad that works really well. In fact I installed node.js and mongodb from my IPad using Prompt. The important thing to know is that both Textastic and Prompt will need to have key pairs to work with the ec2 instance and you will need Putty to generate those for you. Here’s additional info on hooking up ec2 with Prompt.
Once you've done all this you're ready to make code changes on your ec2 instance from your IPad.
I got a call from Best Buy while I was out of town that my laptop was back from Asus and I literally stopped to pick it up on the way home from the airport. What I found is that while you can do work using the IPad I wouldn’t really consider it an alternative to a laptop for full on development. I found myself frustrated not being able to do basic editing and debugging tasks without jumping through hoops. It’ll definitely get you out of a pinch if you want to log on a server and do some basic maintenance of code but that’s about it.
Maybe I’m missing something and I’d love to hear from others with suggestions for better methods of development or tools.
In conclusion I'd say I actually did a fair amount of work. I’m just not sure I was really productive, since the majority of the work I did was just setting up my IPad to prove the concept that I could do work with it.