| 1 |
package Plagger::Plugin::Subscription::BrowserHistory; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use base qw( Plagger::Plugin ); |
|---|
| 4 |
|
|---|
| 5 |
use UNIVERSAL::require; |
|---|
| 6 |
|
|---|
| 7 |
sub init { |
|---|
| 8 |
my $self = shift; |
|---|
| 9 |
$self->SUPER::init( @_ ); |
|---|
| 10 |
|
|---|
| 11 |
my $browser = $self->conf->{ browser } || $self->auto_configure; |
|---|
| 12 |
my $class = __PACKAGE__ . "::$browser"; |
|---|
| 13 |
$class->require or Plagger->context->error( "Error loading $class: $@" ); |
|---|
| 14 |
|
|---|
| 15 |
bless $self, $class; |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
sub auto_configure { |
|---|
| 19 |
my $self = shift; |
|---|
| 20 |
|
|---|
| 21 |
my $path = $self->conf->{ path }; |
|---|
| 22 |
if ( $path ) { |
|---|
| 23 |
if ( $path =~ /history\.dat$/i ) { |
|---|
| 24 |
Plagger->context->log( debug => "$path is a Mozilla bookmarks" ); |
|---|
| 25 |
return "Mozilla"; |
|---|
| 26 |
} elsif ( $path =~ /History\.plist$/ ) { |
|---|
| 27 |
Plagger->context->log( debug => "$path is a Safari bookmarks" ); |
|---|
| 28 |
return "Safari"; |
|---|
| 29 |
} else { |
|---|
| 30 |
Plagger->context->error( "Don't know Bookmark type of $path" ); |
|---|
| 31 |
} |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
if ( $^O eq 'MSWin32' ) { |
|---|
| 36 |
return "InternetExplorer"; |
|---|
| 37 |
} elsif ( $^O eq 'darwin' ) { |
|---|
| 38 |
return "Safari"; |
|---|
| 39 |
} else { |
|---|
| 40 |
return "Mozilla"; |
|---|
| 41 |
} |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
sub register { |
|---|
| 45 |
my ( $self, $context ) = @_; |
|---|
| 46 |
$context->register_hook( $self, |
|---|
| 47 |
'subscription.load' => $self->can( 'load' ), ); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
sub load { die "Override load" } |
|---|
| 51 |
|
|---|
| 52 |
1; |
|---|
| 53 |
|
|---|
| 54 |
__END__ |
|---|
| 55 |
|
|---|
| 56 |
=head1 NAME |
|---|
| 57 |
|
|---|
| 58 |
Plagger::Plugin::Subscription::BrowserHistory - Subscribe to URLs from your history |
|---|
| 59 |
|
|---|
| 60 |
=head1 SYNOPSIS |
|---|
| 61 |
|
|---|
| 62 |
# DWIM: auto-detect browsers (and path) from your OS |
|---|
| 63 |
- module: Subscription::Bookmarks |
|---|
| 64 |
|
|---|
| 65 |
# be a little explicit |
|---|
| 66 |
- module: Subscription::Bookmarks |
|---|
| 67 |
config: |
|---|
| 68 |
browser: InternetExplorer |
|---|
| 69 |
|
|---|
| 70 |
# auto-configure as Mozilla |
|---|
| 71 |
- module: Subscription::Bookmarks |
|---|
| 72 |
config: |
|---|
| 73 |
path: /path/to/bookmarks.html |
|---|
| 74 |
|
|---|
| 75 |
# auto-configure as Safari |
|---|
| 76 |
- module: Subscription::Bookmarks |
|---|
| 77 |
config: |
|---|
| 78 |
path: /path/to/Bookmarks.plist |
|---|
| 79 |
|
|---|
| 80 |
# more verbose |
|---|
| 81 |
- module: Subscription::Bookmarks |
|---|
| 82 |
config: |
|---|
| 83 |
browser: Mozilla |
|---|
| 84 |
path: /path/to/bookmarks.html |
|---|
| 85 |
|
|---|
| 86 |
=head1 DESCRIPTION |
|---|
| 87 |
|
|---|
| 88 |
This plugin allows you to subscribe to your History of your browser |
|---|
| 89 |
like IE, Firefox or Safari. |
|---|
| 90 |
|
|---|
| 91 |
=head1 CONFIGURATION |
|---|
| 92 |
|
|---|
| 93 |
=over 4 |
|---|
| 94 |
|
|---|
| 95 |
=item browser |
|---|
| 96 |
|
|---|
| 97 |
Specify your browser name. Possible values are 'InternetExplorer', 'Mozilla' and 'Safari'. |
|---|
| 98 |
|
|---|
| 99 |
=item path |
|---|
| 100 |
|
|---|
| 101 |
Specify path to your bookmarks file (or directory). |
|---|
| 102 |
|
|---|
| 103 |
=back |
|---|
| 104 |
|
|---|
| 105 |
Configuration is optional. When you omit I<browser>, this plugin auto-configure |
|---|
| 106 |
the default config. On Win32, I<browser> is "InternetExplorer" and I<path> is looked up |
|---|
| 107 |
using Windows Registry. On darwin, I<browser> is "Safari". Otherwise, I<browser> is set |
|---|
| 108 |
to "Mozilla", but I<path> isn't set. |
|---|
| 109 |
|
|---|
| 110 |
=head1 AUTHOR |
|---|
| 111 |
|
|---|
| 112 |
Tatsuhiko Miyagawa for Plagger::Plugin::Subscription::Bookmarks |
|---|
| 113 |
Franck Cuny |
|---|
| 114 |
|
|---|
| 115 |
=head1 SEE ALSO |
|---|
| 116 |
|
|---|
| 117 |
L<Plagger>, L<File::Mork> |
|---|