[PATCH] Move config options into separate package.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allow new gitweb.cgi to be installed without having to
continually tinker with the site-specific configuration
options need for an install.

Signed-off-by: Jon Loeliger <jdl@xxxxxxx>

---

This patch can be pulled directly from the "jdl" branch here:

    http://www.jdl.com/pub/software/gitweb.git


 gitweb.cgi       |   29 ++++++++++++-----------------
 gitweb_config.pm |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 17 deletions(-)
 create mode 100644 gitweb_config.pm

a55eba90ac75a5f722b865e631a728d4a6446d07
diff --git a/gitweb.cgi b/gitweb.cgi
index c1bb624..4d3bcd6 100755
--- a/gitweb.cgi
+++ b/gitweb.cgi
@@ -16,31 +16,26 @@ use Encode;
 use Fcntl ':mode';
 binmode STDOUT, ':utf8';
 
+require gitweb_config;
+
 my $cgi = new CGI;
 my $version =		"264";
 my $my_url =		$cgi->url();
 my $my_uri =		$cgi->url(-absolute => 1);
 my $rss_link =		"";
 
-# absolute fs-path which will be prepended to the project path
-#my $projectroot =	"/pub/scm";
-my $projectroot =	"/home/kay/public_html/pub/scm";
-
-# location of the git-core binaries
-my $gitbin =		"/usr/bin";
-
-# location for temporary files needed for diffs
-my $git_temp =		"/tmp/gitweb";
-
 # target of the home link on top of all pages
-my $home_link =		$my_uri;
+my $home_link =	$my_uri;
 
-# html text to include at home page
-my $home_text =		"indextext.html";
+# Get config values or use defaults.
+my $config_opts = gitweb_config::get_config_opts();
+my $gitbin = $config_opts->{gitbin} || "/usr/bin";
+my $git_temp = $config_opts->{git_temp} || "/tmp/gitweb";
+my $projectroot = $config_opts->{projectroot} || "/pub/scm";
+my $home_text =	$config_opts->{home_text} || "indextext.html";
+my $projects_list = $config_opts->{projects_list} || "index/index.aux";
+my $description_len = $config_opts->{description_len} || 25;
 
-# source of projects list
-#my $projects_list =	$projectroot;
-my $projects_list =	"index/index.aux";
 
 # input validation and dispatch
 my $action = $cgi->param('a');
@@ -853,7 +848,7 @@ sub git_project_list {
 		$pr->{'commit'} = \%co;
 		if (!defined $pr->{'descr'}) {
 			my $descr = git_read_description($pr->{'path'}) || "";
-			$pr->{'descr'} = chop_str($descr, 25, 5);
+			$pr->{'descr'} = chop_str($descr, $description_len, 5);
 		}
 		if (!defined $pr->{'owner'}) {
 			$pr->{'owner'} = get_file_owner("$projectroot/$pr->{'path'}") || "";
diff --git a/gitweb_config.pm b/gitweb_config.pm
new file mode 100644
index 0000000..d67fb34
--- /dev/null
+++ b/gitweb_config.pm
@@ -0,0 +1,42 @@
+#
+# This program is licensed under the GPLv2
+#
+
+#
+# Configuration Options for gitweb
+#
+# gitbin: Location of the git-core binaries
+#	"/usr/bin"
+#
+# git_temp: Location for temporary files needed for diffs
+#	"/tmp/gtiweb"
+#
+# projectroot: Absolute fs-path which will be prepended to the project path
+#	"/pub/scm"
+#	"/home/kay/public_html/pub/scm"
+#
+# projects_list: Source of projects list
+#	"/pub/scm"
+#	"index/index.aux"
+#
+# home_text: Html text to include at home page
+#	"indextext.html"
+#
+# description_len: Length of description field
+#	25
+#	35
+
+package gitweb_config;
+
+my $opts = {
+    gitbin => "/usr/bin",
+    git_temp => "/tmp/gitweb",
+    projectroot => "/pub/software",
+    projects_list => "/pub/software",
+    home_text => "indextext.html",
+    description_len => 35,
+};
+
+sub get_config_opts { return $opts; }
+
+1;
-- 
1.2.4.gc98264

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]