package Dojo; use Mojo::Base 'Mojolicious'; use Dojo::Conf; use Dojo::Model::Vuelo; use Dojo::Model::Users; use Dojo::Model::Data; # 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(ddtt => sub { state $ddtt = Dojo::Model::Data->new }); $self->defaults({%Dojo::Conf::def}); my $r = $self->routes; #router $r->any('/home')->to('home#home'); $r->any('/cal')->to('home#cal'); $r->any('/event/:id'=> [id => qr/\d+/])->to('home#event'); #$r->any('/radio')->to('home#radio'); $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'); $r->any('/json/:dreq')->to('data#simple'); $r->any('/json/candy/:command')->to('data#candy'); $r->any('/admin/:section'=> {section =>'home'})->to('home#admin'); $r->any('/admin/json/:dreq/:id/')->to('data#admin'); $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'); } 1;