The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::Toto - A simple tab and object based site structure

SYNOPSIS

 use Mojolicious::Lite;

 get '/my/url/to/list/beers' => sub {
      shift->render_text("Here is a page for listing beers.");
 } => "beer/list";

 get '/beer/create' => sub {
    shift->render_text("Here is a page to create a beer.");
 } => "beer/create";

 plugin 'toto' =>
    menu => [
        beer    => { one  => [qw/view edit pictures notes/],
                     many => [qw/list create search browse/] },
        brewery => { one  => [qw/view edit directions beers info/],
                     many => [qw/phonelist mailing_list/] },
        pub     => { one  => [qw/view info comments hours/],
                     many => [qw/search map/] },
    ],
    themeswitcher => 1,
 ;

 app->start

 ./Beer daemon

DESCRIPTION

This plugin provides a navigational structure and a default set of routes for a Mojolicious or Mojolicious::Lite app.

It extends the idea of BREAD or CRUD -- in a BREAD application, browse and add are operations on aggregate (0 or many) objects, while edit, add, and delete are operations on 1 object.

Toto groups all pages into two categories : either they act on one object, or they act on 0 or many objects.

One set of tabs provides a way to change between types of objects. Another row of tabs provides a way to change actions.

The actions displayed depend on context -- the type of object, and whether or not an object is selected determine the list of actions that are displayed

The toto menu data structure is used to generate default routes of the form controller/action, for each controller+action pair. It is also used to generate the menu and tabs.

By loading the plugin after creating routes, any routes created manually which use this naming convention will take precedence over the default ones.

For Mojolicious (not lite) apps, methods in controller classes will be used if they exist.

Because routes are created automatically, creating a page may be done by just adding a file named templates/controller/action.html.ep.

Styling is done (mostly) with jquery css.

SEE ALSO

http://www.beer.dotcloud.com