|
Revision 1276
(checked in by miyagawa, 2 years ago)
|
- Implement plagger-search dumb frontend. Fixes #62
- Added Atom stream consumer to store updated entry to Search::* backends. Fixes #354
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
#!/usr/bin/perl |
|---|
| 2 |
use strict; |
|---|
| 3 |
use warnings; |
|---|
| 4 |
|
|---|
| 5 |
use Encode; |
|---|
| 6 |
use FindBin; |
|---|
| 7 |
use Getopt::Long; |
|---|
| 8 |
|
|---|
| 9 |
use lib File::Spec->catdir($FindBin::Bin, '..', 'lib'); |
|---|
| 10 |
use Plagger; |
|---|
| 11 |
|
|---|
| 12 |
my $path = "$FindBin::Bin/../config.yaml"; |
|---|
| 13 |
GetOptions("--config=s", \$path); |
|---|
| 14 |
Getopt::Long::Configure("bundling"); # allows -c |
|---|
| 15 |
|
|---|
| 16 |
my $context = Plagger->new(config => $path); |
|---|
| 17 |
my $query = Encode::decode_utf8($ARGV[0]); |
|---|
| 18 |
|
|---|
| 19 |
my @feeds = $context->search($query); |
|---|
| 20 |
|
|---|
| 21 |
my $feed = $feeds[0]; |
|---|
| 22 |
binmode STDOUT, ":utf8"; |
|---|
| 23 |
print "Search for '$query': ", $feed->count, " entries found.\n\n"; |
|---|
| 24 |
|
|---|
| 25 |
for my $entry ($feed->entries) { |
|---|
| 26 |
print $entry->title, $entry->author ? "(by " . $entry->author . ")" : '', "\n"; |
|---|
| 27 |
print $entry->body; # summary |
|---|
| 28 |
print $entry->permalink, "\n"; |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|