Mojo 0.991231 released

| No TrackBacks
We have just released the last big milestone on the way towards Mojo 1.0, everything from now on will be just documentation, artwork and other polishing tasks.

As usual there are awesome new features such as HTTP 1.1 pipelining, format handling, layout support and a brand new routes syntax.

Thanks to our GSOC Student Pascal Gaudette who squashed many RFC related bugs we are now even further ahead of other HTTP implementations on CPAN. And the best of all, after some refactoring the whole HTTP 1.1 client/server state machine is now completely reusable and independent from the IO layer. This will make modules such as AnyEvent::Mojo absolutely trivial in the future.

And while we are at it, here's a preview of the new "fluffy cloud" Mojo logo!

The complete changelog.
- Rewrote MojoX::Renderer, it is not backward compatible and templates need to be renamed in the following 3 part format "index.html.tt"!
- Added exception support to MojoX::Dispatcher::Routes, this change is not backward compatible and "dispatch" calls now return exception objects for errors and false otherwise.
- Changed routes syntax, this change is not backward compatible and you need to change all your existing routes.
"/:foo" becomes "/(foo)"
"/^foo" becomes "/((foo))"
"/*foo" becomes "/(((foo)))"
- Added full HTTP 1.1 pipelining support to all Mojo layers.
- Added layout support to MojoX::Renderer.
- Made render call optional.
- Added format support to MojoX::Routes.
- Added Mojo::Loader::Exception.
- Added wildcard symbol support to MojoX::Routes and rewrote many routes internals.
- Added Makefile.PL generator.
- Added HttpOnly support to Mojo::Cookie. (burak)
- Support more CGI implementations.
- Added support for namespaces only dispatching in MojoX::Dispatcher::Routes.
- Added encoding support to Mojo::Template and made "utf8" the default.
- Added HEAD support to Mojo::Server::Daemon. (acajou)
- Added new relaxed placeholder to MojoX::Routes::Pattern.
- Added Mojo::Template::Exception.
- Added HEAD support to the Mojo::Transaction state machine and related modules. (acajou)
- Added safe_post option to Mojo::Pipeline. (acajou)
- Made chained => 1 the default in Mojo::Base.
- Fixed compiler bug in Mojo::Template that prevented more advanced control structures, you might have to add additional semicolons to some of your templates.
- Fixed Mojo::Date to not crash on invalid dates. (vti)
- Fixed chunked support in Mojo::Server::Daemon and Mojo::Client.
- Fixed tokenizer in MojoX::Routes::Pattern to support "0" values. (Anatoly Sharifulin)
- Fixed parsing of "0" in Mojo::Path. (charsbar)
- Fix server tests on win32. (charsbar)
- Fixed leading whitespace problem in the request parser. (acajou)
- Fixed broken pipe problem in Mojo::Server::CGI. (vti)
- Added more diagnostics options to Mojo::HelloWorld. (uwe)
- Fixed empty cookie parsing. (vti)
- Fixed a case where child processes migth hang in Mojo::Server::Daemon::Prefork. (gbarr)
- Fixed a bug in MojoX::Dispatcher::Routes where the renderer would be called with an empty stack. (melo)
- Fixed a escaping problem in Mojo::Parameters. (vti)
- Updated Mojo::URL to be more template friendly.
- Improved Solaris compatibility.


P.S. In case you were wondering, the version number is the date of the first futurama episode. ;)

HTTP 1.1 pipelining in Mojo

| No TrackBacks
I've just committed a huge change adding full HTTP 1.1 pipelining support to all layers of Mojo. This makes Mojo the first Perl HTTP implementation to support this feature on the client and server side (not counting LWPng), yay!

Now you might be wondering "wtf is pipelining"? Let me try to explain it with a little illustration. This Wikipedia page has more informations if you are interested. I'm really looking forward to MojoX::UserAgent, which hopefully will be a Google Summer of Code project and make great use of pipelining.

