From f6801d669ee11f0d5e67b2e86aec270d2a225224 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Tue, 11 Jul 2006 11:19:34 +0100 Subject: [PATCH 1/2] gitweb: Send XHTML as 'application/xhtml+xml' where possible "The 'text/html' media type [RFC2854] is primarily for HTML, not for XHTML. In general, this media type is NOT suitable for XHTML." This patch makes gitweb use content negotiation to conservatively send pages as Content-Type 'application/xhtml+xml' when the user agent explicitly claims to support it. It falls back to 'text/html' even if the user agent appears to implicitly support 'application/xhtml+xml' due to a '*/*' glob, working around an insidious bug in Internet Explorer where sending the correct media type prevents the page from being displayed. Signed-off-by: Alp Toker Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 2e87de4769..bd9b9de88c 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -293,7 +293,17 @@ sub git_header_html { } } } - print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status, -expires => $expires); + 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 ($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); print < @@ -301,7 +311,7 @@ sub git_header_html { - + $title From 49da1dafc075e353c0eb3869de4acf600c594621 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Tue, 11 Jul 2006 21:10:26 +0100 Subject: [PATCH 2/2] gitweb: Include a site name in page titles This helps users tell one 'git' bookmark apart from the other in their browser and improves the indexing of gitweb sites in Web search engines. The title defaults to the SERVER_NAME environment variable, often given by the webserver. Signed-off-by: Alp Toker Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index bd9b9de88c..3d9fa4456e 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -46,6 +46,10 @@ if (! -d $git_temp) { # target of the home link on top of all pages our $home_link = $my_uri; +# name of your site or organization to appear in page titles +# replace this with something more descriptive for clearer bookmarks +our $site_name = $ENV{'SERVER_NAME'} || "Untitled"; + # html text to include at home page our $home_text = "indextext.html"; @@ -280,7 +284,7 @@ sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; - my $title = "git"; + my $title = "$site_name git"; if (defined $project) { $title .= " - $project"; if (defined $action) { @@ -1770,7 +1774,7 @@ sub git_opml { print "\n". "\n". "". - " Git OPML Export\n". + " $site_name Git OPML Export\n". "\n". "\n". "\n";