| 1 | package Kwiki::Search; | ||||||||||||||||||||||||||||||||||||||
| 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 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | our $VERSION = '0.12'; | ||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | const class_id => 'search'; | ||||||||||||||||||||||||||||||||||||||
| 8 | const cgi_class => 'Kwiki::Search::CGI'; | ||||||||||||||||||||||||||||||||||||||
| 9 | const css_file => 'search.css'; | ||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my $registry = shift; | |||||||||||||||||||||||||||||||||||||
| 13 | 0 | $registry->add(action => 'search'); | |||||||||||||||||||||||||||||||||||||
| 14 | 0 | $registry->add(toolbar => 'search_box', | |||||||||||||||||||||||||||||||||||||
| 15 | template => 'search_box.html', | ||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $pages = $self->perform_search; | |||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $term = $self->cgi->search_term; | |||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $num = @$pages; | |||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $screen_title = length($term) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 24 | ? "$num Pages Matching '$term'" | ||||||||||||||||||||||||||||||||||||||
| 25 | : "All $num Pages"; | ||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->render_screen( | |||||||||||||||||||||||||||||||||||||
| 27 | screen_title => $screen_title, | ||||||||||||||||||||||||||||||||||||||
| 28 | pages => $pages, | ||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub perform_search { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
perform_search: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $search = $self->cgi->search_term; | |||||||||||||||||||||||||||||||||||||
| 34 | 0 | $search =~ s/[^$WORD\ \-\.\^\$\*\|\:]//g; | |||||||||||||||||||||||||||||||||||||
| 35 | [ | ||||||||||||||||||||||||||||||||||||||
| 36 | grep { | ||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | ($_->id =~ m{$search}i || | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
($_->id =~ /$search/i || $_->content =~ /$search/i) && $_->active
$_->id =~ /$search/i or $_->content =~ /$search/i
MC/DC0%0/3
($_->id =~ /$search/i || $_->content =~ /$search/i) && $_->active
$_->id =~ /$search/i
$_->content =~ /$search/i
$_->active
Truth table0%0/5
A or B && C
A= $_->id =~ /$search/iB= $_->content =~ /$search/iC= $_->active
| |||||||||||||||||||||||||||||||||||||||
| 38 | $_->content =~ m{$search}i | ||||||||||||||||||||||||||||||||||||||
| 39 | ) and $_->active | ||||||||||||||||||||||||||||||||||||||
| 40 | } $self->pages->all | ||||||||||||||||||||||||||||||||||||||
| 41 | ] | ||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | package Kwiki::Search::CGI; | ||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | use Kwiki::CGI -base; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | cgi search_term => -utf8; | ||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | package Kwiki::Search; | ||||||||||||||||||||||||||||||||||||||
| 50 | __DATA__ | ||||||||||||||||||||||||||||||||||||||