diff --git a/webtools/litmus/Litmus/Config.pm b/webtools/litmus/Litmus/Config.pm index c8e49c873b0..defbe5c6f1e 100755 --- a/webtools/litmus/Litmus/Config.pm +++ b/webtools/litmus/Litmus/Config.pm @@ -25,7 +25,8 @@ # Contributor(s): # Chris Cooper # Zach Lipton - # + # Max Kanat-Alexander + # FrŽdŽric Buclin # ***** END LICENSE BLOCK ***** =cut @@ -33,16 +34,38 @@ package Litmus::Config; use strict; +use File::Basename; -do 'localconfig'; +# based on bz_locations() from Bugzilla::Constants +our $datadir = "data/"; +sub litmus_locations { + # We know that Bugzilla/Constants.pm must be in %INC at this point. + # So the only question is, what's the name of the directory + # above it? This is the most reliable way to get our current working + # directory under both mod_cgi and mod_perl. We call dirname twice + # to get the name of the directory above the "Bugzilla/" directory. + # + # Calling dirname twice like that won't work on VMS or AmigaOS + # but I doubt anybody runs Bugzilla on those. + # + # On mod_cgi this will be a relative path. On mod_perl it will be an + # absolute path. + my $libpath = dirname(dirname($INC{'Litmus/Config.pm'})); + return { + libpath => $libpath, + datadir => "$libpath/$datadir", + localconfig => "$libpath/localconfig" + }; +} + +our $localconfig = litmus_locations()->{'localconfig'}; +do $localconfig; our $version = "0.9"; # if true, then Litmus will not accept any requests our $disabled = 0; -our $datadir = "data/"; - # Set/unset this to display inline debugging value/code. our $DEBUG = 0; diff --git a/webtools/litmus/Litmus/Template.pm b/webtools/litmus/Litmus/Template.pm index c2689e89234..820eefd8817 100755 --- a/webtools/litmus/Litmus/Template.pm +++ b/webtools/litmus/Litmus/Template.pm @@ -141,7 +141,7 @@ sub create { POST_CHOMP => 1, EVAL_PERL => 1, - COMPILE_DIR => $Litmus::Config::datadir, + COMPILE_DIR => Litmus::Config::litmus_locations()->{'datadir'}, FILTERS => { # disallow all html in testcase data except for non-evil tags