Skip to content

Commit

Permalink
Item14152: Merge commit '3e701d4fe490defa2e527623e379c8eb01d1620d' in…
Browse files Browse the repository at this point in the history
…to Item14152

* commit '3e701d4fe490defa2e527623e379c8eb01d1620d':
  Item13897: One more iteration to pre-detect correct paths.
  Item13897: Removed forgotten `extensible' feature.
  Item14152: Cherry picked of some changes from commit 505aef1
  Item14152: (cherry picked from commit 5bb22fa)
  • Loading branch information
vrurg committed Sep 19, 2016
2 parents 8151e0d + 3e701d4 commit 82bcacf
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 29 deletions.
42 changes: 28 additions & 14 deletions core/bin/foswiki.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,49 @@ use v5.14;
use Cwd;
use File::Spec;

my $root;
my ( $rootDir, $scriptDir );

BEGIN {
$root = $ENV{FOSWIKI_HOME};
if ( !$root ) {

# Try to guess our root dir by looking into %INC
my $incKey = ( grep { /\/foswiki.*\.psgi$/ } keys %INC )[0];
my $scriptFile = $INC{$incKey};
my ( $volume, $scriptDir ) = File::Spec->splitpath($scriptFile);
$root =
File::Spec->catpath( $volume,
File::Spec->catdir( $scriptDir, File::Spec->updir ), "" );
$rootDir = $ENV{FOSWIKI_HOME};
$scriptDir = $ENV{FOSWIKI_SCRIPTS};

unless ($scriptDir) {
my $script = __FILE__;

# Try to guess our root dir by looking into %INC if __FILE__ isn't
# there.
$script = ( grep { /\/foswiki.*\.psgi$/ } keys %INC )[0]
if defined $INC{$script};

# If scipt is executed directly it won't be found in %INC. Use the
# guessed script name then.
my $scrFileName = $INC{$script} || $script;
my ( $volume, $sdir ) = File::Spec->splitpath($scrFileName);
$scriptDir = File::Spec->catpath( $volume, $sdir, "" );
}

push @INC, File::Spec->catdir( $root, "lib" );
unless ($rootDir) {
$rootDir = File::Spec->catdir( $scriptDir, File::Spec->updir );
}

push @INC, File::Spec->catdir( $rootDir, "lib" );
}

use Plack::Builder;
use Foswiki::App;

my $app = sub {
return Foswiki::App->run( env => shift, );
my $env = shift;

$env->{FOSWIKI_SCRIPTS} = $scriptDir unless $env->{FOSWIKI_SCRIPTS};

return Foswiki::App->run( env => $env, );
};

builder {
enable 'Plack::Middleware::Static',
path => qr/^\/pub\//,
root => $root;
root => $rootDir;
$app;
}
__END__
Expand Down
40 changes: 26 additions & 14 deletions core/bin/foswiki_debug.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@ use Cwd;
use File::Spec;
use Data::Dumper;

my $root;
my ( $rootDir, $scriptDir );

BEGIN {
$root = $ENV{FOSWIKI_HOME};
if ( !$root ) {

# Try to guess our root dir by looking into %INC
my $incKey = ( grep { /\/foswiki.*\.psgi$/ } keys %INC )[0];
my $scriptFile = $INC{$incKey};
my ( $volume, $scriptDir ) = File::Spec->splitpath($scriptFile);
$root =
File::Spec->catpath( $volume,
File::Spec->catdir( $scriptDir, File::Spec->updir ), "" );
$rootDir = $ENV{FOSWIKI_HOME};
$scriptDir = $ENV{FOSWIKI_SCRIPTS};

unless ($scriptDir) {
my $script = __FILE__;

# Try to guess our root dir by looking into %INC if __FILE__ isn't
# there.
$script = ( grep { /\/foswiki.*\.psgi$/ } keys %INC )[0]
if defined $INC{$script};

# If scipt is executed directly it won't be found in %INC. Use the
# guessed script name then.
my $scrFileName = $INC{$script} || $script;
my ( $volume, $sdir ) = File::Spec->splitpath($scrFileName);
$scriptDir = File::Spec->catpath( $volume, $sdir, "" );
}

push @INC, File::Spec->catdir( $root, "lib" );
unless ($rootDir) {
$rootDir = File::Spec->catdir( $scriptDir, File::Spec->updir );
}

push @INC, File::Spec->catdir( $rootDir, "lib" );
}
use Plack::Builder;
use Foswiki::App;
Expand All @@ -42,6 +52,8 @@ my $app = sub {
my $env = shift;

Devel::Leak::Object::checkpoint if CHECKLEAK;

$env->{FOSWIKI_SCRIPTS} = $scriptDir unless $env->{FOSWIKI_SCRIPTS};

my $rc = Foswiki::App->run( env => $env, );

Expand All @@ -50,7 +62,7 @@ my $app = sub {
eval {
require Devel::MAT::Dumper;
Devel::MAT::Dumper::dump(
$root . "/working/logs/foswiki_debug_psgi.pmat" );
$rootDir . "/working/logs/foswiki_debug_psgi.pmat" );
};
}

Expand All @@ -60,7 +72,7 @@ my $app = sub {
builder {
enable 'Plack::Middleware::Static',
path => qr/^\/pub\//,
root => $root;
root => $rootDir;
$app;
};
__END__
Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/Class.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ sub import {
require feature;
feature->import($featureSet);

require namespace::clean;
namespace::clean->import(
-cleanee => $target,
-except => \@noNsClean,
Expand Down

0 comments on commit 82bcacf

Please sign in to comment.