Skip to content

Commit

Permalink
Small amendments to the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Talina06 committed Jul 20, 2014
1 parent 1cc2e23 commit 0fd453f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
10 changes: 5 additions & 5 deletions lib/MetaCPAN/Web/Controller/Account/Stargazer.pm
Expand Up @@ -6,14 +6,14 @@ BEGIN { extends 'MetaCPAN::Web::Controller' }
sub add : Local {
my ( $self, $c ) = @_;
$c->detach('/forbidden') unless ( $c->req->method eq 'POST' );
my $model = $c->model('API::User');
my $data = $c->req->params;
my $model = $c->model('API::User');
my $starring_details = $c->req->params;
my $res;
if ( $data->{remove} ) {
$res = $model->remove_stargazer( $data, $c->token )->recv;
if ( $starring_details->{remove} ) {
$res = $model->remove_stargazer( $starring_details, $c->token )->recv;
}
else {
$res = $model->add_stargazer( $data, $c->token )->recv;
$res = $model->add_stargazer( $starring_details, $c->token )->recv;
}
if ( $c->req->looks_like_browser ) {
$c->res->redirect(
Expand Down
4 changes: 1 addition & 3 deletions lib/MetaCPAN/Web/Controller/Pod.pm
Expand Up @@ -18,10 +18,8 @@ sub root : Chained('/') PathPart('pod') CaptureArgs(0) {
# /pod/$name
sub find : Chained('root') PathPart('') Args(1) {
my ( $self, $c, @path ) = @_;
my $star_flag = 1;
my $user = $c->model('API::User')->get_profile( $c->token )->recv;
my $user = $c->model('API::User')->get_profile( $c->token )->recv;
$c->stash( $c->model('API::Stargazer')->find_starred( $user, $path[0] ) );
$c->stash( { star_flag => $star_flag } );

# TODO: Pass size param so we can disambiguate?
$c->stash->{pod_file} = $c->model('API::Module')->find(@path)->recv;
Expand Down
3 changes: 1 addition & 2 deletions lib/MetaCPAN/Web/Model/API/Stargazer.pm
Expand Up @@ -19,7 +19,7 @@ sub find_starred {
if ( $name eq $module ) {
return (
{
mystargazer => 1,
active_star => 1,
total_starred => $total_starred,
}
);
Expand All @@ -28,7 +28,6 @@ sub find_starred {
}
return (
{
mystargazer => 0,
total_starred => $total_starred,
}
);
Expand Down
4 changes: 1 addition & 3 deletions root/inc/breadcrumbs.html
Expand Up @@ -45,9 +45,7 @@
<% IF mark_unauthorized_releases && NOT release.authorized %><em class="warning">UNAUTHORIZED RELEASE</em><% END %>
</div>
<div class="inline"><%- INCLUDE inc/favorite.html module = module || release %></div>
<% IF button_flag == 1 %>
<div class="inline"><%- INCLUDE inc/stargazer.html mystarred = flag %></div>
<% END %>
<div class="inline"><%- INCLUDE inc/stargazer.html %></div>
<%- IF module %>
<span>&nbsp;/&nbsp;
<% module.documentation %></span>
Expand Down
4 changes: 2 additions & 2 deletions root/inc/stargazer.html
@@ -1,10 +1,10 @@
<% IF user_exists -%>
<form action="/account/stargazer/add" style="display: inline" onsubmit="return starModule(this)">
<% IF mystarred == 1 %><input type="hidden" name="remove" value="1"><% END -%>
<input type="hidden" name="release" value="<% module.release %>">
<input type="hidden" name="author" value="<% module.author %>">
<input type="hidden" name="module" value="<% module.documentation %>">
<% IF mystarred == 1 %>
<% IF active_star %>
<input type="hidden" name="remove" value="1">
<button type="submit" class="stargazer active">Unstar</button>
<% ELSE %> <button type="submit" class="stargazer highlight">Star</button>
<% END %>
Expand Down
2 changes: 1 addition & 1 deletion root/pod.html
Expand Up @@ -3,7 +3,7 @@
<% meta_description = module.abstract %>
<% title = module.documentation _ (module.abstract ? ' - ' _ module.abstract : ''); rss = 'distribution/' _ module.distribution %>

<% INCLUDE inc/breadcrumbs.html flag= mystargazer, button_flag = star_flag %>
<% INCLUDE inc/breadcrumbs.html %>

<ul class="nav nav-list slidepanel" itemscope itemtype="http://schema.org/SoftwareApplication">
<li class="visible-phone search">
Expand Down

0 comments on commit 0fd453f

Please sign in to comment.