Remove debugging statement.
[hcoop/zz_old/gitweb.git] / gitweb.cgi
index 62e6c26..6b5bd8a 100755 (executable)
@@ -43,11 +43,13 @@ our $project_maxdepth = 2007;
 our $home_link = $my_uri || "/";
 
 # string of the home link on top of all pages
-our $home_link_str = "projects";
+# hcoop-change: Customize.
+our $home_link_str = "HCoop";
 
 # name of your site or organization to appear in page titles
 # replace this with something more descriptive for clearer bookmarks
-our $site_name = ""
+# hcoop-change: Customize.
+our $site_name = "HCoop Git"
                  || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
 
 # filename of html text to include at top of each page
@@ -56,6 +58,8 @@ our $site_header = "";
 our $home_text = "indextext.html";
 # filename of html text to include at bottom of each page
 our $site_footer = "";
+# filename of cached version of front page
+our $cached_front_page = "/var/local/lib/gitweb/indexcache.html";
 
 # URI of stylesheets
 our @stylesheets = ("gitweb.css");
@@ -91,7 +95,10 @@ our $strict_export = "";
 
 # list of git base URLs used for URL to where fetch project from,
 # i.e. full URL is "$git_base_url/$project"
-our @git_base_url_list = grep { $_ ne '' } ("");
+# hcoop-change: We like several URLs.
+#our @git_base_url_list = grep { $_ ne '' } ("");
+our @git_base_url_list = ('git://git.hcoop.net/git',
+                          'http://git.hcoop.net/git');
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
@@ -417,6 +424,38 @@ if (defined $file_parent) {
        }
 }
 
+sub git_send_cached_front_page {
+       my $status = shift || "200 OK";
+       my $expires = shift;
+       my $content_type;
+       # require explicit support from the UA if we are to send the page as
+       # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
+       # we have to do this because MSIE sometimes globs '*/*', pretending to
+       # support xhtml+xml but choking when it gets what it asked for.
+       if (defined $cgi->http('HTTP_ACCEPT') &&
+           $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\+xml(,|;|\s|$)/ &&
+           $cgi->Accept('application/xhtml+xml') != 0) {
+               $content_type = 'application/xhtml+xml';
+       } else {
+               $content_type = 'text/html';
+       }
+       print $cgi->header(-type=>$content_type, -charset => 'utf-8',
+                          -status=> $status, -expires => $expires);
+       open (my $fd, $cached_front_page);
+       print <$fd>;
+       close $fd;
+       exit;
+}
+
+# Display a cached page if no parameters were provided and the
+# "nocache" parameter was not passed.
+our $nocache = $cgi->param('nocache');
+our @params = $cgi->Vars;
+if ($cached_front_page && ! defined $nocache && scalar @params == 0
+    && -f $cached_front_page && -r $cached_front_page) {
+       git_send_cached_front_page();
+}
+
 # parameters which are refnames
 our $hash = $cgi->param('h');
 if (defined $hash) {