| 1 | package Kwiki::Plugin; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use Spoon::Plugin -Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | stub 'class_id'; | |||||||||||||||||||||||||||
| 5 | 3 | const cgi_class => ''; | |||||||||||||||||||||||||||
| 6 | 3 | const config_file => ''; | |||||||||||||||||||||||||||
| 7 | 3 | const css_file => ''; | |||||||||||||||||||||||||||
| 8 | 3 | const javascript_file => ''; | |||||||||||||||||||||||||||
| 9 | 3 | const screen_template => 'theme_screen.html'; | |||||||||||||||||||||||||||
| 10 | 3 | const class_title_prefix => 'Kwiki'; | |||||||||||||||||||||||||||
| 11 | 3 | const config_class => 'Kwiki::Config'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | field cgi => -init => '$self->hub->cgi'; | |||||||||||||||||||||||||||
| 14 | 3 | field config => -init => '$self->hub->config'; | |||||||||||||||||||||||||||
| 15 | 3 | field users => -init => '$self->hub->users'; | |||||||||||||||||||||||||||
| 16 | 3 | field pages => -init => '$self->hub->pages'; | |||||||||||||||||||||||||||
| 17 | 3 | field template => -init => '$self->hub->template'; | |||||||||||||||||||||||||||
| 18 | 3 | field preferences => | |||||||||||||||||||||||||||
| 19 | -init => '$self->users->current->preferences'; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | return $self if ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 1 | super; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | $self->init_cgi; | |||||||||||||||||||||||||||
| 28 | 0 | $self->config->add_file($self->config_file); | |||||||||||||||||||||||||||
| 29 | 0 | $self->hub->css->add_file($self->css_file); | |||||||||||||||||||||||||||
| 30 | 0 | $self->hub->javascript->add_file($self->javascript_file); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub init_cgi { | ||||||||||||||||||||||||||
|
Subroutine
init_cgi: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $class = $self->cgi_class | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | or return; | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | eval qq{require $class} unless $class->can('new'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | my $package = ref($self); | |||||||||||||||||||||||||||
| 38 | 0 | field -package => $package, 'cgi'; | |||||||||||||||||||||||||||
| 39 | 0 | my $object = $class->new; | |||||||||||||||||||||||||||
| 40 | 0 | $object->init; | |||||||||||||||||||||||||||
| 41 | 0 | $self->cgi($object); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub render_screen { | ||||||||||||||||||||||||||
|
Subroutine
render_screen: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 0 | $self->template_process($self->screen_template, | |||||||||||||||||||||||||||
| 46 | content_pane => $self->class_id . '_content.html', | ||||||||||||||||||||||||||||
| 47 | @_, | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub template_process { | ||||||||||||||||||||||||||
|
Subroutine
template_process: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $self->hub->css->add_file($self->css_file) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | if $self->css_file; | ||||||||||||||||||||||||||||
| 54 | 0 | my $template = shift; | |||||||||||||||||||||||||||
| 55 | 0 | $self->template->process($template, | |||||||||||||||||||||||||||
| 56 | self => $self, | ||||||||||||||||||||||||||||
| 57 | $self->pages->current->all, | ||||||||||||||||||||||||||||
| 58 | $self->cgi->all, | ||||||||||||||||||||||||||||
| 59 | @_, | ||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub redirect { | ||||||||||||||||||||||||||
|
Subroutine
redirect: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | $self->hub->headers->redirect($self->redirect_url(@_)); | |||||||||||||||||||||||||||
| 65 | 0 | return ''; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub redirect_url { | ||||||||||||||||||||||||||
|
Subroutine
redirect_url: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $target = shift; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | return $target | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target =~ m[^(https?:|/)]i or $target =~ /\?/
MC/DC0%0/2
$target =~ m[^(https?:|/)]i or $target =~ /\?/
$target =~ m[^(https?:|/)]i
$target =~ /\?/
Truth table0%0/3
A or B
A= $target =~ m[^(https?:|/)]iB= $target =~ /\?/
| |||||||||||||||||||||||||||||
| 71 | if $target =~ /^(https?:|\/)/i or | ||||||||||||||||||||||||||||
| 72 | $target =~ /\?/; | ||||||||||||||||||||||||||||
| 73 | 0 | CGI::url(-full => 1) . '?' . $target; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub new_preference { | ||||||||||||||||||||||||||
|
Subroutine
new_preference: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | $self->hub->preferences->new_preference(scalar(caller), @_); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 3 | __DATA__ | |||||||||||||||||||||||||||