Catalyst Javascript Testbed

singingfish on 2007-06-01T11:36:00

Quick way to get a javascript testbed going:

$ catalyst.pl MyApp $ cd MyApp

# put this in MyApp::Controller::Root

sub default : Path { my ( $self, $c, $arg ) = @_;

unless ($arg =~ /boo|hoo|snoo/) { $c->res->status('404'); $c->res->body('404 not found'); } else { $c->config->{$arg}++; $c->res->header('Content-Type', 'text/plain'); $c->res->body($c->config->{$arg}); } }

sub index : Private { my ($self, $c) = @_; $c->res->redirect($c->uri_for('/static/index.htm')); }

# download your js libraries of choice (jquery here) to root/static/js (create dir as nescessary) # And in /static/index.htm <-- NOTE the lack of 'l' at the end - there is a reason for this!