#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => "about";
my @menu = (
nav => [ qw{overview examples source feedback} ],
sidebar => {
overview => [
qw{toto/elements element toto/quickstart toto/inspiration toto/examples toto/download}
],
examples => [
qw{example/list example},
],
source => [
qw{file/list file},
],
feedback => [
qw{comments/view comments/add},
],
},
tabs => {
element => [ qw/description example/ ],
example => [ qw/description source/ ],
file => [ qw/pod raw git/ ],
}
);
plugin toto => @menu;
app->start;
__DATA__
@@ about.html.ep
A navigational structure based on tabs and objects.
<%= link_to "toto/elements", class =>"btn btn-primary btn-large" => begin %> Learn more <%= end %>
Each page in an application created with toto has :
Pages are created using <%= link_to "element/default" => { key => "template" } => begin %> templates<%= end %>.
The toto <%= link_to "element/default" => { key => "layout" } => begin %> layout<%= end %> generates the navigational structure.
A number of <%= link_to "element/default" => { key => "helpers" } => begin %> helpers <%= end %> are added for use within templates.
A number of <%= link_to "element/default" => { key => "stashkey" } => begin %> stash keys %= end are set which may also be accessed from within the templates.
@@ toto/quickstart.html.epTo get a sample toto site running, just <%= link_to "toto/download" => begin %>download<%= end %> toto, and run one of the <%= link_to "toto/examples" => begin %>examples<%= end %>.
$ cpanm Mojolicious::Plugin::Toto $ cpanm --look Mojolicious::Plugin::Toto $ ./eg/toto.pl daemon@@ toto/download.html.ep
<%= link_to "https://metacpan.org/module/Mojolicious::Plugin::Toto" => begin %>Mojolicious-Plugin-Toto<%= end %> is available on <%= link_to "http://cpan.org" => begin %>CPAN<%= end %>.
It can be downloaded from there directly, or using a tool, such as <%= link_to "https://metacpan.org/module/cpanm" => begin %>cpanm<%= end %>.
curl http://cpanmin.us > ~/bin/cpanm chmod +x ~/bin/cpanm ~/bin/cpanm Mojolicious::Plugin::Toto@@ element/navbar/description.html.ep The nav bar is created from a list of words. The words are used for a few purposes :
The side bar is a hash mapping nav bar items to lists of elements in the side bar.
Keys in the hash are elements of the nav bar array. Values in the hash may take one of two forms :
%= dumper( toto_config->{$what} )
@@ element/template/description.html.ep
Templates in a toto application may be found in several locations, depending on how generic the template is. templates from the following paths are loaded :
%= $self->app->renderer->get_data_template({},'element/template/example.html.ep');
but the code for the more generic "example" template, used by most of the other
example pages on this site
(
<%= link_to 'element/example', { key => 'navbar' } => begin %>navbar<%= end %>,
<%= link_to 'element/example', { key => 'sidebar' } => begin %>sidebar<%= end %>, etc.
)
is :
%= $self->app->renderer->get_data_template({},'element/example.html.ep');
@@ element/object/description.html.ep
Toto makes use of the objects in your application, by using the namespace you provide when you initilize the plugin. When a route of the form "$noun/$key/$action" is encountered, $noun will be camelcased and appended to the namespace. Then a constructor will be called which uses $key, like so :
$c->model_class->new(key => $key);
This behavior is encapsulated in a helper called "current_instance". To change this default behavior, write another "current_instance" helper to replace the default one.
Besides new(), the following methods may be implemented :
%= Mojo::Asset::File->new(path => $INC{q[Mojolicious/Plugin/Toto/Model.pm]})->slurp;
@@ element/helpers/description.html.ep
$app->defaults(layout => "toto")The layout and supporting files, are builded with the plugin and used as defaults, but may be overridden. Some stash values may be set for minimal customization :
% my $path = $self->app->renderer->template_path({template => "layouts/toto", format => "html", handler => 'ep'});
%= Mojo::Asset::File->new(path => $path)->slurp;