Skip to content

Commit

Permalink
gitweb: Add git_project_index for generating index.aux
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Sep 15, 2006
1 parent c83a77e commit fc2b2be
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ sub feature_pickaxe {
# those below don't need $project
"opml" => \&git_opml,
"project_list" => \&git_project_list,
"project_index" => \&git_project_index,
);

if (defined $project) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fc2b2be

Please sign in to comment.