Archive for the ‘Comp’ category

Serve up Dancer webapps for six bucks

June 2nd, 2010

After a few weeks of mulling over the Perl Shared Hosting idea, a few enthusiastic messages from people and getting inspired by chromatic musing about a similar idea for a Perl Cookbook, I decided to JFDI.

So, perlsharedhosting.com is now officially up and running.

Rather than wasting my time building a web app for the site before the idea has been proven, I decided to use a simple CMS and focus my energies on the content instead (there’s a wonderful irony in using a PHP CMS to deliver content about Perl shared hosting..).

I’ve added quick-start guides on how to install the following core technologies on your shared hosting account:

These pages are not in any way supposed to replace the official documentation sources. Ideally, they just tell you what the tool/lib  is, why you need it, and how to install it with minimum fuss. In reality, we also need to list any issues you may run into when using them in a shared hosting environment, but the idea is that we feed this information back to the upstream projects so that workarounds become unnecessary.

I’ve tested two different hosting providers, neither of which I’m going to mention by name here because I’m not trying to actually promote their brand.

  • The first one had a major limitation – no access to cc and hence the inability to compile XS modules (their tech support has offered to install CPAN modules on request, but it’s less than ideal).
  • The second one has so far passed all tests with flying colours – “cpanm Task::Kensho” works flawlessly, including all the XS modules. This is perhaps not all that surprising given that this is the same hosting provider that I used last year to get WebGUI running under PSGI on a shared account.

I started playing with Dancer for the first time, and soon had live demos of Dancer running in both CGI and FastCGI modes. Those URLs will change in the future but the idea is that we set up live versions of each web framework running on each hosting provider. Maybe in the future we could use a monitoring service to track the reliability and response time of each combination.

So already, the Perl Shared Hosting site has step-by-step instructions for how to run Dancer web apps on a shared hosting account for less than six bucks per month. That’s not half bad.

If you have a shared hosting account on a provider that isn’t listed (or you work for a shared hosting company and want to get yourself listed) then please contact me to get involved.

Next up, we need to add more information about resource limits. I also plan on adding more web frameworks such as Web::SimpleMojoMojoCatalystTatsumaki, ..

Once we have an idea about what features are most important, I’d like to then turn it around and start contacting the providers to ask them if they will add support for certain features to match (or beat) their competitors. I think there’s real potential for communicating back to the shared hosting providers that there’s a large market for modern Perl hosting, and ideally, what features we need/want. The site may also be useful for feeding back to the Perl toolchain/framework people what rough edges people are running into in shared environments.

WebGUI Articles

May 13th, 2010

Speaking of articles, I finally got around to documenting two of the larger systems I designed for WebGUI (the Perl CMS) last year:

These features are both now part of the WebGUI core.

Shout-out to the translators

May 13th, 2010

This morning I had an email from someone in the ExtJS community letting me know that they’d translated my Extending Ext Components article into German. I had a look and all of my ExtJS articles have been translated into at least one other language. My record is Playing With ExtJS The Easy Way which has been translated into 10 different languages: Deutsch, Chinese,  Korean,  Japanese, French, Russian, Spanish, Turkish, Portuguese and Hungarian. Page views of the English versions of these articles are just about to tick over the 500,000 mark.

Recently Padre::Plugin::Plack, my Plack (the Perl Web Server) plugin for Padre (the Perl IDE) was translated into Dutch, Brazilian Portuguese and French.

I always get such a buzz when I find out that something I’ve worked on has been translated into another language. It sends a clear message that someone found your work useful enough to go to the effort of translating it so that a new community of people could use it. That’s an awesome form of positive feedback, and a great motivator for being involved in open source software.

Thanks translators!

Plack Middleware for your iPhone

March 24th, 2010

I started playing with HTML5 iPhone apps this week, and as a result there is a new piece of Plack middleware sitting on CPAN called Plack::Middleware::iPhone. It’s a (borderline ACME) module that rewrites html on the fly to make it play nicer with iPhones.

Here’s a silly example:


# A Perl one-liner for the iPhone generation
plackup -MPlack::App::Directory -e 'builder {enable iPhone; Plack::App::Directory->new}'

That makes your current directory browsable as a web app, with some special iPhone meta tags injected so that the viewport is appropriately resized & fullscreen mode is enabled when you launch your “app” from your Home Screen.

Here’s a slightly more usable one – your own personal mobile.search.cpan.org:


plackup -MPlack::App::Proxy -e 'builder {enable iPhone; Plack::App::Proxy->new(remote => "http://search.cpan.org/") }'

You can customise things too:

# app.psgi
use Plack::Builder;
use Plack::App::Proxy;
builder {
    enable "iPhone",
        statusbar => 'black-translucent', # transparent status bar
        startup_image => 'loading.png', # displayed as the app loads
        icon => 'icon.png'; # cutom app shortcut icon
    Plack::App::Proxy->new(remote => "http://search.cpan.org/");
};

Here’s an actual app that I have running on my phone to display the New York subway map (images courtesy of the MTA website):

<!-- index.html -->
<html>
    <head>
        <title>NYC Map</title>
        <style>
            body, img { margin: 0; padding: 0; }
        </style>
    </head>
    <body>
        <script>
            window.scrollTo(300, 700); // Initially zoom in on my local area
        </script>
        <img src="sub1a.gif">
        <img src="sub2a.gif">
    </body>
</html>
# app.psgi
use Plack::App::Directory;
builder {
    enable "iPhone",
        icon => 'icon.png',
        manifest => 1,
        viewport => 'initial-scale = 1, maximum-scale = 1.5, width = device-width',
        statusbar => 'black-translucent',
        startup_image => 'loading.png';
    Plack::App::Directory->new;
};

Use plackup to run the site on your local network, connect via Safari on your iPhone (via wifi) and then use the “Add to Home Screen” option to add an app shortcut to it on your phone. Your 57×57 icon.png image will be used as the app icon, and your 320×460 loading image will appear as the app loads. The viewport string sets the initial zoom scale and limits how far in the user can zoom. Nice and shiny.

With the manifest option enabled, Plack::Middleware::iPhone automatically generates a manifest file and injects the appropriate html to enable HTML5 offline web app caching on your iPhone. This means that your app keeps working once you Ctrl-C the plackup server and walk out your front door. And it keeps on working when you’re stuck in the New York subway system without phone reception, trying to figure out what train you’re supposed to catch to get home.

If you’ve just started exploring how to build iPhone apps with web technologies, I suggest you check out Jonathan Stark’s book “Building iPhone Apps with HTML, CSS, and JavaScript” (online here).