From ebdf0c28a3a6ee645bf9af333bf2234e808c3434 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 25 Apr 2011 15:01:38 -0500 Subject: [PATCH] add collaboration to test_content and fix bugs --- lib/WebGUI/Asset/Post.pm | 6 +- lib/WebGUI/Command/test_content.pm | 130 ++++++++++++++++++++++++++--- 2 files changed, 123 insertions(+), 13 deletions(-) diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index 2b7474b21..09ffddece 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -1608,7 +1608,7 @@ sub www_edit { $var{'user.isVisitor' } = ($user->isVisitor); $var{'visitorName.form'} = WebGUI::Form::text($session, { name => "visitorName", - value => $form->process('visitorName') || $self->visitorName + value => $form->process('visitorName') || $self->username }); for my $x (1..5) { @@ -1693,9 +1693,9 @@ sub www_edit { $var{'karmaScale.form'} = WebGUI::Form::integer($session, { name=>"karmaScale", defaultValue=>$self->getThread->getParent->defaultKarmaScale, - value=>$self->karmaScale, + value=>$self->getThread->karmaScale, }); - $var{karmaIsEnabled} = $session->setting->useKarma; + $var{karmaIsEnabled} = $session->setting->get('useKarma'); $var{'form.preview'} = WebGUI::Form::submit($session, { value=>$i18n->get("preview","Asset_Collaboration") }); diff --git a/lib/WebGUI/Command/test_content.pm b/lib/WebGUI/Command/test_content.pm index d88d7655d..1aae2466f 100644 --- a/lib/WebGUI/Command/test_content.pm +++ b/lib/WebGUI/Command/test_content.pm @@ -133,11 +133,12 @@ Build one asset on the page, recursing into any _children. =cut sub buildAsset { - my ( $self, $class, $page, $props ) = @_; + my ( $self, $class, $page, $rawprops ) = @_; my $session = $self->{_session}; - my $files = delete $props->{_files} || []; - my $children = delete $props->{_children} || []; + my $files = $rawprops->{_files} || []; + my $children = $rawprops->{_children} || []; + my $props = { map { $_ => $rawprops->{$_} } grep { !/^_/ } keys %$rawprops }; my $asset = $page->addChild({ className => $class, @@ -229,6 +230,7 @@ my $DT_NOW = DateTime->now; 'WebGUI::Asset::Wobject::Calendar' => [ { title => 'Calendar', + description => lorem(0,1,2), isHidden => 1, displayTitle => 1, _children => [ @@ -262,6 +264,7 @@ my $DT_NOW = DateTime->now; 'WebGUI::Asset::Wobject::DataForm' => [ { title => 'Data Form', + description => lorem(0,1,2), isHidden => 1, defaultView => 0, useCaptcha => 1, @@ -348,6 +351,7 @@ my $DT_NOW = DateTime->now; 'WebGUI::Asset::Wobject::DataTable' => [ { title => 'DataTable (YUI)', + description => lorem(0,1,2), isHidden => 1, templateId => '3rjnBVJRO6ZSkxlFkYh_ug', data => JSON->new->encode( { @@ -387,6 +391,7 @@ my $DT_NOW = DateTime->now; 'WebGUI::Asset::Wobject::Map' => [ { title => 'Map', + description => lorem(0,1,2), mapApiKey => 'ABQIAAAAxadBCYjK6rRsw7rJkBgiEBT7g5bZECU_gqoByQmzcFSTeCxKshSKEU-GQYssxXNgQ1qkA3XtjOGYog', # Key only works for "localhost:5000" startLatitude => '43.068888', @@ -398,21 +403,21 @@ my $DT_NOW = DateTime->now; title => 'Lake Poygan', latitude => '44.166445', longitude => '-88.791504', - description => 'I have never heard of this place before', + description => lorem(0), }, { className => 'WebGUI::Asset::MapPoint', title => 'Chicago', latitude => '41.885921', longitude => '-87.670898', - description => 'Best pizza in the world', + description => lorem(1), }, { className => 'WebGUI::Asset::MapPoint', title => 'Dubuque', latitude => '42.569264', longitude => '-90.725098', - description => 'At the corner of three states', + description => lorem(2), }, ], }, @@ -425,6 +430,7 @@ my $DT_NOW = DateTime->now; title => 'Search', isHidden => 1, searchRoot => 'PBasset000000000000001', + description => lorem(0,1,2), }, ], 'WebGUI::Asset::Snippet' => [ @@ -435,7 +441,111 @@ my $DT_NOW = DateTime->now; }, ], 'WebGUI::Asset::Wobject::Collaboration' => [ - + { + title => 'Collaboration (Forum)', + isHidden => 1, + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000026', + _children => [ + { + className => 'WebGUI::Asset::Post::Thread', + title => 'Thread', + content => lorem(0,1,2), + synopsis => lorem(0), + _children => [ + { + className => 'WebGUI::Asset::Post', + title => "Post", + content => lorem(3,4,5), + }, + ], + }, + ], + }, + { + title => 'Collaboration (FAQ)', + postFormTemplateId => 'PBtmpl0000000000000099', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000080', + _children => [ + { + className => 'WebGUI::Asset::Post::Thread', + title => "Question 1?", + content => '

Answer!

' . lorem(0), + }, + { + className => 'WebGUI::Asset::Post::Thread', + title => "Question 2?", + content => '

Answer!

' . lorem(1), + }, + { + className => 'WebGUI::Asset::Post::Thread', + title => "Question 3?", + content => '

Answer!

' . lorem(2), + }, + ], + }, + { + title => 'Collaboration (Job)', + postFormTemplateId => 'PBtmpl0000000000000122', + threadTemplateId => 'PBtmpl0000000000000098', + collaborationTemplateId => 'PBtmpl0000000000000077', + }, + { + title => 'Collaboration (Link List)', + postFormTemplateId => 'PBtmpl0000000000000114', + threadTemplateId => 'PBtmpl0000000000000113', + collaborationTemplateId => 'PBtmpl0000000000000083', + }, + { + title => 'Collaboration (Request Tracker)', + postFormTemplateId => 'PBtmpl0000000000000210', + threadTemplateId => 'PBtmpl0000000000000209', + collaborationTemplateId => 'PBtmpl0000000000000208', + }, + { + title => 'Collaboration (Blog)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000112', + }, + { + title => 'Collaboration (Classifieds)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000128', + }, + { + title => 'Collaboration (Guest Book)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000133', + }, + { + title => 'Collaboration (Ordered List)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000101', + }, + { + title => 'Collaboration (Photo Gallery)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000121', + }, + { + title => 'Collaboration (Topics)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000079', + }, + { + title => 'Collaboration (Traditional with Thumbnails)', + postFormTemplateId => 'PBtmpl0000000000000029', + threadTemplateId => 'PBtmpl0000000000000032', + collaborationTemplateId => 'PBtmpl0000000000000097', + }, ], 'WebGUI::Asset::Wobject::Gallery' => [ @@ -528,16 +638,16 @@ to pull from __DATA__ our @LOREM; sub lorem { - my ( $self, @indexes ) = @_; + my ( @indexes ) = @_; return join "", map { "

$_

" } split "\n\n", lorem_text( @indexes ); } sub lorem_text { - my ( $self, @indexes ) = @_; + my ( @indexes ) = @_; if ( !@LOREM ) { @LOREM = ; } - if ( !@indexes ) { + if ( scalar @indexes == 0 ) { @indexes = ( 0..3 ); } return join "\n\n", @LOREM[ @indexes ];