diff --git a/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg b/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg index 48c1d0eb6..f63fed1af 100644 Binary files a/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg and b/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg differ diff --git a/lib/WebGUI/Asset/Story.pm b/lib/WebGUI/Asset/Story.pm index f231470ec..645b6fc95 100644 --- a/lib/WebGUI/Asset/Story.pm +++ b/lib/WebGUI/Asset/Story.pm @@ -110,7 +110,7 @@ sub definition { defaultValue => '', }, subtitle => { - fieldType => 'text', + fieldType => 'textarea', #label => $i18n->get('subtitle'), #hoverHelp => $i18n->get('subtitle help'), defaultValue => '', @@ -223,7 +223,7 @@ sub getEditForm { name => 'title', value => $form->get('title') || $self->get('title'), } ), - subTitleForm => WebGUI::Form::text($session, { + subTitleForm => WebGUI::Form::textarea($session, { name => 'subtitle', value => $form->get('subtitle') || $self->get('subtitle') } ), @@ -546,13 +546,25 @@ Template variables will be added onto this hash ref. sub viewTemplateVariables { my ($self) = @_; my $session = $self->session; - my $var = $self->get; + my $archive = $self->getArchive; + my $var = $self->get; + if ($var->{highlights}) { - my @highlights = split "\n", $var->{highlights}; + my @highlights = split "\n+", $var->{highlights}; foreach my $highlight (@highlights) { - push @{ $var->{highlightsLoop} }, { highlight => $highlight }; + push @{ $var->{highlights_loop} }, { highlight => $highlight }; } } + + my $key = WebGUI::Keyword->new($session); + my $keywords = $key->getKeywordsForAsset( { asArrayRef => 1, asset => $self }); + $var->{keyword_loop} = []; + foreach my $keyword (@{ $keywords }) { + push @{ $var->{keyword_loop} }, { + keyword => $keyword, + url => $archive->getUrl("func=search;submit=1;keywords=".$session->url->escape($keyword)), + }; + } ##TODO: publish time, calculated from revisionDate return $var; } diff --git a/t/Asset/Story.t b/t/Asset/Story.t index 08a79f80b..20bb7390c 100644 --- a/t/Asset/Story.t +++ b/t/Asset/Story.t @@ -18,9 +18,10 @@ use WebGUI::Storage; use Test::More; # increment this value for each test you create use Test::Deep; +use Data::Dumper; my $tests = 1; -plan tests => 13 +plan tests => 16 + $tests ; @@ -123,6 +124,39 @@ cmp_deeply( 'setPhotoData: wipes the stored data if nothing is passed' ); +############################################################ +# +# viewTemplateVariables +# +############################################################ + +$story->update({ + highlights => "one\ntwo\nthree", + keywords => "foxtrot tango whiskey", +}); +is($story->get('highlights'), "one\ntwo\nthree", 'highlights set correctly for template var check'); +my $viewVariables = $story->viewTemplateVariables; +#diag Dumper $viewVariables; +cmp_deeply( + $viewVariables->{highlights_loop}, + [ + { highlight => "one", }, + { highlight => "two", }, + { highlight => "three", }, + ], + 'viewTemplateVariables: highlights_loop is okay' +); + +cmp_bag( + $viewVariables->{keyword_loop}, + [ + { keyword => "foxtrot", url => '/home/test-archive?func=search;submit=1;keywords=foxtrot', }, + { keyword => "tango", url => '/home/test-archive?func=search;submit=1;keywords=tango', }, + { keyword => "whiskey", url => '/home/test-archive?func=search;submit=1;keywords=whiskey', }, + ], + 'viewTemplateVariables: keywords_loop is okay' +); + } END {