{"thread":{"id":"2476","subject":"[Patch] gitweb added site css, header and footer","startedAt":"2005-11-12T17:50:30Z","lastAt":"2005-11-12T17:50:30Z","messageCount":1,"participants":["Alan Chandler"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"11688","messageId":"200511121750.30477.alan@chandlerfamily.org.uk","threadId":"2476","inReplyTo":null,"subject":"[Patch] gitweb added site css, header and footer","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2005-11-12T17:50:30Z","receivedAt":"2005-11-12T17:50:30Z","isPatch":true,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"I wanted to include gitweb on my site - but with the ability to keep my own \nsite header and footer.  I have therefore made a few changes to enable this \nto happen.  I also had a problem in that I had installed gitweb.cgi \nin /usr/lib/cgi-bin, and it was attempting to read indextext.html from this \ndirectory rather than the projectroot.\n\nI have therefore changed it to pick up this file from projectroot, and also \ntwo other files header.html and footer.html which contain the html for the \nheader and footer of each page.\n\nLastly, I have made a paramter at the top of the file for the the url to my \nsite wide css file.\n\nSigned-off-by: Alan Chandler <alan@chandlerfamily.org.uk>\n\nI am not sure what the netiquette is with regards these changes.\n\nI have published them as the master branch at \n\nhttp://www.chandlerfamily.org.uk/git/gitweb.git\n\nbut I have also attached a patch below (and someone can tell me if kmail does \nthe \"right thing\")\n\nWhat should one do about the changes to the variables at the top of the file, \nyou will see I have changed $projectroot and $gitbin\n\n---------\n\ndiff --git a/gitweb.cgi b/gitweb.cgi\nindex b8f1537..d16def4 100755\n--- a/gitweb.cgi\n+++ b/gitweb.cgi\n@@ -22,10 +22,10 @@ my $rss_link = \"\";\n \n # absolute fs-path which will be prepended to the project path\n #my $projectroot =\t\"/pub/scm\";\n-my $projectroot = \"/home/kay/public_html/pub/scm\";\n+my $projectroot = \"/var/lib/git\";\n \n # location of the git-core binaries\n-my $gitbin =\t\t\"/usr/bin\";\n+my $gitbin =\t\t\"/usr/local/bin\";\n \n # location for temporary files needed for diffs\n my $git_temp =\t\t\"/tmp/gitweb\";\n@@ -33,12 +33,25 @@ my $git_temp =\t\t\"/tmp/gitweb\";\n # target of the home link on top of all pages\n my $home_link =\t\t$my_uri;\n \n+#css url for overall site\n+\n+my $site_css_url = \"/style/site.css\";\n+\n+#page header and footer for all pages on this site\n+\n+my $site_header=\t$projectroot.\"/header.html\";\n+my $site_footer=\t$projectroot.\"/footer.html\";\n+\n # html text to include at home page\n-my $home_text =\t\t\"indextext.html\";\n+my $home_text =\t\t$projectroot.\"/indextext.html\";\n \n # source of projects list\n-#my $projects_list = $projectroot;\n-my $projects_list = \"index/index.aux\";\n+my $projects_list = $projectroot;\n+#my $projects_list = \"index/index.aux\";\n+\n+\n+\n+\n \n # input validation and dispatch\n my $action = $cgi->param('a');\n@@ -217,6 +230,12 @@ sub git_header_html {\n \t\t\t$title .= \"/$action\";\n \t\t}\n \t}\n+\n+\tmy $site_css = \"\";\n+\tif (defined $site_css_url) {\n+\t\t$site_css=\"<link rel=\\\"stylesheet\\\" text=\\\"text/css\\\" \nhref=\\\"$site_css_url\\\"/>\";\n+\t}\n+\t\n \tprint $cgi->header(-type=>'text/html',  -charset => 'utf-8', -status=> \n$status, -expires => $expires);\n \tprint <<EOF;\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n@@ -228,6 +247,7 @@ sub git_header_html {\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\n $rss_link\n+$site_css\n <style type=\"text/css\">\n body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid \n#d9d8d1; border-width:1px; margin:10px; }\n a { color:#0000cc; }\n@@ -284,6 +304,13 @@ a.rss_logo:hover { background-color:#ee5\n </head>\n <body>\n EOF\n+\n+\tif (-f $site_header) {\n+\t\topen (my $fd, $site_header);\n+\t\tprint <$fd>;\n+\t\tclose $fd;\n+\t}\n+\n \tprint \"<div class=\\\"page_header\\\">\\n\" .\n \t      \"<a href=\\\"http://www.kernel.org/pub/software/scm/git/docs/\\\" \ntitle=\\\"git documentation\\\">\" .\n \t      \"<img src=\\\"$my_uri?a=git-logo.png\\\" width=\\\"72\\\" height=\\\"27\\\" \nalt=\\\"git\\\" style=\\\"float:right; border-width:0px;\\\"/>\" .\n@@ -329,8 +356,15 @@ sub git_footer_html {\n \t} else {\n \t\tprint $cgi->a({-href => \"$my_uri?a=opml\", -class => \"rss_logo\"}, \"OPML\") . \n\"\\n\";\n \t}\n-\tprint \"</div>\\n\" .\n-\t      \"</body>\\n\" .\n+\tprint \"</div>\\n\";\n+\tif (-f $site_footer) {\n+\t\topen (my $fd, $site_footer);\n+\t\tprint <$fd>;\n+\t\tclose $fd;\n+\t}\n+\n+\n+\tprint \"</body>\\n\" .\n \t      \"</html>\";\n }\n \n\n-- \nAlan Chandler\nhttp://www.chandlerfamily.org.uk\nOpen Source. It's the difference between trust and antitrust.\n"}]}