Skip to content

Commit

Permalink
fix branch paging
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed Oct 12, 2016
1 parent 9a6ae80 commit 42079ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Gitprep.pm
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ sub startup {
$r->get('/commits/*rev_file' => sub { shift->render_maybe('/commits') });

# Branches
$r->any('/branches/:display' => {display => undef} => sub { shift->render_maybe('/branches') });
$r->any('/branches' => sub { shift->render_maybe('/branches') });

# Tags
$r->get('/tags' => sub { shift->render_maybe('/tags') });
Expand Down
16 changes: 5 additions & 11 deletions templates/branches.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
my $user_id = param('user');
my $project_id = param('project');
my $op = param('op') || '';
my $display = 'all';
my $page = param('page') || 1;

# Git
Expand Down Expand Up @@ -57,17 +56,17 @@
my $default_branch = $git->branch($self->app->rep_info($user_id, $project_id), $default_branch_name);

# Branches
my $branch_types;
my $all_branches = [];
my $branches = [];

# Pagenation
my $page_count = 20;
my $skip = $page_count * ($page - 1);

my $branches = $git->branches($self->app->rep_info($user_id, $project_id));
my $all_branches = $git->branches($self->app->rep_info($user_id, $project_id));
my $max = 0;
my $all_count = 0;
for my $branch (@$branches) {
for my $branch (@$all_branches) {
$branch->{status} = $git->branch_status(
$self->app->rep_info($user_id, $project_id),
$default_branch->{name},
Expand Down Expand Up @@ -285,26 +284,21 @@
% } else {
% my $newer_page = $page - 1;
<li>
<a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$newer_page") %>">Newer</a>
<a href="<%= url_for("/$user_id/$project_id/branches?page=$newer_page") %>">Newer</a>
</li>
% }
% if ($branches_count < $page_count) {
<li><span>Older</span></li>
% } else {
% my $older_page = $page + 1;
<li>
<a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$older_page") %>">Older</a>
<a href="<%= url_for("/$user_id/$project_id/branches?page=$older_page") %>">Older</a>
</li>
% }
</ul>
</div>
% } else {
<li style="text-align:center;text-color:#767676">
<%
my $branch_type_name;
$branch_type_name = '';
%>

There aren’t any branches.
</li>
% }
Expand Down

0 comments on commit 42079ef

Please sign in to comment.