All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] Pagination for gitweb
@ 2010-09-10 16:17 Lubomir Rintel
  2010-09-10 16:17 ` [PATCH 1/2] gitweb: Make it possible to paginate projects Lubomir Rintel
  2010-09-10 18:57 ` [RESEND] Pagination for gitweb Jakub Narebski
  0 siblings, 2 replies; 10+ messages in thread
From: Lubomir Rintel @ 2010-09-10 16:17 UTC (permalink / raw)
  To: git; +Cc: Lubomir Rintel

I tought something like this could be a starter for better handling long
gitweb project lists (such as http://pkgs.fedoraproject.org/gitweb/).

Could anyone please take a look?
Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH 1/2] gitweb: Make it possible to paginate projects
@ 2010-08-25  0:18 Lubomir Rintel
  0 siblings, 0 replies; 10+ messages in thread
From: Lubomir Rintel @ 2010-08-25  0:18 UTC (permalink / raw)
  To: git; +Cc: Lubomir Rintel

This adds simple pagination (next and prev links), to project lists,
analogous to what is done for commit history lists.
---
 gitweb/gitweb.perl |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d0687f4..135ca55 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -255,6 +255,9 @@ our %highlight_ext = (
 	map { $_ => 'xml' } qw(xhtml html htm),
 );
 
+# Set this to non-zero to enable project list pagination
+our $projects_per_page = 0;
+
 # You define site-wide feature defaults here; override them with
 # $GITWEB_CONFIG as necessary.
 our %feature = (
@@ -4613,9 +4616,19 @@ sub git_project_list_body {
 	my @projects = fill_project_list_info($projlist, $check_forks);
 
 	$order ||= $default_projects_order;
+	$page ||= 0;
+	if ($projects_per_page) {
+		$from = $page * $projects_per_page unless defined $from;
+		$to = $from + $projects_per_page - 1 unless defined $to;
+	}
 	$from = 0 unless defined $from;
 	$to = $#projects if (!defined $to || $#projects < $to);
 
+	my $prev_link = $cgi->a({-href => href(-replay=>1, page=>$page-1),
+		 -accesskey => "p", -title => "Alt-p"}, "prev") if ($page > 0);
+	my $next_link = $cgi->a({-href => href(-replay=>1, page=>$page+1),
+		 -accesskey => "n", -title => "Alt-n"}, "next") if ($#$projlist > $to);
+
 	my %order_info = (
 		project => { key => 'path', type => 'str' },
 		descr => { key => 'descr_long', type => 'str' },
@@ -4709,6 +4722,19 @@ sub git_project_list_body {
 		print "<td colspan=\"5\">$extra</td>\n" .
 		      "</tr>\n";
 	}
+
+	if ($prev_link or $next_link) {
+		print "<tr>\n";
+		if ($check_forks) {
+			print "<td></td>\n";
+		}
+		print "<td colspan=\"5\">";
+		print $prev_link if $prev_link;
+		print " &sdot; " if $prev_link and $next_link;
+		print $next_link if $next_link;
+		print "</td>\n</tr>\n";
+	}
+
 	print "</table>\n";
 }
 
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-09-12 19:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-10 16:17 [RESEND] Pagination for gitweb Lubomir Rintel
2010-09-10 16:17 ` [PATCH 1/2] gitweb: Make it possible to paginate projects Lubomir Rintel
2010-09-10 16:17   ` [PATCH 2/2] gitweb: Optimize paging when sorted by path Lubomir Rintel
2010-09-10 19:24     ` Jakub Narebski
2010-09-10 19:10   ` [PATCH 1/2] gitweb: Make it possible to paginate projects Jakub Narebski
2010-09-10 18:57 ` [RESEND] Pagination for gitweb Jakub Narebski
2010-09-10 19:05   ` J.H.
2010-09-10 21:53     ` Jakub Narebski
2010-09-12 19:40     ` Jakub Narebski
  -- strict thread matches above, loose matches on Subject: below --
2010-08-25  0:18 [PATCH 1/2] gitweb: Make it possible to paginate projects Lubomir Rintel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.