File Coverage

blib/lib/Kwiki/Toolbar/List.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Kwiki::Toolbar::List;
2 1     1   32305 use strict;
  1         2  
  1         42  
3 1     1   4 use warnings;
  1         2  
  1         33  
4 1     1   473 use Kwiki::Toolbar '-Base';
  0            
  0            
5              
6             our $VERSION = 0.01;
7              
8             #const class_id => 'toolbar';
9             const class_title => 'Kwiki Toolbar List';
10             const toolbar_template => 'toolbar_pane.html';
11             #const css_file => 'toolbar.css';
12             #const config_file => 'toolbar.yaml';
13              
14             sub html {
15             my $lookup = $self->hub->registry->lookup;
16             my $tools = $lookup->{toolbar}
17             or return '';
18             my %toolmap;
19             for (keys %$tools) {
20             my $array = $tools->{$_};
21             push @{$toolmap{$array->[0]}}, {@{$array}[1..$#{$array}]};
22             }
23             my %classmap = reverse %{$lookup->{classes}};
24             my $x = 1;
25             my %class_ids = map {
26             ($classmap{$_}, $x++)
27             } @{$self->hub->config->plugin_classes};
28             my @class_ids = grep {
29             delete $class_ids{$_}
30             } @{$self->config->toolbar_order};
31             push @class_ids, sort {
32             $class_ids{$a} <=> $class_ids{$b}
33             } keys %class_ids;
34             my @toolbar_content = ();
35             @toolbar_content = grep {
36             defined $_ and do {
37             my $button = $_;
38             $button =~ s///gs;
39             $button =~ /\S/;
40             }
41             } map {
42             $self->show($_) ? defined($_->{template}) ? $self->template->process($_->{template}) : undef : undef
43             } map {
44             defined $toolmap{$_} ? @{$toolmap{$_}} : ()
45             } @class_ids;
46              
47             $self->template->process($self->toolbar_template,
48             toolbar_content => \@toolbar_content,
49             action => $self->hub->action,
50             );
51             }
52              
53             1;
54              
55             __DATA__