Dancer::Plugin::DirectoryView

September 4th, 2011

Developing Perl modules seems to become my habitual weekend activity. Here’s a new plugin for the Dancer web framework — Dancer::Plugin::DirectoryView.

The plugin generates directory indexes for selected directories on the server, allowing the users to browse through those directories and download files. It basically does the same that Apache’s mod_autoindex and Plack::App::Directory do, but it has the advantage of being integrated into the Dancer application and not depending upon how the application is deployed.

An obligatory screenshot:

Directory index generated by Dancer::Plugin::DirectoryView

I’ve put the plugin up on GitHub, and will relase it on CPAN shortly (after I polish the code a little bit).

WebService::Amazon::Route53

August 31st, 2011

In the last few days, I’ve been working on moving several domains (including this one) from EditDNS to Amazon’s Route 53. EditDNS was a small DNS provider that offered very good service (I praised them for that in the past), unfortunately some time ago they got acquired by Dyn, and are now being shut down.

I looked for a decent replacement for EditDNS, and finally decided to go with Route 53, because of two things: they have a good pricing scheme, and a well-documented API. The latter was probably the most important factor, as I do a lot of domain management stuff using automatic tools that work with an API.

A side effect of this move operation is a Perl module that I developed and used in the process, and which I’m now releasing — WebService::Amazon::Route53. It provides a Perl interface to Route 53 API, and thus allows you to manage domains and DNS records hosted at Route 53 from the comfort of your Perl scripts.

The module is available on CPAN and on GitHub.

Split Screen Greasemonkey Script

August 14th, 2011

Yesterday I had another crazy idea that ended up implemented as a Greasemonkey script. I was browsing some source code in Firefox, and I thought that the browser is missing one feature that I commonly use in an IDE, and that is the ability to open the same source file in two views displayed side-by-side. This is useful when you need to look at two parts of the code that are related, but are many lines away — like, a function definition and the place where the function is called.

For those of you thinking “meh, couldn’t you just open a second window?” — sure, and I sometimes do that, but it’s not very convenient, as it requires me to do some dragging/resizing to get the desired layout. I wanted an easier solution.

I implemented this in a very simple manner, by replacing the current page with a new document containing two iframes, and loading the current URL in both of them. To make it more useful, I also added the ability to resize the iframes by dragging the splitter bar between them. Here’s a screenshot of the script being used to view a source file on GitHub:

Split Screen script used to view a source code file

The script is available on Userscripts.org.

Dancer::Plugin::DebugToolbar 0.011

August 7th, 2011

This weekend we’re having pretty nice weather here in Warsaw, so what better way to spend your day other than to stay indoors and hack Perl? I’m here with a new version of the debugging toolbar plugin for the Dancer web framework.

A new feature introduced in this version is basic database tracking functionality. The information window can now show the DBI trace data, and display (some of) the SQL queries sent to the database. Here’s a screenshot of that:

Database information screen

I’ve also made significant changes in the basic structure of the code, and rewrote some of it from scratch. In the first release, the HTML code used to inspect the data structures was generated by Perl, which wasn’t especially elegant. Now, pretty much all presentation-related stuff happens in JavaScript, and the Perl code is only responsible for providing the data structures to display.

In the future, this might even allow me to quickly adapt the plugin to other frameworks/languages.

The new version is available on CPAN and GitHub. And, since today happens to be Dancer’s second birthday, let this release be my way of celebrating it. Happy birthday, Dancer!

SelectList 0.4.2

July 31st, 2011

I have released a new minor version of selectList. It introduces a small feature that was requested by a few people, and that is the ability to easily remove all selected items. Before this release, this was possible, but unnecessarily complicated. Now, it’s just a matter of calling the remove() API method with no arguments:

$('select').selectList({ instance: true }).remove();

As always, thanks for everyone’s feedback.

Dancer::Plugin::DebugToolbar

July 29th, 2011

As you might remember, I recently got interested in Dancer, the fabulous micro web framework for Perl. That interest led me to rewrite my website to Dancer, but that wasn’t enough — I found the framework really fun and wanted to play with it a bit more. So I started a small project to develop a plugin that adds a debugging toolbar to Dancer web applications.

I have now made the plugin available on GitHub, and I will be releasing it on CPAN shortly. It’s still in an early stage of development — at this point, it only allows you to inspect your application’s routes and basic data structures. I hope to eventually turn it into a decent development tool, which would also be easy to use to help new Dancer users get familiar with the framework.

Here’s a screenshot of the toolbar displayed at the top of the browser viewport:

Dancer debugging toolbar

And this is how the data inspection window looks:

Debugging toolbar data window

As usual, I’m looking forward to feedback, especially from you fellow dancers out there.

MonkeyConfig

July 17th, 2011

Here’s a slightly late announcement — a few days back, I added a new project to the projects page. It’s called MonkeyConfig and it’s a configuration dialog builder for Greasemonkey scripts.

As with most of my projects, it was born out of necessity. I wanted to add a user-friendly configuration screen to another script of mine, View as Source. I knew about the de-facto standard configuration library GM_config, but I had trouble getting it to do what I wanted — I couldn’t find an easy way to create a form field combined of two drop-down lists, and the generated configuration screen looked ugly for whatever reason (like some styles were missing). I finally gave up on it and decided to develop my own solution.

The just-released version is still pretty immature, but it’s already functional enough to be useful, especially for simple scripts with just a few configuration parameters. Here’s an example of a configuration dialog generated by MonkeyConfig for the View as Source script:

View as Source configuration dialogIf you’re a Greasemonkey script author and would like to give it a try, you’ll find some basic usage instructions on the project page and in the documentation (it’s pretty minimal at this moment, I’ll be expanding it).

The script is also on Userscripts.org and GitHub.

$self =~ s/Symfony/Dancer/

June 30th, 2011

Notice anything different about my site? No? Good, this means that the transition went smooth. I rewrote the engine that my website runs on from Symfony to Perl Dancer.

You might remember that I introduced the Symfony-based engine less than six months ago, so why the switch? Well, back when I launched it, I kind of felt that it might not last very long — mostly because Symfony was just a better-than-nothing choice. For years, my website was running on an ugly framework-wannabe solution that I developed myself. By the way, if you ever get the same idea, consider this advice:

(source: gojko.net)

By the time I finally decided to rebuild it, Symfony just happened to be around — I had a Symfony project coming up and thought it might be good to first get familiar with the framework on a smaller task. I started working on the rewrite, and I quickly got the feeling that Symfony is just too big for the purpose of running a small website like this — I only needed a tiny subset of its numerous features. All in all, it felt way too heavy. But, I really wanted to replace the old engine, so I still went with it.

As for Dancer, I first heard of it about a year ago and I knew I was going to give it a try at some point. Why? Two reasons:

  1. It’s a micro framework, which is much better suited for simple sites than a full-blown MVC framework
  2. It’s Perl, dammit!

So, two weekends of enjoyable hacking, and here it is — my website running on Perl. More precisely, it’s a Perl/PHP hybrid, as the blog is still powered by WordPress. But, the blog engine is feeding its output to the Dancer application, so everything you see is processed by Perl.

ImgAreaSelect 0.9.8

June 18th, 2011

It has been just three days since the previous release of imgAreaSelect, and I’m already here with a new version! How’s that for short release cycles? But seriously, I screwed up a bit with the last release. There was a problem with the implementation of scaling which limited the area available for selection on scaled images, and it somehow went unnoticed during testing. Anyway, version 0.9.8 fixes it.

Thanks to Martin Fowler for catching this issue.

ImgAreaSelect 0.9.7

June 14th, 2011

ImgAreaSelect 0.9.7 has just been released. It’s a few days later than I originally anticipated, as I bumped into some problems with the automated tests. Well, I guess with a dozen browsers, some running on virtual machines, some compiled from source code, I can’t expect things to be easy. Anyways, the significant changes in this version are:

  • The minWidth/minHeight/maxWidth/maxHeight options now respect scaling
  • There is a new API method, cancelSelection(), which cancels the current selection (as the name suggests)

Big thanks to everyone who provided feedback, especially to Loa and Greg.

With each new version, I spend some time making sure the plugin code is as small as possible — after all, the project home page states “the packed version is less than 8 KB”, and I want to keep it that way. But, the packed code for this release was initially about 40 bytes more than 8 KB, so I had to do some refactoring. By changing a few regular expressions, I managed to get it down to 8191 bytes, which happens to be exactly one byte less than 8 KB. That’s a close call, but, hooray, my statement still holds true!