|
Revision 1741
(checked in by miyagawa, 2 years ago)
|
merge from hackathon-summary
|
| Line | |
|---|
| 1 |
package Plagger::Plugin::Summary::Auto; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use base qw( Plagger::Plugin ); |
|---|
| 4 |
|
|---|
| 5 |
use Plagger::Util; |
|---|
| 6 |
|
|---|
| 7 |
sub register { |
|---|
| 8 |
my($self, $context) = @_; |
|---|
| 9 |
$context->register_hook( |
|---|
| 10 |
$self, |
|---|
| 11 |
'update.entry.fixup' => \&auto_summarize, |
|---|
| 12 |
); |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
sub auto_summarize { |
|---|
| 16 |
my($self, $context, $args) = @_; |
|---|
| 17 |
|
|---|
| 18 |
if ($args->{entry}->body && !$args->{entry}->summary) { |
|---|
| 19 |
|
|---|
| 20 |
my $summary = $context->run_hook_once('summarizer.summarize', { |
|---|
| 21 |
entry => $args->{entry}, |
|---|
| 22 |
feed => $args->{feed}, |
|---|
| 23 |
text => $args->{entry}->body, |
|---|
| 24 |
}); |
|---|
| 25 |
$args->{entry}->summary($summary) if defined $summary; |
|---|
| 26 |
} |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
1; |
|---|
| 30 |
__END__ |
|---|
| 31 |
|
|---|
| 32 |
=head1 NAME |
|---|
| 33 |
|
|---|
| 34 |
Plagger::Plugin::Summary::Auto - Auto-create summary for entry without summary |
|---|
| 35 |
|
|---|
| 36 |
=head1 SYNOPSIS |
|---|
| 37 |
|
|---|
| 38 |
- module: Summary::Auto |
|---|
| 39 |
|
|---|
| 40 |
=head1 DESCRIPTION |
|---|
| 41 |
|
|---|
| 42 |
This plugin automatically creates summary for entries without summary, |
|---|
| 43 |
using Plagger::Util::summarize function. Summary::Auto is autoloaded |
|---|
| 44 |
by core and you don't actually need to specify in config files. |
|---|
| 45 |
|
|---|
| 46 |
=head1 AUTHOR |
|---|
| 47 |
|
|---|
| 48 |
Tatsuhiko Miyagawa |
|---|
| 49 |
|
|---|
| 50 |
=head1 SEE ALSO |
|---|
| 51 |
|
|---|
| 52 |
L<Plagger> |
|---|
| 53 |
|
|---|
| 54 |
=cut |
|---|