Allow snippets to be really empty, without showing the Page Not Found screen.
This commit is contained in:
parent
508f7ed287
commit
d6400799aa
4 changed files with 33 additions and 18 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
- fixed: Have just 1 list of protected groups. Use that everywhere.
|
- fixed: Have just 1 list of protected groups. Use that everywhere.
|
||||||
- fixed #10488: Map.gif is missing for Map wobject
|
- fixed #10488: Map.gif is missing for Map wobject
|
||||||
- fixed #10553: WebGUI vulnerable to CSRF attacks
|
- fixed #10553: WebGUI vulnerable to CSRF attacks
|
||||||
|
- fixed #10607: snippets empty
|
||||||
|
|
||||||
7.7.13
|
7.7.13
|
||||||
- fixed #10574: Creating Calendar Entry
|
- fixed #10574: Creating Calendar Entry
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ sub view {
|
||||||
unless ($noCache) {
|
unless ($noCache) {
|
||||||
WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->set($output,$self->get("cacheTimeout"));
|
WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->set($output,$self->get("cacheTimeout"));
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -311,7 +311,11 @@ sub www_view {
|
||||||
my $mimeType=$self->getValue('mimeType');
|
my $mimeType=$self->getValue('mimeType');
|
||||||
$self->session->http->setMimeType($mimeType || 'text/html');
|
$self->session->http->setMimeType($mimeType || 'text/html');
|
||||||
$self->session->http->setCacheControl($self->get("cacheTimeout"));
|
$self->session->http->setCacheControl($self->get("cacheTimeout"));
|
||||||
return $self->view(1);
|
my $output = $self->view(1);
|
||||||
|
if (!defined $output) {
|
||||||
|
$output = 'empty';
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,18 @@ These subroutines are available from this package:
|
||||||
|
|
||||||
The Apache request handler for this package.
|
The Apache request handler for this package.
|
||||||
|
|
||||||
|
This handler takes care of certain special tokens returns by a sub-handler.
|
||||||
|
|
||||||
|
=head3 chunked
|
||||||
|
|
||||||
|
This indicates that the handler has already returned the output to Apache. Commonly
|
||||||
|
used in Assets to get head tags back to the user to speed up the rendering process.
|
||||||
|
|
||||||
|
=head3 empty
|
||||||
|
|
||||||
|
This token indicates that the asset is legitimatally empty. Returns nothing
|
||||||
|
to the user, instead of displaying the Page Not Found page.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub handler {
|
sub handler {
|
||||||
|
|
@ -71,6 +83,12 @@ sub handler {
|
||||||
}
|
}
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
if ($output eq "empty") {
|
||||||
|
if ($session->errorHandler->canShowDebug()) {
|
||||||
|
$session->output->print($session->errorHandler->showDebug(),1);
|
||||||
|
}
|
||||||
|
last;
|
||||||
|
}
|
||||||
elsif (defined $output && $output ne "") {
|
elsif (defined $output && $output ne "") {
|
||||||
$session->http->sendHeader;
|
$session->http->sendHeader;
|
||||||
$session->output->print($output);
|
$session->output->print($output);
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,14 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use Test::More tests => 15; # increment this value for each test you create
|
use Test::More tests => 16; # increment this value for each test you create
|
||||||
use WebGUI::Asset::Snippet;
|
use WebGUI::Asset::Snippet;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||||
$versionTag->set({name=>"Snippet Test"});
|
$versionTag->set({name=>"Snippet Test"});
|
||||||
|
WebGUI::Test->tagsToRollback($versionTag);
|
||||||
my $snippet = $node->addChild({className=>'WebGUI::Asset::Snippet'});
|
my $snippet = $node->addChild({className=>'WebGUI::Asset::Snippet'});
|
||||||
|
|
||||||
# Test for a sane object type
|
# Test for a sane object type
|
||||||
|
|
@ -77,24 +78,15 @@ $snippet->update({
|
||||||
snippet => q|^SQL(select value from settings where name="<tmpl_var title>");|
|
snippet => q|^SQL(select value from settings where name="<tmpl_var title>");|
|
||||||
});
|
});
|
||||||
|
|
||||||
my $sqlMacroAdded = exists $session->config->get('macros')->{'SQL'};
|
WebGUI::Test->originalConfig('macros');
|
||||||
if (! $sqlMacroAdded) {
|
$session->config->addToHash('macros', 'SQL', 'SQL');
|
||||||
$session->config->addToHash('macros', 'SQL', 'SQL');
|
|
||||||
}
|
|
||||||
|
|
||||||
is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in the correct order');
|
is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in the correct order');
|
||||||
|
|
||||||
if (! $sqlMacroAdded) {
|
my $empty = $node->addChild( { className => 'WebGUI::Asset::Snippet', } );
|
||||||
$session->config->deleteFromHash('macros', 'SQL');
|
is($empty->www_view, 'empty', 'www_view: snippet with no content returns "empty"');
|
||||||
}
|
|
||||||
|
|
||||||
TODO: {
|
TODO: {
|
||||||
local $TODO = "Tests to make later";
|
local $TODO = "Tests to make later";
|
||||||
ok(0, 'Test indexContent method');
|
ok(0, 'Test indexContent method');
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
|
||||||
# Clean up after thy self
|
|
||||||
$versionTag->rollback();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue