網路城邦
RSS Feed Link 部落格聯播
左線預備,右線預備,全線預備,開保險,開始射擊!

文章數:3
App.pm
知識學習語言 2016/02/18 04:14:47

package App;

use strict;
use warnings;
use Mojo::Base 'Mojolicious';

our ($data, $sql, $bv, $result);

sub init
{
my $self = shift;

$data->{log_level} = {
production => 'debug',
development => 'debug',
test => 'debug',
stage => 'debug',
demo => 'debug',
sandbox => 'debug',
};

$self->log->level($data->{log_level}->{$self->mode});

shift @{$self->renderer->paths};
push @{$self->renderer->paths}, $self->home->to_string.'/web/templates';

$self->plugin('Plugin::Debug');
#$self->DEBUG(0, '$self', $self->Dump($self));

$self->{timestamp}->{start} = $self->timestamp;

if($self->{conf})
{
my $file = $self->{conf};
#$self->DEBUG(0, '$file', $self->Dump($file));
if(open FILE, $file)
{
$self->config(eval(join('', )));
close FILE;
}
else
{
die("$file: $!\n");
}
}
my $config = $self->config;

$config->{dir}->{app_home} = $self->home->to_string;
#push(@{$self->static->paths}, "$config->{dir}->{app_home}/web/public");

$self->plugin('Plugin::Util', $config);
$self->plugin('Plugin::Mail', $config);

push(@{$self->static->paths}, @{$config->{dir}->{static}});

$self->renderer->encoding('UTF-8');

my $mason = $self->plugin('Plugin::Mason2',
{
preload_regexps => [ '.mc$', $config->{dir}->{mason_comp}],
interp_params =>
{
comp_root => $config->{dir}->{mason_comp},
data_dir => $config->{dir}->{mason_data}.'/'.$self->mode,
allow_globals => [qw($q $db)],
},
request_params => {},
set_global_items => {'$q' => $self},
});

#$self->secrets($config->{session}->{secrets}.$self->{timestamp}->{D});
$self->secrets($config->{session}->{secrets});
$self->sessions->cookie_name($config->{session}->{cookie_name});
$self->sessions->default_expiration($config->{session}->{default_expiration});
$self->sessions->cookie_path('/');

return 1;
}

sub startup {
my $self = shift;

$self->init(@_);

my $r = $self->routes;

my $auth = $r->under('/')->to(controller => 'auth', action => 'user');
$auth->route('/#controller/#action/#target/#task/#perform/#object/#move')->name('move_route');
$auth->route('/#controller/#action/#target/#task/#perform/#object')->name('oid_route');
$auth->route('/#controller/#action/#target/#task/#perform')->name('perform_route');
$auth->route('/#controller/#action/#target/#task')->name('task_route');
$auth->route('/#controller/#action/#target')->name('target_route');
$auth->route('/#controller/#action')->name('action_route');
$auth->route('/#controller')->name('controller_route')->to(action => 'view');
$auth->route('/')->name('root_route')->to(controller => 'page', action => 'view', target=>'home');

return 1;
}

1;

最新創作
App.pm
2016/02/18 04:14:47 |瀏覽 102 回應 0 推薦 0 引用 0
新槍開箱 Smith & Wesson M&P15-22史密斯威森
2014/08/12 02:29:20 |瀏覽 290 回應 0 推薦 2 引用 0
買槍 1 - 法規
2014/07/16 15:14:23 |瀏覽 454 回應 0 推薦 0 引用 0