diff --git a/docs/create.sql b/docs/create.sql index 188efc80b..524ec766e 100644 --- a/docs/create.sql +++ b/docs/create.sql @@ -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; diff --git a/lib/WebGUI/Asset/RSSCapable.pm b/lib/WebGUI/Asset/RSSCapable.pm index d75af0d9c..f6c86652d 100644 --- a/lib/WebGUI/Asset/RSSCapable.pm +++ b/lib/WebGUI/Asset/RSSCapable.pm @@ -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); } diff --git a/lib/WebGUI/Asset/RSSFromParent.pm b/lib/WebGUI/Asset/RSSFromParent.pm index edb052db4..27127e341 100644 --- a/lib/WebGUI/Asset/RSSFromParent.pm +++ b/lib/WebGUI/Asset/RSSFromParent.pm @@ -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); diff --git a/lib/WebGUI/i18n/English/Asset_RSSCapable.pm b/lib/WebGUI/i18n/English/Asset_RSSCapable.pm index 36e4fcd23..58c803c82 100644 --- a/lib/WebGUI/i18n/English/Asset_RSSCapable.pm +++ b/lib/WebGUI/i18n/English/Asset_RSSCapable.pm @@ -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 }, diff --git a/t/Asset/Wobject/Collaboration.t b/t/Asset/Wobject/Collaboration.t index ef7039417..cbd8c91a9 100644 --- a/t/Asset/Wobject/Collaboration.t +++ b/t/Asset/Wobject/Collaboration.t @@ -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"; diff --git a/t/Asset/Wobject/GalleryAlbum/rss.t b/t/Asset/Wobject/GalleryAlbum/rss.t index c5433ea23..383d81711 100644 --- a/t/Asset/Wobject/GalleryAlbum/rss.t +++ b/t/Asset/Wobject/GalleryAlbum/rss.t @@ -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