Tag: catalyst

My App GrowlsGrowl is a nice notification utility for Mac OS X. There are many applications or plugins avaiable which interact with Growl (e. g. Skype, Mail, VLC etc.).

I thought it would be nice if I could redirect the catalyst debug output to it as well. Log::Dispatch has a nice appender Log::Dispatch::MacGrowl. Load Log::Dispatch as plugin in MyApp.pm (after ConfigLoader):

use Catalyst qw/-Debug
                ConfigLoader
                Log::Dispatch
                Static::Simple/;

and configure your app accordingly:

<Log::Dispatch>
	class     = MacGrowl
	name      = growl
	app_name  = MyAppGrowls
	title     = MyApp
	sticky    = 0
	min_level = notice
	format    = [%p] %m %n
</Log::Dispatch>

I cannot recommend to set min_level to info or below because this will add all start up log statements to be rendered on your screen. Kind of annoying.

Put a log statement anywhere in your code and start up your dev server. A growl notification should appear when you hit the log statement.

You can get a sample application MyAppGrowls from GitHub.

Make sure you have the following modules installed (or run perl Makefile.PL):

  • Catalyst::Plugin::Log::Dispatch
  • Log::Dispatch::Config
  • Log::Dispatch::MacGrowl

Writing documentation is sometimes hard but inevitable. If you write code which is published on the CPAN you can always access the documentation through search.cpan.org. For those cases where you cannot publish your code on the CPAN it would be great if you had a web site like CPAN where you can access the documentation. For this reason I wrote Pod::Browser a while back. Pod::Browser is a browser for all your local modules and all the modules from the CPAN. The interface is rendered by ExtJS, a powerful JavaScript framework.

Pod::Browser

After installing Pod::Browser and running the server (pod_browser_server.pl) you should be able to access the browser via http://localhost:3000. On the right hand side of the page is a tree which contains all the modules installed on your system. The main page contains a search box where you can search the CPAN via it’s XML interface. If you open a module which is also installed on your system, the local pod will be served. Otherwise the pod is read from the CPAN. Each module has its own ExtJS tab. This allows to have multiple documents open at the same time in a single browser window. The table of contents is shown in the upper left panel.

Since this browser has been implemented as a single Catalyst controller, you can simply create an empty controller in your application and use Catalyst::Controller::POD as base class:

package MyApp::Controller::Docs;
 
  use strict;
  use warnings;
  use base 'Catalyst::Controller::POD';
  __PACKAGE__->config(
    inc        => 1,
    namespaces => [qw(Catalyst::Manual*)],
    self       => 1,
  );
  1;

This will make the documentation to your application avaiable from /docs. The pod tree will also contain all the modules which are listed in the namespaces config attribute (in this case Catalyst::Manual).

For more information on Pod::Browser and Catalyst::Controller::POD please read the documentation on the CPAN.

Warning:

If you set inc to 1 and leave the namespaces parameter blank it can take a while until all modules are indexed and presented in your browser. Be either patient or restrict the namespace to a sane subset of your modules.

Why not Angerwhale?

As a Perl programmer I prefer to do everything I want in that language. Since I decided to run a blog and was wondering what blog engine I should use. The easiest way would have been to sign up at blogger.com or similar services but I want to host my stuff on my own.

I searched the net and of course CPAN for a blogging engine based on Perl. The only one I came up with was Angerwhale. I read through the CPAN pods and looked at blog.jrock.us to see it in action. It seemed pretty nice and I decided to give it a try.

I read the README file, ran “perl Makefile.PL” and “make test” as I was supposed to do. There were some unmet dependencies, of course. Many of them failed to install unfortunately. After spending a lot of time installing all of them manually (most of them needed additional development packages from debian) I was almost there.

Three to go: Catalyst::View::Jemplate. That damn thing wouldn’t install because most of the tests failed. As it turned out it was the fault of the latest Jemplate upgrade which made some changes to its API. A dev release of Jemplate fixed that problem, but that’s not the way it is supposed to work.

Two to go: Test::WWW::Mechanize. Tests failed. Both on my system and most of the CPAN testers’. Seems like a libwww release breaks these tests.

One more to go: Kate. This is a syntax highlighting engine. Angerwhale uses it to format and color code passages. It failed to install as well. There is a fix for that problem but this patch is 4 month old! Why didn’t the maintainer apply that patch and push a new release to cpan?

At that point I was pretty sick and tired of trying to force install or patch any more modules.

After rethinking this whole blog thing I visited wordpress.com.

wget http://wordpress.org/latest.tar.gz
unp latest.tar.gz
lynx http://localhost/wordpress

Well, and after entering db user / password etc. I had my blog up and running.

There might have been some coincidences and bad timing but after all I must say that installing wordpress took me about 5min. Not installing Angerwhale took me more than an hour.

Wordpress does a great job and it just works. It’s just sad that there is no such success story with a perl written blog engine.