Skip to content

Commit

Permalink
fix wiki pages count
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed May 29, 2017
1 parent 2c200e3 commit 8f556d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 23 additions & 1 deletion lib/Gitprep/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sub exists_wiki_page {
}

sub get_wiki_pages {
my ($self, $user_id, $project_id, $title) = @_;
my ($self, $user_id, $project_id) = @_;

my $wiki_work_rep_info = $self->app->wiki_work_rep_info($user_id, $project_id);

Expand All @@ -82,6 +82,28 @@ sub get_wiki_pages {
return \@pages;
}

sub get_wiki_pages_count {
my ($self, $user_id, $project_id) = @_;

my $wiki_work_rep_info = $self->app->wiki_work_rep_info($user_id, $project_id);

# Open directory
my $dir = $wiki_work_rep_info->{work_tree};
opendir my $dh, $dir
or croak "Can't open directory \"$dir\":$!";

# Pages
my $count = 0;
while (my $file = readdir $dh) {
$file = decode('UTF-8', $file);
next if $file =~ /^\./;
$file =~ s/\.[^\.]+$//;
$count++;
}

return $count;
}

sub get_wiki_page_content {
my ($self, $user_id, $project_id, $title) = @_;

Expand Down
4 changes: 3 additions & 1 deletion templates/wiki.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
}
}

my $pages_count = $api->get_wiki_pages_count($user_id, $project_id);

layout 'common', title => "Wiki - $user_id/$project_id";
%>

Expand Down Expand Up @@ -280,7 +282,7 @@
<a href="<%= url_for("/$user_id/$project_id/wiki/_pages") %>">
<span class="wiki-count-number">
<i class="icon-leaf" style="position:relative;top:-1px"></i>
<%= 13 %>
<%= $pages_count %>
</span>
<span class="wiki-count-type">
pages
Expand Down

0 comments on commit 8f556d5

Please sign in to comment.