Merge branch 'master' into WebGUI8, up to 7.9.10. Some tests failing due to changes in default content.

This commit is contained in:
Colin Kuskie 2010-07-27 22:55:57 -07:00
commit ca9a3bd6c7
34 changed files with 386 additions and 49 deletions

View file

@ -1,4 +1,13 @@
7.9.11
7.9.10
- fixed #11721: spamStopWords not in WebGUI.conf.original
- fixed #11729: Trash your User Function Style, and WebGUI locks you out
- fixed #11745: Pagination doesn't work in DataForm list mode
- fixed #11741: i18n Asset_Carousel ::carousel slideHeight description
- fixed #11742: linktag FilePump macro not xhtml valid
- fixed #11744: Default DataForm list template does not contain pagination
- fixed #11683: URL with UTF8 (for äÄöÖüÜß)
7.9.9
- fixed #11693: Shopping cart does not show for visitor user

Binary file not shown.

View file

@ -0,0 +1,123 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.9.11';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
print "\tUpgrading package $file\n" unless $quiet;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = eval {
my $node = WebGUI::Asset->getImportNode($session);
$node->importPackage( $storage, {
overwriteLatest => 1,
clearPackageFlag => 1,
setDefaultTemplate => 1,
} );
};
if ($package eq 'corrupt') {
die "Corrupt package found in $file. Stopping upgrade.\n";
}
if ($@ || !defined $package) {
die "Error during package import on $file: $@\nStopping upgrade\n.";
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -1088,13 +1088,18 @@
"Opera Mini"
],
#A list of UserAgents of recognized mobile platforms. If useMobileStyle is set in the
#Admin settings, then the mobile style will be used for these browsers.
# For the siteIndex content plugin. Whether or not the auto-generated siteIndex should
# show hidden pages
"siteIndex" : {
"showHiddenPages" : 0
},
#The complete path to the maintenance page.
"maintenancePage" : "/data/WebGUI/www/maintenance.html"
"maintenancePage" : "/data/WebGUI/www/maintenance.html",
# An array of SPAM words. Used in the Post and WikiPage to block spam by sending the asset directly
# to the trash.
"spamStopWords" : [
]
}

View file

