[PATCH v2] repolist pagination changes

Jamie Couture jamie.couture at gmail.com
Wed Jan 4 18:44:05 CET 2012


bold the current page we're viewing

Signed-off-by: Jamie Couture <jamie.couture at gmail.com>
---
 cgit.css      |    4 ++++
 ui-repolist.c |   11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/cgit.css b/cgit.css
index 3734ca7..b45d220 100644
--- a/cgit.css
+++ b/cgit.css
@@ -550,6 +550,10 @@ div.pager a {
 	margin: 0em 0.5em;
 }
 
+div.pager .current {
+	font-weight: bold;
+}
+
 span.age-mins {
 	font-weight: bold;
 	color: #080;
diff --git a/ui-repolist.c b/ui-repolist.c
index a09a689..ea19afd 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -120,11 +120,14 @@ void print_header(int columns)
 
 void print_pager(int items, int pagelen, char *search, char *sort)
 {
-	int i;
+	int i, ofs;
+	char *class = NULL;
 	html("<div class='pager'>");
-	for(i = 0; i * pagelen < items; i++)
-		cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL,
-				search, sort, i * pagelen);
+	for(i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) {
+		class = (ctx.qry.ofs == ofs) ? "current" : NULL;
+		cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), class,
+				search, sort, ofs);
+	}
 	html("</div>");
 }
 
-- 
1.7.7.4





More information about the CGit mailing list