diff --git a/app.psgi b/app.psgi index 7b1e27a0bc..49447de179 100644 --- a/app.psgi +++ b/app.psgi @@ -67,6 +67,7 @@ $app = Plack::Middleware::Assets->wrap( cpan toolbar github + contributors ) ], ); diff --git a/lib/MetaCPAN/Web/Controller/Release.pm b/lib/MetaCPAN/Web/Controller/Release.pm index 0ee2e85e2d..57d783a8b7 100644 --- a/lib/MetaCPAN/Web/Controller/Release.pm +++ b/lib/MetaCPAN/Web/Controller/Release.pm @@ -82,6 +82,9 @@ sub view : Private { $c->res->last_modified( $out->{date} ); + $self->groom_contributors( $c, $out ); + + # TODO: make took more automatic (to include all) $c->stash( { template => 'release.html', @@ -106,4 +109,36 @@ 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/root/inc/contributors.html b/root/inc/contributors.html new file mode 100644 index 0000000000..98251ee661 --- /dev/null +++ b/root/inc/contributors.html @@ -0,0 +1,25 @@ +<% IF contributors %> + +
+ and <% contributors.size %> contributors +
+ show them +
+ +
+ +<% END %> diff --git a/root/release.html b/root/release.html index ce1645e9c7..f70581026b 100644 --- a/root/release.html +++ b/root/release.html @@ -57,7 +57,12 @@ +
<% INCLUDE inc/author-pic.html author = author %> +<% INCLUDE inc/contributors.html + contributors = release.metadata.x_contributors %> +
<% INCLUDE inc/dependencies.html dependencies = release.dependency %>
diff --git a/root/static/js/contributors.js b/root/static/js/contributors.js new file mode 100644 index 0000000000..7bd78c5782 --- /dev/null +++ b/root/static/js/contributors.js @@ -0,0 +1,31 @@ +$(function(){ + $('a.cpan_author').each(function(){ + var $anchor = $(this); + var author = $anchor.attr('data-cpan-author'); + if( typeof author == 'undefined' ) { + return; + } + + $.getJSON( "https://api.metacpan.org/author/" + author, function( data ){ + if ( typeof data.name == 'undefined' ) { + return; + } + // TODO make this an :before pseudo-class + var gravatar = data.gravatar_url; + gravatar = gravatar.replace( + "^http://(www\.)?gravatar.com/", + "https://secure.gravatar.com/" + ).replace( + /s=\d+/, + 's=20' + ); + var $img = $('').attr( 'src', gravatar ) + .attr( 'width', 20 ) + .attr( 'height', 20 ); + $anchor.css( 'margin-left', '1px' ); + $anchor.parent().css( 'padding-left', '1px' ); + $anchor.text( data.name ); + $anchor.before( $img ); + }); + }); +});