{"thread":{"id":"3703","subject":"[PATCH] Move config options into separate package.","startedAt":"2006-03-23T02:49:51Z","lastAt":"2006-03-23T02:49:51Z","messageCount":1,"participants":["Jon Loeliger"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"17801","messageId":"E1FMFtX-0000W4-Tx@jdl.com","threadId":"3703","inReplyTo":null,"subject":"[PATCH] Move config options into separate package.","fromName":"Jon Loeliger","fromEmail":"jdl@jdl.com","sentAt":"2006-03-23T02:49:51Z","receivedAt":"2006-03-23T02:49:51Z","isPatch":true,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"\nAllow new gitweb.cgi to be installed without having to\ncontinually tinker with the site-specific configuration\noptions need for an install.\n\nSigned-off-by: Jon Loeliger <jdl@jdl.com>\n\n---\n\nThis patch can be pulled directly from the \"jdl\" branch here:\n\n    http://www.jdl.com/pub/software/gitweb.git\n\n\n gitweb.cgi       |   29 ++++++++++++-----------------\n gitweb_config.pm |   42 ++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 54 insertions(+), 17 deletions(-)\n create mode 100644 gitweb_config.pm\n\na55eba90ac75a5f722b865e631a728d4a6446d07\ndiff --git a/gitweb.cgi b/gitweb.cgi\nindex c1bb624..4d3bcd6 100755\n--- a/gitweb.cgi\n+++ b/gitweb.cgi\n@@ -16,31 +16,26 @@ use Encode;\n use Fcntl ':mode';\n binmode STDOUT, ':utf8';\n \n+require gitweb_config;\n+\n my $cgi = new CGI;\n my $version =\t\t\"264\";\n my $my_url =\t\t$cgi->url();\n my $my_uri =\t\t$cgi->url(-absolute => 1);\n my $rss_link =\t\t\"\";\n \n-# absolute fs-path which will be prepended to the project path\n-#my $projectroot =\t\"/pub/scm\";\n-my $projectroot =\t\"/home/kay/public_html/pub/scm\";\n-\n-# location of the git-core binaries\n-my $gitbin =\t\t\"/usr/bin\";\n-\n-# location for temporary files needed for diffs\n-my $git_temp =\t\t\"/tmp/gitweb\";\n-\n # target of the home link on top of all pages\n-my $home_link =\t\t$my_uri;\n+my $home_link =\t$my_uri;\n \n-# html text to include at home page\n-my $home_text =\t\t\"indextext.html\";\n+# Get config values or use defaults.\n+my $config_opts = gitweb_config::get_config_opts();\n+my $gitbin = $config_opts->{gitbin} || \"/usr/bin\";\n+my $git_temp = $config_opts->{git_temp} || \"/tmp/gitweb\";\n+my $projectroot = $config_opts->{projectroot} || \"/pub/scm\";\n+my $home_text =\t$config_opts->{home_text} || \"indextext.html\";\n+my $projects_list = $config_opts->{projects_list} || \"index/index.aux\";\n+my $description_len = $config_opts->{description_len} || 25;\n \n-# source of projects list\n-#my $projects_list =\t$projectroot;\n-my $projects_list =\t\"index/index.aux\";\n \n # input validation and dispatch\n my $action = $cgi->param('a');\n@@ -853,7 +848,7 @@ sub git_project_list {\n \t\t$pr->{'commit'} = \\%co;\n \t\tif (!defined $pr->{'descr'}) {\n \t\t\tmy $descr = git_read_description($pr->{'path'}) || \"\";\n-\t\t\t$pr->{'descr'} = chop_str($descr, 25, 5);\n+\t\t\t$pr->{'descr'} = chop_str($descr, $description_len, 5);\n \t\t}\n \t\tif (!defined $pr->{'owner'}) {\n \t\t\t$pr->{'owner'} = get_file_owner(\"$projectroot/$pr->{'path'}\") || \"\";\ndiff --git a/gitweb_config.pm b/gitweb_config.pm\nnew file mode 100644\nindex 0000000..d67fb34\n--- /dev/null\n+++ b/gitweb_config.pm\n@@ -0,0 +1,42 @@\n+#\n+# This program is licensed under the GPLv2\n+#\n+\n+#\n+# Configuration Options for gitweb\n+#\n+# gitbin: Location of the git-core binaries\n+#\t\"/usr/bin\"\n+#\n+# git_temp: Location for temporary files needed for diffs\n+#\t\"/tmp/gtiweb\"\n+#\n+# projectroot: Absolute fs-path which will be prepended to the project path\n+#\t\"/pub/scm\"\n+#\t\"/home/kay/public_html/pub/scm\"\n+#\n+# projects_list: Source of projects list\n+#\t\"/pub/scm\"\n+#\t\"index/index.aux\"\n+#\n+# home_text: Html text to include at home page\n+#\t\"indextext.html\"\n+#\n+# description_len: Length of description field\n+#\t25\n+#\t35\n+\n+package gitweb_config;\n+\n+my $opts = {\n+    gitbin => \"/usr/bin\",\n+    git_temp => \"/tmp/gitweb\",\n+    projectroot => \"/pub/software\",\n+    projects_list => \"/pub/software\",\n+    home_text => \"indextext.html\",\n+    description_len => 35,\n+};\n+\n+sub get_config_opts { return $opts; }\n+\n+1;\n-- \n1.2.4.gc98264\n"}]}