| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Loy::Atom::Threading; |
|
2
|
3
|
|
|
3
|
|
3475
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
96
|
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
138
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $PREFIX; |
|
6
|
3
|
|
|
3
|
|
84
|
BEGIN { $PREFIX = 'thr' }; |
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
|
|
17
|
use XML::Loy with => ( |
|
9
|
|
|
|
|
|
|
prefix => $PREFIX, |
|
10
|
|
|
|
|
|
|
namespace => 'http://purl.org/syndication/thread/1.0' |
|
11
|
3
|
|
|
3
|
|
16
|
); |
|
|
3
|
|
|
|
|
6
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
31
|
use Carp qw/carp/; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
2176
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# No constructor |
|
17
|
|
|
|
|
|
|
sub new { |
|
18
|
1
|
|
|
1
|
1
|
419
|
carp 'Only use ' . __PACKAGE__ . ' as an extension to Atom'; |
|
19
|
1
|
|
|
|
|
594
|
return; |
|
20
|
|
|
|
|
|
|
}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Set 'in-reply-to' element |
|
24
|
|
|
|
|
|
|
sub in_reply_to { |
|
25
|
10
|
|
|
10
|
1
|
22
|
my ($self, $ref, $param) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Add in-reply-to |
|
28
|
10
|
100
|
|
|
|
35
|
if ($ref) { |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# No ref defined |
|
31
|
4
|
50
|
|
|
|
11
|
return unless defined $ref; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Adding a related link as advised in the spec |
|
34
|
4
|
50
|
|
|
|
10
|
if (defined $param->{href}) { |
|
35
|
4
|
|
|
|
|
16
|
my $link = $self->link(related => $param->{href}); |
|
36
|
4
|
100
|
|
|
|
17
|
$link->attr->{type} = $param->{type} if $param->{type}; |
|
37
|
|
|
|
|
|
|
}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
48
|
$param->{ref} = $ref; |
|
40
|
4
|
|
|
|
|
13
|
return $self->add('in-reply-to' => $param ); |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Current node is root |
|
44
|
6
|
100
|
|
|
|
19
|
unless ($self->parent) { |
|
45
|
2
|
|
|
|
|
29
|
return $self->at('*')->children('in-reply-to'); |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Return collection |
|
49
|
4
|
|
|
|
|
110
|
return $self->children('in-reply-to'); |
|
50
|
|
|
|
|
|
|
}; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Add 'link' element for replies |
|
54
|
|
|
|
|
|
|
sub replies { |
|
55
|
6
|
|
|
6
|
1
|
14
|
my $self = shift; |
|
56
|
6
|
|
|
|
|
9
|
my $href = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Add link |
|
59
|
6
|
100
|
|
|
|
17
|
if ($href) { |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
6
|
my %param = %{ shift(@_) }; |
|
|
3
|
|
|
|
|
12
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
9
|
my %new_param = (href => $href); |
|
64
|
3
|
50
|
|
|
|
8
|
if (exists $param{count}) { |
|
65
|
3
|
|
|
|
|
9
|
$new_param{$PREFIX . ':count'} = delete $param{count}; |
|
66
|
|
|
|
|
|
|
}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# updated parameter exists |
|
69
|
3
|
100
|
|
|
|
10
|
if (exists $param{updated}) { |
|
70
|
2
|
|
|
|
|
4
|
my $date = delete $param{updated}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Date is no object |
|
73
|
2
|
50
|
|
|
|
26
|
$date = XML::Loy::Date::RFC3339->new($date) unless ref $date; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Set parameter |
|
76
|
2
|
|
|
|
|
9
|
$new_param{$PREFIX . ':updated'} = $date->to_string; |
|
77
|
|
|
|
|
|
|
}; |
|
78
|
|
|
|
|
|
|
|
|
79
|
3
|
|
33
|
|
|
23
|
$new_param{type} = $param{type} // $self->mime; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Add atom link |
|
82
|
3
|
|
|
|
|
18
|
return $self->link(rel => 'replies', %new_param ); |
|
83
|
|
|
|
|
|
|
}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Get replies |
|
86
|
3
|
|
|
|
|
10
|
my $replies = $self->link('replies'); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Return first link |
|
89
|
3
|
50
|
|
|
|
68
|
return $replies->[0] if $replies->[0]; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
return; |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Add total value |
|
96
|
|
|
|
|
|
|
sub total { |
|
97
|
10
|
|
|
10
|
1
|
25
|
my ($self, $count, $param) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Set count |
|
100
|
10
|
100
|
|
|
|
27
|
if ($count) { |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Set new total element |
|
103
|
5
|
|
50
|
|
|
33
|
return $self->set(total => ($param || {}) => $count); |
|
104
|
|
|
|
|
|
|
}; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Get total |
|
107
|
5
|
|
|
|
|
8
|
my $total; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Current node is root |
|
110
|
5
|
100
|
|
|
|
21
|
unless ($self->parent) { |
|
111
|
1
|
|
|
|
|
14
|
$total = $self->at('*')->children('total'); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Current node is entry or something |
|
115
|
|
|
|
|
|
|
else { |
|
116
|
4
|
|
|
|
|
93
|
$total = $self->children('total'); |
|
117
|
|
|
|
|
|
|
}; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# No total set |
|
120
|
5
|
50
|
|
|
|
44
|
return 0 unless $total = $total->[0]; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Return count |
|
123
|
5
|
50
|
|
|
|
34
|
return $total->text if $total->text; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return 0; |
|
126
|
|
|
|
|
|
|
}; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |