use Bugzilla::App::CGI;
use Bugzilla::App::OAuth2::Clients;
use Bugzilla::App::SES;
-use Bugzilla::App::Home;
+use Bugzilla::App::Main;
use Bugzilla::App::API;
use Bugzilla::App::Static;
use Mojo::Loader qw( find_modules );
my $r = $self->routes;
Bugzilla::App::CGI->setup_routes($r);
- Bugzilla::App::CGI->load_one('bzapi_cgi', 'extensions/BzAPI/bin/rest.cgi');
-
- $r->get('/home')->to('Home#index');
- $r->any('/')->to('CGI#index_cgi');
- $r->any('/bug/<id:num>')->to('CGI#show_bug_cgi');
- $r->any('/<id:num>')->to('CGI#show_bug_cgi');
- $r->get('/testagent.cgi')->to('CGI#testagent');
- $r->add_type('hex32' => qr/[[:xdigit:]]{32}/);
- $r->post('/announcement/hide/<checksum:hex32>')->to('CGI#announcement_hide');
-
- $r->any('/rest')->to('CGI#rest_cgi');
- $r->any('/rest.cgi/*PATH_INFO')->to('CGI#rest_cgi' => {PATH_INFO => ''});
- $r->any('/rest/*PATH_INFO')->to('CGI#rest_cgi' => {PATH_INFO => ''});
- $r->any('/extensions/BzAPI/bin/rest.cgi/*PATH_INFO')->to('CGI#bzapi_cgi');
- $r->any('/latest/*PATH_INFO')->to('CGI#bzapi_cgi');
- $r->any('/bzapi/*PATH_INFO')->to('CGI#bzapi_cgi');
+ Bugzilla::App::Main->setup_routes($r);
+ Bugzilla::App::API->setup_routes($r);
+ Bugzilla::App::SES->setup_routes($r);
+ Bugzilla::App::OAuth2::Clients->setup_routes($r);
$r->static_file('/__lbheartbeat__');
$r->static_file(
$r->page('/user_profile', 'user_profile.html');
$r->page('/userprofile', 'user_profile.html');
$r->page('/request_defer', 'request_defer.html');
-
- $r->get('/__heartbeat__')->to('CGI#heartbeat_cgi');
- $r->get('/robots.txt')->to('CGI#robots_cgi');
- $r->any('/login')->to('CGI#index_cgi' => {'GoAheadAndLogIn' => '1'});
- $r->any('/:new_bug' => [new_bug => qr{new[-_]bug}])->to('CGI#new_bug_cgi');
-
- Bugzilla::App::API->setup_routes($r);
- Bugzilla::App::SES->setup_routes($r);
- Bugzilla::App::OAuth2::Clients->setup_routes($r);
}
1;
our $C;
my %SEEN;
-sub testagent {
- my ($self) = @_;
- $self->render(text => "OK Mojolicious");
-}
-
-sub announcement_hide {
- my ($self) = @_;
- my $checksum = $self->param('checksum');
- if ($checksum && $checksum =~ /^[[:xdigit:]]{32}$/) {
- $self->session->{announcement_checksum} = $checksum;
- }
- $self->render(json => {});
-}
-
sub setup_routes {
my ($class, $r) = @_;
$class->load_one($name, $file);
$r->any("/$file")->to("CGI#$name");
}
+ $r->get('/home')->to('CGI#index_cgi');
+
+ $r->any('/bug/<id:num>')->to('CGI#show_bug_cgi');
+ $r->any('/<id:num>')->to('CGI#show_bug_cgi');
+
+ $r->any('/rest')->to('CGI#rest_cgi');
+ $r->any('/rest.cgi/*PATH_INFO')->to('CGI#rest_cgi' => {PATH_INFO => ''});
+ $r->any('/rest/*PATH_INFO')->to('CGI#rest_cgi' => {PATH_INFO => ''});
+
+ $r->get('/__heartbeat__')->to('CGI#heartbeat_cgi');
+ $r->get('/robots.txt')->to('CGI#robots_cgi');
+ $r->any('/login')->to('CGI#index_cgi' => {'GoAheadAndLogIn' => '1'});
+ $r->any('/:new_bug' => [new_bug => qr{new[-_]bug}])->to('CGI#new_bug_cgi');
}
sub load_one {
+++ /dev/null
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-package Bugzilla::App::Home;
-use Mojo::Base 'Mojolicious::Controller';
-
-use Bugzilla::Error;
-use Try::Tiny;
-use Bugzilla::Constants;
-
-sub index {
- my ($c) = @_;
- $c->bugzilla->login(LOGIN_REQUIRED) or return;
- try {
- ThrowUserError('invalid_username', {login => 'batman'}) if $c->param('error');
- $c->render(handler => 'bugzilla', template => 'index');
- }
- catch {
- $c->bugzilla->error_page($_);
- };
-}
-
-1;
--- /dev/null
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::App::Main;
+use Mojo::Base 'Mojolicious::Controller';
+
+use Bugzilla::Error;
+use Try::Tiny;
+use Bugzilla::Constants;
+
+sub setup_routes {
+ my ($class, $r) = @_;
+
+ $r->any('/')->to('Main#root');
+
+ $r->get('/testagent.cgi')->to('Main#testagent');
+
+ $r->add_type('hex32' => qr/[[:xdigit:]]{32}/);
+ $r->post('/announcement/hide/<checksum:hex32>')->to('Main#announcement_hide');
+}
+
+sub root {
+ my ($c) = @_;
+ $c->res->headers->cache_control('public, max-age=3600, immutable');
+ $c->render(handler => 'bugzilla');
+}
+
+sub testagent {
+ my ($self) = @_;
+ $self->render(text => "OK Mojolicious");
+}
+
+sub announcement_hide {
+ my ($self) = @_;
+ my $checksum = $self->param('checksum');
+ if ($checksum && $checksum =~ /^[[:xdigit:]]{32}$/) {
+ $self->session->{announcement_checksum} = $checksum;
+ }
+ $self->render(json => {});
+}
+
+1;
$cache->{rest_handlers} = $all_handlers;
}
+
+
+
return $cache->{rest_handlers};
}
+sub app_startup {
+ my ($self, $args) = @_;
+ my $app = $args->{app};
+ my $r = $app->routes;
+
+ Bugzilla::App::CGI->load_one('bzapi_cgi', 'extensions/BzAPI/bin/rest.cgi');
+ $r->any('/extensions/BzAPI/bin/rest.cgi/*PATH_INFO')->to('CGI#bzapi_cgi');
+ $r->any('/latest/*PATH_INFO')->to('CGI#bzapi_cgi');
+ $r->any('/bzapi/*PATH_INFO')->to('CGI#bzapi_cgi');
+}
+
__PACKAGE__->NAME;
->json_like('/announcement' => qr/Mojo::Test is awesome/);
# for web requests, you use text_like (or text_is) with CSS selectors.
-$t->get_ok('/')->status_is(200)
+$t->get_ok('/home')->status_is(200)
->text_like('#new_announcement div' => qr/Mojo::Test is awesome/);
+$t->get_ok('/')->status_is(200);
+
# Chaining is not magical, you can break up longer lines
# by calling methods on $t, as below.
$t->get_ok('/rest/whoami' => {'X-Bugzilla-API-Key' => $api_key});
[% IF Param('utf8') %]
<meta charset="UTF-8">
[% END %]
+ [% IF meta_refresh %]
+ <meta http-equiv="refresh"
+ content="[% meta_refresh FILTER html %]">
+ [% END %]
[% USE Bugzilla %]
[% IF Bugzilla.cgi.should_block_referrer %]
<header id="header" role="banner">
<div class="inner">
- <h1 id="header-title" class="title"><a href="[% basepath FILTER none %]" title="Go to home page">[% terms.Bugzilla %]</a></h1>
+ <h1 id="header-title" class="title"><a href="[% c.url_for('/home').to_abs FILTER html %]" title="Go to home page">[% terms.Bugzilla %]</a></h1>
<form role="search" id="header-search" class="quicksearch" action="[% basepath FILTER none %]buglist.cgi" data-no-csrf>
<section class="searchbox-outer dropdown" role="combobox" aria-expanded="false" aria-haspopup="listbox"
aria-owns="header-search-dropdown">
--- /dev/null
+[% SET home_url = c.url_for('/home').to_abs %]
+[% PROCESS index.html.tmpl meta_refresh="0;URL='$home_url'" %]