Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ $app = Plack::Middleware::Assets->wrap(
cpan
toolbar
github
contributors
)
],
);
Expand Down
35 changes: 35 additions & 0 deletions lib/MetaCPAN/Web/Controller/Release.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
25 changes: 25 additions & 0 deletions root/inc/contributors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% IF contributors %>

<div id="contributors">
<strong>and <% contributors.size %> contributors</strong>
<div align="right">
<a name="authors" href="#authors"
onclick="$(this).hide(); $('#contributors ul').slideDown()"
>show them</a>
</div>
<ul style="display: none">
<% FOREACH contributor IN contributors %>
<li style="text-align: left; padding-left: 22px;">
<% IF contributor.pauseid %>
<a href="<% contributor.url %>"
class="cpan_author"
data-cpan-author="<% contributor.pauseid %>"><% contributor.name %></a>
<% ELSE %>
<% contributor.name %>
<% END %>
</li>
<% END %>
</ul>
</div>

<% END %>
5 changes: 5 additions & 0 deletions root/release.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
</ul>
</div>

<div id="authors"
style="text-align: center; float: <% IF float == 'left' %>left; padding-left: 20px<% ELSE %>right; width: 160px; padding-left: 80px<% END %>">
<% INCLUDE inc/author-pic.html author = author %>
<% INCLUDE inc/contributors.html
contributors = release.metadata.x_contributors %>
</div>
<% INCLUDE inc/dependencies.html dependencies = release.dependency %>

<div class="content">
Expand Down
31 changes: 31 additions & 0 deletions root/static/js/contributors.js
Original file line number Diff line number Diff line change
@@ -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 = $('<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 );
});
});
});