gitweb: Add git_project_index for generating index.aux
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>
Jakub Narebski committed
Sep 15, 2006 at 04:56 UTC
fc2b2be031f44aef0106cf7f872b750cd90b2253
1 file changed
+25
gitweb/gitweb.perl
+25
@@ -296,6 +296,7 @@ my %actions = (
296
# those below don't need $project
297
"opml" => \&git_opml,
298
"project_list" => \&git_project_list,
299
+ "project_index" => \&git_project_index,
300
);
301
302
if (defined $project) {
@@ -2210,6 +2211,30 @@ sub git_project_list {
2211
git_footer_html();
2212
}
2213
2214
+sub git_project_index {
2215
+ my @projects = git_get_projects_list();
2216
+
2217
+ print $cgi->header(
2218
+ -type => 'text/plain',
2219
+ -charset => 'utf-8',
2220
+ -content_disposition => qq(inline; filename="index.aux"));
2221
+
2222
+ foreach my $pr (@projects) {
2223
+ if (!exists $pr->{'owner'}) {
2224
+ $pr->{'owner'} = get_file_owner("$projectroot/$project");
2225
+ }
2226
+
2227
+ my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});
2228
+ # quote as in CGI::Util::encode, but keep the slash, and use '+' for ' '
2229
+ $path =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf("%%%02X", ord($1))/eg;
2230
+ $owner =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf("%%%02X", ord($1))/eg;
2231
+ $path =~ s/ /\+/g;
2232
+ $owner =~ s/ /\+/g;
2233
+
2234
+ print "$path $owner\n";
2235
+ }
2236
+}
2237
+
2238
sub git_summary {
2239
my $descr = git_get_project_description($project) || "none";
2240
my $head = git_get_head_hash($project);