Skip to content

Commit e21843e

Browse files
committed
Update recent wiki pages; paginate
1 parent 57c3189 commit e21843e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

app/controllers/recent_wiki_pages_controller.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
class RecentWikiPagesController < ApplicationController
2+
def self.pages_with_updated_on
3+
WikiPage.with_updated_on
4+
.joins(:content)
5+
.order("#{WikiContent.table_name}.updated_on DESC")
6+
end
7+
28
def date_index
3-
@pages = WikiPage.find :all,
4-
:select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
5-
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
6-
:order => "#{WikiContent.table_name}.updated_on DESC"
9+
@paginator, @pages = paginate self.class.pages_with_updated_on
710
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
8-
@pages_by_parent_id = @pages.group_by(&:parent_id)
911

1012
@pages.first.wiki
1113
end

app/views/my/blocks/_recent_wiki_pages.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<%
22
#see WikiController::load_pages_for_index
3-
pages = WikiPage.with_updated_on.find :all, :order => "updated_on DESC", :limit => 10,:include => {:wiki => :project}
3+
pages = RecentWikiPagesController.pages_with_updated_on
4+
.limit(10)
5+
.includes(:wiki => :project)
46
%>
57

68
<span style="display:inline-block"> <h3>Top 10 Most Recent Wiki Pages</h3></span>

app/views/recent_wiki_pages/date_index.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313
<% end %>
1414
</ul>
1515
<% end %>
16+
17+
<span class="pagination">
18+
<%= pagination_links_full @paginator, :per_page_links => true %>
19+
</span>

0 commit comments

Comments
 (0)