Tests, bugfixes, and adding synopsis to the byKeyword template.
This commit is contained in:
parent
39b44504c3
commit
960ff2287c
3 changed files with 19 additions and 5 deletions
Binary file not shown.
|
|
@ -520,7 +520,9 @@ The hierarchy data structure that looks like this:
|
||||||
{ # If there are no children, this key/value pair will not be present
|
{ # If there are no children, this key/value pair will not be present
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
descendants => 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 = [];
|
my $hierarchy = [];
|
||||||
$keywords ||= $self->getTopLevelKeywordsList;
|
$keywords ||= $self->getTopLevelKeywordsList;
|
||||||
$seen ||= {};
|
$seen ||= {};
|
||||||
|
my $assetKeyword = WebGUI::Keyword->new($session);
|
||||||
KEYWORD: foreach my $keyword (sort @{ $keywords }) {
|
KEYWORD: foreach my $keyword (sort @{ $keywords }) {
|
||||||
my $datum = {
|
my $datum = {
|
||||||
title => $keyword, ##Note, same as keyword
|
title => $keyword, ##Note, same as keyword
|
||||||
url => $self->getUrl('func=byKeyword;keyword='.$keyword),
|
url => $self->getUrl('func=byKeyword;keyword='.$keyword),
|
||||||
|
descendants => scalar @{ $assetKeyword->getMatchingAssets( { startAsset => $self, keyword => $keyword, }) },
|
||||||
};
|
};
|
||||||
##Prevent recursion if seen again
|
##Prevent recursion if seen again
|
||||||
if (! $seen->{$keyword}++) {
|
if (! $seen->{$keyword}++) {
|
||||||
##Replace this with a call to getSubKeywords.
|
##Replace this with a call to getSubKeywords.
|
||||||
my $children = $self->getKeywordHierarchy($self->getSubKeywords($keyword), $seen, );
|
my $children = $self->getKeywordHierarchy($self->getSubKeywords($keyword), $seen, );
|
||||||
if (@{ $children } ) {
|
if (@{ $children } ) {
|
||||||
|
foreach my $child (@{ $children }) {
|
||||||
|
$datum->{descendants} += $child->{descendants};
|
||||||
|
}
|
||||||
$datum->{children} = $children;
|
$datum->{children} = $children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,9 @@ my $variables = $wiki->getKeywordVariables($hierarchy);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$hierarchy->[0],
|
$hierarchy->[0],
|
||||||
{
|
{
|
||||||
title => 'criminals',
|
title => 'criminals',
|
||||||
url => '/testwiki?func=byKeyword;keyword=criminals',
|
url => '/testwiki?func=byKeyword;keyword=criminals',
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
"getKeywordVariables, does not alter the original hierarchy passed in",
|
"getKeywordVariables, does not alter the original hierarchy passed in",
|
||||||
);
|
);
|
||||||
|
|
@ -99,18 +100,21 @@ cmp_deeply(
|
||||||
url => '/testwiki?func=byKeyword;keyword=criminals',
|
url => '/testwiki?func=byKeyword;keyword=criminals',
|
||||||
level => 0,
|
level => 0,
|
||||||
indent_loop => [],
|
indent_loop => [],
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title => 'inmates',
|
title => 'inmates',
|
||||||
url => '/testwiki?func=byKeyword;keyword=inmates',
|
url => '/testwiki?func=byKeyword;keyword=inmates',
|
||||||
level => 0,
|
level => 0,
|
||||||
indent_loop => [],
|
indent_loop => [],
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title => 'staff',
|
title => 'staff',
|
||||||
url => '/testwiki?func=byKeyword;keyword=staff',
|
url => '/testwiki?func=byKeyword;keyword=staff',
|
||||||
level => 0,
|
level => 0,
|
||||||
indent_loop => [],
|
indent_loop => [],
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"... variables",
|
"... variables",
|
||||||
|
|
@ -157,6 +161,7 @@ cmp_bag(
|
||||||
superhashof({ title => 'red', }),
|
superhashof({ title => 'red', }),
|
||||||
superhashof({ title => 'andy', }),
|
superhashof({ title => 'andy', }),
|
||||||
),
|
),
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates',
|
title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates',
|
||||||
|
|
@ -164,6 +169,7 @@ cmp_bag(
|
||||||
superhashof({ title => 'heywood', }),
|
superhashof({ title => 'heywood', }),
|
||||||
superhashof({ title => 'brooks', }),
|
superhashof({ title => 'brooks', }),
|
||||||
),
|
),
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff',
|
title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff',
|
||||||
|
|
@ -171,6 +177,7 @@ cmp_bag(
|
||||||
superhashof({ title => 'norton', }),
|
superhashof({ title => 'norton', }),
|
||||||
superhashof({ title => 'hadley', }),
|
superhashof({ title => 'hadley', }),
|
||||||
),
|
),
|
||||||
|
descendants => 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"getKeywordHierarchy: simple hierarchy",
|
"getKeywordHierarchy: simple hierarchy",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue