RSS Limiter
This commit is contained in:
parent
a57a6ba87b
commit
e7a3282af3
6 changed files with 60 additions and 14 deletions
|
|
@ -971,6 +971,7 @@ CREATE TABLE `RSSCapable` (
|
|||
`rssCapableRssEnabled` int(11) NOT NULL default '1',
|
||||
`rssCapableRssTemplateId` char(22) NOT NULL default 'PBtmpl0000000000000142',
|
||||
`rssCapableRssFromParentId` char(22) default NULL,
|
||||
`rssCapableRssLimit` integer default '10',
|
||||
PRIMARY KEY (`assetId`,`revisionDate`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
SET character_set_client = @saved_cs_client;
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ using the RSSFromParent asset.
|
|||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_RSSCapable');
|
||||
|
||||
# We do this prefixing to avoid name collisions because properties aren't namespaced.
|
||||
|
|
@ -58,6 +58,13 @@ sub definition {
|
|||
label => $i18n->get('rssTemplateId label'),
|
||||
hoverHelp => $i18n->get('rssTemplateId hoverHelp')
|
||||
},
|
||||
rssCapableRssLimit => { tab => 'display',
|
||||
fieldType => 'integer',
|
||||
defaultValue => 10,
|
||||
namespace => 'RSSCapable/RSS',
|
||||
label => $i18n->get('rssLimit label'),
|
||||
hoverHelp => $i18n->get('rssLimit hoverHelp')
|
||||
},
|
||||
rssCapableRssFromParentId => { fieldType => 'hidden',
|
||||
noFormPost => 1,
|
||||
defaultValue => undef,
|
||||
|
|
@ -65,12 +72,12 @@ sub definition {
|
|||
);
|
||||
|
||||
push @$definition, { assetName => $i18n->get('assetName'),
|
||||
tableName => 'RSSCapable',
|
||||
autoGenerateForms => 1,
|
||||
className => 'WebGUI::Asset::RSSCapable',
|
||||
icon => 'rssCapable.gif',
|
||||
properties => \%properties
|
||||
};
|
||||
tableName => 'RSSCapable',
|
||||
autoGenerateForms => 1,
|
||||
className => 'WebGUI::Asset::RSSCapable',
|
||||
icon => 'rssCapable.gif',
|
||||
properties => \%properties
|
||||
};
|
||||
return $class->NEXT::definition($session, $definition);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ sub www_view {
|
|||
my $self = shift;
|
||||
return '' unless $self->session->asset->getId eq $self->getId;
|
||||
return '' unless $self->getParent->isa('WebGUI::Asset::RSSCapable');
|
||||
return '' unless $self->getParent->canView; # Go to parent for auth
|
||||
return '' unless $self->getParent->canView; # Go to parent for auth
|
||||
my $parent = $self->getParent;
|
||||
my $template = WebGUI::Asset::Template->new($self->session, $parent->get('rssCapableRssTemplateId'));
|
||||
$template->prepare($self->getMetaDataAsTemplateVariables);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ our $I18N =
|
|||
{
|
||||
'rssEnabled label' => { message => 'Enable RSS', lastUpdate => 1162487361 },
|
||||
'rssEnabled hoverHelp' => { message => q|Whether or not to enable the RSS feed for this asset. If enabled, an RSS From Parent asset will be created and managed as an extra child for this purpose. If not enabled, no such child will be created and the existing one will be deleted.|, lastUpdate => 1162487361 },
|
||||
'rssLimit label' => { message => 'RSS Display limit', lastUpdate => 1162487361 },
|
||||
'rssLimit hoverHelp' => { message => q|How many RSS items to display|, lastUpdate => 1162487361 },
|
||||
'rssTemplateId label' => { message => 'RSS Template', lastUpdate => 1162487361 },
|
||||
'rssTemplateId hoverHelp' => { message => q|The template to use for the RSS feed of this asset.|, lastUpdate => 1162487361 },
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use WebGUI::Asset::Wobject::Collaboration;
|
|||
use WebGUI::Asset::Post;
|
||||
use WebGUI::Asset::Wobject::Layout;
|
||||
use Data::Dumper;
|
||||
use Test::More tests => 4; # increment this value for each test you create
|
||||
use Test::More tests => 8; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -60,6 +60,38 @@ ok(defined $collab->get('groupToEditPost'), 'groupToEditPost field is defined');
|
|||
|
||||
# Verify sane defaults
|
||||
cmp_ok($collab->get('groupToEditPost'), 'eq', $collab->get('groupIdEdit'), 'groupToEditPost defaults to groupIdEdit correctly');
|
||||
is($collab->get('rssCapableRssLimit'), 10, 'rssCapableRssLimit is set to the default');
|
||||
|
||||
# finally, add the post to the collaboration system
|
||||
my $props = {
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
content => 'hello, world!',
|
||||
};
|
||||
my $post = $collab->addChild($props,
|
||||
undef,
|
||||
undef,
|
||||
{
|
||||
skipAutoCommitWorkflows => 1,
|
||||
});
|
||||
|
||||
# Test for a sane object type
|
||||
isa_ok($post, 'WebGUI::Asset::Post::Thread');
|
||||
|
||||
$props = {
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
content => 'jello, world!',
|
||||
};
|
||||
$post = $collab->addChild($props,
|
||||
undef,
|
||||
undef,
|
||||
{
|
||||
skipAutoCommitWorkflows => 1,
|
||||
});
|
||||
|
||||
my $rssitems = $collab->getRssItems();
|
||||
is($rssitems, 2, 'rssitems set to number of posts added');
|
||||
|
||||
is($collab->get('rssCapableRssLimit'), 10, 'rssCapableRssLimit is set to the default');
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
|
|
|
|||
|
|
@ -74,7 +74,11 @@ $oldSettings{ specialState } = $session->setting->get( 'specialState' );
|
|||
$session->setting->set( 'specialState', '' );
|
||||
|
||||
my ( $mech );
|
||||
my $baseUrl = 'http://' . $session->config->get('sitename')->[0];
|
||||
my $config_port;
|
||||
if ($session->config->get('webServerPort')) {
|
||||
$config_port = $session->config->get('webServerPort') || 80;
|
||||
}
|
||||
my $baseUrl = 'http://' . $session->config->get('sitename')->[0] . ":$config_port";
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue