threads / patch / 5442

patchgitweb: Add git_project_index for generating index.aux

Subject: [PATCH] gitweb: Add git_project_index for generating index.aux

## tl;dr

2 messages between Aug 31, 2006 and Aug 31, 2006. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Jakub Narebski· Aug 31, 2006, 13:17 UTC · lore

Add git_project_index, which generates index.aux file that can be used as a source of projects list, instead of generating projects list from a directory. Using file as a source of projects list allows for some projects to be not present in gitweb main (project_list) page, and/or correct project owner info.

This also allows for easy getting list of all available (well, gitweb available) projects. OPML output offers something similar.

This action is not linked from anywhere, one must put p=project_index into query string by hand.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
Show changes to gitweb/gitweb.perl +25 −0
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index fa7f62a..98193be 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -268,6 +268,7 @@ my %actions = (
 	# those below don't need $project
 	"opml" => \&git_opml,
 	"project_list" => \&git_project_list,
+	"project_index" => \&git_project_index,
 );
 
 if (defined $project) {
@@ -2069,6 +2070,30 @@ sub git_project_list {
 	git_footer_html();
 }
 
+sub git_project_index {
+	my @projects = git_get_projects_list();
+
+	print $cgi->header(
+		-type => 'text/plain',
+		-charset => 'utf-8',
+		-content_disposition => qq(inline; filename="index.aux"));
+
+	foreach my $pr (@projects) {
+		if (!exists $pr->{'owner'}) {
+			$pr->{'owner'} = get_file_owner("$projectroot/$project");
+		}
+
+		my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});
+		# quote as in CGI::Util::encode, but keep the slash, and use '+' for ' '
+		$path  =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf("%%%02X", ord($1))/eg;
+		$owner =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf("%%%02X", ord($1))/eg;
+		$path  =~ s/ /\+/g;
+		$owner  =~ s/ /\+/g;
+
+		print "$path $owner\n";
+	}
+}
+
 sub git_summary {
 	my $descr = git_get_project_description($project) || "none";
 	my $head = git_get_head_hash($project);
-- 
1.4.1.1
Jakub Narebski· Aug 31, 2006, 14:33 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: Add git_project_index for generating index.aux

Jakub Narebski wrote:
> This action is not linked from anywhere, one must put p=project_index
> into query string by hand.
Of course it should be a=project_index (or rather ?a=project_index).
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

← back to recent threads