| 1 | package Kwiki::CachedDisplay; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Kwiki::Plugin -Base; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | our $VERSION = '0.07'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | const class_id => 'cached_display'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | my $reg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | $reg->add(hook => 'display:display', pre => 'check_cached'); | |||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub check_cached { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_cached: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my $hook = pop; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my $display = $self; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | $self = $display->hub->cached_display; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $page = $self->pages->current; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | return unless $page->exists; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | return if (defined $self->config->can('cached_display_ignore') and | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | grep {$page->id} @{$self->config->cached_display_ignore}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->config->can("cached_display_ignore") and grep {$page->id;} @{$self->config->cached_display_ignore;}
MC/DC0%0/2
defined $self->config->can("cached_display_ignore") and grep {$page->id;} @{$self->config->cached_display_ignore;}
defined $self->config->can("cached_display_ignore")
grep {$page->id;} @{$self->config->cached_display_ignore;}
Truth table0%0/3
A and B
A= defined $self->config->can("cached_display_ignore")B= grep {$page->id;} @{$self->config->cached_display_ignore;}
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $html = io->catfile($self->plugin_directory,$page->id)->utf8; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $content; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $depup = 0; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if (defined $self->config->can('cached_display_dependencies')){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | for (@{$self->config->cached_display_dependencies}){ | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $deppage = $self->pages->new_page($_); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $depup = 1 if $deppage->modified_time > $html->mtime; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if($depup or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$depup or not $html->exists or $page->modified_time > $html->mtime
$depup or not $html->exists
MC/DC0%0/3
$depup or not $html->exists or $page->modified_time > $html->mtime
$depup
not $html->exists
$page->modified_time > $html->mtime
Truth table0%0/4
A or not(B) or C
A= $depupB= not $html->existsC= $page->modified_time > $html->mtime
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | !$html->exists or | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ($page->modified_time > $html->mtime)) { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $code = $hook->code; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $content = $code->($display); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $html->print($content); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $content ||= $html->all; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$content ||= $html->all
MC/DC0%0/2
$content ||= $html->all
$content
$html->all
Truth table0%0/3
A ||= B
A= $contentB= $html->all
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $hook->cancel; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | __END__ | |||||||||||||||||||||||||||||||||||||||||