/[Grep]/lib/Grep/Source.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Source.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 72 by dpavlin, Fri Feb 23 09:54:28 2007 UTC revision 73 by dpavlin, Fri Feb 23 11:48:39 2007 UTC
# Line 28  Returns all available sources. Line 28  Returns all available sources.
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    
# Line 95  sub search { Line 99  sub search {
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 );
# Line 108  sub search { Line 111  sub search {
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 {
# Line 135  sub add_record { Line 143  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;

Legend:
Removed from v.72  
changed lines
  Added in v.73

  ViewVC Help
Powered by ViewVC 1.1.26