{"thread":{"id":"5795","subject":"[PATCH] Gitweb - provide site headers and footers","startedAt":"2006-10-03T12:49:03Z","lastAt":"2006-10-05T20:45:08Z","messageCount":3,"participants":["Alan Chandler"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"28154","messageId":"1159879743194-git-send-email-alan@chandlerfamily.org.uk","threadId":"5795","inReplyTo":null,"subject":"[PATCH] Gitweb - provide site headers and footers","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2006-10-03T12:49:03Z","receivedAt":"2006-10-03T12:49:03Z","isPatch":true,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"From: Alan Chandler <alan@chandlerfamily.org.uk>\n\nThis allows web sites with a header and footer standard for each page\nto add them to the pages produced by gitweb.\n\nTwo new variables $site_header and $site_footer are defined (default\nto null) each of which can specify a file containing the header and\nfooter html.\n\nIn addition, if the $stylesheet variable is undefined, a new array\n@stylesheets (which defaults to a single element of gitweb.css) can be\nused to specify more than one style sheet.  This allows the clasical\ngitweb.css styles to be retained, but a site wide style sheet used\nwithin the header and footer areas.\n\nSigned-off-by: Alan Chandler <alan@chandlerfamily.org.uk>\n---\n Makefile           |    4 ++++\n gitweb/gitweb.perl |   45 ++++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 42 insertions(+), 7 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 401b893..32a546e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -132,6 +132,8 @@ GITWEB_HOMETEXT = indextext.html\n GITWEB_CSS = gitweb.css\n GITWEB_LOGO = git-logo.png\n GITWEB_FAVICON = git-favicon.png\n+GITWEB_SITE_HEADER = \n+GITWEB_SITE_FOOTER =\n \n export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR\n \n@@ -675,6 +677,8 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \t    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \\\n \t    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \\\n \t    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \\\n+\t    -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \\\n+\t    -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \\\n \t    $< >$@+\n \tchmod +x $@+\n \tmv $@+ $@\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 44991b1..1ec4435 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -41,11 +41,19 @@ # name of your site or organization to a\n # replace this with something more descriptive for clearer bookmarks\n our $site_name = \"++GITWEB_SITENAME++\" || $ENV{'SERVER_NAME'} || \"Untitled\";\n \n+# filename of html text to include at top of each page\n+our $site_header = \"++GITWEB_SITE_HEADER++\";\n # html text to include at home page\n our $home_text = \"++GITWEB_HOMETEXT++\";\n+# filename of html text to include at bottom of each page\n+our $site_footer = \"++GITWEB_SITE_FOOTER++\";\n+\n+# URI of stylesheets\n+our @stylesheets = (\"++GITWEB_CSS++\");\n+our $stylesheet;\n+# default is not to define style sheet, but it can be overwritten later\n+undef $stylesheet;\n \n-# URI of default stylesheet\n-our $stylesheet = \"++GITWEB_CSS++\";\n # URI of GIT logo\n our $logo = \"++GITWEB_LOGO++\";\n # URI of GIT favicon, assumed to be image/png type\n@@ -1351,8 +1359,17 @@ sub git_header_html {\n <meta name=\"generator\" content=\"gitweb/$version git/$git_version\"/>\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\n-<link rel=\"stylesheet\" type=\"text/css\" href=\"$stylesheet\"/>\n EOF\n+# print out each stylesheet that exist\n+\tif (defined $stylesheet) {\n+#provides backwards capability for those people who define style sheet in a config file\n+\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.$stylesheet.'\"/>'.\"\\n\";\n+\t} else {\n+\t\tforeach my $stylesheet (@stylesheets) {\n+\t\t\tnext unless $stylesheet;\n+\t\t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.$stylesheet.'\"/>'.\"\\n\";\n+\t\t}\n+\t}\n \tif (defined $project) {\n \t\tprintf('<link rel=\"alternate\" title=\"%s log\" '.\n \t\t       'href=\"%s\" type=\"application/rss+xml\"/>'.\"\\n\",\n@@ -1370,8 +1387,15 @@ EOF\n \t}\n \n \tprint \"</head>\\n\" .\n-\t      \"<body>\\n\" .\n-\t      \"<div class=\\\"page_header\\\">\\n\" .\n+\t      \"<body>\\n\";\n+\t      \n+\tif (-f $site_header) {\n+\t\topen (my $fd, $site_header);\n+\t\tprint <$fd>;\n+\t\tclose $fd;\n+\t}\n+\t\n+\tprint \"<div class=\\\"page_header\\\">\\n\" .\n \t      \"<a href=\\\"http://www.kernel.org/pub/software/scm/git/docs/\\\" title=\\\"git documentation\\\">\" .\n \t      \"<img src=\\\"$logo\\\" width=\\\"72\\\" height=\\\"27\\\" alt=\\\"git\\\" style=\\\"float:right; border-width:0px;\\\"/>\" .\n \t      \"</a>\\n\";\n@@ -1422,8 +1446,15 @@ sub git_footer_html {\n \t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n \t\t              -class => \"rss_logo\"}, \"TXT\") . \"\\n\";\n \t}\n-\tprint \"</div>\\n\" .\n-\t      \"</body>\\n\" .\n+\tprint \"</div>\\n\" ;\n+\t\n+\tif (-f $site_footer) {\n+\t\topen (my $fd, $site_footer);\n+\t\tprint <$fd>;\n+\t\tclose $fd;\n+\t}\n+\t\n+\tprint \"</body>\\n\" .\n \t      \"</html>\";\n }\n \n-- \n1.4.2.1\n"},{"id":"28155","messageId":"E1GUkNO-0007p9-QJ@home.chandlerfamily.org.uk","threadId":"5795","inReplyTo":"1159879743194-git-send-email-alan@chandlerfamily.org.uk","subject":"Re: [PATCH] Gitweb - provide site headers and footers","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2006-10-03T13:32:02Z","receivedAt":"2006-10-03T13:32:02Z","isPatch":true,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"Alan Chandler writes: \n\n> From: Alan Chandler <alan@chandlerfamily.org.uk> \n> \n> This allows web sites with a header and footer standard for each page\n> to add them to the pages produced by gitweb. \n> \n\nMy web site at http://www.chandlerfamily.org.uk/git shows the example of \nthis, although the list of projects is null at the moment, \n\nThat is because I am using the very latest gitweb from master, but git is an \nolder version (debian etch) which doesn't understand git --git-dir=... \n\nI will update to latest git sometime later this week, but I am away on \nbusiness for a couple of days. \n\n\n --\nAlan Chandler\nalan@chandlerfamily.org.uk\n(via webmail - normally means I am not at my computer)\n"},{"id":"28246","messageId":"200610052145.08903.alan@chandlerfamily.org.uk","threadId":"5795","inReplyTo":"E1GUkNO-0007p9-QJ@home.chandlerfamily.org.uk","subject":"Re: [PATCH] Gitweb - provide site headers and footers","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2006-10-05T20:45:08Z","receivedAt":"2006-10-05T20:45:08Z","isPatch":true,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"On Tuesday 03 October 2006 14:32, Alan Chandler wrote:\n> Alan Chandler writes:\n> > From: Alan Chandler <alan@chandlerfamily.org.uk>\n> >\n> > This allows web sites with a header and footer standard for each page\n> > to add them to the pages produced by gitweb.\n>\n> My web site at http://www.chandlerfamily.org.uk/git shows the example of\n> this, although the list of projects is null at the moment,\n\nThe site is working now, that I have updated the underlying git to 1.4.2\n\n-- \nAlan Chandler\nhttp://www.chandlerfamily.org.uk\n"}]}