Browse Source

* add 'db' and 'captcha' accessors

master
Alex 'AdUser' Z 7 years ago
parent
commit
120929dab7
  1. 16
      lib/CMTD.pm

16
lib/CMTD.pm

@ -11,17 +11,27 @@ sub startup {
$self->plugin('CMTD::Helpers'); $self->plugin('CMTD::Helpers');
$self->plugin(Config => {file => 'cmtd.conf'}); $self->plugin(Config => {file => 'cmtd.conf'});
$self->app->attr(captcha => sub {
my $config = $self->app->config->{captcha};
require CMTD::Captcha;
my $cap = CMTD::Captcha->new(%{ $config });
return $cap;
});
$self->app->attr(db => sub {
my $config = $self->app->config->{db} || [];
require DBIx::Simple;
my $dbh = DBIx::Simple->new(@{ $config });
return $dbh;
});
my $r = $self->routes; my $r = $self->routes;
$r->get('/') $r->get('/')
-> to('main#index'); -> to('main#index');
$r->get('/captcha') $r->get('/captcha')
-> to('main#captcha'); -> to('main#captcha');
$r->get('/comments/list') $r->get('/comments/list')
-> to('main#c_list'); -> to('main#c_list');
$r->get('/comments/add') $r->get('/comments/add')
-> to('main#c_add'); -> to('main#c_add');
} }

Loading…
Cancel
Save