* [PATCH] Gitweb - provide site headers and footers
@ 2006-10-03 12:49 Alan Chandler
2006-10-03 13:32 ` Alan Chandler
0 siblings, 1 reply; 3+ messages in thread
From: Alan Chandler @ 2006-10-03 12:49 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Alan Chandler
From: Alan Chandler <alan@chandlerfamily.org.uk>
This allows web sites with a header and footer standard for each page
to add them to the pages produced by gitweb.
Two new variables $site_header and $site_footer are defined (default
to null) each of which can specify a file containing the header and
footer html.
In addition, if the $stylesheet variable is undefined, a new array
@stylesheets (which defaults to a single element of gitweb.css) can be
used to specify more than one style sheet. This allows the clasical
gitweb.css styles to be retained, but a site wide style sheet used
within the header and footer areas.
Signed-off-by: Alan Chandler <alan@chandlerfamily.org.uk>
---
Makefile | 4 ++++
gitweb/gitweb.perl | 45 ++++++++++++++++++++++++++++++++++++++-------
2 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 401b893..32a546e 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,8 @@ GITWEB_HOMETEXT = indextext.html
GITWEB_CSS = gitweb.css
GITWEB_LOGO = git-logo.png
GITWEB_FAVICON = git-favicon.png
+GITWEB_SITE_HEADER =
+GITWEB_SITE_FOOTER =
export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
@@ -675,6 +677,8 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
-e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
-e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
+ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
+ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
$< >$@+
chmod +x $@+
mv $@+ $@
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 44991b1..1ec4435 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -41,11 +41,19 @@ # name of your site or organization to a
# replace this with something more descriptive for clearer bookmarks
our $site_name = "++GITWEB_SITENAME++" || $ENV{'SERVER_NAME'} || "Untitled";
+# filename of html text to include at top of each page
+our $site_header = "++GITWEB_SITE_HEADER++";
# html text to include at home page
our $home_text = "++GITWEB_HOMETEXT++";
+# filename of html text to include at bottom of each page
+our $site_footer = "++GITWEB_SITE_FOOTER++";
+
+# URI of stylesheets
+our @stylesheets = ("++GITWEB_CSS++");
+our $stylesheet;
+# default is not to define style sheet, but it can be overwritten later
+undef $stylesheet;
-# URI of default stylesheet
-our $stylesheet = "++GITWEB_CSS++";
# URI of GIT logo
our $logo = "++GITWEB_LOGO++";
# URI of GIT favicon, assumed to be image/png type
@@ -1351,8 +1359,17 @@ sub git_header_html {
<meta name="generator" content="gitweb/$version git/$git_version"/>
<meta name="robots" content="index, nofollow"/>
<title>$title</title>
-<link rel="stylesheet" type="text/css" href="$stylesheet"/>
EOF
+# print out each stylesheet that exist
+ if (defined $stylesheet) {
+#provides backwards capability for those people who define style sheet in a config file
+ print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
+ } else {
+ foreach my $stylesheet (@stylesheets) {
+ next unless $stylesheet;
+ print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
+ }
+ }
if (defined $project) {
printf('<link rel="alternate" title="%s log" '.
'href="%s" type="application/rss+xml"/>'."\n",
@@ -1370,8 +1387,15 @@ EOF
}
print "</head>\n" .
- "<body>\n" .
- "<div class=\"page_header\">\n" .
+ "<body>\n";
+
+ 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=\"$logo\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
"</a>\n";
@@ -1422,8 +1446,15 @@ sub git_footer_html {
print $cgi->a({-href => href(project=>undef, action=>"project_index"),
-class => "rss_logo"}, "TXT") . "\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>";
}
--
1.4.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Gitweb - provide site headers and footers
2006-10-03 12:49 [PATCH] Gitweb - provide site headers and footers Alan Chandler
@ 2006-10-03 13:32 ` Alan Chandler
2006-10-05 20:45 ` Alan Chandler
0 siblings, 1 reply; 3+ messages in thread
From: Alan Chandler @ 2006-10-03 13:32 UTC (permalink / raw)
To: git
Alan Chandler writes:
> From: Alan Chandler <alan@chandlerfamily.org.uk>
>
> This allows web sites with a header and footer standard for each page
> to add them to the pages produced by gitweb.
>
My web site at http://www.chandlerfamily.org.uk/git shows the example of
this, although the list of projects is null at the moment,
That is because I am using the very latest gitweb from master, but git is an
older version (debian etch) which doesn't understand git --git-dir=...
I will update to latest git sometime later this week, but I am away on
business for a couple of days.
--
Alan Chandler
alan@chandlerfamily.org.uk
(via webmail - normally means I am not at my computer)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-05 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-03 12:49 [PATCH] Gitweb - provide site headers and footers Alan Chandler
2006-10-03 13:32 ` Alan Chandler
2006-10-05 20:45 ` Alan Chandler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).