blob: 8f1484d9155785b12961ef0799362c4dc7ea5bb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/env perl
use Mojolicious::Lite;
use Bugzilla::Constants;
use Bugzilla::CGI::Mojo;
use Try::Tiny;
plugin 'PODRenderer';
app->hook(
around_dispatch => sub {
my ($next, $c) = @_;
try {
local %{ Bugzilla->request_cache } = ();
Bugzilla->usage_mode(USAGE_MODE_MOJO);
Bugzilla->cgi( Bugzilla::CGI::Mojo->new(controller => $c) );
$next->();
} catch {
die $_ unless /\bModPerl::Util::exit\b/;
};
}
);
get '/' => sub {
my $c = shift;
my $user = Bugzilla->login(LOGIN_OPTIONAL);
$c->render( template => 'index', user => $user );
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
<p>Hello, <%= $user->name %> <<%= $user->email %>>
</p>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
|