8 |
=cut |
=cut |
9 |
|
|
10 |
package Grep::Action::Search; |
package Grep::Action::Search; |
11 |
use base qw/Grep::Action::SearchItem/; |
|
12 |
|
use Grep::Search; |
13 |
|
|
14 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
15 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
16 |
|
|
17 |
|
use Jifty::Param::Schema; |
18 |
|
use Jifty::Action schema { |
19 |
|
|
20 |
|
param q => |
21 |
|
type is 'text', |
22 |
|
label is 'Search for', |
23 |
|
hint is 'enter few words to search for'; |
24 |
|
|
25 |
|
param item_fragment => |
26 |
|
label is 'Show', |
27 |
|
render as 'select', |
28 |
|
available are qw/long short title/; |
29 |
|
|
30 |
|
}; |
31 |
|
|
32 |
=head2 take_action |
=head2 take_action |
33 |
|
|
34 |
=cut |
=cut |
36 |
sub take_action { |
sub take_action { |
37 |
my $self = shift; |
my $self = shift; |
38 |
|
|
39 |
my $q = $self->argument_value('content_contains') || warn "can't find content_contains"; |
my $q = $self->argument_value('q') || warn "no q?"; |
|
|
|
|
$self->SUPER::take_action( @_ ); |
|
40 |
|
|
41 |
my $coll = $self->result->content('search'); |
my $coll = Grep::Search->collection( $q ); |
42 |
|
|
43 |
Jifty->log->error('result not collection but ', dump( $coll )) |
Jifty->log->error('result not collection but ', dump( $coll )) |
44 |
unless ( $coll->isa('Jifty::Collection') ); |
unless ( $coll->isa('Jifty::Collection') ); |
51 |
$self->result->error('No local results, try remote feeds...'); |
$self->result->error('No local results, try remote feeds...'); |
52 |
} |
} |
53 |
|
|
54 |
|
$self->result->content( search => $coll ); |
55 |
|
|
56 |
return $coll; |
return $coll; |
57 |
} |
} |
58 |
|
|