| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: Atom feed for web |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Web::Atom; |
|
4
|
|
|
|
|
|
|
BEGIN { |
|
5
|
2
|
|
|
2
|
|
1209
|
$Web::Atom::VERSION = '0.1.0'; |
|
6
|
|
|
|
|
|
|
} |
|
7
|
2
|
|
|
2
|
|
16
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
68
|
|
|
8
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
67
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Web::Atom - Atom feed for web |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
version 0.1.0 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Write your own plugin to parse webpage and then generate Atom feed. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Web::Atom; |
|
25
|
|
|
|
|
|
|
my $feed = Web::Atom->new(p => 'Bank::Cathaybk::Creditbank'); |
|
26
|
|
|
|
|
|
|
$feed->id('http://feeds.hasname.com/feed/cathaybk.creditcard.atom'); |
|
27
|
|
|
|
|
|
|
print $feed->as_xml; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
5823
|
use Any::Moose; |
|
|
2
|
|
|
|
|
84753
|
|
|
|
2
|
|
|
|
|
15
|
|
|
32
|
|
|
|
|
|
|
has 'feed' => (is => 'rw', isa => 'XML::Atom::Feed', lazy_build => 1, handles => {as_xml => 'as_xml', id => 'id'}); |
|
33
|
|
|
|
|
|
|
has 'p' => (is => 'ro', isa => 'Str', required => 1); |
|
34
|
|
|
|
|
|
|
has 'plugin' => (is => 'rw', isa => 'Web::Atom::Plugin', lazy_build => 1); |
|
35
|
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
5001
|
use XML::Atom::Entry; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use XML::Atom::Feed; |
|
38
|
|
|
|
|
|
|
use XML::Atom::Link; |
|
39
|
|
|
|
|
|
|
use XML::Atom::Person; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _build_feed { |
|
42
|
|
|
|
|
|
|
my $self = shift; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $plugin = $self->plugin; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $author = XML::Atom::Person->new(Version => 1.0); |
|
47
|
|
|
|
|
|
|
$author->email($plugin->author_email); |
|
48
|
|
|
|
|
|
|
$author->name($plugin->author_name); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $link = XML::Atom::Link->new(Version => 1.0); |
|
51
|
|
|
|
|
|
|
$link->type('text/html'); |
|
52
|
|
|
|
|
|
|
$link->rel('alternate'); |
|
53
|
|
|
|
|
|
|
$link->href($plugin->url); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $feed = XML::Atom::Feed->new(Version => 1.0); |
|
56
|
|
|
|
|
|
|
$feed->add_link($link); |
|
57
|
|
|
|
|
|
|
$feed->author($author); |
|
58
|
|
|
|
|
|
|
$feed->title($plugin->title); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
foreach my $e (@{$plugin->entries}) { |
|
61
|
|
|
|
|
|
|
my $entry = XML::Atom::Entry->new(Version => 1.0); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if (defined $entry->author) { |
|
64
|
|
|
|
|
|
|
my $entryAuthor = XML::Atom::Author->new(Version => 1.0); |
|
65
|
|
|
|
|
|
|
$entryAuthor->email($e->author_email); |
|
66
|
|
|
|
|
|
|
$entryAuthor->name($e->author_name); |
|
67
|
|
|
|
|
|
|
$entry->author($entryAuthor); |
|
68
|
|
|
|
|
|
|
} else { |
|
69
|
|
|
|
|
|
|
$entry->author($author); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$entry->id($e->id); |
|
73
|
|
|
|
|
|
|
$entry->content($e->content); |
|
74
|
|
|
|
|
|
|
$entry->title($e->title); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $link = XML::Atom::Link->new(Version => 1.0); |
|
77
|
|
|
|
|
|
|
$link->type('text/html'); |
|
78
|
|
|
|
|
|
|
$link->rel('alternate'); |
|
79
|
|
|
|
|
|
|
$link->href($e->url); |
|
80
|
|
|
|
|
|
|
$entry->add_link($link); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$feed->add_entry($entry); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return $feed; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _build_plugin { |
|
89
|
|
|
|
|
|
|
my $self = shift; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $p = $self->p; |
|
92
|
|
|
|
|
|
|
my $pname = "Web::Atom::$p"; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
eval "require $pname;"; |
|
95
|
|
|
|
|
|
|
$pname->new; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Gea-Suan Lin, C<< >> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright 2011 Gea-Suan Lin. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is released under 3-clause BSD license. See |
|
107
|
|
|
|
|
|
|
L for more |
|
108
|
|
|
|
|
|
|
information. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |