From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EE533138A87 for ; Sun, 22 Feb 2015 00:00:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 601E0E0784; Sun, 22 Feb 2015 00:00:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0E632E0784 for ; Sun, 22 Feb 2015 00:00:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 19A5934087F for ; Sun, 22 Feb 2015 00:00:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B2C6112454 for ; Sun, 22 Feb 2015 00:00:08 +0000 (UTC) From: "Alex Legler" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Alex Legler" Message-ID: <1424563199.416dec280acb094e40338fe6198b682e71659ba8.a3li@gentoo> Subject: [gentoo-commits] proj/ag-web:master commit in: views/ X-VCS-Repository: proj/ag-web X-VCS-Files: views/pagination.erb X-VCS-Directories: views/ X-VCS-Committer: a3li X-VCS-Committer-Name: Alex Legler X-VCS-Revision: 416dec280acb094e40338fe6198b682e71659ba8 X-VCS-Branch: master Date: Sun, 22 Feb 2015 00:00:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 4bef72c1-ff79-45d0-92ee-a8ab3bf80fda X-Archives-Hash: 746968bdfee5054bde5b8a2d20dfbb92 commit: 416dec280acb094e40338fe6198b682e71659ba8 Author: Alex Legler a3li li> AuthorDate: Sat Feb 21 23:59:59 2015 +0000 Commit: Alex Legler gentoo org> CommitDate: Sat Feb 21 23:59:59 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=416dec28 Limit pages shown in pagination --- views/pagination.erb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/views/pagination.erb b/views/pagination.erb index 7d7be9c..9b85ec9 100644 --- a/views/pagination.erb +++ b/views/pagination.erb @@ -12,9 +12,15 @@ <% end %> - <% (1..max_pages).each do |page| %> + <% min = [1, current_page - 5].max ; max = [max_pages, current_page + 5].min %> + <% if min > 10 %> +
  • 1
  • + <% end %> + <% (min..max).each do |page| %>
  • <%= 'class="active"' %><% end %>><%= page %>
  • <% end %> + <% if (max_pages - max) > 10 %> +
  • <%= max_pages %>
  • <% if current_page == max_pages %>