Simple/Plugin/NodeList.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« Simple/Setup.pm ↑ Summary Simple/Plugin/RecentChanges.pm »
1 package CGI::Wiki::Simple::Plugin::NodeList;
2 0 ▶use CGI::Wiki::Simple::Plugin();
Subroutine BEGIN: called CC=1 SCAR=2.6
3 use HTML::Entities;
4  
5 use vars qw($VERSION);
6 $VERSION = 0.09;
7  
8 =head1 NAME
9  
10 CGI::Wiki::Simple::Plugin::NodeList - Node that lists all existing nodes on a wiki
11  
12 =head1 DESCRIPTION
13  
14 This node lists all nodes in your wiki. Think of it as the master index to your wiki.
15  
16 =head1 SYNOPSIS
17  
18 =for example begin
19  
20 use CGI::Wiki::Simple;
21 use CGI::Wiki::Simple::Plugin::NodeList( name => 'AllNodes' );
22 # nothing else is needed
23  
24 use CGI::Wiki::Simple::Plugin::NodeList( name => 'AllCategories', re => qr/^Category:(.*)$/ );
25  
26 =for example end
27  
28 =cut
29  
30 use vars qw(%re);
31  
32 sub import {
33 my ($module,%args) = @_;
34 my $node = $args{name};
35 $re{$node} = $args{re} || '^(.*)$';
36 CGI::Wiki::Simple::Plugin::register_nodes(module => $module, name => $node);
37 };
38  
39 sub retrieve_node {
40 my (%args) = @_;
41  
42 my $node = $args{name};
43 my $re = $re{$node};
44 my %nodes = map { /$re/ ? ($_ => $1) : () } ($args{wiki}->list_all_nodes, keys %CGI::Wiki::Simple::magic_node);
45  
46 return (
47 "<ul>" .
48 join ("\n", map { "<li>" . $args{wiki}->inside_link( node => $_, title => $nodes{$_} ) . "</li>" }
49 sort { uc($nodes{$a}) cmp uc($nodes{$b}) }
50 keys %nodes)
51 . "</ul>",0,"");
52 };
53  
54 1;
« Simple/Setup.pm ↑ Summary Simple/Plugin/RecentChanges.pm »