Padre::Plugin::Plack

Posted on December 24th, 2009 in Comp, Perl by Patrick

In conjunction with today’s Christmas release of Padre, I’d like to announce my latest Padre plugin: Padre::Plugin::Plack.

As the name suggests, Padre::Plugin::Plack adds Plack awareness to Padre. With the plugin installed, opening *.psgi files causes some special things to happen. PSGI files are really just ordinary Perl files, so Padre does its normal Perl lexing/syntax highlighting magic on them, but the real fun starts with the Plack-specific features that appear in the per-file graphical plackup control panel that shows up. The panel lets you run your web app in a Plack server at the click of a button, view server output, configure plackup options and launch a web browser on the appropriate port.

The great thing about Plack/PSGI is that unlike my previous plugin (Padre::Plugin::WebGUI) which was specific to a single web app (albeit a big one), this plugin can be used for any web app built in a web framework that supports Plack (Catalyst, CGI::Application, HTTP::Engine, etc..). This potential for cross-framework application is one of the motivating factors that makes developing Plack modules (Middleware etc..) so much fun.

The plugin turns on plackup’s “–reload” option by default, which conveniently causes the plack server to reload every time you modify your source files in Padre. This makes for quite a nice, if somewhat minimal “Plack IDE” experience (this is version 0.01 after all).

The plugin integrates all of the Plack example “dot-psgi” files as templates that can be used to create different types of Plack apps straight from the GUI menu.

The pre-populated list of Plack servers and the simple start/stop button makes for a nice way of exploring the Plack server ecosystem. You can use the other panel options to enter a specific port to run on, toggle auto-start mode and pass additional options to plackup (options that start with “–” are passed through to the backend server).

The output panel is similar to the output panel that Padre normally displays when you execute Perl files, except that you get one panel per .psgi file meaning that you can run multiple plack servers simultaneously and independently view their output. The appropriate panel is automatically selected when you click on the corresponding file tab, and running processes are stopped when you close the tab.

It should be really easy to turn Padre::Plugin::Plack into new plugins that involve the same basic ingredients, namely  a file extension and an external command for running those files, with a per-file panel for command options and output. So I encourage anyone who has a similar plugin in mind to steal liberally from Padre::Plugin::Plack (as I did from Padre::Plugin::Catalyst – thanks garu++). Ruby Rack support comes to mind as a trivial example.

Make Padre your domain-specific IDE today :)

Plack helps with Javascript development too

Posted on December 19th, 2009 in Comp, Javascript, Perl by Patrick

Today I was debugging a Javascript bug in ExtJS + AIR, and I wanted to check rendering in another browser. I created a static html file with the minimal javascript test case embedded in it, but then realised that I needed to load in the ExtJS files from somewhere. With other JS libraries you can use freely available CDNs for this sort of thing, but because ExtJS has funky ideas about licensing, this isn’t an option. What I needed was a quick and easy way to serve up the ExtJS files, which were sitting in a folder on my computer, over http. This sort of thing happens frequently with custom code too, when you attempt to create a static (minimal test case) version of a live site.

Plack has a really neat solution to this problem.

Following a tip from day #5 of Miyagawa’s Plack advent calendar, serving up the current directory over http is as simple as this Perl one-liner:


$ plackup -MPlack::App::Directory -e 'Plack::App::Directory->new

Plack::Server::Standalone: Accepting connections at http://0:5000/
$ plackup -MPlack::App::Directory -e ‘Plack::App::Directory->new’Plack::Server::Standalone: Accepting connections at http://0:5000/$ plackup -MPlack::App::Directory -e ‘Plack::App::Directory->new’
Plack::Server::Standalone: Accepting connections at http://0:5000/
# Or if you need the files over port 80:
$ sudo plackup -MPlack::App::Directory -e ‘Plack::App::Directory->new’ -p 80
Plack::Server::Standalone: Accepting connections at http://0:80/

Or if you need the files served over port 80:


$ sudo plackup -MPlack::App::Directory -e 'Plack::App::Directory->new' -p 80

Plack::Server::Standalone: Accepting connections at http://0:80/

Tarpo now on GitHub

Posted on November 30th, 2009 in Air, Comp, Javascript by Patrick

Tarpo Logo

At about 11pm on the night before I headed off for the States, Ted the Vet and I sat down to talk Tarpo.

In case you’re wondering, Tarpo is an open source, cross platform Data Management desktop application for Dog Health programs in rural and remote Indigenous Australian communities, written entirely in Javascript.

The last time I blogged about Tarpo was way back in April 2008, and since then I haven’t really touched the code, but in the meantime Ted and his team of helpers have used it to record several thousand House Visits, Medical and Surgical Cases as part of the Maningrida Dog Health program.

Several other Veterinarians have started expressing interest in using Tarpo for their own Dog Health programs, and needless to say, we’ve accumulated a long list of bugs and feature requests over the past 18 months. So this afternoon, with a bit of spare time up my sleeve, I decided to get the ball rolling again.

Tarpo now has a proper project page, which you can visit at: http://pdonelan.github.com/tarpo

As you can see from the url, the code now lives on GitHub. Apart from the front page which has the all-important “Install Tarpo” button, the most important page on the GitHub project page is the Issue Tracker, which I’m hoping Ted and other Vets will use to report all Bugs and Feature requests. With a bit of luck, that will also make it easier for other developers to get involved too.

With these things in place, I started attacking the bit rot. Firstly I had to install Aptana and the Adobe Air plugin, which took several hours and reminded me how much I prefer doing development in Padre! On a side note, I spent a few hours trying to think if there was some way I could rewrite the entire app in Perl (I like Javascript in a twisted sort of way, but I’d rather ditch Adobe Air since it’s a proprietary framework) – but in the end I decided to stuck with the existing architecture, at least for now.

I though about doing it as a wxPerl app (like Padre), but I’d hate to lose the HTML widget set that ExtJS gives me.. hmm that gets me thinking (help me out if you’re reading Gábor or any of the other Padre gurus..) does wxPerl have a modern embedded browser that I could use? Maybe webkit-based one..? Then the backend could be rewritten as a standalone Plack-powered webapp and I’d have all of CPAN at my disposal.. hmm maybe that’s too ambitious, but it does feel like the sort of thing you *should* be able to do with Perl..

I didn’t have much time left to do any real coding after that, except for updating a few dependencies so that Tarpo at least starts up ok on the latest version of Adobe Air (a small victory). But at least now in a position to start attacking the ticket list, which means that real progress can’t be too far off..

  • Comments Off

Plack roundup at SF.pm

Posted on November 30th, 2009 in Comp, Perl by Patrick

Miyagawa has posted up a screencast of his recent PSGI/Plack talk at SF.pm. I highly recommend it if you’re still getting your head round the whole PSGI/Plack thing or you want to watch a nice recap of recent developments.

I got a kick out of seeing Miyagawa pull up my blog post on PlebGUI in response to someone’s question about porting mod_perl applications (e.g. apps that pass around an Apache $r object) to Plack. For the sake of the guy who asked the question, the way I did it (at least for the first pass) should be equally viable for other mod_perl applications – just create a fake Apache $r object that delegates everything to Plack::Request and Plack::Response (your mileage will obviously vary depending on how much of the mod_perl API your app uses).

  • Comments Off
Next Page »