diff --git a/app/helpers/list_helper.rb b/app/helpers/list_helper.rb new file mode 100644 index 00000000000..a7cf7766acb --- /dev/null +++ b/app/helpers/list_helper.rb @@ -0,0 +1,20 @@ +module ListHelper + def page_links(topic) + posts = topic.posts_count + max_pages = 10 + total_pages = (posts / TopicView.chunk_size) + (posts == TopicView.chunk_size ? 0 : 1) + + return if total_pages < 2 + + page = [total_pages - (max_pages+1), 2].max + + result = "(" + while page <= total_pages + result << " #{page} " + page += 1 + end + + result << ")" + result.html_safe + end +end diff --git a/app/views/list/list.erb b/app/views/list/list.erb index 81663c7d861..7382cea1c02 100644 --- a/app/views/list/list.erb +++ b/app/views/list/list.erb @@ -21,10 +21,11 @@ <%= t.title %> + <%= page_links(t) %> <% if !@category && t.category %> [<%= t.category.name %>] <% end %> - '>(<%= t.posts_count %>) + '>(<%= t.posts_count %>) <% end %>