Static export for the topic is done.

This commit is contained in:
Colin Kuskie 2009-04-16 17:09:48 +00:00
parent 905537e9e5
commit fbbd63eaa5
2 changed files with 50 additions and 4 deletions

View file

@ -83,6 +83,22 @@ sub definition {
return $class->SUPER::definition($session, $definition); return $class->SUPER::definition($session, $definition);
} }
#-------------------------------------------------------------------
=head2 exportHtml_view ( )
Extend the base method to change how stories are linked to.
Sets an internal flag to indicate that it is exporting to signal viewTemplateVars
to make those changes.
=cut
sub exportHtml_view {
my $self = shift;
$self->{_exportMode} = 1;
return $self->next::method(@_);
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -150,7 +166,9 @@ sub viewTemplateVariables {
my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate}); my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate});
next STORY unless $story; next STORY unless $story;
push @{$var->{story_loop}}, { push @{$var->{story_loop}}, {
url => $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}), url => ( $self->{_exportMode}
? $story->getUrl
: $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}) ),
title => $story->getTitle, title => $story->getTitle,
creationDate => $story->get('creationDate'), creationDate => $story->get('creationDate'),
} }

View file

@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
my $tests = 14; my $tests = 15;
plan tests => 1 + $tests; plan tests => 1 + $tests;
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -84,6 +84,8 @@ $topic->update({
storiesShort => 3, storiesShort => 3,
}); });
$versionTag->commit;
################################################################ ################################################################
# #
# viewTemplateVariables # viewTemplateVariables
@ -154,7 +156,7 @@ cmp_deeply(
creationDate => $now, creationDate => $now,
}, },
], ],
'viewTemplateVars has right number and contents in the story_loop in standalone mode' 'viewTemplateVars has right number and contents in the story_loop in standalone mode. Top story not present in story_loop'
); );
is($templateVars->{topStoryTitle}, 'bogs', '... topStoryTitle'); is($templateVars->{topStoryTitle}, 'bogs', '... topStoryTitle');
@ -212,7 +214,6 @@ cmp_deeply(
'... photo template variables set' '... photo template variables set'
); );
$topic->update({ $topic->update({
storiesShort => 20, storiesShort => 20,
}); });
@ -227,6 +228,33 @@ cmp_deeply(
'viewTemplateVariables: is only finding things with its keywords' 'viewTemplateVariables: is only finding things with its keywords'
); );
$topic->{_exportMode} = 1;
$topic->update({
storiesShort => 3,
});
$templateVars = $topic->viewTemplateVariables;
cmp_deeply(
$templateVars->{story_loop},
[
{
title => 'bogs',
url => $storyHandler->{'bogs'}->getUrl,
creationDate => $now,
},
{
title => 'red',
url => $storyHandler->{'red'}->getUrl,
creationDate => $now,
},
{
title => 'brooks',
url => $storyHandler->{'brooks'}->getUrl,
creationDate => $now,
},
],
'... export mode, URLs are the regular story URLs'
);
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------