All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitweb: optionally read config from GITWEB_CONFIG
@ 2006-08-02 19:23 Jeff King
  2006-08-02 20:17 ` [PATCH] gitweb: use single quotes for values replaced by the Makefile Matthias Lederhofer
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Jeff King @ 2006-08-02 19:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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>
---
This is on top of next.

This patch seemed to get a favorable response, so I cleaned it up and
actually tested it. The main changes are reordering a few of the setup
statements so that changes introduced in the config file are respected
as suggested by Matthias (and a few by me). It would be good if other
gitweb people could check it over and/or try it with their config to
make sure I didn't miss anything.

 Makefile           |    2 ++
 gitweb/gitweb.perl |   19 ++++++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 2562a2c..170d082 100644
--- a/Makefile
+++ b/Makefile
@@ -127,6 +127,7 @@ GIT_PYTHON_DIR = $(prefix)/share/git-cor
 # DESTDIR=
 
 # default configuration for gitweb
+GITWEB_CONFIG = gitweb_config.perl
 GITWEB_SITENAME =
 GITWEB_PROJECTROOT = /pub/git
 GITWEB_LIST =
@@ -629,6 +630,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 	    -e 's|@@GIT_VERSION@@|$(GIT_VERSION)|g' \
 	    -e 's|@@GIT_BINDIR@@|$(bindir)|g' \
+	    -e 's|@@GITWEB_CONFIG@@|$(GITWEB_CONFIG)|g' \
 	    -e 's|@@GITWEB_SITENAME@@|$(GITWEB_SITENAME)|g' \
 	    -e 's|@@GITWEB_PROJECTROOT@@|$(GITWEB_PROJECTROOT)|g' \
 	    -e 's|@@GITWEB_LIST@@|$(GITWEB_LIST)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1db1414..d5b2de8 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -31,14 +31,8 @@ # absolute fs-path which will be prepend
 #our $projectroot = "/pub/scm";
 our $projectroot = "@@GITWEB_PROJECTROOT@@";
 
-# version of the core git binary
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
-
 # location for temporary files needed for diffs
 our $git_temp = "/tmp/gitweb";
-if (! -d $git_temp) {
-	mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp");
-}
 
 # target of the home link on top of all pages
 our $home_link = $my_uri;
@@ -56,7 +50,7 @@ # URI of GIT logo
 our $logo = "@@GITWEB_LOGO@@";
 
 # source of projects list
-our $projects_list = "@@GITWEB_LIST@@" || "$projectroot";
+our $projects_list = "@@GITWEB_LIST@@";
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
@@ -66,6 +60,17 @@ # file to use for guessing MIME types be
 # (relative to the current git repository)
 our $mimetypes_file = undef;
 
+our $GITWEB_CONFIG = "@@GITWEB_CONFIG@@";
+require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+
+# version of the core git binary
+our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+
+$projects_list ||= $projectroot;
+if (! -d $git_temp) {
+	mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp");
+}
+
 # input validation and dispatch
 our $action = $cgi->param('a');
 if (defined $action) {
-- 
1.4.2.rc2.g59706-dirty

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2006-08-02 21:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-02 19:23 [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jeff King
2006-08-02 20:17 ` [PATCH] gitweb: use single quotes for values replaced by the Makefile Matthias Lederhofer
2006-08-02 20:50   ` Junio C Hamano
2006-08-02 20:57     ` Matthias Lederhofer
2006-08-02 20:58     ` Jeff King
2006-08-02 20:21 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Jakub Narebski
2006-08-02 20:31   ` Matthias Lederhofer
2006-08-02 20:36     ` Jakub Narebski
2006-08-02 20:41   ` Jeff King
2006-08-02 20:28 ` Junio C Hamano
2006-08-02 20:29 ` [PATCH] gitweb: require $ENV{'GITWEB_CONFIG'} Matthias Lederhofer
2006-08-02 20:50   ` Jeff King
2006-08-02 20:58     ` Junio C Hamano
2006-08-02 20:59       ` Jeff King
2006-08-02 20:51 ` [PATCH] gitweb: optionally read config from GITWEB_CONFIG Luben Tuikov
2006-08-02 20:56   ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.