|
Revision 346
(checked in by miyagawa, 3 years ago)
|
- Add new plugin Filter::ImageInfo? to fetch width & height from feed images. Fixes #80
- Plagger::TT plugins
- Plagger::Util::dumbnail function to resize images using img attributes
- Add $feed->image to $entry->icon when copied to SmartFeed?
- Fixed Frepa regular expression since they updated HTML
- Updated Gmail template to fix big logo issue. Fixes #68
|
- Property svn:keywords set to
Id Revision
|
| Line | |
|---|
| 1 |
package Plagger::Plugin::SmartFeed; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use base qw( Plagger::Plugin ); |
|---|
| 4 |
|
|---|
| 5 |
use Plagger::Tag; |
|---|
| 6 |
|
|---|
| 7 |
sub rule_hook { 'smartfeed.entry' } |
|---|
| 8 |
|
|---|
| 9 |
sub register { |
|---|
| 10 |
my($self, $context) = @_; |
|---|
| 11 |
$context->register_hook( |
|---|
| 12 |
$self, |
|---|
| 13 |
'smartfeed.init' => $self->can('feed_init'), |
|---|
| 14 |
'smartfeed.entry' => $self->can('feed_entry'), |
|---|
| 15 |
'smartfeed.finalize' => $self->can('feed_finalize'), |
|---|
| 16 |
); |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
sub feed_init { |
|---|
| 20 |
my($self, $context, $args) = @_; |
|---|
| 21 |
|
|---|
| 22 |
my $feed = Plagger::Feed->new; |
|---|
| 23 |
$feed->type('smartfeed'); |
|---|
| 24 |
$feed->id( $self->conf->{id} || ('smartfeed:' . $self->rule->id) ); |
|---|
| 25 |
$feed->title( $self->conf->{title} || "Entries " . $self->rule->as_title ); |
|---|
| 26 |
|
|---|
| 27 |
$self->{feed} = $feed; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
sub feed_entry { |
|---|
| 31 |
my($self, $context, $args) = @_; |
|---|
| 32 |
|
|---|
| 33 |
my $entry = $args->{entry}->clone; |
|---|
| 34 |
my $feed = $args->{feed}->clone; |
|---|
| 35 |
$feed->clear_entries; |
|---|
| 36 |
$entry->source($feed); |
|---|
| 37 |
$entry->icon($feed->image) if !$entry->icon && $feed->image; |
|---|
| 38 |
|
|---|
| 39 |
$self->{feed}->add_entry($entry); |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
sub feed_finalize { |
|---|
| 43 |
my($self, $context, $args) = @_; |
|---|
| 44 |
$context->update->add($self->{feed}) if $self->{feed}->count; |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
1; |
|---|