| 1 |
package Plagger::Plugin::Widget::BloglinesSubscription; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use base qw( Plagger::Plugin ); |
|---|
| 4 |
|
|---|
| 5 |
use HTML::Entities; |
|---|
| 6 |
use URI; |
|---|
| 7 |
|
|---|
| 8 |
sub register { |
|---|
| 9 |
my($self, $context) = @_; |
|---|
| 10 |
$context->register_hook( |
|---|
| 11 |
$self, |
|---|
| 12 |
'publish.entry.fixup' => \&add, |
|---|
| 13 |
); |
|---|
| 14 |
} |
|---|
| 15 |
|
|---|
| 16 |
sub add { |
|---|
| 17 |
my($self, $context, $args) = @_; |
|---|
| 18 |
|
|---|
| 19 |
my $feed = $args->{entry}->source || $args->{feed}; |
|---|
| 20 |
unless (exists $feed->meta->{bloglines_subid}) { |
|---|
| 21 |
$context->log(warn => "bloglines_subid not found. Skip"); |
|---|
| 22 |
return; |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
my $widget = Plagger::Plugin::Widget::BloglinesSubscription::Widget->new; |
|---|
| 27 |
$widget->{feed} = $feed; |
|---|
| 28 |
|
|---|
| 29 |
$args->{entry}->add_widget($widget); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
package Plagger::Plugin::Widget::BloglinesSubscription::Widget; |
|---|
| 33 |
|
|---|
| 34 |
sub new { bless {}, shift } |
|---|
| 35 |
|
|---|
| 36 |
sub html { |
|---|
| 37 |
my($self, $entry) = @_; |
|---|
| 38 |
my $uri = URI->new('http://www.bloglines.com/modsub'); |
|---|
| 39 |
|
|---|
| 40 |
$uri->query_form(subid => $self->{feed}->meta->{bloglines_subid}); |
|---|
| 41 |
|
|---|
| 42 |
my $url = HTML::Entities::encode($uri->as_string); |
|---|
| 43 |
return qq(<a href="$url"><img src="http://www.bloglines.com/images/favicon.gif" alt="Edit Bloglines Subscription" style="border:0;vertical-align:middle" /></a>); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
1; |
|---|
| 47 |
|
|---|
| 48 |
__END__ |
|---|
| 49 |
|
|---|
| 50 |
=head1 NAME |
|---|
| 51 |
|
|---|
| 52 |
Plagger::Plugin::Widget::BloglinesSubscription - Bloglines Subscription Widget |
|---|
| 53 |
|
|---|
| 54 |
=head1 SYNOPSIS |
|---|
| 55 |
|
|---|
| 56 |
- module: Subscription::Bloglines |
|---|
| 57 |
config: |
|---|
| 58 |
fetch_meta: 1 |
|---|
| 59 |
... |
|---|
| 60 |
|
|---|
| 61 |
- module: Widget::BloglinesSubscription |
|---|
| 62 |
|
|---|
| 63 |
=head1 DESCRIPTION |
|---|
| 64 |
|
|---|
| 65 |
This plugins puts a widget to edit subscription on Bloglines. This |
|---|
| 66 |
makes it easy for you to quickly unsubscribe to massively updated |
|---|
| 67 |
feeds, or update feed configuration to ignore content updates. |
|---|
| 68 |
|
|---|
| 69 |
You should use this plugin combined with |
|---|
| 70 |
L<Plagger::Plugin::Subscription::Bloglines> and set I<fetch_meta> |
|---|
| 71 |
config on. |
|---|
| 72 |
|
|---|
| 73 |
=head1 TIPS |
|---|
| 74 |
|
|---|
| 75 |
Due to how Bloglines works, the I<Unsubscribe> button on opened page |
|---|
| 76 |
doesn't work (it requires window.opener to be a valid Bloglines |
|---|
| 77 |
subscription page). Just append C<&remove=1> to the URL and you can |
|---|
| 78 |
unsubscribe from the feed. |
|---|
| 79 |
|
|---|
| 80 |
=head1 AUTHOR |
|---|
| 81 |
|
|---|
| 82 |
Tatsuhiko Miyagawa |
|---|
| 83 |
|
|---|
| 84 |
=head1 SEE ALSO |
|---|
| 85 |
|
|---|
| 86 |
L<Plagger>, L<Plagger::Plugin::Subscription::Bloglines>, L<http://www.bloglines.com/> |
|---|
| 87 |
|
|---|
| 88 |
=cut |
|---|