@ -1127,7 +1127,7 @@ sub postProcess {
my %data = ();
($data{synopsis}, $data{content}) = $self->getSynopsisAndContent($self->synopsis, $self->content);
my $spamStopWords = $self->session->config->get('spamStopWords');
if (ref $spamStopWords eq 'ARRAY') {
if (ref $spamStopWords eq 'ARRAY' && @{ $spamStopWords }) {
my $spamRegex = join('|',@{$spamStopWords});
$spamRegex =~ s/\s/\\ /g;
if ($data{content} =~ m/$spamRegex/xmsi) {

View file

@ -139,6 +139,22 @@ These methods are available from this class:
#-------------------------------------------------------------------
=head2 cut ( )
Extend the base method to handle cutting the User Function Style template and destroying your site.
If the current template is the User Function Style template with the Fail Safe template.
=cut
around cut => sub {
my ( $orig, $self ) = @_;
my $returnValue = $self->$orig();
if ($returnValue && $self->getId eq $self->session->setting->get('userFunctionStyleId')) {
$self->session->setting->set('userFunctionStyleId', 'PBtmpl0000000000000060');
}
return $returnValue;
};
=head2 addRevision ( )
Override the master addRevision to copy attachments
@ -415,7 +431,7 @@ Override to import attachments from old versions of WebGUI
override importAssetCollateralData => sub {
my ( $self, $data, @args ) = @_;
if ( $data->{template_attachments} ) {
$self->update( { attachmentsJson => $data->{template_attachments} } );
$self->update( { attachmentsJson => JSON::to_json($data->{template_attachments}) } );
}
return super();
};
@ -617,6 +633,27 @@ sub processRaw {
#-------------------------------------------------------------------
=head2 purge ( )
Extend the base method to handle purging the User Function Style template and destroying your site.
If the current template is the User Function Style template with the Fail Safe template.
=cut
around purge => sub {
my $orig = shift;
my $self = shift;
my $session = $self->session;
my $assetId = $self->assetId;
my $returnValue = $self->$orig(@_);
if ($returnValue && $assetId eq $session->setting->get('userFunctionStyleId')) {
$session->setting->set('userFunctionStyleId', 'PBtmpl0000000000000060');
}
return $returnValue;
};
#-------------------------------------------------------------------
=head2 www_edit
Hand draw this form so that a warning can be displayed to the user when editing a

View file

@ -130,7 +130,7 @@ sub getAutoCommitWorkflowId {
# delete spam
my $spamStopWords = $self->session->config->get('spamStopWords');
if (ref $spamStopWords eq 'ARRAY') {
if (ref $spamStopWords eq 'ARRAY' && @{ $spamStopWords }) {
my $spamRegex = join('|',@{$spamStopWords});
$spamRegex =~ s/\s/\\ /g;
if ($self->content =~ m{$spamRegex}xmsi) {

View file

@ -725,7 +725,7 @@ sub getListTemplateVars {
} @{ $self->getFieldOrder };
$var->{field_loop} = \@fieldLoop;
my @recordLoop;
my $p = WebGUI::Paginator->new($session);
my $p = WebGUI::Paginator->new($session,$self->getUrl("mode=list"));
$p->setDataByCallback(sub { return $self->entryClass->iterateAll($self, { offset => $_[0], limit => $_[1], }); });
my $entryIter = $p->getPageIterator();
while ( my $entry = $entryIter->() ) {

View file

@ -95,6 +95,24 @@ property approvalWorkflowId => (
label => ['approval workflow', 'Asset_StoryArchive'],
hoverHelp => ['approval workflow help', 'Asset_StoryArchive'],
);
property storySortOrder => (
fieldType => "selectBox",
tab => 'display',
default => 'Chronologically',
options => \&_storySortOrder_options,
label => ['sortAlphabeticallyChronologically', 'Asset_StoryArchive'],
hoverHelp => ['sortAlphabeticallyChronologically description', 'Asset_StoryArchive'],
);
sub _storySortOrder_options {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, 'Asset_StoryArchive');
return {
Alphabetically => $i18n->get('alphabetically'),
Chronologically => $i18n->get('chronologically'),
};
}
with 'WebGUI::Role::Asset::RssFeed';
use WebGUI::International;
@ -506,11 +524,12 @@ sub viewTemplateVariables {
$p = $search->getPaginatorResultSet($self->getUrl, $self->get('storiesPerPage'));
}
else {
$var->{mode} = 'view';
##Only return assetIds, we'll build data for the things that are actually displayed.
$var->{mode} = 'view';
my $orderBy = $self->get('storySortOrder') eq 'Alphabetically' ? 'menuTitle, lineage' : 'creationDate desc, lineage';
my $storySql = $self->getLineageSql(['descendants'],{
excludeClasses => ['WebGUI::Asset::Wobject::Folder'],
orderByClause => 'creationDate desc, lineage',
orderByClause => $orderBy,
});
my $storiesPerPage = $self->storiesPerPage;
if ($exporting) {
@ -520,6 +539,7 @@ sub viewTemplateVariables {
$p = WebGUI::Paginator->new($session, $self->getUrl, $storiesPerPage);
$p->setDataByQuery($storySql);
}
my $storyIds = $p->getPageData();
if (! $exporting ) {
##Pagination variables aren't useful in export mode

View file

@ -342,8 +342,10 @@ sub getFirstChild {
my $lineage = $assetLineage->{firstChild}{$self->getId};
unless ($lineage) {
($lineage) = $self->session->db->quickArray("select min(asset.lineage) from asset where asset.parentId=? and asset.state='published'",[$self->getId]);
$assetLineage->{firstChild}{$self->getId} = $lineage;
$self->session->stow->set("assetLineage", $assetLineage);
if ($lineage) {
$assetLineage->{firstChild}{$self->getId} = $lineage;
$self->session->stow->set("assetLineage", $assetLineage);
}
}
$child = eval { WebGUI::Asset->newByLineage($self->session,$lineage); };
$self->cacheChild(first => $child);

View file

@ -261,15 +261,25 @@ sub importPackage {
my $decompressed = $storage->untar($storage->getFiles->[0]);
return undef
if $storage->getErrorCount;
my %assets = (); # All the assets we've imported
my $package = undef; # The asset package
my $error = $self->session->errorHandler;
# The debug output for long requests would be too long, and we'd have to
# keep it all in memory.
$error->preventDebugOutput();
$error->info("Importing package.");
# Your parent is on this stack somewhere because we're going through these
# assets depth-first. This way we only have to keep one branch in-memory
# at a time, and it's always the right branch.
my @stack;
my $json = JSON->new->utf8->relaxed(1);
foreach my $file (sort(@{$decompressed->getFiles})) {
next unless ($decompressed->getFileExtension($file) eq "json");
$error->info("Found data file $file");
my $data = eval {
JSON->new->utf8->relaxed(1)->decode($decompressed->getFileContentsAsScalar($file))
$json->decode($decompressed->getFileContentsAsScalar($file))
};
if ($@ || $data->{properties}{assetId} eq "" || $data->{properties}{className} eq "" || $data->{properties}{revisionDate} eq "") {
$error->error("package corruption: ".$@) if ($@);
@ -280,20 +290,27 @@ sub importPackage {
my $assetStorage = WebGUI::Storage->get($self->session, $storageId);
$decompressed->untar($storageId.".storage", $assetStorage);
}
my $asset = $assets{$data->{properties}{parentId}} || $self;
my $parentId = $data->{properties}->{parentId};
my $asset;
while ($asset = pop(@stack)) {
if ($asset->getId eq $parentId) {
push(@stack, $asset);
last;
}
}
$asset ||= $self;
my $newAsset = $asset->importAssetData($data, $options);
$newAsset->importAssetCollateralData($data);
$assets{$newAsset->getId} = $newAsset;
# First imported asset must be the "package"
unless ($package) {
$package = $newAsset;
}
push(@stack, $newAsset);
# First imported asset must be the "package"
$package ||= $newAsset;
}
return $package
if $package;
return 'corrupt';
return $package || 'corrupt';
}
#-------------------------------------------------------------------

View file

@ -195,7 +195,7 @@ on your print CSS tag.
sub linkTag {
my ($session, $url, $extras) = @_;
my $template = qq|<link rel="stylesheet" type="text/css" href="%s" $extras>\n|;
my $template = qq|<link rel="stylesheet" type="text/css" href="%s" $extras />\n|;
return sprintf $template, $url;
}

View file

@ -22,6 +22,7 @@ use Scalar::Util qw( weaken );
use WebGUI::International;
use WebGUI::Utility;
use Scalar::Util qw(weaken);
use Encode;
=head1 NAME
@ -326,7 +327,7 @@ sub getRequestedUrl {
my $self = shift;
return undef unless ($self->session->request);
unless ($self->{_requestedUrl}) {
$self->{_requestedUrl} = $self->session->request->path_info; # TODO - is path_info right?
$self->{_requestedUrl} = decode_utf8($self->session->request->path_info); # TODO - is path_info right?
my $gateway = $self->session->config->get("gateway");
$self->{_requestedUrl} =~ s/^$gateway([^?]*)\??.*$/$1/;
}

View file

@ -40,8 +40,8 @@ our $I18N = {
},
'carousel slideHeight description' => {
message => q|Height in pixels. The Carousel will not automatically resize itself for content of various widths. Setting this width will help it render properly. If left with the default, 0, then the width of the Carousel is set by the width of the first element.|,
lastUpdated => 0,
message => q|Height in pixels. The Carousel will not automatically resize itself for content of various heights. Setting this height will help it render properly. If left with the default, 0, then the height of the Carousel is set by the height of the first element.|,
lastUpdated => 1280253825,
context => q|Description of the carousel template field, used as hover help.|
},

View file

@ -333,6 +333,30 @@ our $I18N = {
lastUpdated => 0,
},
'sortAlphabeticallyChronologically' => {
message => q|Sort Order|,
context => q|Label in the edit screen|,
lastUpdated => 1276631190,
},
'sortAlphabeticallyChronologically description' => {
message => q|Set messages to appear in order of publish date or alphabetically by title|,
context => q|Tooltip in the edit screen|,
lastUpdated => 1276631190,
},
'alphabetically' => {
message => q|Alphabetically|,
context => q|Select option in the edit screen|,
lastUpdated => 1276631190,
},
'chronologically' => {
message => q|Chronologically|,
context => q|Select option in the edit screen|,
lastUpdated => 1276631190,
},
};
1;

File diff suppressed because one or more lines are too long

View file

@ -16,7 +16,7 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Asset::Template;
use Exception::Class;
use Test::More tests => 42; # increment this value for each test you create
use Test::More tests => 46; # increment this value for each test you create
use Test::Deep;
use Data::Dumper;
use JSON qw{ from_json };
@ -179,3 +179,35 @@ WebGUI::Test->interceptLogging( sub {
WebGUI::Test->addToCleanup(WebGUI::VersionTag->getWorking($session));
my $userStyleTemplate = $importNode->addChild({
className => "WebGUI::Asset::Template",
title => "user function style",
url => "ufs",
template => "user function style",
namespace => 'WebGUI Test Template',
});
my $someOtherTemplate = $importNode->addChild({
className => "WebGUI::Asset::Template",
title => "some other template",
url => "sot",
template => "some other template",
namespace => 'WebGUI Test Template',
});
$session->setting->set('userFunctionStyleId', $userStyleTemplate->getId);
my $purgeCutTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($purgeCutTag);
is($session->setting->get('userFunctionStyleId'), $userStyleTemplate->getId, 'Setup for cut tests.');
$userStyleTemplate->cut;
is($session->setting->get('userFunctionStyleId'), 'PBtmpl0000000000000060', 'cut resets the user function style template to Fail Safe');
$userStyleTemplate->publish;
$session->setting->set('userFunctionStyleId', $userStyleTemplate->getId);
is($session->setting->get('userFunctionStyleId'), $userStyleTemplate->getId, 'Reset for purge test');
$userStyleTemplate->purge;
is($session->setting->get('userFunctionStyleId'), 'PBtmpl0000000000000060', 'purge resets the user function style template to Fail Safe');

View file

@ -670,6 +670,68 @@ is($archive->getKeywordStaticURL('bar'), '/home/mystories/keyword_bar.html', '..
$archive->update({ url => '/home/mystories' });
################################################################
#
# sortOrder
#
################################################################
my $aaa_child = $archive->addChild({className => 'WebGUI::Asset::Story', title => 'Aaaa'}, @skipAutoCommit);
my $zzz_child = $archive->addChild({className => 'WebGUI::Asset::Story', title => 'Zzzz'}, @skipAutoCommit);
WebGUI::Test->addToCleanup($aaa_child);
WebGUI::Test->addToCleanup($zzz_child);
$archive->update({storiesPerPage => 25, storySortOrder => 'Alphabetically' });
$tag1 = WebGUI::VersionTag->getWorking($session);
$tag1->commit;
WebGUI::Test->addToCleanup($tag1);
$templateVars = $archive->viewTemplateVariables();
cmp_deeply (
$templateVars->{date_loop},
[
{
'story_loop' => [
{
'creationDate' => ignore(),
'deleteIcon' => ignore(),
'editIcon' => ignore(),
'url' => re('aaaa'),
'title' => 'Aaaa'
},
ignore(),
ignore(),
ignore(),
ignore(),
],
'epochDate' => ignore(),
},
{
'story_loop' => ignore(),
'epochDate' => $wgBdayMorn,
},
{
'story_loop' => ignore(),
'epochDate' => $yesterdayMorn,
},
{
'story_loop' => [
{
'creationDate' => ignore(),
'deleteIcon' => ignore(),
'editIcon' => ignore(),
'url' => re('zzzz'),
'title' => 'Zzzz'
},
],
'epochDate' => ignore(),
},
],
'viewTemplateVariables: sorted by story title'
);
$creationDateSth->finish;
done_testing();

View file

@ -35,7 +35,7 @@ my $xmlData = XMLin($output,
ForceArray => ['url'],
);
my @actual_urls = map { $_->{loc} } @{ $xmlData->{urlset}->{url} };
my @expected_urls = map { $session->url->getSiteURL . '/' . $_ } qw{ home getting_started your_next_step the_latest_news tell_a_friend documentation site_map };
my @expected_urls = map { $session->url->getSiteURL . '/' . $_ } qw{ home getting_started your_next_step documentation join_us site_map };
cmp_deeply(
\@actual_urls,
\@expected_urls,
@ -73,7 +73,7 @@ $xmlData = XMLin($output,
ForceArray => ['url'],
);
@actual_urls = map { $_->{loc} } @{ $xmlData->{urlset}->{url} };
@expected_urls = map { $session->url->getSiteURL . '/' . $_ } qw{ home getting_started your_next_step the_latest_news tell_a_friend documentation site_map hidden_page };
@expected_urls = map { $session->url->getSiteURL . '/' . $_ } qw{ home getting_started your_next_step documentation join_us site_map hidden_page };
cmp_deeply(
\@actual_urls,
\@expected_urls,

View file

@ -83,7 +83,7 @@ is(
);
is(
WebGUI::Macro::FilePump::process($session, 'test bundle', 'CSS'),
sprintf(qq|<link rel="stylesheet" type="text/css" href="%s" >\n|,
sprintf(qq|<link rel="stylesheet" type="text/css" href="%s" />\n|,
join('/', $uploadsURL, 'filepump', $bundle->bundleUrl . '.'. $bundle->get('lastBuild'), $bundle->bundleUrl.'.css'),
),
'... check CSS file, normal mode'
@ -104,7 +104,7 @@ is(
);
is(
WebGUI::Macro::FilePump::process($session, 'test bundle', 'CSS'),
sprintf(qq|<link rel="stylesheet" type="text/css" href="/filePumpFileAsset" >\n|, $fileAsset->getUrl),
sprintf(qq|<link rel="stylesheet" type="text/css" href="/filePumpFileAsset" />\n|, $fileAsset->getUrl),
'... check CSS file, normal mode'
);
is(

View file

@ -50,7 +50,7 @@ my @getRefererUrlTests = (
);
use Test::More;
plan tests => 83 + scalar(@getRefererUrlTests);
plan tests => 84 + scalar(@getRefererUrlTests);
my $session = WebGUI::Test->session;
my $request = $session->request;
@ -217,6 +217,13 @@ $session->url->{_requestedUrl} = undef; ##Manually clear cached value
$setUri->('/path2/file2?param1=one;param2=two');
is($session->url->getRequestedUrl, 'path2/file2', 'getRequestedUrl, does not return params');
$session->url->{_requestedUrl} = undef;
my $utf8_url = "Viel Spa\x{00DF}";
$setUri->($utf8_url);
use Encode;
my $decoded_url = decode_utf8($utf8_url);
is $session->url->getRequestedUrl(), $decoded_url, 'getRequestedUrl returns utf8 decoded data';
#######################################
#
# page

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB