Skip to content

Commit

Permalink
Use full country name for flag on author page.
Browse files Browse the repository at this point in the history
Closes #1039.
  • Loading branch information
oalders committed Jan 31, 2014
1 parent 7b75e90 commit 3033db7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/MetaCPAN/Web/Controller/Account.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use Moose;
use List::MoreUtils qw(pairwise);
use DateTime ();
use JSON::XS ();
use Locale::Country ();

BEGIN { extends 'MetaCPAN::Web::Controller' }

Expand All @@ -18,7 +17,7 @@ sub auto : Private {

sub logout : Local {
my ( $self, $c ) = @_;
$c->detach('/forbidden') unless( $c->req->method eq 'POST' );
$c->detach('/forbidden') unless ( $c->req->method eq 'POST' );
$c->req->session->expire;
$c->res->redirect('/');
}
Expand Down Expand Up @@ -74,7 +73,6 @@ sub profile : Local {
: undef;
$data->{$_} = $req->params->{$_} eq "" ? undef : $req->params->{$_}
for (qw(name asciiname gravatar_url city region country));
$data->{countryName} = Locale::Country::code2country($req->params->{country}) if $req->params->{country} ne '';
$data->{$_} = [ grep {$_} $req->param($_) ] for (qw(website email));
$data->{extra}
= eval { JSON->new->relaxed->utf8->decode( $req->params->{extra} ) };
Expand Down
6 changes: 6 additions & 0 deletions lib/MetaCPAN/Web/Controller/Author.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use Moose;
use List::Util ();
use DateTime::Format::ISO8601 ();
use namespace::autoclean;
use Locale::Country ();

BEGIN { extends 'MetaCPAN::Web::Controller' }

Expand Down Expand Up @@ -47,6 +48,11 @@ sub index : Path : Args(1) {
template => 'author.html'
}
);

if ( $author->{country} ne '' ) {
$c->stash( author_country_name =>
Locale::Country::code2country( $author->{country} ) );
}
}

__PACKAGE__->meta->make_immutable;
Expand Down
2 changes: 1 addition & 1 deletion root/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<% IF author.country || author.city || author.region %>
<strong>Location</strong><br>
<% IF author.country %>
<img src="/static/images/flag/<% author.country.lower %>.png" alt="<% author.countryName %>" title="<% author.countryName %>" width=16 height=11> &nbsp;
<img src="/static/images/flag/<% author.country.lower %>.png" alt="<% author_country_name %>" title="<% author_country_name %>" width=16 height=11> &nbsp;
<%- END %>
<%- author.city; %><% IF author.city && author.region %>, <% END %><%- author.region %><br>
<% END %>
Expand Down

0 comments on commit 3033db7

Please sign in to comment.