Make rssUrl and atomUrl variables respond to exportMode.

This commit is contained in:
Colin Kuskie 2009-04-16 21:19:17 +00:00
parent 1ddf1b50a4
commit c439453784
4 changed files with 57 additions and 20 deletions

View file

@ -388,12 +388,13 @@ sub viewTemplateVariables {
$var->{addStoryUrl} = $var->{canPostStories}
? $self->getUrl('func=add;class=WebGUI::Asset::Story')
: '';
$var->{rssUrl} = $self->getUrl('func=viewRss');
$var->{atomUrl} = $self->getUrl('func=viewAtom');
$var->{keywordCloud} = WebGUI::Keyword->new($session)->generateCloud({
$var->{rssUrl} = $self->{_exportMode} ? $self->getStaticRssFeedUrl : $self->getRssFeedUrl;
$var->{atomUrl} = $self->{_exportMode} ? $self->getStaticAtomFeedUrl : $self->getAtomFeedUrl;
my $cloudOptions = {
startAsset => $self,
displayFunc => 'view',
});
};
$var->{keywordCloud} = WebGUI::Keyword->new($session)->generateCloud($cloudOptions);
if (! $self->{_exportMode}) {
my $i18n = WebGUI::International->new($session, 'Asset');
$var->{searchHeader} = WebGUI::Form::formHeader($session, { action => $self->getUrl })

View file

@ -17,7 +17,8 @@ use Tie::IxHash;
use WebGUI::International;
use WebGUI::Utility;
use WebGUI::Asset::Story;
use base 'WebGUI::Asset::Wobject';
use Class::C3;
use base qw/WebGUI::AssetAspect::RssFeed WebGUI::Asset::Wobject/;
use constant DATE_FORMAT => '%c_%D_%y';
@ -201,8 +202,8 @@ sub viewTemplateVariables {
}
}
$var->{standAlone} = $self->{_standAlone};
$var->{rssUrl} = $self->getUrl('func=viewRss');
$var->{atomUrl} = $self->getUrl('func=viewAtom');
$var->{rssUrl} = $self->{_exportMode} ? $self->getStaticRssFeedUrl : $self->getRssFeedUrl;
$var->{atomUrl} = $self->{_exportMode} ? $self->getStaticAtomFeedUrl : $self->getAtomFeedUrl;
return $var;
}

View file

@ -58,7 +58,7 @@ $canPostMaker->prepare({
fail => [1, $reader ],
});
my $tests = 33
my $tests = 35
+ $canPostMaker->plan
;
plan tests => 1
@ -195,6 +195,15 @@ cmp_deeply(
'viewTemplateVars: search variables present'
);
cmp_deeply(
$templateVars,
superhashof({
rssUrl => $archive->getRssFeedUrl,
atomUrl => $archive->getAtomFeedUrl,
}),
'viewTemplateVars: RSS and Atom feed template variables'
);
KEY: foreach my $key (keys %{ $templateVars }) {
next KEY if isIn($key, qw/canPostStories addStoryUrl date_loop mode/);
delete $templateVars->{$key};
@ -380,6 +389,25 @@ cmp_bag(
'viewTemplateVariables: search mode returns the correct assets in the same form as view mode'
);
$archive->{_exportMode} = 1;
$templateVars = $archive->viewTemplateVariables();
ok( ( !exists $templateVars->{searchHeader}
&& !exists $templateVars->{searchForm}
&& !exists $templateVars->{searchButton}
&& !exists $templateVars->{searchForm}
),
'... export mode, no search variables present'
);
cmp_deeply(
$templateVars,
superhashof({
rssUrl => $archive->getStaticRssFeedUrl,
atomUrl => $archive->getStaticAtomFeedUrl,
}),
'... export mode, RSS and Atom feed template variables show the static url'
);
$archive->{_exportMode} = 0;
################################################################
#
@ -399,17 +427,6 @@ cmp_bag(
'keywordCloud template variable has keywords and correct links',
);
$archive->{_exportMode} = 1;
$templateVars = $archive->viewTemplateVariables();
ok( ( !exists $templateVars->{searchHeader}
&& !exists $templateVars->{searchForm}
&& !exists $templateVars->{searchButton}
&& !exists $templateVars->{searchForm}
),
'... export mode, no search variables present'
);
$archive->{_exportMode} = 0;
################################################################
#
# RSS and Atom checks

View file

@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 15;
my $tests = 17;
plan tests => 1 + $tests;
#----------------------------------------------------------------------------
@ -94,6 +94,15 @@ $versionTag->commit;
my $templateVars;
$templateVars = $topic->viewTemplateVariables();
cmp_deeply(
$templateVars,
superhashof({
rssUrl => $topic->getRssFeedUrl,
atomUrl => $topic->getAtomFeedUrl,
}),
'viewTemplateVars: RSS and Atom feed template variables'
);
cmp_deeply(
$templateVars->{story_loop},
[
@ -254,6 +263,15 @@ cmp_deeply(
],
'... export mode, URLs are the regular story URLs'
);
cmp_deeply(
$templateVars,
superhashof({
rssUrl => $topic->getStaticRssFeedUrl,
atomUrl => $topic->getStaticAtomFeedUrl,
}),
'... export mode, RSS and Atom feed template variables show the static url'
);
$topic->{_exportMode} = 0;
}