line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Atom::Ext::Threading; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
492
|
|
|
1
|
|
|
|
|
70
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
5
|
use base 'XML::Atom::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
939
|
|
6
|
|
|
|
|
|
|
use XML::Atom 0.28; |
7
|
|
|
|
|
|
|
use XML::Atom::Entry; |
8
|
|
|
|
|
|
|
use XML::Atom::Link; |
9
|
|
|
|
|
|
|
use XML::Atom::Ext::Threading::InReplyTo; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#unless ($XML::Atom::VERSION > 0.28) { |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
require XML::Atom::Base; |
16
|
|
|
|
|
|
|
no warnings 'redefine'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
*XML::Atom::Base::get_attr = sub { |
19
|
|
|
|
|
|
|
my $obj = shift; |
20
|
|
|
|
|
|
|
my $val; |
21
|
|
|
|
|
|
|
if (@_ == 1) { |
22
|
|
|
|
|
|
|
my ($attr) = @_; |
23
|
|
|
|
|
|
|
$val = $obj->elem->getAttribute($attr); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif (@_ == 2) { |
26
|
|
|
|
|
|
|
my ($ns, $attr) = @_; |
27
|
|
|
|
|
|
|
if (XML::Atom->LIBXML) { |
28
|
|
|
|
|
|
|
$val = $obj->elem->getAttributeNS($ns->{uri}, $attr); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
|
|
|
|
|
|
my $attr = "$ns->{prefix}:$attr"; |
32
|
|
|
|
|
|
|
require XML::XPath::Node::Namespace; |
33
|
|
|
|
|
|
|
my $ns = XML::XPath::Node::Namespace->new($ns->{prefix}, $ns->{uri}); |
34
|
|
|
|
|
|
|
$obj->elem->appendNamespace($ns); |
35
|
|
|
|
|
|
|
$val = $obj->elem->getAttribute($attr); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
if ($] >= 5.008) { |
39
|
|
|
|
|
|
|
require Encode; |
40
|
|
|
|
|
|
|
Encode::_utf8_off($val) unless $XML::Atom::ForceUnicode; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
$val; |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
*XML::Atom::Base::mk_attr_accessors = sub { |
46
|
|
|
|
|
|
|
my $class = shift; |
47
|
|
|
|
|
|
|
my (@list) = @_; |
48
|
|
|
|
|
|
|
my $override_ns; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
if (ref $list[-1]) { |
51
|
|
|
|
|
|
|
my $ns = pop @list; |
52
|
|
|
|
|
|
|
$ns = $ns->[0] if ref $ns eq 'ARRAY'; |
53
|
|
|
|
|
|
|
if (eval { $ns->isa('XML::Atom::Namespace') }) { |
54
|
|
|
|
|
|
|
$override_ns = $ns; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif (ref $ns eq 'HASH') { |
57
|
|
|
|
|
|
|
$override_ns = XML::Atom::Namespace->new(%$ns); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif (not ref $ns) { |
60
|
|
|
|
|
|
|
$override_ns = $ns; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
no strict 'refs'; |
65
|
|
|
|
|
|
|
for my $attr (@list) { |
66
|
|
|
|
|
|
|
(my $meth = $attr) =~ tr/\-/_/; |
67
|
|
|
|
|
|
|
*{"${class}::$meth"} = sub { |
68
|
|
|
|
|
|
|
my $obj = shift; |
69
|
|
|
|
|
|
|
if (@_) { |
70
|
|
|
|
|
|
|
return $obj->set_attr($override_ns || $obj->ns, $attr, $_[0]); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
|
|
|
|
|
|
return $obj->get_attr($override_ns || $obj->ns, $attr); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
$class->_add_attribute($attr); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
82
|
|
|
|
|
|
|
no warnings 'redefine'; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# thr:in-reply-to |
85
|
|
|
|
|
|
|
XML::Atom::Entry->mk_object_accessor( |
86
|
|
|
|
|
|
|
'in-reply-to' => 'XML::Atom::Ext::Threading::InReplyTo', |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
# thr:total |
89
|
|
|
|
|
|
|
XML::Atom::Entry->mk_elem_accessors( |
90
|
|
|
|
|
|
|
qw( total ), __PACKAGE__->element_ns, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
# link[@thr:count], link[@thr:updated] |
93
|
|
|
|
|
|
|
XML::Atom::Link->mk_attr_accessors( |
94
|
|
|
|
|
|
|
qw( count updated ), __PACKAGE__->element_ns, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub element_ns { |
99
|
|
|
|
|
|
|
XML::Atom::Namespace->new(thr => 'http://purl.org/syndication/thread/1.0'); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
XML::Atom::Ext::Threading - XML::Atom extension for Atom Threading Extensions (RFC 4685) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
use XML::Atom::Entry; |
111
|
|
|
|
|
|
|
use XML::Atom::Link; |
112
|
|
|
|
|
|
|
use XML::Atom::Ext::Threading; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $entry = XML::Atom::Entry->new; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# "in-reply-to" extension element |
117
|
|
|
|
|
|
|
my $reply = XML::Atom::Ext::Threading::InReplyTo->new; |
118
|
|
|
|
|
|
|
$reply->ref('tag:example.org,2005:1'); |
119
|
|
|
|
|
|
|
$reply->href('http://www.example.org/entries/1'); |
120
|
|
|
|
|
|
|
$reply->type('application/xhtml+xml'); |
121
|
|
|
|
|
|
|
$entry->in_reply_to($reply); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# "replies" link relation |
124
|
|
|
|
|
|
|
my $link = XML::Atom::Link->new; |
125
|
|
|
|
|
|
|
$link->rel('replies'); |
126
|
|
|
|
|
|
|
$link->type('application/atom+xml'); |
127
|
|
|
|
|
|
|
$link->href('http://www.example.org/mycommentsfeed.xml'); |
128
|
|
|
|
|
|
|
$link->count(10); |
129
|
|
|
|
|
|
|
$link->updated('2005-07-28T12:10:00Z'); |
130
|
|
|
|
|
|
|
$entry->add_link($link); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# "total" extension element |
133
|
|
|
|
|
|
|
$entry->total(10); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 element_ns |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
returns the Atom Threading namespace, C |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
NAKAGAWA Masaki Emasaki@cpan.orgE |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
148
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L, L |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |