hydra: put contents links into html, add links to files from contents page

This commit is contained in:
Rob Vermaas 2011-01-04 12:50:59 +00:00
parent 039d1bed21
commit f35c9a4574
3 changed files with 9 additions and 4 deletions

View File

@ -204,7 +204,6 @@ sub download_by_type : Chained('build') PathPart('download-by-type') {
$c->res->redirect(defaultUriForProduct($self, $c, $product, @path)); $c->res->redirect(defaultUriForProduct($self, $c, $product, @path));
} }
sub contents : Chained('build') PathPart Args(1) { sub contents : Chained('build') PathPart Args(1) {
my ($self, $c, $productnr) = @_; my ($self, $c, $productnr) = @_;
@ -220,6 +219,10 @@ sub contents : Chained('build') PathPart Args(1) {
if ($product->type eq "nix-build" && -d $path) { if ($product->type eq "nix-build" && -d $path) {
$res = `cd $path && find . -print0 | xargs -0 ls -ld --`; $res = `cd $path && find . -print0 | xargs -0 ls -ld --`;
error($c, "`ls -lR' error: $?") if $? != 0; error($c, "`ls -lR' error: $?") if $? != 0;
my $baseuri = $c->uri_for('/build', $c->stash->{build}->id, 'download', $product->productnr);
$baseuri .= "/".$product->name if $product->name;
$res =~ s/(\.\/)($relPathRE)/<a href="$baseuri\/$2">$1$2<\/a>/g;
} }
elsif ($path =~ /\.rpm$/) { elsif ($path =~ /\.rpm$/) {
@ -259,8 +262,9 @@ sub contents : Chained('build') PathPart Args(1) {
die unless $res; die unless $res;
$c->stash->{'plain'} = { data => $res }; $c->stash->{title} = "Contents of ".$product->path;
$c->forward('Hydra::View::Plain'); $c->stash->{contents} = "<pre>$res</pre>";
$c->stash->{template} = 'plain.tt';
} }

View File

@ -145,6 +145,7 @@ sub robots_txt : Path('robots.txt') {
, uri_for('Build', 'view_nixlog', ["*"], "*") , uri_for('Build', 'view_nixlog', ["*"], "*")
, uri_for('Build', 'view_log', ["*"], "*") , uri_for('Build', 'view_log', ["*"], "*")
, uri_for('Build', 'view_log', ["*"]) , uri_for('Build', 'view_log', ["*"])
, uri_for('Build', 'download', ["*"], "*")
, uri_for('Root', 'nar', [], "*") , uri_for('Root', 'nar', [], "*")
, uri_for('Root', 'status', []) , uri_for('Root', 'status', [])
, uri_for('Root', 'all', []) , uri_for('Root', 'all', [])

View File

@ -206,7 +206,7 @@ sub trim {
# Security checking of filenames. # Security checking of filenames.
Readonly::Scalar our $pathCompRE => "(?:[A-Za-z0-9-\+][A-Za-z0-9-\+\._]*)"; Readonly::Scalar our $pathCompRE => "(?:[A-Za-z0-9-\+\.][A-Za-z0-9-\+\._]*)";
Readonly::Scalar our $relPathRE => "(?:$pathCompRE(?:/$pathCompRE)*)"; Readonly::Scalar our $relPathRE => "(?:$pathCompRE(?:/$pathCompRE)*)";
Readonly::Scalar our $relNameRE => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)"; Readonly::Scalar our $relNameRE => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)";
Readonly::Scalar our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)"; Readonly::Scalar our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)";