Files
dojo/lib/Dojo.pm

93 lines
3.5 KiB
Perl
Raw Permalink Normal View History

2018-07-13 19:06:08 -05:00
package Dojo;
use Mojo::Base 'Mojolicious';
use Dojo::Conf;
use Dojo::Model::Vuelo;
use Dojo::Model::Users;
2020-01-15 23:42:58 -06:00
use Dojo::Model::Vdgproc;
2018-07-13 19:06:08 -05:00
# This method will run once at server start
2020-01-20 18:19:38 -06:00
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
2018-07-20 05:16:47 -05:00
2020-01-20 18:19:38 -06:00
$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 });
2020-01-15 23:42:58 -06:00
$self->defaults({%Dojo::Conf::def});
2020-01-20 18:19:38 -06:00
my $r = $self->routes; #router
2018-07-20 05:16:47 -05:00
2020-01-20 18:19:38 -06:00
# 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');
# =============================================================================
2020-01-15 23:42:58 -06:00
2020-01-20 18:19:38 -06:00
# 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');
# =============================================================================
2018-07-20 05:16:47 -05:00
2020-01-20 18:19:38 -06:00
# candy =======================================================================
$r->any('/json/candy/:command')->to('data#candy');
$r->any('/candy')->to('home#candy');
# =============================================================================
2019-03-19 02:56:18 -06:00
2020-01-20 18:19:38 -06:00
# usuarios y accesos ==========================================================
$r->any('/reg')->to('users#reg');
2018-07-13 19:06:08 -05:00
2020-01-20 18:19:38 -06:00
# login guest ======
$r->any('/login')->to('users#login');
$r->any('/logout')->to('users#logout');
2019-03-19 02:56:18 -06:00
2020-01-20 18:19:38 -06:00
my $logged_in = $r->under('/')->to('users#is_logged');
$logged_in->get('/radio')->to('home#radio');
# ===================
2018-07-25 19:07:29 -05:00
2020-05-27 15:28:41 -05:00
# login any temp pass=
my $usert = $r->under('/')->to('users#is_tmp');
2020-01-20 18:19:38 -06:00
# 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');
2020-05-27 15:28:41 -05:00
$guest->any('/radiop')->to('home#radiop');
2020-01-20 18:19:38 -06:00
# ===================
# admin =======================================================================
my $admin = $r->under('/admin')->to('users#is_admin');
$admin->any('')->to('admin#admin');
2020-01-22 18:22:31 -06:00
$admin->any('home')->to('admin#home');
2020-01-20 18:19:38 -06:00
$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 ==================================================================
2020-01-15 23:42:58 -06:00
2019-04-03 14:08:45 -06:00
$r->any('/*whatever' => {whatever => ''} => sub {
2020-01-20 18:19:38 -06:00
my $c = shift;
my $whatever = $c->param('whatever');
$c->stash(layout=>'clean');
$c->render(template=>'home/not_found', status=>404);
});
2018-07-13 19:06:08 -05:00
}
1;