2011-03-10 15:19:34 +00:00
|
|
|
package Explain;
|
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious';
|
|
|
|
|
|
|
|
sub startup {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# register Explain plugins namespace
|
|
|
|
$self->plugins->namespaces( [ "Explain::Plugin", @{ $self->plugins->namespaces } ] );
|
|
|
|
|
|
|
|
# setup charset
|
|
|
|
$self->plugin( charset => { charset => 'utf8' } );
|
|
|
|
|
|
|
|
# load configuration
|
2012-01-26 11:28:02 +01:00
|
|
|
my $config = $self->plugin( 'JSONConfig' );
|
2011-03-10 15:19:34 +00:00
|
|
|
|
|
|
|
# setup secret passphrase
|
|
|
|
$self->secret( $config->{ secret } || 'Xwyfe-_d:yGDr+p][Vs7Kk+e3mmP=c_|s7hvExF=b|4r4^gO|' );
|
|
|
|
|
|
|
|
# startup database connection
|
|
|
|
$self->plugin( 'database', $config->{ database } || {} );
|
|
|
|
|
|
|
|
# startup mail sender
|
|
|
|
$self->plugin( 'mail_sender', $config->{ mail_sender } || {} );
|
|
|
|
|
|
|
|
# routes
|
|
|
|
my $routes = $self->routes;
|
|
|
|
|
|
|
|
# route: 'index'
|
2011-03-11 06:19:50 +00:00
|
|
|
$routes->route( '/' )->to( 'controller#index' )->name( 'new-explain' );
|
2011-03-10 15:19:34 +00:00
|
|
|
|
|
|
|
# route: 'show'
|
2011-03-11 06:19:50 +00:00
|
|
|
$routes->route( '/s/:id' )->to( 'controller#show', id => '' )->name( 'show' );
|
2011-03-10 15:19:34 +00:00
|
|
|
|
2013-03-30 20:18:27 +01:00
|
|
|
# route: 'delete'
|
|
|
|
$routes->route( '/d/:id/:key' )->to( 'controller#delete', id => '', key => '' )->name( 'delete' );
|
|
|
|
|
2011-03-10 15:19:34 +00:00
|
|
|
# route: 'history'
|
2011-03-11 06:19:50 +00:00
|
|
|
$routes->route( '/history/:date' )->to( 'controller#history', date => '' )->name( 'history' );
|
2011-03-10 15:19:34 +00:00
|
|
|
|
|
|
|
# route: 'contact'
|
|
|
|
$routes->route( '/contact' )->to( 'controller#contact' )->name( 'contact' );
|
|
|
|
|
|
|
|
# route: 'help'
|
|
|
|
$routes->route( '/help' )->to( 'controller#help' )->name( 'help' );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|