Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Logic for accessing stragazers data.
  • Loading branch information
Talina06 committed Jul 4, 2014
1 parent 56806bc commit 3b3acfb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/MetaCPAN/Web/Controller/Pod.pm
Expand Up @@ -15,6 +15,21 @@ with qw(
sub root : Chained('/') PathPart('pod') CaptureArgs(0) {
}

sub stargazer : Chained('root') PathPart('') Args(1) {
my ( $self, $c, @path ) = @_;

# TODO: Pass size param so we can disambiguate?
my $user = $c->model('API::User')->get_profile( $c->token )->recv;
$c->stash( $c->model('API::Stargazer')->find_starred( $user, $path[0] ) );

This comment has been minimized.

Copy link
@Talina06

Talina06 Jul 4, 2014

Author Contributor

I'm calling the find_starred sub here: Which stashes mystarred if the module is starred, else it doesn't stash mystarred.


$c->stash->{pod_file} = $c->model('API::Module')->find(@path)->recv;

# TODO: Disambiguate if there's more than once match. #176

$c->forward( 'view', [@path] );

}

# /pod/$name
sub find : Chained('root') PathPart('') Args(1) {
my ( $self, $c, @path ) = @_;
Expand Down
11 changes: 11 additions & 0 deletions lib/MetaCPAN/Web/Model/API/User.pm
Expand Up @@ -37,6 +37,17 @@ sub remove_favorite {
undef, { method => 'DELETE', token => $token } );
}

sub add_stargazer {
my ( $self, $data, $token ) = @_;
$self->request( "/user/stargazer/", $data, { token => $token } );
}

sub remove_stargazer {
my ( $self, $data, $token ) = @_;
$self->request( "/user/stargazer/" . $data->{module},
undef, { method => 'DELETE', token => $token } );
}

sub turing {
my ( $self, $challenge, $answer, $token ) = @_;
$self->request(
Expand Down

0 comments on commit 3b3acfb

Please sign in to comment.