<%
if @filter_context.page_count>1
max_pages = @filter_context.page_count
- max_pages = 20 if @filter_context.page_count > 20
+ current_page = @filter_context.page_id
+ start_page = 1
+ end_page = max_pages
+ if max_pages > 20
+ if current_page < 12
+ start_page = 1
+ end_page = 20
+ elsif current_page > max_pages-10
+ start_page = max_pages-20
+ end_page = max_pages
+ else
+ start_page = current_page-10
+ end_page = current_page+9
+ end
+ end
%>
|
- <%= link_to_if @filter_context.page_id>1, message('paging_previous'), {:overwrite_params => {:page_id => @filter_context.page_id-1}} %>
- <% for index in 1..max_pages %>
- <%= link_to_unless index==@filter_context.page_id, index.to_s, {:overwrite_params => {:page_id => index}} %>
+ <% if max_pages > 20 && start_page > 1 %>
+ <%= link_to message('paging_first'), {:overwrite_params => {:page_id => 1}} -%>
+ <% end %>
+ <%= link_to_if current_page>start_page, message('paging_previous'), {:overwrite_params => {:page_id => current_page-1}} %>
+ <% for index in start_page..end_page %>
+ <%= link_to_unless index==current_page, index.to_s, {:overwrite_params => {:page_id => index}} %>
+ <% end %>
+ <%= link_to_if current_page<end_page, message('paging_next'), {:overwrite_params => {:page_id => 1+current_page}} %>
+ <% if max_pages > 20 && end_page < max_pages %>
+ <%= link_to message('paging_last'), {:overwrite_params => {:page_id => max_pages}} -%>
<% end %>
- <%= '... ' if @filter_context.page_count>20 -%>
- <%= link_to_if @filter_context.page_id<20, message('paging_next'), {:overwrite_params => {:page_id => 1+@filter_context.page_id}} %>
<% end %>
<% if @filter.projects_homepage? %>