releases as a dynamic view on the database was misguided, since doing thing like adding a new job to a release set will invalidate all old releases. So we rename release sets to views, and we'll reintroduce releases as separate, static entities in the database.
139 lines
4.0 KiB
Perl
139 lines
4.0 KiB
Perl
package Hydra::Controller::Root;
|
|
|
|
use strict;
|
|
use warnings;
|
|
use base 'Hydra::Base::Controller::ListBuilds';
|
|
use Hydra::Helper::Nix;
|
|
use Hydra::Helper::CatalystUtils;
|
|
|
|
|
|
# Put this controller at top-level.
|
|
__PACKAGE__->config->{namespace} = '';
|
|
|
|
|
|
sub begin :Private {
|
|
my ($self, $c) = @_;
|
|
$c->stash->{curUri} = $c->request->uri;
|
|
$c->stash->{version} = $ENV{"HYDRA_RELEASE"} || "<devel>";
|
|
$c->stash->{nixVersion} = $ENV{"NIX_RELEASE"} || "<devel>";
|
|
}
|
|
|
|
|
|
sub index :Path :Args(0) {
|
|
my ($self, $c) = @_;
|
|
$c->stash->{template} = 'overview.tt';
|
|
$c->stash->{projects} = [$c->model('DB::Projects')->search({}, {order_by => 'displayname'})];
|
|
getBuildStats($c, $c->model('DB::Builds'));
|
|
}
|
|
|
|
|
|
sub login :Local {
|
|
my ($self, $c) = @_;
|
|
|
|
my $username = $c->request->params->{username} || "";
|
|
my $password = $c->request->params->{password} || "";
|
|
|
|
if ($username && $password) {
|
|
if ($c->authenticate({username => $username, password => $password})) {
|
|
$c->response->redirect(
|
|
defined $c->flash->{afterLogin}
|
|
? $c->flash->{afterLogin}
|
|
: $c->uri_for('/'));
|
|
return;
|
|
}
|
|
$c->stash->{errorMsg} = "Bad username or password.";
|
|
}
|
|
|
|
$c->stash->{template} = 'login.tt';
|
|
}
|
|
|
|
|
|
sub logout :Local {
|
|
my ($self, $c) = @_;
|
|
$c->logout;
|
|
$c->response->redirect($c->uri_for('/'));
|
|
}
|
|
|
|
|
|
sub queue :Local {
|
|
my ($self, $c) = @_;
|
|
$c->stash->{template} = 'queue.tt';
|
|
$c->stash->{queue} = [$c->model('DB::Builds')->search(
|
|
{finished => 0}, {join => 'schedulingInfo', order_by => ["priority DESC", "timestamp"]})];
|
|
}
|
|
|
|
|
|
# Hydra::Base::Controller::ListBuilds needs this.
|
|
sub get_builds : Chained('/') PathPart('') CaptureArgs(0) {
|
|
my ($self, $c) = @_;
|
|
$c->stash->{allBuilds} = $c->model('DB::Builds');
|
|
$c->stash->{jobStatus} = $c->model('DB')->resultset('JobStatus');
|
|
$c->stash->{allJobsets} = $c->model('DB::Jobsets');
|
|
$c->stash->{allJobs} = $c->model('DB::Jobs');
|
|
$c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceeded');
|
|
$c->stash->{channelBaseName} = "everything";
|
|
}
|
|
|
|
|
|
sub robots_txt : Path('robots.txt') {
|
|
my ($self, $c) = @_;
|
|
|
|
sub uri_for {
|
|
my ($controller, $action, @args) = @_;
|
|
return $c->uri_for($c->controller($controller)->action_for($action), @args)->path;
|
|
}
|
|
|
|
sub channelUris {
|
|
my ($controller, $bindings) = @_;
|
|
return
|
|
( uri_for($controller, 'closure', $bindings, "*")
|
|
, uri_for($controller, 'manifest', $bindings)
|
|
, uri_for($controller, 'nar', $bindings, "*")
|
|
, uri_for($controller, 'pkg', $bindings, "*")
|
|
, uri_for($controller, 'nixexprs', $bindings)
|
|
, uri_for($controller, 'channel_contents', $bindings)
|
|
);
|
|
}
|
|
|
|
# Put actions that are expensive or not useful for indexing in
|
|
# robots.txt. Note: wildcards are not universally supported in
|
|
# robots.txt, but apparently Google supports them.
|
|
my @rules =
|
|
( uri_for('Build', 'buildtimedeps', ["*"])
|
|
, uri_for('Build', 'runtimedeps', ["*"])
|
|
, uri_for('Build', 'view_nixlog', ["*"], "*")
|
|
, channelUris('Root', ["*"])
|
|
, channelUris('Project', ["*", "*"])
|
|
, channelUris('Jobset', ["*", "*", "*"])
|
|
, channelUris('Job', ["*", "*", "*", "*"])
|
|
, channelUris('Build', ["*"])
|
|
);
|
|
|
|
$c->stash->{'plain'} = { data => "User-agent: *\n" . join('', map { "Disallow: $_\n" } @rules) };
|
|
$c->forward('Hydra::View::Plain');
|
|
}
|
|
|
|
|
|
sub default :Path {
|
|
my ($self, $c) = @_;
|
|
notFound($c, "Page not found.");
|
|
}
|
|
|
|
|
|
sub end : ActionClass('RenderView') {
|
|
my ($self, $c) = @_;
|
|
|
|
if (scalar @{$c->error}) {
|
|
$c->stash->{template} = 'error.tt';
|
|
$c->stash->{errors} = $c->error;
|
|
if ($c->response->status >= 300) {
|
|
$c->stash->{httpStatus} =
|
|
$c->response->status . " " . HTTP::Status::status_message($c->response->status);
|
|
}
|
|
$c->clear_errors;
|
|
}
|
|
}
|
|
|
|
|
|
1;
|