From 960ff2287cff7b17595b0b78beceb12970c51adb Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 4 May 2010 15:50:14 -0700 Subject: [PATCH] Tests, bugfixes, and adding synopsis to the byKeyword template. --- .../wiki-master-by-keyword-template.tmpl.wgpkg | Bin 0 -> 1024 bytes lib/WebGUI/Asset/Wobject/WikiMaster.pm | 13 ++++++++++--- t/Asset/Wobject/WikiMaster.t | 11 +++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 docs/upgrades/packages-7.9.4/wiki-master-by-keyword-template.tmpl.wgpkg diff --git a/docs/upgrades/packages-7.9.4/wiki-master-by-keyword-template.tmpl.wgpkg b/docs/upgrades/packages-7.9.4/wiki-master-by-keyword-template.tmpl.wgpkg new file mode 100644 index 0000000000000000000000000000000000000000..218e26948dd7bf20a6bd98031b845b167b828b9e GIT binary patch literal 1024 zcmV+b1poUViwFP!00000|Ls=okJ>gE=X3uGE0v~A8jt`Xlrf}xX?Lhcbyc}ur!gTz z4EPAPXFEsP)c?JYoqz+!-G}LrHi>*7AM!(hJ9{T?iFV*1Qa|ro6zqk`rq(_aIgQ38q5oVY99YOR{tx?Wc)tYgk=wmE9#*fVSiV=AWOW(6Di&#^cSRgC9pyeebOk{byE-%P>#bsRH6tkkC zs17Suis;-(}=>wX;1S-JgOaN0Rx8S#lJB5mnw2>tLnXw`o~F0-O4s9aN} zE2$Xp!0$e*%wWW<&m3PB0J?1H6rP8y&~-K^lImNTypw!+gC(rtew%H2AMi4pi#sy@ z?Y7r$pPAWew+HzeJC|^#5kQ=IF;jMc>YcV-!iza(vqLLtR=dw*I;Gi`c|k1--uPj? z5jq$77=ETCTh_>l>^N8?$jm=7l~L$?jq*)EKgMK=p`|}L8?~U~1J@99V%u-ccNWDA zJRT=miUo;Xw@>u%OwcM~G-;-m4?HY@#~zAY1KgJm%-}wQ)Zr6Y0!3KWCwkFtUk&=# zk2^zQr3_zXRJg-fR9$9;*w41upG;P()mnc2P1tmh%q%O|l*U146x;PGMqJh z=43p&VO1Naz&~ovS3UNQ%Vk!~qUgs@#aR{5pwXoZ7`uC-{bfEqMoF^q<`i#srs~r zb78rk8&%oicxYm6<2D1~73yja&7F=0tuP83VN_6pNd≻eBkRUq%;U7-2aO&CAjK u>O8pr=-_R;oZ~Zx{I^%%UgCq| 25, # The total number of wiki pages that this keyword, and any other sub-keywords + # of this keyword, refer to. } ] @@ -542,16 +544,21 @@ sub getKeywordHierarchy { my $hierarchy = []; $keywords ||= $self->getTopLevelKeywordsList; $seen ||= {}; + my $assetKeyword = WebGUI::Keyword->new($session); KEYWORD: foreach my $keyword (sort @{ $keywords }) { my $datum = { - title => $keyword, ##Note, same as keyword - url => $self->getUrl('func=byKeyword;keyword='.$keyword), + title => $keyword, ##Note, same as keyword + url => $self->getUrl('func=byKeyword;keyword='.$keyword), + descendants => scalar @{ $assetKeyword->getMatchingAssets( { startAsset => $self, keyword => $keyword, }) }, }; ##Prevent recursion if seen again if (! $seen->{$keyword}++) { ##Replace this with a call to getSubKeywords. my $children = $self->getKeywordHierarchy($self->getSubKeywords($keyword), $seen, ); if (@{ $children } ) { + foreach my $child (@{ $children }) { + $datum->{descendants} += $child->{descendants}; + } $datum->{children} = $children; } } diff --git a/t/Asset/Wobject/WikiMaster.t b/t/Asset/Wobject/WikiMaster.t index 6b6dd5e56..65f0fb1f3 100644 --- a/t/Asset/Wobject/WikiMaster.t +++ b/t/Asset/Wobject/WikiMaster.t @@ -85,8 +85,9 @@ my $variables = $wiki->getKeywordVariables($hierarchy); cmp_deeply( $hierarchy->[0], { - title => 'criminals', - url => '/testwiki?func=byKeyword;keyword=criminals', + title => 'criminals', + url => '/testwiki?func=byKeyword;keyword=criminals', + descendants => 0, }, "getKeywordVariables, does not alter the original hierarchy passed in", ); @@ -99,18 +100,21 @@ cmp_deeply( url => '/testwiki?func=byKeyword;keyword=criminals', level => 0, indent_loop => [], + descendants => 0, }, { title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates', level => 0, indent_loop => [], + descendants => 0, }, { title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff', level => 0, indent_loop => [], + descendants => 0, }, ], "... variables", @@ -157,6 +161,7 @@ cmp_bag( superhashof({ title => 'red', }), superhashof({ title => 'andy', }), ), + descendants => 0, }, { title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates', @@ -164,6 +169,7 @@ cmp_bag( superhashof({ title => 'heywood', }), superhashof({ title => 'brooks', }), ), + descendants => 0, }, { title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff', @@ -171,6 +177,7 @@ cmp_bag( superhashof({ title => 'norton', }), superhashof({ title => 'hadley', }), ), + descendants => 0, }, ], "getKeywordHierarchy: simple hierarchy",