root/trunk/plagger/lib/Plagger/Plugin/Subscription/Bookmarks/Safari.pm

Revision 995 (checked in by youpy, 14 years ago)

add Plugin::Subscription::Bookmarks::Safari

Line 
1 package Plagger::Plugin::Subscription::Bookmarks::Safari;
2 use base qw( Plagger::Plugin::Subscription::Bookmarks );
3
4 use Mac::Tie::PList;
5 use URI;
6
7 sub load {
8     my($self, $context) = @_;
9
10     my $plist = Mac::Tie::PList->new_from_file($self->conf->{path});
11     $self->find_feed($context, $plist);
12 }
13
14 sub find_feed {
15     my($self, $context, $plist) = @_;
16
17     if(my @children = @{$plist->{Children}}) {
18         for my $child (@children) {
19             $self->find_feed($context, $child);
20         }
21     } elsif($plist->{URLString}) {
22         my $url = new URI($plist->{URLString});
23
24         if($url->scheme eq 'feed') {
25             if($url->as_string =~ m|^feed:https|) {
26                 $url->scheme('');
27             } else {
28                 $url->scheme('http');
29             }
30         }
31
32         my $feed = Plagger::Feed->new;
33         $feed->url($url->as_string);
34         $feed->title($plist->{URIDictionary}->{title});
35         $context->subscription->add($feed);
36     }
37 }
38    
39 1;
Note: See TracBrowser for help on using the browser.