Changeset 1186
- Timestamp:
- 07/30/06 16:27:52
- Files:
-
- trunk/plagger/lib/Plagger/Plugin/Search/Estraier.pm (modified) (4 diffs)
- trunk/plagger/t/TestPlagger.pm (modified) (2 diffs)
- trunk/plagger/t/plugins/Search-Estraier (added)
- trunk/plagger/t/plugins/Search-Estraier/search.t (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Search/Estraier.pm
r675 r1186 10 10 $self->SUPER::init(@_); 11 11 12 $self->conf->{url} ||= "http://localhost:1978/node/ Plagger";12 $self->conf->{url} ||= "http://localhost:1978/node/plagger"; 13 13 $self->conf->{username} ||= "admin"; 14 14 $self->conf->{password} ||= "admin"; … … 27 27 $self, 28 28 'publish.entry' => \&entry, 29 'searcher.search' => \&search, 29 30 ); 30 31 } … … 52 53 } 53 54 55 sub search { 56 my($self, $context, $args) = @_; 57 58 my $cond = Search::Estraier::Condition->new; 59 $cond->set_phrase( encode_utf8($args->{query}) ); 60 61 my $nres = $self->{node}->search($cond, 0); 62 defined $nres or $context->error("search failed: " . $self->{node}->status); 63 64 my $feed = Plagger::Feed->new; 65 $feed->type('search:Estraier'); 66 $feed->title("Search: $args->{query}"); 67 68 for my $i ( 0 .. $nres->doc_num - 1 ) { 69 my $doc = $nres->get_doc($i); 70 my $entry = Plagger::Entry->new; 71 72 $entry->link( $doc->attr('@uri') ); 73 $entry->title( decode_utf8($doc->attr('@title')) ); 74 $entry->date( $doc->attr('@cdate') ) if $doc->attr('@cdate'); 75 $entry->author( decode_utf8($doc->attr('@author')) ) if $doc->attr('@author'); 76 $entry->body( decode_utf8($doc->snippet) ); 77 78 $feed->add_entry($entry); 79 } 80 81 82 return $feed; 83 } 84 54 85 sub _u { 55 86 my $str = shift; … … 70 101 - module: Search::Estraier 71 102 config: 72 url: http://localhost:1978/node/ Plagger103 url: http://localhost:1978/node/plagger 73 104 username: foobar 74 105 password: p4ssw0rd trunk/plagger/t/TestPlagger.pm
r1173 r1186 3 3 use Plagger; 4 4 5 our @EXPORT = qw(test_requires test_requires_network run_eval_expected slurp_file file_contains file_doesnt_contain); 5 our @EXPORT = qw(test_requires test_requires_network test_requires_command 6 run_eval_expected slurp_file file_contains file_doesnt_contain); 6 7 7 8 sub test_requires() { … … 31 32 plan skip_all => "Test requires network which is not available now."; 32 33 } 34 } 35 36 sub test_requires_command { 37 my $command = $self; 38 for my $path (split /:/, $ENV{PATH}) { 39 if (-e File::Spec->catfile($path, $command) && -x _) { 40 return 1; 41 } 42 } 43 plan skip_all => "Test requires '$command' command but it's not found"; 33 44 } 34 45
