diff --git a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm index ec2be36d07..ec93a9c169 100644 --- a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm +++ b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm @@ -7,7 +7,16 @@ BEGIN { extends 'MetaCPAN::Web::Controller' } use List::Util (); -sub index : Chained('/') : PathPart('contributing-to') : CaptureArgs(0) { +sub index : Chained('/') : PathPart('contributing-to') : CaptureArgs(0) { } + +sub dist : Chained('index') : PathPart('') : Args(1) { + my ( $self, $c, $dist ) = @_; + + my $release = $c->model('API::Release')->find($dist)->get->{release}; + if ( $release && $release->{author} && $release->{name} ) { + return $c->forward( 'get', [ $release->{author}, $release->{name} ] ); + } + $c->detach('/not_found'); } sub release : Chained('index') : PathPart('') : Args(2) { @@ -26,7 +35,7 @@ sub release : Chained('index') : PathPart('') : Args(2) { sub get : Private { my ( $self, $c, @args ) = @_; - my $contributing_re = qr/(CONTRIBUTING|HACKING)/i; + my $contributing_re = qr/CONTRIBUTING|HACKING/i; my $files = $c->model('API::Release')->interesting_files(@args)->get->{files}; @@ -45,12 +54,14 @@ sub get : Private { $c->detach('/not_found'); } else { - my $path = join '/' => @$file{qw(author release path)}; - if ( $path =~ /\.(pod|pm)$/ ) { - $c->res->redirect( "/pod/release/$path", 301 ); + my @path = split m{/}, $file->{path}; + if ( $file->{pod_lines} && @{ $file->{pod_lines} } ) { + $c->forward( "/pod/release", + [ $file->{author}, $file->{release}, @path ] ); } else { - $c->res->redirect( "/source/$path", 301 ); + $c->forward( "/source/index", + [ $file->{author}, $file->{release}, @path ] ); } } } diff --git a/root/inc/release-info.html b/root/inc/release-info.html index d1512f2634..e0313970cf 100644 --- a/root/inc/release-info.html +++ b/root/inc/release-info.html @@ -7,7 +7,7 @@ <% END %>