# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package CrashTest;
use Mojo::Base 'Mojolicious';
use CrashTest::Model::Storage;
use CrashTest::Model::StackFilter;
use CrashTest::Model::CrashReport;
use CrashTest::Model::CrashGroup;
use CrashTest::Model::CrashProcessor;
use CrashTest::Model::BugLink;
# This method will run once at server start
sub startup {
my $self = shift;
$self->secrets([
'My secret passphrase here'
]);
# External plugins
$self->plugin('InstallablePaths');
$self->plugin('Config');
$self->plugin('bootstrap_pagination');
# Documentation browser under "/perldoc"
#$self->plugin('PODRenderer');
# Commands
push @{$self->commands->namespaces}, 'CrashTest::Command';
# Helpers
$self->plugin("CrashTest::Helper::DateTime");
$self->plugin("CrashTest::Helper::Backtrace");
$self->plugin("CrashTest::Helper::XmlEscape");
$self->plugin("CrashTest::Helper::Stats");
$self->plugin("CrashTest::Helper::BugLinks", $self->config->{WebInterface}->{BugTrackerLinks});
$self->plugin("CrashTest::Helper::Version");
$self->helper(crash_reports => sub { state $crash_reports = CrashTest::Model::CrashReport->new (app => $self); });
$self->helper(crash_groups => sub { state $crash_groups = CrashTest::Model::CrashGroup->new (app => $self); });
$self->helper(crash_processor => sub { state $crash_processor = CrashTest::Model::CrashProcessor->new (app => $self, config => $self->config); });
$self->helper(stackfilter => sub { state $stackfilter = CrashTest::Model::StackFilter->new (app => $self, config => $self->config); });
$self->helper(storage => sub { state $storage = CrashTest::Model::Storage->new (app => $self, config => $self->config); });
$self->helper(bug_link => sub { state $bug_link = CrashTest::Model::BugLink->new (app => $self, config => $self->config->{WebInterface}->{BugTrackerLinks}); });
$self->plugin('Minion', $self->config->{Processor}->{JobQueue}->{Backend}->{Minion});
$self->storage->load_plugins();
$self->crash_processor->load_plugins();
$self->bug_link->load_plugins();
# Router
my $r = $self->routes;
# Normal route to controller
$r->get('/' => [format => ['html', 'atom']])->to('crash_reports#index', format => undef)->name('index');
$r->get('/reports' => [format => ['html', 'atom']])->to('crash_reports#index', format => undef)->name('reports');
$r->get('/groups')->to('crash_groups#index')->name('groups');
$r->get('/groups/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ])->to('crash_groups#show')->name('group');
$r->get('/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ])->to('crash_reports#show')->name('report');
$r->post('/submit')->to('crash_inserter#insert');
}
1;