git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] gitweb: Add git_project_index for generating index.aux

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 15, 2006, 02:56 UTC
Message-ID
<200609150456.03972.jnareb@gmail.com>
In-Reply-To
<200609150453.42231.jnareb@gmail.com>

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. And is probably faster.

Additionally it can be used to get the list of all available repositories for scripts (in easily parseable form).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b4a890b..7dbcb88 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -296,6 +296,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) {
@@ -2210,6 +2211,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.2
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 8 in “Add git_project_index, improve href()”
  1. 0/3 Add git_project_index, improve href()Jakub Narebski, Sep 15, 2006
  2. 1/3 gitweb: Add git_project_index for generating index.auxJakub Narebski, Sep 15, 2006
  3. 2/3 gitweb: Allow for href() to be used for projectless linksJakub Narebski, Sep 15, 2006
  4. Junio C HamanoSep 15, 2006
  5. Jakub NarebskiSep 15, 2006
  6. 3/3 gitweb: Add link to "project_index" view to "project_list" pageJakub Narebski, Sep 15, 2006
  7. 3/3 gitweb: Add link to "project_index" view to "project_list" pageJakub Narebski, Sep 15, 2006
  8. 2/3 gitweb: Allow for href() to be used for links without project paramJakub Narebski, Sep 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.