Skip to content

Commit

Permalink
Add recent action.
Browse files Browse the repository at this point in the history
  • Loading branch information
plu committed Jul 31, 2011
1 parent 46081e0 commit 037306f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/lib/GMC.pm
Expand Up @@ -23,6 +23,7 @@ sub startup {
$r->route('/')->to('root#list');
$r->route('/about')->to('root#about');
$r->route('/faq')->to('root#faq');
$r->route('/recent')->to('root#recent');
$r->route('/user/:user')->to('root#view');
}

Expand Down
9 changes: 9 additions & 0 deletions app/lib/GMC/Controller/Root.pm
Expand Up @@ -25,6 +25,15 @@ sub list {
);
}

sub recent {
my ($self) = @_;
my $users = $self->db->users->find( { created => { '$gt' => time - 86400 } } )->sort( { rank => -1 } );
$self->stash(
db_status => $self->db->status->find->next,
users => $users,
);
}

sub view {
my ($self) = @_;
my $pauseid = $self->match->captures->{user};
Expand Down
1 change: 1 addition & 0 deletions app/templates/layouts/default.html.ep
Expand Up @@ -11,6 +11,7 @@
<div class="navigation">
<ul>
<li><a href="<%= url_for '/' %>">Ranking</a></li>
<li><a href="<%= url_for '/recent' %>">Recent</a></li>
<li><a href="<%= url_for '/faq' %>">FAQ</a></li>
<li><a href="<%= url_for '/about' %>">About</a></li>
</ul>
Expand Down
12 changes: 12 additions & 0 deletions app/templates/root/faq.html.ep
Expand Up @@ -44,3 +44,15 @@
</p>
</div>

<div class="item">
<p>
<abbr title="Question">Q:</abbr>
What is the "Recent" section?
</p>
<p>
<abbr title="Answer">A:</abbr>
A list of users, who have been added to github-meets-cpan.com in the
last 24 hours.
</p>
</div>

12 changes: 12 additions & 0 deletions app/templates/root/recent.html.ep
@@ -0,0 +1,12 @@
% layout 'default';
% title 'Recent';
% my $pos = 1;
% if ($users->count) {
% while (my $user = $users->next) {
<%= include 'parts/user', user => $user, pos => $pos %>
% $pos++;
% }
% }
% else {
<div class="item"><p>There have been no new users added in the last 24 hours.</p></div>
% }

0 comments on commit 037306f

Please sign in to comment.