* Move everything up one directory.
This commit is contained in:
58
src/lib/Hydra/Base/Controller/ListBuilds.pm
Normal file
58
src/lib/Hydra/Base/Controller/ListBuilds.pm
Normal file
@ -0,0 +1,58 @@
|
||||
package Hydra::Base::Controller::ListBuilds;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base 'Hydra::Base::Controller::NixChannel';
|
||||
use Hydra::Helper::Nix;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
|
||||
sub jobstatus : Chained('get_builds') PathPart Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{template} = 'jobstatus.tt';
|
||||
$c->stash->{latestBuilds} = getLatestBuilds($c, $c->stash->{allBuilds}, {});
|
||||
}
|
||||
|
||||
|
||||
sub all : Chained('get_builds') PathPart {
|
||||
my ($self, $c, $page) = @_;
|
||||
|
||||
$c->stash->{template} = 'all.tt';
|
||||
|
||||
$page = (defined $page ? int($page) : 1) || 1;
|
||||
|
||||
my $resultsPerPage = 50;
|
||||
|
||||
my $nrBuilds = scalar($c->stash->{allBuilds}->search({finished => 1}));
|
||||
|
||||
$c->stash->{baseUri} = $c->uri_for($self->action_for("all"), $c->req->captures);
|
||||
|
||||
$c->stash->{page} = $page;
|
||||
$c->stash->{resultsPerPage} = $resultsPerPage;
|
||||
$c->stash->{totalBuilds} = $nrBuilds;
|
||||
|
||||
$c->stash->{builds} = [$c->stash->{allBuilds}->search(
|
||||
{finished => 1}, {order_by => "timestamp DESC", rows => $resultsPerPage, page => $page})];
|
||||
}
|
||||
|
||||
|
||||
sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) {
|
||||
my ($self, $c, $channelName) = @_;
|
||||
eval {
|
||||
if ($channelName eq "latest") {
|
||||
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest";
|
||||
getChannelData($c, getLatestBuilds($c, $c->stash->{allBuilds}, {buildStatus => 0}));
|
||||
}
|
||||
elsif ($channelName eq "all") {
|
||||
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-all";
|
||||
getChannelData($c, [$c->stash->{allBuilds}->all]);
|
||||
}
|
||||
else {
|
||||
error($c, "Unknown channel `$channelName'.");
|
||||
}
|
||||
};
|
||||
error($c, $@) if $@;
|
||||
}
|
||||
|
||||
|
||||
1;
|
88
src/lib/Hydra/Base/Controller/NixChannel.pm
Normal file
88
src/lib/Hydra/Base/Controller/NixChannel.pm
Normal file
@ -0,0 +1,88 @@
|
||||
package Hydra::Base::Controller::NixChannel;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base 'Catalyst::Controller';
|
||||
use Hydra::Helper::Nix;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
|
||||
sub closure : Chained('nix') PathPart {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{current_view} = 'Hydra::View::NixClosure';
|
||||
|
||||
# !!! quick hack; this is to make HEAD requests return the right
|
||||
# MIME type. This is set in the view as well, but the view isn't
|
||||
# called for HEAD requests. There should be a cleaner solution...
|
||||
$c->response->content_type('application/x-nix-export');
|
||||
}
|
||||
|
||||
|
||||
sub manifest : Chained('nix') PathPart("MANIFEST") Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{current_view} = 'Hydra::View::NixManifest';
|
||||
$c->stash->{narBase} = $c->uri_for($self->action_for("nar"), $c->req->captures);
|
||||
}
|
||||
|
||||
|
||||
sub nar : Chained('nix') PathPart {
|
||||
my ($self, $c, @rest) = @_;
|
||||
|
||||
my $path .= "/" . join("/", @rest);
|
||||
|
||||
error($c, "Path " . $path . " is no longer available.") unless isValidPath($path);
|
||||
|
||||
# !!! check that $path is in the closure of $c->stash->{storePaths}.
|
||||
|
||||
$c->stash->{current_view} = 'Hydra::View::NixNAR';
|
||||
$c->stash->{storePath} = $path;
|
||||
}
|
||||
|
||||
|
||||
sub pkg : Chained('nix') PathPart Args(1) {
|
||||
my ($self, $c, $pkgName) = @_;
|
||||
|
||||
my $pkg = $c->stash->{nixPkgs}->{$pkgName};
|
||||
|
||||
notFound($c, "Unknown Nix package `$pkgName'.")
|
||||
unless defined $pkg;
|
||||
|
||||
$c->stash->{build} = $pkg->{build};
|
||||
|
||||
$c->stash->{manifestUri} = $c->uri_for($self->action_for("manifest"), $c->req->captures);
|
||||
|
||||
$c->stash->{current_view} = 'Hydra::View::NixPkg';
|
||||
|
||||
$c->response->content_type('application/nix-package');
|
||||
}
|
||||
|
||||
|
||||
sub nixexprs : Chained('nix') PathPart('nixexprs.tar.bz2') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{current_view} = 'Hydra::View::NixExprs';
|
||||
}
|
||||
|
||||
|
||||
sub name {
|
||||
my ($build) = @_;
|
||||
return $build->resultInfo->releasename || $build->nixname;
|
||||
}
|
||||
|
||||
|
||||
sub sortPkgs {
|
||||
# Sort by name, then timestamp.
|
||||
return sort
|
||||
{ lc(name($a->{build})) cmp lc(name($b->{build}))
|
||||
or $a->{build}->timestamp <=> $b->{build}->timestamp
|
||||
} @_;
|
||||
}
|
||||
|
||||
|
||||
sub channel_contents : Chained('nix') PathPart('') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{template} = 'channel-contents.tt';
|
||||
$c->stash->{nixPkgs} = [sortPkgs (values %{$c->stash->{nixPkgs}})];
|
||||
}
|
||||
|
||||
|
||||
1;
|
Reference in New Issue
Block a user