add Gallery to test_content and fix problems with RssFeed role

This commit is contained in:
Doug Bell 2011-04-25 15:53:55 -05:00
parent ebdf0c28a3
commit bdb803915e
5 changed files with 109 additions and 30 deletions

View file

@ -329,6 +329,7 @@ use WebGUI::International;
use WebGUI::Search;
use XML::Simple;
use WebGUI::HTML;
use WebGUI::Asset::Wobject::GalleryAlbum;
=head1 NAME
@ -950,9 +951,9 @@ See WebGUI::Asset::prepareView() for details.
=cut
sub prepareView {
my $self = shift;
$self->next::method();
around prepareView => sub {
my ( $orig, $self, @args ) = @_;
$self->$orig( @args );
if ( $self->viewDefault eq "album" && $self->viewAlbumAssetId && $self->viewAlbumAssetId ne 'PBasset000000000000001') {
my $asset
@ -968,7 +969,7 @@ sub prepareView {
else {
$self->prepareViewListAlbums;
}
}
};
#----------------------------------------------------------------------------
@ -1058,7 +1059,7 @@ instead of having to block things from being added.
=cut
sub www_add {
override www_add => sub {
my $self = shift;
unless ( $self->hasBeenCommitted ) {
@ -1066,8 +1067,8 @@ sub www_add {
return $self->processStyle($i18n->get("error add uncommitted"));
}
return $self->next::method( @_ );
}
return super();
};
#----------------------------------------------------------------------------

View file

@ -387,7 +387,7 @@ are authorized to see them.
=cut
sub getCurrentRevisionDate {
override getCurrentRevisionDate => sub {
my $class = shift;
my $session = shift;
my $assetId = shift;
@ -410,9 +410,9 @@ sub getCurrentRevisionDate {
return $revisionDate;
}
else {
return $class->next::method( $session, $assetId );
return super();
}
}
};
#----------------------------------------------------------------------------
@ -721,9 +721,9 @@ See WebGUI::Asset::prepareView() for details.
=cut
sub prepareView {
my $self = shift;
$self->next::method();
around prepareView => sub {
my ($orig, $self, @args) = @_;;
$self->$orig(@args);
my $templateId = $self->getParent->templateIdViewAlbum;
@ -740,7 +740,7 @@ sub prepareView {
$self->{_viewTemplate} = $template;
$self->{_viewVariables} = $self->getTemplateVars;
}
};
#----------------------------------------------------------------------------

View file

@ -70,19 +70,11 @@ sub run {
my $page = $categories{ $cat }->addChild({
className => $LAYOUT_CLASS,
styleTemplateId => $style->getId,
title => $sets[0]->{title},
});
$page->indexContent;
my $asset = $self->buildAsset( $class, $page, $sets[0] );
$page->title( $asset->getName );
$page->menuTitle( $asset->getName );
# Fix the URLs to take the new titles
$page->url( '' );
$page->write;
$page->indexContent;
$asset->url( '' );
$asset->write;
$asset->indexContent;
# Make subpages for the other ones
for my $set ( @sets[1..$#sets] ) {
@ -91,6 +83,7 @@ sub run {
%{ $set },
};
my $subpage = $page->addChild({
url => $asset->url . '/' . $set->{title},
className => $LAYOUT_CLASS,
title => $set->{title},
styleTemplateId => $style->getId,
@ -149,11 +142,13 @@ sub buildAsset {
my %storage = ();
for my $file ( @$files ) {
my $storage;
next unless -f $file->{file};
if ( !($storage = $storage{ $file->{property} }) ) {
$storage = $storage{ $file->{property} } = WebGUI::Storage->create( $session );
$asset->update({ $file->{property} => $storage->getId });
}
$storage->addFileFromFilesystem( $file->{file} );
my $filename = $storage->addFileFromFilesystem( $file->{file} );
$storage->generateThumbnail( $filename );
}
# Add children
@ -458,10 +453,22 @@ my $DT_NOW = DateTime->now;
className => 'WebGUI::Asset::Post',
title => "Post",
content => lorem(3,4,5),
_files => [
{
property => 'storageId',
file => catfile( WebGUI::Paths->extras, 'plainblack.gif' ),
},
],
},
],
},
],
_files => [
{
property => 'storageId',
file => catfile( WebGUI::Paths->extras, 'wg.png' ),
},
],
},
{
title => 'Collaboration (FAQ)',
@ -478,6 +485,12 @@ my $DT_NOW = DateTime->now;
className => 'WebGUI::Asset::Post::Thread',
title => "Question 2?",
content => '<p>Answer!</p>' . lorem(1),
_files => [
{
property => 'storageId',
file => catfile( WebGUI::Paths->extras, 'plainblack.gif' ),
},
],
},
{
className => 'WebGUI::Asset::Post::Thread',
@ -548,7 +561,69 @@ my $DT_NOW = DateTime->now;
},
],
'WebGUI::Asset::Wobject::Gallery' => [
{
title => 'Gallery',
isHidden => 1,
_children => [
{
className => 'WebGUI::Asset::Wobject::GalleryAlbum',
title => 'Album 1',
_children => [
{
className => 'WebGUI::Asset::File::GalleryFile::Photo',
title => 'WebGUI Logo',
filename => 'wg.png',
_files => [
{
property => 'storageId',
file => catfile( WebGUI::Paths->extras, 'wg.png' ),
},
],
},
{
className => 'WebGUI::Asset::File::GalleryFile::Photo',
title => 'Plainblack logo',
filename => 'plainblack.gif',
_files => [
{
property => 'storageId',
file => catfile( WebGUI::Paths->extras, 'plainblack.gif' ),
},
],
},
],
},
{
className => 'WebGUI::Asset::Wobject::GalleryAlbum',
title => 'Icons',
_children => [
map { {
className => 'WebGUI::Asset::File::GalleryFile::Photo',
title => ucfirst $_,
filename => $_,
_files => [
{
property => 'storageId',
file => catfile( WebGUI::Paths->extras, 'icon', $_ ),
},
],
} } qw(
application.png keyboard.png layers.png layout.png anchor.png lightbulb.png
lightning.png link.png maginifier.png map.png attach.png money.png basket.png
monitor.png mouse.png bell.png bin.png bomb.png book.png note.png new.png music.png
page.png brick.png briefcase.png bug.png building.png cake.png calculator.png
calendar.png car.png camera.png cart.png cd.png pencil.png phone.png chart_bar.png
photo.png picture.png clock.png printer.png rainbow.png report.png plugin.png
cog.png coins.png comment.png resultset_first.png resultset_next.png
contrast.png script.png controller.png server.png cross.png css.png shading.png
shield.png date.png database.png sound.png disk.png door.png star.png stop.png
dvd.png email.png table.png error.png feed.png television.png folder.png font.png
group.png user.png world.png xhtml.png image.png key.png zoom.png wrench.png
)
],
},
],
}
],
'WebGUI::Asset::Wobject::MessageBoard' => [

View file

@ -79,6 +79,9 @@ sub dispatch {
$fragment =~ s/$url//;
$session->asset($asset);
my $output = eval { $asset->dispatch($fragment); };
if ( $@ ) {
$session->log->error( "Problem with dispatching $url: " . $@ );
}
return $output if defined $output;
}
}

View file

@ -129,8 +129,8 @@ Extent the base method in Asset.pm to handle RSS feeds.
=cut
sub dispatch {
my ( $self, $fragment ) = @_;
around dispatch => sub {
my ( $orig, $self, $fragment ) = @_;
if ($fragment eq '.rss') {
return $self->www_viewRss;
}
@ -140,8 +140,8 @@ sub dispatch {
elsif ($fragment eq '.rdf') {
return $self->www_viewRdf;
}
return $self->next::method($fragment);
}
return $self->$orig($fragment);
};
#-------------------------------------------------------------------