Mojo Documentation

| No TrackBacks
Back in December 2008 the Perl Foundation accepted my grant application for the Mojo Documentation Project. Sadly i had to delay all grant work because of health problems until now. But things are finally getting better and i'm highly motivated to get back to work.

I know some of you can't wait, so here's a little sneak preview of the chapters. (the first chapter should hit the github repository soon)
Mojo::Manual::GettingStarted - Step by step instructions to get you started with Mojo.
    * Installation
    * Running the development server
    * Writing your first micro application and testing it

Mojo::Manual::Transaction - Everything in Mojo was built around the idea of processing HTTP requests as transactions.
    * HTTP Messages
    * Request
    * Response
    * Cookies
    * Parameters
    * Content

Mojo::Manual::Deployment - Running Mojo applications in different environemnts.
    * Designed for portability
    * Built in servers
    * CGI
    * FastCGI
    * Easy to extend

Mojo::Manual::Mojolicious - Introduction to Mojolicious, the Mojo example web framework.
    * The MVC design pattern
    * Application class
    * Dispatchers
    * Controllers
    * Routes
    * Renderer and templates
    * Modes

Mojo::Manual::MojoliciousExample - Building your first real web application with Mojolicious, a POD reader.
    * Directory structure
    * Model
    * Controller
    * Templates
    * Testing

Mojo::Manual::Cookbook - Cooking with Mojo and Mojolicious.
Note that i've disabled comments on my blog, but you can still send trackbacks. ;)

Google Voice

| No TrackBacks
via NY Times
It unifies your phone numbers, transcribes your voice mail, blocks telemarketers and elevates text messages to first-class communication citizens. And that’s just the warm-up...

...Each time you answered a call, while the caller was still hearing “one ringy-dingy, two ringy-dingies,” you heard a recording offering four ways to handle the call: “Press 1 to accept, 2 to send to voice mail, 3 to listen in on voice mail, or 4 to accept and record the call.” If you pressed 3, the call went directly to voice mail, but you could listen in. If you felt that the caller deserved your immediate attention, you could press * to pick up and join the call. This subtle feature saved time, conserved cellular minutes and, in certain cases, avoided a great deal of interpersonal conflict...

...If you dial your own Google Voice number from one of your phones, you’re offered an option to call overseas at rates even lower than Skype’s (and much lower than your cellphone company’s): 2 cents a minute to France or China, 3 cents to Chile or the Czech Republic. Sweet.
This could really shake up the telco business, but do i want Google to transcribe and possibly index all my voice mail?

Mozilla Bespin

| No TrackBacks
Bespin from the Mozilla Labs is full featured text editor implemented with Javascript and the HTML 5 <canvas> element. Very impressive and crazy, i'll have to keep an eye on this.


View Introduction to Bespin

Perl community not generating any internal buzz...

| No TrackBacks
via Marcus
Chromatic points to a trend in the Perl community of not giving any link love to our own. Somehow, it feels like I’ve heard this before. I agree this is a negative trend, but I find it amusing that it comes from chromatic, the only posters I can remember him linking to in his journal is people spreading FUD about Perl, in is mission to refute their statements. Somehow it seems to me like linking to these people and giving them attention is only making them stronger…
There is a lot of truth to this, somehow people prefer to complain about the problem instead of actually starting some link love.

xkcd++

| No TrackBacks

Mojo 0.9 released

| No TrackBacks
Our biggest update so far, with many awesome new features like built in log file support and Modes. Mojolicious got even more userfriendly, take a look!
- Added modes to Mojolicious.
- Added Mojo::Log and log support for Mojo/Mojolicious.
- Changed MojoX::Renderer and Mojo::Template api to make catching errors easier, we now use a scalar ref for results like most template engines.
- Added MojoX::Context.
- Added multi level controller class support to Mojolicious.
- MojoX::Dispatcher::Routes should be able to fail.
- Added diagnostics functions to Mojo::HelloWorld.
- Made the env parser Apache compatible.
- Made Mojo::Server::FastCGI Apache compatible.
- Added namespace, class and method captures to MojoX::Dispatcher::Routes.
- Made url_for work for rebased applications.
- Added ctx, render, req, res and stash methods to Mojolicious controllers.
- Changed cookie, param and upload in Mojo::Parameters to return a list.
- Added support for templateless renderers to MojoX::Renderer.
- Added blacklist to MojoX::Dispatcher::Routes.
- Fixed Mojo::Date bugs. (vti)
- Fixed / routes matching too much.
- New Windows workaround in Mojo::Client and Mojo::Server::Daemon.
- Cleaned up Mojo::Transaction. (Ask Bjoern Hansen)
- Added .perltidyrc. (Ask Bjoern Hansen)
- Allow chains to be broken with return values in MojoX::Dispatcher::Routes.
- The stack in MojoX::Routes resets now.
- Renamed default_handler to default_format in MojoX::Renderer.
- Disallow actions beginning with _ in MojoX::Dispatcher::Routes.
- Preload application in servers. (Graham Barr)
- Renamed is_version to at_least_version. (Mark Stosberg)
- Added documentation. (Ch Lamprecht)
- Added param tests. (Mark Stosberg)
- Added documentation for Mojo::Log. (Mark Stosberg)
- Add test for MojoX::Renderer. (Mark Stosberg)
- When testing, allow servers a few seconds to stop. (Leon Brocard) - Fixed typos.

Small things that make a big difference

| No TrackBacks
Mojolicious and Catalyst actions have always been very similar since i've basically cargo culted them both from Maypole. But we've never been happy with the idea of explicitly passing around the context object in Mojolicious.

sub list {
    my ($self, $c) = @_;
    $self->_list($c);
    $c->render;
}

sub _list {
    my ($self, $c) = @_;
    $c->stash(items => [qw/23 54/]);
}
Ask Bjoern Hansen recently proposed a small change to this which got a discussion started.

sub list {
    my $self = shift;
    $self->_list;
    $self->ctx->render;
}

sub _list {
    my $self = shift;
    $self->ctx->stash(items => [qw/23 54/]);
}
Making the context a controller attribute was a big step forward but still couldn't be considered beautiful. After some more unsuccessful tries Mark Stosberg popped up with some CGI::Application examples, and it totally made sense for us.

sub list {
    my $self = shift;
    $self->_list;
    $self->render;
}

sub _list {
    my $self = shift;
    $self->stash(items => [qw/23 54/]);
}
All we had to do to make it finally beautiful was adding the 4 most often used methods/attributes from the context to the controller.

sub test {
    my $self = shift;

    # Request
    my $req = $self->req;

    # Response
    my $res = $self->res;

    # Stash
    $self->stash(foo => 23);

    # Renderer
    $self->render;
}
It's incredible how much of a difference such a minor change can make usability wise.

Environments for Mojolicious

| No TrackBacks
Back in the days when i was working on Catalyst, i thought it would be a great idea to have a special debug environment. You could activate it with a simple -Debug flag in the import list. But what if your development process has more stages than development and production? Right, you are screwed. That's why we've decided to use a more ambitious concept we call Modes in Mojolicious, where you can have an unlimited number of different environments.

package MyApp;
use base 'Mojolicious';

sub production_mode {
    my $self = shift;

    # Production templates
    $self->renderer->root('/Users/production/templates');
}

sub development_mode {
    my $self = shift;

    # Development templates
    $self->renderer->root('/Users/dev/templates');
}

sub startup {
    my $self = shift;

    # Default templates for everything else
    $self->renderer->root('/Users/defaul/templates');
}

1;
As you can see we've chosen a very minimalistic approach that feels in line with the rest of Mojolicious. Switching between modes is as easy as changing a environment variable.
% MOJO_MODE=production bin/my_app daemon