Add feed support to StoryTopic.
This commit is contained in:
parent
070df97708
commit
f2451e2f7e
2 changed files with 66 additions and 1 deletions
|
|
@ -103,6 +103,34 @@ sub exportHtml_view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getRssFeedItems ( )
|
||||
|
||||
Returns an arrayref of hashrefs, containing information on stories
|
||||
for generating an RSS and Atom feeds.
|
||||
|
||||
=cut
|
||||
|
||||
sub getRssFeedItems {
|
||||
my ($self) = @_;
|
||||
my $session = $self->session;
|
||||
my $wordList = WebGUI::Keyword::string2list($self->get('keywords'));
|
||||
my $key = WebGUI::Keyword->new($session);
|
||||
my $storyIds = $key->getMatchingAssets({
|
||||
keywords => $wordList,
|
||||
isa => 'WebGUI::Asset::Story',
|
||||
rowsPerPage => $self->get('storiesPer'),
|
||||
});
|
||||
my $storyData = [];
|
||||
STORY: foreach my $storyId (@{ $storyIds }) {
|
||||
my $story = WebGUI::Asset->newByDynamicClass($session, $storyId);
|
||||
next STORY unless $story;
|
||||
push @{ $storyData }, $story->getRssData;
|
||||
}
|
||||
return $storyData;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
my $tests = 17;
|
||||
my $tests = 18;
|
||||
plan tests => 1 + $tests;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -273,6 +273,43 @@ cmp_deeply(
|
|||
);
|
||||
$topic->{_exportMode} = 0;
|
||||
|
||||
################################################################
|
||||
#
|
||||
# getRssFeedItems
|
||||
#
|
||||
################################################################
|
||||
|
||||
$topic->update({
|
||||
storiesPer => 3,
|
||||
});
|
||||
cmp_deeply(
|
||||
$topic->getRssFeedItems(),
|
||||
[
|
||||
{
|
||||
title => 'bogs',
|
||||
description => ignore(),
|
||||
'link' => ignore(),
|
||||
date => ignore(),
|
||||
author => ignore(),
|
||||
},
|
||||
{
|
||||
title => 'red',
|
||||
description => ignore(),
|
||||
'link' => ignore(),
|
||||
date => ignore(),
|
||||
author => ignore(),
|
||||
},
|
||||
{
|
||||
title => 'brooks',
|
||||
description => ignore(),
|
||||
'link' => ignore(),
|
||||
date => ignore(),
|
||||
author => ignore(),
|
||||
},
|
||||
],
|
||||
'rssFeedItems'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue