gitweb: optionally read config from GITWEB_CONFIG
Configuration will first be taken from variables inside the gitweb.cgi script, which in turn come from the Makefile. Afterwards, the contents of GITWEB_CONFIG are read, overriding the builtin defaults. This should eliminate the need for editing the gitweb script at all. Users should edit the Makefile and/or add a config file. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jeff King committed
Aug 2, 2006 at 15:23 UTC
c8d138a8c004ebce6ef840cfcc7c47227c2d16ba
2 files changed
+14
-7
Makefile
+2
@@ -117,6 +117,7 @@ GIT_PYTHON_DIR = $(prefix)/share/git-core/python
117
# DESTDIR=
118
119
# default configuration for gitweb
120
+GITWEB_CONFIG = gitweb_config.perl
121
GITWEB_SITENAME =
122
GITWEB_PROJECTROOT = /pub/git
123
GITWEB_LIST =
@@ -585,6 +586,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
586
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
587
-e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \
588
-e 's|@@GIT_BINDIR@@|$(bindir)|g' \
589
+ -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \
590
-e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \
591
-e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \
592
-e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \
gitweb/gitweb.perl
+12
-7
@@ -31,14 +31,8 @@ our $GIT = "@@GIT_BINDIR@@/git";
31
#our $projectroot = "/pub/scm";
32
our $projectroot = "@@GITWEB_PROJECTROOT@@";
33
34
-# version of the core git binary
35
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
36
-
34
# location for temporary files needed for diffs
35
our $git_temp = "/tmp/gitweb";
39
-if (! -d $git_temp) {
40
- mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp");
41
-}
36
37
# target of the home link on top of all pages
38
our $home_link = $my_uri;
@@ -56,7 +50,7 @@ our $stylesheet = "@@GITWEB_CSS@@";
50
our $logo = "@@GITWEB_LOGO@@";
51
52
# source of projects list
59
-our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
53
+our $projects_list = "@@GITWEB_LIST@@";
54
55
# default blob_plain mimetype and default charset for text/plain blob
56
our $default_blob_plain_mimetype = 'text/plain';
@@ -66,6 +60,17 @@ our $default_text_plain_charset = undef;
60
# (relative to the current git repository)
61
our $mimetypes_file = undef;
62
63
+our $GITWEB_CONFIG = "@@GITWEB_CONFIG@@";
64
+require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
65
+
66
+# version of the core git binary
67
+our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
68
+
69
+$projects_list ||= $projectroot;
70
+if (! -d $git_temp) {
71
+ mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp");
72
+}
73
+
74
# input validation and dispatch
75
our $action = $cgi->param('a');
76
if (defined $action) {