| 1 | package Plagger::Plugin::Notify::OpenBrowser; | ||
| 2 | use strict; | ||
| 3 | use base qw( Plagger::Plugin ); | ||
| 4 | |||
| 5 | sub init { | ||
| 6 | my $self = shift; | ||
| 7 | $self->SUPER::init(@_); | ||
| 8 | |||
| 9 | my $class = 'Plagger::Plugin::Notify::OpenBrowser::' . lc($^O); | ||
| 10 | eval "require $class;"; | ||
| 11 | if ($@) { | ||
| 12 | Plagger->context->error("Browser plugin doesn't run on your platform $^O"); | ||
| 13 | } | ||
| 14 | bless $self, $class; | ||
| 15 | } | ||
| 16 | |||
| 17 | sub register { | ||
| 18 | my($self, $context) = @_; | ||
| 19 | |||
| 20 | $context->register_hook( | ||
| 21 | $self, | ||
| 22 | 'publish.entry' => \&entry, | ||
| 23 | ); | ||
| 24 | } | ||
| 25 | |||
| 26 | sub entry { | ||
| 27 | my($self, $context, $args) = @_; | ||
| 28 | $self->open($args->{entry}->permalink); | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | __END__ |