Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Pagination view tweaks: use same style for posts and topics and show …
Browse files Browse the repository at this point in the history
…pagination on top and bottom
  • Loading branch information
juozasg committed May 17, 2012
1 parent 9e15e57 commit 69199ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/helpers/forem/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ def forem_markdown(text, *options)
forem_format(text)
end

def forem_pages_widget(collection)
if collection.num_pages > 1
("<div class='pages'>\n" +
t('forem.common.pages') + ':' + forem_paginate(collection) + "\n" +
"</div>").html_safe
end
end

def forem_paginate(collection, options={})
if respond_to?(:will_paginate)
# If parent app is using Will Paginate, we need to use it also
Expand Down
9 changes: 4 additions & 5 deletions app/views/forem/forums/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<%= render :partial => 'forem/forums/head', :locals => { :forum => @forum } %>

<% if @topics.num_pages > 1 %>
<div class='pages'>
<%= t('forem.common.pages') -%>: <%= forem_paginate @topics %>
</div>
<% end %>
<%= forem_pages_widget(@topics) %>

<table class='topics subdued' cellspacing='0'>
<thead>
<tr>
Expand All @@ -22,3 +19,5 @@
<%= render @topics %>
</tbody>
</table>

<%= forem_pages_widget(@topics) %>
5 changes: 4 additions & 1 deletion app/views/forem/topics/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
</div>
<% end %>

<%= forem_paginate @posts %>
<%= forem_pages_widget(@posts) %>

<div id='posts'>
<%= render :partial => "forem/posts/post", :collection => @posts %>
</div>

<%= forem_pages_widget(@posts) %>
</div>

0 comments on commit 69199ee

Please sign in to comment.