91 lines
3.4 KiB
Perl
Executable File
91 lines
3.4 KiB
Perl
Executable File
package Dojo;
|
|
use Mojo::Base 'Mojolicious';
|
|
use Dojo::Conf;
|
|
use Dojo::Model::Vuelo;
|
|
use Dojo::Model::Users;
|
|
use Dojo::Model::Vdgproc;
|
|
|
|
# This method will run once at server start
|
|
sub startup {
|
|
my $self = shift;
|
|
my $config = $self->plugin('Config'); #Config hash dojo.conf
|
|
# $self->plugin('PODRenderer') if $config->{perldoc}; #doc
|
|
$self->secrets(['Mojojojo jojo']); #cookies
|
|
|
|
$self->helper(dbv => sub { state $dbv = Dojo::Model::Vuelo->new });
|
|
$self->helper(dbg => sub { state $dbg = Dojo::Model::Users->new });
|
|
$self->helper(mproc => sub { state $mproc = Dojo::Model::Vdgproc->new });
|
|
$self->defaults({%Dojo::Conf::def});
|
|
my $r = $self->routes; #router
|
|
|
|
# de la pagina ===============================================================
|
|
$r->any('/')->to('home#home_');
|
|
$r->any('/home')->to('home#home');
|
|
$r->any('/pod')->to('home#podcast');
|
|
# $r->any('/store')->to('home#store');
|
|
$r->any('/tv')->to('home#tv');
|
|
$r->any('/contact')->to('home#contact');
|
|
$r->any('/contact2')->to('home#contact2');
|
|
$r->any('/pang')->to('home#pang');
|
|
# json ==================
|
|
$r->any('/json/*dreq')->to('data#simple');
|
|
# =============================================================================
|
|
|
|
# de la tienda ================================================================
|
|
$r->any('/cal')->to('proc#cal');
|
|
$r->any('/event/:id'=> [id => qr/\d+/])->to('proc#event');
|
|
$r->any('/spay/:class/:id' => [class => qr/\d+/, id => qr/\d+/])->to('proc#spay');
|
|
$r->any('/spay/intentCreate')->to('proc#intentCreate');
|
|
$r->any('/spay/intentConfirm')->to('proc#intentConfirm');
|
|
$r->any('/spay/userCheck')->to('proc#userCheck');
|
|
# =============================================================================
|
|
|
|
# candy =======================================================================
|
|
$r->any('/json/candy/:command')->to('data#candy');
|
|
$r->any('/candy')->to('home#candy');
|
|
# =============================================================================
|
|
|
|
# usuarios y accesos ==========================================================
|
|
$r->any('/reg')->to('users#reg');
|
|
|
|
# login guest ======
|
|
$r->any('/login')->to('users#login');
|
|
$r->any('/logout')->to('users#logout');
|
|
|
|
my $logged_in = $r->under('/')->to('users#is_logged');
|
|
$logged_in->get('/radio')->to('home#radio');
|
|
# ===================
|
|
|
|
# login user grulla =
|
|
# common grulla user
|
|
my $user = $r->under('/')->to('users#is_grulla');
|
|
$user->any('/ccast')->to('home#bcast');
|
|
# personal
|
|
my $guest = $r->under('/')->to('users#is_grulla_tmp');
|
|
$guest->any('/bcast')->to('home#bcast');
|
|
# ===================
|
|
|
|
# admin =======================================================================
|
|
my $admin = $r->under('/admin')->to('users#is_admin');
|
|
$admin->any('')->to('admin#admin');
|
|
$admin->any('home')->to('admin#home');
|
|
$admin->any('radio')->to('admin#radio');
|
|
$admin->any('eventos')->to('admin#eventos');
|
|
$admin->any('eventos/:type'=> [type=>['e','p','c']])->to('admin#eventos');
|
|
$admin->any('mensajes')->to('admin#mensajes');
|
|
$admin->any('json/:dreq/:id')->to('admin#json');
|
|
|
|
# =============================================================================
|
|
|
|
# a not foud ==================================================================
|
|
|
|
$r->any('/*whatever' => {whatever => ''} => sub {
|
|
my $c = shift;
|
|
my $whatever = $c->param('whatever');
|
|
$c->stash(layout=>'clean');
|
|
$c->render(template=>'home/not_found', status=>404);
|
|
});
|
|
}
|
|
|
|
1;
|