From a8e26e3a76f609638662b94508cb5170e53dddd2 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sun, 3 Jun 2018 17:06:51 +0200 Subject: [PATCH] add /release/DIST/source/FILE endpoint We already have /source/AUTHOR/RELEASE/FILE but that requires the specific author and version of the release. The URL is under /release/DIST/source because it can't fit under /source/ given the way that already works. --- lib/MetaCPAN/Web/Controller/Release.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/MetaCPAN/Web/Controller/Release.pm b/lib/MetaCPAN/Web/Controller/Release.pm index ee86967f62..22f4cd9b15 100644 --- a/lib/MetaCPAN/Web/Controller/Release.pm +++ b/lib/MetaCPAN/Web/Controller/Release.pm @@ -22,12 +22,14 @@ sub by_distribution : Chained('root') PathPart('') Args(1) { } sub index : Chained('/') PathPart('release') CaptureArgs(1) { - my ( $self, $c, $dist ) = @_; - $c->stash( $c->model('API::Favorite')->find_plussers($dist)->get ); + my ( $self, $c, $distribution ) = @_; + $c->stash( distribution => $distribution ); } sub plusser_display : Chained('index') PathPart('plussers') Args(0) { my ( $self, $c ) = @_; + my $dist = $c->stash->{distribution}; + $c->stash( $c->model('API::Favorite')->find_plussers($dist)->get ); $c->stash( { template => 'plussers.html' } ); } @@ -48,6 +50,15 @@ sub by_author_and_release : Chained('root') PathPart('') Args(2) { $c->forward('view'); } +sub source : Chained('index') PathPart('source') Args { + my ( $self, $c, @path ) = @_; + my $dist = $c->stash->{distribution}; + my $release = $c->model('API::Release')->find($dist)->get->{release} + or $c->detach('/not_found'); + $c->forward( '/source/index', + [ $release->{author}, $release->{name}, @path ] ); +} + sub view : Private { my ( $self, $c ) = @_;