From 8c8477d41f3a854855b2b94fbe9d93781396039f Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 22 May 2018 17:49:00 +0200 Subject: [PATCH 1/2] end point and link to contributing for dist rather than release --- lib/MetaCPAN/Web/Controller/ContributingDoc.pm | 11 ++++++++++- root/inc/release-info.html | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm index ec2be36d07..67335d5c74 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) { 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 %>
  • - How to Contribute + How to Contribute
  • <% IF release.resources.repository %>
  • From 92c49aee48c9992c0e8288014299d8b481a08b56 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 23 May 2018 19:40:49 +0200 Subject: [PATCH 2/2] view contributing files directly rather than redirecting --- lib/MetaCPAN/Web/Controller/ContributingDoc.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm index 67335d5c74..ec93a9c169 100644 --- a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm +++ b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm @@ -35,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}; @@ -54,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 ] ); } } }