Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor improvements

Updated TODO
Enabled preloading
Added defaultPSGI to WebGUI::Paths
Added example of testing site via Plack::Test
  • Loading branch information...
commit 5c70ffb3e08998d2324add1c2ad8606a975274f9 1 parent f99f672
@patspam patspam authored
View
3  TODO
@@ -1,8 +1,9 @@
TODO
* Deprecate WebGUI::Session::HTTP - replace with WebGUI::Request/Response
* Investigate moving Cookie handling into middleware
-* Replace WebGUI::authen with something equivalent
+* Reinstate WebGUI::authen with something equivalent
* Refactor assets to use streaming response
+* Fix WebGUI::Form::param
DONE
* $session->request is now a Plack::Request object
View
7 app.psgi
@@ -1,16 +1,13 @@
use strict;
use Plack::Builder;
-use WebGUI::Paths -inc;
+use WebGUI::Paths -preload;
use WebGUI::Config;
-use File::Spec;
-
-my $standard_psgi = File::Spec->catfile(WebGUI::Paths->var, 'site.psgi');
builder {
my $first_app;
for my $config_file (WebGUI::Paths->siteConfigs) {
my $config = WebGUI::Config->new($config_file);
- my $psgi = $config->get('psgiFile') || $standard_psgi;
+ my $psgi = $config->get('psgiFile') || WebGUI::Paths->defaultPsgi;
my $app = do {
$ENV{WEBGUI_CONFIG} = $config_file;
Plack::Util::load_psgi($psgi);
View
1  lib/WebGUI/Paths.pm
@@ -107,6 +107,7 @@ BEGIN {
defaultUploads => catdir($root, 'www', 'uploads'),
defaultCreateSQL => catdir($root, 'docs', 'create.sql'),
var => catdir($root, 'var'),
+ defaultPSGI => catdir($root, 'var', 'site.psgi'),
);
my $meta = Class::MOP::Class->initialize(__PACKAGE__);
for my $sub (keys %paths) {
View
2  lib/WebGUI/Session/ErrorHandler.pm
@@ -207,7 +207,7 @@ sub new {
# Thanks to Plack, wG has been decoupled from Log4Perl
# However when called outside a web context, we currently still fall back to Log4perl
# (pending a better idea)
- Log::Log4perl->init_once( $session->config->getWebguiRoot . "/etc/log.conf" );
+ Log::Log4perl->init_once( WebGUI::Paths->logConfig );
my $log4perl = Log::Log4perl->get_logger( $session->config->getFilename );
$logger = sub {
my $args = shift;
View
5 lib/WebGUI/Session/Form.pm
@@ -78,10 +78,7 @@ Returns true if the param is part of the submitted form data, or a URL param.
sub hasParam {
my $self = shift;
my $param = shift;
- return undef unless $param;
- return undef unless $self->session->request;
- my $hashRef = $self->session->request->param();
- return exists $hashRef->{$param};
+ return $param && $self->session->request && exists $self->session->request->parameters->{$param};
}
View
23 t/PSGI/default-site.t
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+use Test::More tests => 4;
+
+use Plack::Test;
+use Plack::Util;
+use HTTP::Request::Common;
+use WebGUI::Paths;
+
+my $app = Plack::Util::load_psgi( WebGUI::Paths->defaultPSGI );
+
+test_psgi $app, sub {
+ my $cb = shift;
+
+ my $res = $cb->( GET "/" );
+ is $res->code, 200;
+ like $res->content, qr/My Company/;
+
+ $res = $cb->( GET "/?op=editSettings" );
+ is $res->code, 401;
+ like $res->content, qr/Administrative Function/;
+
+};
View
8 var/site.psgi
@@ -2,16 +2,8 @@ use strict;
use Plack::Builder;
use Plack::App::File;
use WebGUI;
-
-# Temporary preload hack
-use WebGUI::Paths -preload;
-use DBI;
-DBI->install_driver("mysql");
-# end hack
-
use WebGUI::Middleware::Debug::Performance;
-my $config = $ENV{WEBGUI_CONFIG};
builder {
my $wg = WebGUI->new( site => $ENV{WEBGUI_CONFIG} );
my $config = $wg->config;
Please sign in to comment.
Something went wrong with that request. Please try again.