[PATCH/RFC] gitweb: Separate features with no project specific override

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

 



Put features for which project specific override is not supported into
separate %global_feature hash, updating gitweb_check_feature()
subroutine to use it.

While at it remove stale comment for 'pathinfo' feature; requiring to
use workaround specified was fixed in b65910f (gitweb: remove
PATH_INFO from $my_url and $my_uri).

Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
This patch has the advantage of clear separation of non-overridable
and overridable features; currently the only difference is lack of
subroutine and comment on feature.  For non-overridable features the
complexisty of {'sub'=>..., 'override'=>..., 'default'=>...} is not
needed.

It has the disadvantage of invalidating old gitweb configuration, and
that now there are two sources of gitweb config.

FIX IT: some spurious "HASH.." is printed to STDERR (by my 'run gitweb
from command line' script), which I didn't found yet.

 gitweb/gitweb.perl |   59 ++++++++++++++++++++++++----------------------------
 1 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index cc6edbe..82068f9 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -215,13 +215,6 @@ our %feature = (
 		'override' => 0,
 		'default' => ['tgz']},
 
-	# Enable text search, which will list the commits which match author,
-	# committer or commit text to a given string.  Enabled by default.
-	# Project specific override is not supported.
-	'search' => {
-		'override' => 0,
-		'default' => [1]},
-
 	# Enable grep search, which will list the files in currently selected
 	# tree containing the given string. Enabled by default. This can be
 	# potentially CPU-intensive, of course.
@@ -248,6 +241,18 @@ our %feature = (
 		'sub' => \&feature_pickaxe,
 		'override' => 0,
 		'default' => [1]},
+);
+
+our %global_feature = (
+	# feature => [ default options...] (array reference)
+	#
+	# For those features project specific override is not supported.
+	#
+	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
+
+	# Enable text search, which will list the commits which match author,
+	# committer or commit text to a given string.  Enabled by default.
+	'search' => [1],
 
 	# Make gitweb use an alternative format of the URLs which can be
 	# more readable and natural-looking: project name is embedded
@@ -257,16 +262,8 @@ our %feature = (
 	# generates links.
 
 	# To enable system wide have in $GITWEB_CONFIG
-	# $feature{'pathinfo'}{'default'} = [1];
-	# Project specific override is not supported.
-
-	# Note that you will need to change the default location of CSS,
-	# favicon, logo and possibly other files to an absolute URL. Also,
-	# if gitweb.cgi serves as your indexfile, you will need to force
-	# $my_uri to contain the script name in your $GITWEB_CONFIG.
-	'pathinfo' => {
-		'override' => 0,
-		'default' => [0]},
+	# $global_feature{'pathinfo'} = [1];
+	'pathinfo' => [0],
 
 	# Make gitweb consider projects in project root subdirectories
 	# to be forks of existing projects. Given project $projname.git,
@@ -277,11 +274,8 @@ our %feature = (
 	# to be listed after the main project.
 
 	# To enable system wide have in $GITWEB_CONFIG
-	# $feature{'forks'}{'default'} = [1];
-	# Project specific override is not supported.
-	'forks' => {
-		'override' => 0,
-		'default' => [0]},
+	# $global_feature{'forks'} = [1];
+	'forks' => [0],
 
 	# Insert custom links to the action bar of all project pages.
 	# This enables you mainly to link to third-party scripts integrating
@@ -296,12 +290,9 @@ our %feature = (
 	# hash base (hb gitweb parameter); %% expands to %.
 
 	# To enable system wide have in $GITWEB_CONFIG e.g.
-	# $feature{'actions'}{'default'} = [('graphiclog',
+	# $global_feature{'actions'} = [('graphiclog',
 	# 	'/git-browser/by-commit.html?r=%n', 'summary')];
-	# Project specific override is not supported.
-	'actions' => {
-		'override' => 0,
-		'default' => []},
+	'actions' => [],
 
 	# Allow gitweb scan project content tags described in ctags/
 	# of project repository, and display the popular Web 2.0-ish
@@ -315,16 +306,20 @@ our %feature = (
 	# a pretty tag cloud instead of just a list of tags.
 
 	# To enable system wide have in $GITWEB_CONFIG
-	# $feature{'ctags'}{'default'} = ['path_to_tag_script'];
+	# $global_feature{'ctags'} = ['path_to_tag_script'];
 	# Project specific override is not supported.
-	'ctags' => {
-		'override' => 0,
-		'default' => [0]},
+	'ctags' => [0],
 );
 
 sub gitweb_check_feature {
-	my ($name) = @_;
+	my $name = shift;
+
+	if (exists $global_feature{$name}) {
+		return @{$global_feature{$name}};
+	}
+
 	return unless exists $feature{$name};
+
 	my ($sub, $override, @defaults) = (
 		$feature{$name}{'sub'},
 		$feature{$name}{'override'},

-- 
Stacked GIT 0.14.3
git version 1.6.0.2
--
To unsubscribe from this list: 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]

  Powered by Linux