Changeset 1391
- Timestamp:
- 08/19/06 15:55:27
- Files:
-
- trunk/plagger/bin/plagger-atom-stream-consumer (added)
- trunk/plagger/bin/plagger-search (added)
- trunk/plagger/examples/rss2email.yaml (added)
- trunk/plagger/lib/Plagger.pm (modified) (5 diffs)
- trunk/plagger/lib/Plagger/ConfigLoader.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Search/Estraier.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Search/KinoSearch.pm (modified) (2 diffs)
- trunk/plagger/t/plugins/Search-Estraier/search.t (modified) (2 diffs)
- trunk/plagger/t/plugins/Search-KinoSearch/search.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger.pm
r1370 r1391 27 27 use Plagger::Update; 28 28 29 sub context { undef } 30 31 sub bootstrap { 29 my $context; 30 sub context { $context } 31 sub set_context { $context = $_[1] } 32 33 sub new { 32 34 my($class, %opt) = @_; 33 35 … … 52 54 } 53 55 54 no warnings 'redefine'; 55 local *Plagger::context = sub { $self }; 56 Plagger->set_context($self); 56 57 57 58 $loader->load_recipes($config); … … 59 60 $self->load_plugins(@{ $config->{plugins} || [] }); 60 61 $self->rewrite_config if @{ $self->{rewrite_tasks} }; 62 63 $self; 64 } 65 66 sub bootstrap { 67 my $class = shift; 68 my $self = $class->new(@_); 61 69 $self->run(); 62 63 70 $self; 71 } 72 73 sub clear_session { 74 my $self = shift; 75 $self->{update} = Plagger::Update->new; 76 $self->{subscription} = Plagger::Subscription->new; 64 77 } 65 78 … … 291 304 292 305 $self->run_hook('aggregator.finalize'); 306 $self->do_run_with_feeds; 307 $self->run_hook('plugin.finalize'); 308 309 Plagger->set_context(undef); 310 $self; 311 } 312 313 sub run_with_feeds { 314 my $self = shift; 315 $self->run_hook('plugin.init'); 316 $self->do_run_with_feeds; 317 $self->run_hook('plugin.finalize'); 318 319 Plagger->set_context(undef); 320 $self; 321 } 322 323 sub do_run_with_feeds { 324 my $self = shift; 293 325 294 326 for my $feed ($self->update->feeds) { … … 324 356 325 357 $self->run_hook('publish.finalize'); 358 } 359 360 sub search { 361 my($self, $query) = @_; 362 363 Plagger->set_context($self); 364 $self->run_hook('plugin.init'); 365 366 my @feeds; 367 $context->run_hook('searcher.search', { query => $query }, 0, sub { push @feeds, $_[0] }); 368 369 Plagger->set_context(undef); 370 return @feeds; 326 371 } 327 372 trunk/plagger/lib/Plagger/ConfigLoader.pm
r1327 r1391 29 29 my($self, $config) = @_; 30 30 31 return unless $config->{include}; 32 for (@{ $config->{include} }) { 33 my $include = YAML::LoadFile($_); 31 my $includes = $config->{include} or return; 32 $includes = [ $includes ] unless ref $includes; 33 34 for my $file (@$includes) { 35 my $include = YAML::LoadFile($file); 34 36 35 37 for my $key (keys %{ $include }) { trunk/plagger/lib/Plagger/Plugin/Search/Estraier.pm
r1366 r1391 80 80 } 81 81 82 83 82 return $feed; 84 83 } trunk/plagger/lib/Plagger/Plugin/Search/KinoSearch.pm
r1185 r1391 9 9 use KinoSearch::Analysis::PolyAnalyzer; 10 10 11 sub init { 12 my $self = shift; 13 $self->SUPER::init(@_); 11 sub register { 12 my($self, $context) = @_; 13 $context->register_hook( 14 $self, 15 'publish.entry' => \&entry, 16 'plugin.init' => \&initialize, 17 'plugin.finalize' => \&finalize, 18 'searcher.search' => \&search, 19 ); 20 } 21 22 sub initialize { 23 my($self, $context, $args) = @_; 14 24 15 25 $self->conf->{invindex} ||= $self->cache->path_to('invindex'); … … 34 44 $self->{indexer}->spec_field( name => 'date' ); 35 45 $self->{indexer}->spec_field( name => 'author' ); 36 }37 38 sub register {39 my($self, $context) = @_;40 $context->register_hook(41 $self,42 'publish.entry' => \&entry,43 'publish.finalize' => \&finalize,44 'searcher.search' => \&search,45 );46 46 } 47 47 trunk/plagger/t/plugins/Search-Estraier/search.t
r1388 r1391 94 94 url: http://localhost:$main::port/node/plagger 95 95 --- expected 96 # xxx this is clumsy 97 no warnings 'redefine'; 98 *Plagger::context = sub { $context }; 99 96 Plagger->set_context($context); 100 97 my $feed; 101 98 $context->run_hook('searcher.search', { query => "murakami" }, 0, sub { $feed = $_[0] }); … … 118 115 url: http://localhost:$main::port/node/plagger 119 116 --- expected 117 Plagger->set_context($context); 120 118 ok -e $main::dir, 'invindex exists'; 121 122 # xxx this is clumsy123 no warnings 'redefine';124 *Plagger::context = sub { $context };125 119 126 120 my $feed; trunk/plagger/t/plugins/Search-KinoSearch/search.t
r1328 r1391 30 30 --- expected 31 31 ok -e $main::dir, 'invindex exists'; 32 33 # xxx this is clumsy 34 no warnings 'redefine'; 35 *Plagger::context = sub { $context }; 32 Plagger->set_context($context); 36 33 37 34 my $feed; … … 56 53 --- expected 57 54 ok -e $main::dir, 'invindex exists'; 58 59 # xxx this is clumsy 60 no warnings 'redefine'; 61 *Plagger::context = sub { $context }; 55 Plagger->set_context($context); 62 56 63 57 my $feed;
