package Plagger::Plugin::Subscription::BrowserHistory; use strict; use base qw( Plagger::Plugin ); use UNIVERSAL::require; sub init { my $self = shift; $self->SUPER::init( @_ ); my $browser = $self->conf->{ browser } || $self->auto_configure; my $class = __PACKAGE__ . "::$browser"; $class->require or Plagger->context->error( "Error loading $class: $@" ); bless $self, $class; } sub auto_configure { my $self = shift; my $path = $self->conf->{ path }; if ( $path ) { if ( $path =~ /history\.dat$/i ) { Plagger->context->log( debug => "$path is a Mozilla bookmarks" ); return "Mozilla"; } elsif ( $path =~ /History\.plist$/ ) { Plagger->context->log( debug => "$path is a Safari bookmarks" ); return "Safari"; } else { Plagger->context->error( "Don't know Bookmark type of $path" ); } } # Hmm, no clue for path. Find it automatically ... only works for IE if ( $^O eq 'MSWin32' ) { return "InternetExplorer"; } elsif ( $^O eq 'darwin' ) { return "Safari"; # xxx } else { return "Mozilla"; # xxx don't work because path is missing } } sub register { my ( $self, $context ) = @_; $context->register_hook( $self, 'subscription.load' => $self->can( 'load' ), ); } sub load { die "Override load" } 1; __END__ =head1 NAME Plagger::Plugin::Subscription::BrowserHistory - Subscribe to URLs from your history =head1 SYNOPSIS # DWIM: auto-detect browsers (and path) from your OS - module: Subscription::Bookmarks # be a little explicit - module: Subscription::Bookmarks config: browser: InternetExplorer # auto-configure as Mozilla - module: Subscription::Bookmarks config: path: /path/to/bookmarks.html # auto-configure as Safari - module: Subscription::Bookmarks config: path: /path/to/Bookmarks.plist # more verbose - module: Subscription::Bookmarks config: browser: Mozilla path: /path/to/bookmarks.html =head1 DESCRIPTION This plugin allows you to subscribe to your History of your browser like IE, Firefox or Safari. =head1 CONFIGURATION =over 4 =item browser Specify your browser name. Possible values are 'InternetExplorer', 'Mozilla' and 'Safari'. =item path Specify path to your bookmarks file (or directory). =back Configuration is optional. When you omit I, this plugin auto-configure the default config. On Win32, I is "InternetExplorer" and I is looked up using Windows Registry. On darwin, I is "Safari". Otherwise, I is set to "Mozilla", but I isn't set. =head1 AUTHOR Tatsuhiko Miyagawa for Plagger::Plugin::Subscription::Bookmarks Franck Cuny =head1 SEE ALSO L, L