2009-03-04 12:23:54 +00:00
|
|
|
package Hydra::Base::Controller::NixChannel;
|
2009-02-25 14:34:29 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2009-03-04 10:59:14 +00:00
|
|
|
use base 'Catalyst::Controller';
|
2009-02-25 14:34:29 +00:00
|
|
|
use Hydra::Helper::Nix;
|
|
|
|
use Hydra::Helper::CatalystUtils;
|
|
|
|
|
|
|
|
|
|
|
|
sub closure : Chained('nix') PathPart {
|
|
|
|
my ($self, $c) = @_;
|
2010-06-22 12:00:19 +00:00
|
|
|
$c->stash->{current_view} = 'NixClosure';
|
2009-02-25 14:34:29 +00:00
|
|
|
|
|
|
|
# !!! 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');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-03 14:21:27 +00:00
|
|
|
sub manifest : Chained('nix') PathPart("MANIFEST") Args(0) {
|
2009-02-25 14:34:29 +00:00
|
|
|
my ($self, $c) = @_;
|
2010-06-22 12:00:19 +00:00
|
|
|
$c->stash->{current_view} = 'NixManifest';
|
|
|
|
$c->stash->{narBase} = $c->uri_for($c->controller('Root')->action_for("nar"));
|
2009-02-25 14:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-25 15:39:51 +00:00
|
|
|
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;
|
|
|
|
|
2009-03-04 14:49:21 +00:00
|
|
|
$c->stash->{build} = $pkg->{build};
|
2009-02-25 15:39:51 +00:00
|
|
|
|
2009-02-26 21:33:29 +00:00
|
|
|
$c->stash->{manifestUri} = $c->uri_for($self->action_for("manifest"), $c->req->captures);
|
|
|
|
|
2010-06-22 12:00:19 +00:00
|
|
|
$c->stash->{current_view} = 'NixPkg';
|
2009-02-25 15:39:51 +00:00
|
|
|
|
|
|
|
$c->response->content_type('application/nix-package');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-03 10:44:54 +00:00
|
|
|
sub nixexprs : Chained('nix') PathPart('nixexprs.tar.bz2') Args(0) {
|
2009-03-02 17:17:36 +00:00
|
|
|
my ($self, $c) = @_;
|
2010-06-22 12:00:19 +00:00
|
|
|
$c->stash->{current_view} = 'NixExprs';
|
2009-03-02 17:17:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 14:49:21 +00:00
|
|
|
sub name {
|
|
|
|
my ($build) = @_;
|
2009-04-03 15:37:21 +00:00
|
|
|
return $build->get_column('releasename') || $build->nixname;
|
2009-03-04 14:49:21 +00:00
|
|
|
}
|
|
|
|
|
2009-03-04 15:47:42 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
} @_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 14:49:21 +00:00
|
|
|
sub channel_contents : Chained('nix') PathPart('') Args(0) {
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
$c->stash->{template} = 'channel-contents.tt';
|
2009-03-04 15:47:42 +00:00
|
|
|
$c->stash->{nixPkgs} = [sortPkgs (values %{$c->stash->{nixPkgs}})];
|
2009-03-04 14:49:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-25 14:34:29 +00:00
|
|
|
1;
|