[Patch] gitweb added site css, header and footer

From: Alan Chandler <alan@chandlerfamily.org.uk>
Date: 2005-11-13 04:50:30
I wanted to include gitweb on my site - but with the ability to keep my own 
site header and footer.  I have therefore made a few changes to enable this 
to happen.  I also had a problem in that I had installed gitweb.cgi 
in /usr/lib/cgi-bin, and it was attempting to read indextext.html from this 
directory rather than the projectroot.

I have therefore changed it to pick up this file from projectroot, and also 
two other files header.html and footer.html which contain the html for the 
header and footer of each page.

Lastly, I have made a paramter at the top of the file for the the url to my 
site wide css file.

Signed-off-by: Alan Chandler <alan@chandlerfamily.org.uk>

I am not sure what the netiquette is with regards these changes.

I have published them as the master branch at 

http://www.chandlerfamily.org.uk/git/gitweb.git

but I have also attached a patch below (and someone can tell me if kmail does 
the "right thing")

What should one do about the changes to the variables at the top of the file, 
you will see I have changed $projectroot and $gitbin

---------

diff --git a/gitweb.cgi b/gitweb.cgi
index b8f1537..d16def4 100755
--- a/gitweb.cgi
+++ b/gitweb.cgi
@@ -22,10 +22,10 @@ my $rss_link = "";
 
 # absolute fs-path which will be prepended to the project path
 #my $projectroot =	"/pub/scm";
-my $projectroot = "/home/kay/public_html/pub/scm";
+my $projectroot = "/var/lib/git";
 
 # location of the git-core binaries
-my $gitbin =		"/usr/bin";
+my $gitbin =		"/usr/local/bin";
 
 # location for temporary files needed for diffs
 my $git_temp =		"/tmp/gitweb";
@@ -33,12 +33,25 @@ my $git_temp =		"/tmp/gitweb";
 # target of the home link on top of all pages
 my $home_link =		$my_uri;
 
+#css url for overall site
+
+my $site_css_url = "/style/site.css";
+
+#page header and footer for all pages on this site
+
+my $site_header=	$projectroot."/header.html";
+my $site_footer=	$projectroot."/footer.html";
+
 # html text to include at home page
-my $home_text =		"indextext.html";
+my $home_text =		$projectroot."/indextext.html";
 
 # source of projects list
-#my $projects_list = $projectroot;
-my $projects_list = "index/index.aux";
+my $projects_list = $projectroot;
+#my $projects_list = "index/index.aux";
+
+
+
+
 
 # input validation and dispatch
 my $action = $cgi->param('a');
@@ -217,6 +230,12 @@ sub git_header_html {
 			$title .= "/$action";
 		}
 	}
+
+	my $site_css = "";
+	if (defined $site_css_url) {
+		$site_css="<link rel=\"stylesheet\" text=\"text/css\" 
href=\"$site_css_url\"/>";
+	}
+	
 	print $cgi->header(-type=>'text/html',  -charset => 'utf-8', -status=> 
$status, -expires => $expires);
 	print <<EOF;
 <?xml version="1.0" encoding="utf-8"?>
@@ -228,6 +247,7 @@ sub git_header_html {
 <meta name="robots" content="index, nofollow"/>
 <title>$title</title>
 $rss_link
+$site_css
 <style type="text/css">
 body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid 
#d9d8d1; border-width:1px; margin:10px; }
 a { color:#0000cc; }
@@ -284,6 +304,13 @@ a.rss_logo:hover { background-color:#ee5
 </head>
 <body>
 EOF
+
+	if (-f $site_header) {
+		open (my $fd, $site_header);
+		print <$fd>;
+		close $fd;
+	}
+
 	print "<div class=\"page_header\">\n" .
 	      "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" 
title=\"git documentation\">" .
 	      "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" 
alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
@@ -329,8 +356,15 @@ sub git_footer_html {
 	} else {
 		print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "OPML") . 
"\n";
 	}
-	print "</div>\n" .
-	      "</body>\n" .
+	print "</div>\n";
+	if (-f $site_footer) {
+		open (my $fd, $site_footer);
+		print <$fd>;
+		close $fd;
+	}
+
+
+	print "</body>\n" .
 	      "</html>";
 }
 

-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Sun Nov 13 04:51:01 2005

This archive was generated by hypermail 2.1.8 : 2005-11-13 04:51:06 EST