28 |
|
|
29 |
=cut |
=cut |
30 |
|
|
31 |
warn "Found source plugins: ", dump( __PACKAGE__->sources() ); |
Jifty->log->debug("Found source plugins: ", join(", ", __PACKAGE__->sources() ) ); |
32 |
|
|
33 |
=head2 new |
=head2 new |
34 |
|
|
35 |
my $source = Grep::Source->new({ feed => $feed_record }); |
my $source = Grep::Source->new({ feed => $feed_record }); |
36 |
|
|
37 |
|
This will also setup: |
38 |
|
|
39 |
|
=head2 feed |
40 |
|
|
41 |
|
isa L<Grep::Model::Feed> |
42 |
|
|
43 |
=head2 search |
=head2 search |
44 |
|
|
45 |
my $collection = $source->search( 'query string' ); |
my $collection = $source->search( 'query string' ); |
46 |
|
|
47 |
It will also setup following accessors: |
It will also setup following accessors: |
48 |
|
|
49 |
=over 8 |
=head2 q |
|
|
|
|
=item q |
|
50 |
|
|
51 |
Search query |
Search query |
52 |
|
|
53 |
=item uri |
=head2 uri |
54 |
|
|
55 |
URI of feed with embedded search query |
URI of feed with embedded search query |
56 |
|
|
57 |
=item new_items |
=head2 new_items |
58 |
|
|
59 |
Number of new items in result collection |
Number of new items in result collection |
60 |
|
|
99 |
|
|
100 |
$self->collection( Grep::Model::ItemCollection->new() ); |
$self->collection( Grep::Model::ItemCollection->new() ); |
101 |
|
|
102 |
my $class = 'Grep::Source::Feed'; |
my $class = $self->feed->source || 'Grep::Source::Feed'; |
|
$class = 'Grep::Source::MoinMoin'; |
|
103 |
Jifty->log->debug("using $class"); |
Jifty->log->debug("using $class"); |
104 |
|
|
105 |
$class->fetch( $self ); |
$class->fetch( $self ); |
111 |
|
|
112 |
=head2 add_record |
=head2 add_record |
113 |
|
|
114 |
|
Plugins will be called with parametar C<$parent> so they can call this method to add |
115 |
|
record into result collection (and store in cache and index). |
116 |
|
|
117 |
$parent->add_record( id => 42, foo => 'bar', ... ); |
$parent->add_record( id => 42, foo => 'bar', ... ); |
118 |
|
|
119 |
|
This will also update L</new_items> |
120 |
|
|
121 |
=cut |
=cut |
122 |
|
|
123 |
sub add_record { |
sub add_record { |
143 |
} |
} |
144 |
} |
} |
145 |
|
|
146 |
|
=head2 content_class |
147 |
|
|
148 |
|
Return class registred for particular content. |
149 |
|
|
150 |
|
my $class = $source->content_class( $content ); |
151 |
|
|
152 |
|
=cut |
153 |
|
|
154 |
|
sub content_class { |
155 |
|
my $self = shift; |
156 |
|
|
157 |
|
my $content = shift or die "no content?"; |
158 |
|
|
159 |
|
foreach my $s ( $self->sources ) { |
160 |
|
Jifty->log->debug("testing source class $s"); |
161 |
|
if ($s->can('content_have') && $s->content_have( $content ) ) { |
162 |
|
Jifty->log->debug("${s}->content_have succesful"); |
163 |
|
return "$s"; |
164 |
|
} |
165 |
|
} |
166 |
|
} |
167 |
|
|
168 |
1; |
1; |