Files
dojo/lib/Dojo.pm

71 lines
2.9 KiB
Perl
Raw 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;
# This method will run once at server start
2018-07-20 05:16:47 -05:00
sub startup {
my $self = shift;
my $config = $self->plugin('Config'); #Config hash dojo.conf
2019-03-04 03:30:22 +01:00
# $self->plugin('PODRenderer') if $config->{perldoc}; #doc
2018-07-20 05:16:47 -05:00
$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->defaults({%Dojo::Conf::def});
my $r = $self->routes; #router
# user ========================================================================
2018-07-27 16:45:29 -05:00
$r->any('/')->to('home#home_');
2018-07-20 05:16:47 -05:00
$r->any('/home')->to('home#home');
$r->any('/cal')->to('home#cal');
$r->any('/event/:id'=> [id => qr/\d+/])->to('home#event');
$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');
$r->any('/tst')->to('home#tst');
# =============================================================================
# json ========================================================================
$r->any('/json/:dreq')->to('data#simple');
# =============================================================================
# candy =======================================================================
$r->any('/json/candy/:command')->to('data#candy');
2018-07-25 20:48:58 +00:00
$r->any('/candy')->to('home#candy');
2018-07-20 05:16:47 -05:00
# =============================================================================
2018-07-25 20:48:58 +00:00
2018-07-27 16:45:29 -05:00
# login guest =================================================================
2018-07-20 05:16:47 -05:00
$r->any('/login')->to('users#login');
$r->any('/logout')->to('users#logout');
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
my $logged_in = $r->under('/')->to('users#is_logged');
$logged_in->get('/radio')->to('home#radio');
2018-07-27 16:45:29 -05:00
# =============================================================================
2018-07-25 19:07:29 -05:00
2018-07-27 16:45:29 -05:00
# login user grulla ===========================================================
my $guestp = $r->under('/')->to('users#is_grulla');
$guestp->any('/bcast')->to('home#bcast');
# =============================================================================
# admin =======================================================================
2018-07-25 19:07:29 -05:00
my $admin = $r->under('/admin')->to('users#is_admin');
$admin->any('')->to('home#admin');
$admin->any('home')->to('home#admin_home');
$admin->any('radio')->to('home#admin_radio');
$admin->any('eventos')->to('home#admin_eventos');
$admin->any('eventos/:type'=> [type=>['e','p','c']])->to('home#admin_eventos');
$admin->any('mensajes')->to('home#admin_mensajes');
$admin->any('json/:dreq/:id')->to('home#admin_json');
2018-07-20 05:16:47 -05:00
# =============================================================================
2018-07-13 19:06:08 -05:00
}
1;