diff --git a/lib/MetaCPAN/Web/Controller/Pod.pm b/lib/MetaCPAN/Web/Controller/Pod.pm index 579a98620b2..52c2ed15fda 100644 --- a/lib/MetaCPAN/Web/Controller/Pod.pm +++ b/lib/MetaCPAN/Web/Controller/Pod.pm @@ -161,6 +161,8 @@ sub view : Private { my $dist = $release->{distribution}; $c->stash( $c->model('API::Favorite')->find_plussers($dist) ); + my $contribs = $self->groom_contributors( $c, $release ); + $c->stash( { module => $data, @@ -169,6 +171,7 @@ sub view : Private { template => 'pod.html', canonical => $canonical, documented_module => $documented_module, + contributors => $contribs, } ); unless ( $reqs->{pod}->{raw} ) { diff --git a/lib/MetaCPAN/Web/Controller/Release.pm b/lib/MetaCPAN/Web/Controller/Release.pm index 54e13360488..0534bbb7fb5 100644 --- a/lib/MetaCPAN/Web/Controller/Release.pm +++ b/lib/MetaCPAN/Web/Controller/Release.pm @@ -101,7 +101,7 @@ sub view : Private { $c->res->last_modified( $out->{date} ); - $self->groom_contributors( $c, $out ); + my $contribs = $self->groom_contributors( $c, $out ); $c->stash( $c->model('API::Favorite')->find_plussers($distribution) ); @@ -123,6 +123,8 @@ sub view : Private { examples => \@examples, files => \@view_files, + contributors => $contribs, + # TODO: Put this in a more general place. # Maybe make a hash for feature flags? ( @@ -135,35 +137,4 @@ sub view : Private { ); } -# massage the x_contributors field into what we want -sub groom_contributors { - my ( $self, $c, $out ) = @_; - - return unless $out->{metadata}{x_contributors}; - - # just in case a lonely contributor makes it as a scalar - $out->{metadata}{x_contributors} = [ $out->{metadata}{x_contributors} ] - unless ref $out->{metadata}{x_contributors}; - - my @contributors = map { - s/<(.*)>//; - { name => $_, email => $1 } - } @{ $out->{metadata}{x_contributors} }; - - $out->{metadata}{x_contributors} = \@contributors; - - for my $contributor ( @{ $out->{metadata}{x_contributors} } ) { - - # heuristic to autofill pause accounts - $contributor->{pauseid} = uc $1 - if !$contributor->{pauseid} - and $contributor->{email} =~ /^(.*)\@cpan.org/; - - next unless $contributor->{pauseid}; - - $contributor->{url} = $c->uri_for_action( '/author/index', - [ $contributor->{pauseid} ] ); - } -} - 1; diff --git a/lib/MetaCPAN/Web/Role/ReleaseInfo.pm b/lib/MetaCPAN/Web/Role/ReleaseInfo.pm index e02f1f2ecbf..99b52700b62 100644 --- a/lib/MetaCPAN/Web/Role/ReleaseInfo.pm +++ b/lib/MetaCPAN/Web/Role/ReleaseInfo.pm @@ -67,4 +67,48 @@ sub recv_all { return { map { $_ => $condvars->{$_}->recv } keys %$condvars }; } +# massage the x_contributors field into what we want +sub groom_contributors { + my ( $self, $c, $release ) = @_; + + my $contribs = $release->{metadata}{x_contributors} || []; + my $authors = $release->{metadata}{author} || []; + + # just in case a lonely contributor makes it as a scalar + $contribs = [$contribs] + if !ref $contribs; + $authors = [$authors] + if !ref $authors; + + my %seen = ( lc "$release->{author}\@cpan.org" => 1, ); + my @contribs; + + for my $contrib ( @$authors, @$contribs ) { + my $name = $contrib; + $name =~ s/\s*<([^<>]+@[^<>]+)>//; + my $info = { + name => $name, + $1 ? ( email => $1 ) : (), + }; + + next + if $seen{ $info->{email} }++; + + # heuristic to autofill pause accounts + if ( !$info->{pauseid} + and $info->{email} =~ /^(.*)\@cpan\.org$/ ) + { + $info->{pauseid} = uc $1; + } + + if ( $info->{pauseid} ) { + $info->{url} + = $c->uri_for_action( '/author/index', [ $info->{pauseid} ] ); + } + push @contribs, $info; + } + + return \@contribs; +} + 1; diff --git a/root/inc/contributors.html b/root/inc/contributors.html index 90cf5d3da1d..d4d9ddd4dab 100644 --- a/root/inc/contributors.html +++ b/root/inc/contributors.html @@ -1,13 +1,13 @@ -<% IF contributors %> +<% IF contributors and contributors.size %>
- and <% contributors.size %> contributors +
and <% contributors.size %> contributors
- show them
-