| 1 | package Kwiki::Favorites; | ||||||||||||
| 2 | 1 | ▶ | use Kwiki::Plugin -Base; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 1 | ▶ | use mixin 'Kwiki::Installer'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | our $VERSION = '0.13'; | |||||||||||
| 5 | |||||||||||||
| 6 | 1 | const class_id => 'favorites'; | |||||||||||
| 7 | 1 | const css_file => 'favorites.css'; | |||||||||||
| 8 | |||||||||||||
| 9 | 0 | ▶ | sub register { | ||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 10 | 0 | my $registry = shift; | |||||||||||
| 11 | 0 | $registry->add(action => 'favorites'); | |||||||||||
| 12 | 0 | $registry->add(action => 'favorites_add'); | |||||||||||
| 13 | 0 | $registry->add(action => 'favorites_remove'); | |||||||||||
| 14 | 0 | $registry->add(toolbar => 'favorites_button', | |||||||||||
| 15 | template => 'favorites_button.html', | ||||||||||||
| 16 | ); | ||||||||||||
| 17 | 0 | $registry->add(widget => 'favorites_query', | |||||||||||
| 18 | template => 'favorites_query.html', | ||||||||||||
| 19 | show_for => 'display', | ||||||||||||
| 20 | ); | ||||||||||||
| 21 | } | ||||||||||||
| 22 | |||||||||||||
| 23 | 0 | ▶ | sub favorites { | ||||||||||
|
Subroutine
favorites: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 24 | my $favorites = | ||||||||||||
| 25 | 0 | ▶ | $self->hub->cookie->jar->{favorites} || {}; | ||||||||||
|
Condition0%0/2
$self->hub->cookie->jar->{'favorites'} || {}
MC/DC0%0/1
$self->hub->cookie->jar->{'favorites'} || {}
$self->hub->cookie->jar->{'favorites'}
Truth table0%0/2
A
A= $self->hub->cookie->jar->{'favorites'}
| |||||||||||||
| 26 | my @pages = sort { | ||||||||||||
| 27 | 0 | $b->metadata->edit_unixtime <=> $a->metadata->edit_unixtime; | |||||||||||
| 28 | } map { | ||||||||||||
| 29 | 0 | $self->pages->new_page($_); | |||||||||||
| 30 | } keys %$favorites; | ||||||||||||
| 31 | 0 | $self->render_screen(pages => \@pages); | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 0 | ▶ | sub favorites_add { | ||||||||||
|
Subroutine
favorites_add: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 35 | 0 | my $page_name = $self->pages->name_to_id($self->cgi->page_name); | |||||||||||
| 36 | 0 | ▶ | my $favorites = $self->hub->cookie->jar->{favorites} || {}; | ||||||||||
|
Condition0%0/2
$self->hub->cookie->jar->{'favorites'} || {}
MC/DC0%0/1
$self->hub->cookie->jar->{'favorites'} || {}
$self->hub->cookie->jar->{'favorites'}
Truth table0%0/2
A
A= $self->hub->cookie->jar->{'favorites'}
| |||||||||||||
| 37 | 0 | $favorites->{$page_name} = 1; | |||||||||||
| 38 | 0 | $self->hub->cookie->jar->{favorites} = $favorites; | |||||||||||
| 39 | 0 | return "$page_name added"; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 0 | ▶ | sub favorites_remove { | ||||||||||
|
Subroutine
favorites_remove: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 43 | 0 | my $page_name = $self->pages->name_to_id($self->cgi->page_name); | |||||||||||
| 44 | 0 | ▶ | my $favorites = $self->hub->cookie->jar->{favorites} || {}; | ||||||||||
|
Condition0%0/2
$self->hub->cookie->jar->{'favorites'} || {}
MC/DC0%0/1
$self->hub->cookie->jar->{'favorites'} || {}
$self->hub->cookie->jar->{'favorites'}
Truth table0%0/2
A
A= $self->hub->cookie->jar->{'favorites'}
| |||||||||||||
| 45 | 0 | delete $favorites->{$page_name}; | |||||||||||
| 46 | 0 | $self->hub->cookie->jar->{favorites} = $favorites; | |||||||||||
| 47 | 0 | return "$page_name added"; | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 1 | __DATA__ | |||||||||||