line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::RSS::PicLens; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26762
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
88
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use base qw( XML::RSS ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1003
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
XML::RSS::PicLens - Create a PicLens compatible RSS feed |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This document describes XML::RSS::PicLens version 0.04 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use XML::RSS::PicLens; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $feed = XML::RSS::PicLens->new; |
26
|
|
|
|
|
|
|
$feed->add_content( |
27
|
|
|
|
|
|
|
link => 'foo.jpg', |
28
|
|
|
|
|
|
|
image => 'foo.jpg', |
29
|
|
|
|
|
|
|
thumbnail => 'thumbs/foo.jpg', |
30
|
|
|
|
|
|
|
title => 'An bootiful foo' |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
print $feed->as_string; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
PicLens is an immersive media browser that can be launched directly from |
37
|
|
|
|
|
|
|
a web browser when visiting a supported site. It uses RSS autodiscovery |
38
|
|
|
|
|
|
|
to locate an RSS feed describing the available media. This module |
39
|
|
|
|
|
|
|
provides a simple interface for generating such a feed. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
See L for more information. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 INTERFACE |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 C<< new >> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Create a new C object. C is a |
48
|
|
|
|
|
|
|
subclass of L; any arguments to C are passed to the |
49
|
|
|
|
|
|
|
superclass's constructor. The RSS version defaults to 2.0. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
54
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
55
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( version => '2.0', @_ ); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->add_module( |
58
|
|
|
|
|
|
|
prefix => 'media', |
59
|
|
|
|
|
|
|
uri => 'http://search.yahoo.com/mrss' |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C<< add_content >> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Add media content to the feed: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$feed->add_content( |
70
|
|
|
|
|
|
|
link => 'foo.jpg', |
71
|
|
|
|
|
|
|
content => 'foo.jpg', |
72
|
|
|
|
|
|
|
thumbnail => 'thumbs/foo.jpg', |
73
|
|
|
|
|
|
|
title => 'An bootiful foo', |
74
|
|
|
|
|
|
|
content_type => 'image/jpeg', |
75
|
|
|
|
|
|
|
thumbnail_type => 'image/jpeg', |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
At least one of C, C must be supplied. Optionally you |
79
|
|
|
|
|
|
|
may supply C and C. If these are omitted they will default |
80
|
|
|
|
|
|
|
to values based on C or C. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The optional C and C items may be used to |
83
|
|
|
|
|
|
|
specify the MIME types of the content. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
For backwards compatibility with previous versions C and |
86
|
|
|
|
|
|
|
C are accepted as aliases for C and |
87
|
|
|
|
|
|
|
C. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub add_content { |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
0
|
0
|
|
|
|
|
croak "add_content must be called as a method" |
94
|
|
|
|
|
|
|
unless ref $self; |
95
|
0
|
0
|
|
|
|
|
croak "add_content needs a number of key => value pairs" |
96
|
|
|
|
|
|
|
if @_ % 1; |
97
|
0
|
|
|
|
|
|
my %args = @_; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Allow image and image_type as aliases for content and content_type |
100
|
|
|
|
|
|
|
exists $args{"image$_"} |
101
|
|
|
|
|
|
|
and $args{"content$_"} = delete $args{"image$_"} |
102
|
0
|
|
0
|
|
|
|
for '', '_type'; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $enc = sub { |
105
|
0
|
|
|
0
|
|
|
my $name = shift; |
106
|
0
|
|
|
|
|
|
my $tname = "${name}_type"; |
107
|
0
|
0
|
|
|
|
|
exists $args{$name} |
|
|
0
|
|
|
|
|
|
108
|
|
|
|
|
|
|
? ( |
109
|
|
|
|
|
|
|
$name => { |
110
|
|
|
|
|
|
|
url => $args{$name}, |
111
|
|
|
|
|
|
|
exists $args{$tname} |
112
|
|
|
|
|
|
|
? ( type => $args{$tname} ) |
113
|
|
|
|
|
|
|
: (), |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
) |
116
|
|
|
|
|
|
|
: (); |
117
|
0
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
0
|
0
|
0
|
|
|
|
croak "add_content needs at least one of content, thumbnail" |
120
|
|
|
|
|
|
|
unless exists $args{content} |
121
|
|
|
|
|
|
|
or exists $args{thumbnail}; |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
my $default |
124
|
|
|
|
|
|
|
= exists $args{content} |
125
|
|
|
|
|
|
|
? $args{content} |
126
|
|
|
|
|
|
|
: $args{thumbnail}; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $link = $args{link}; |
129
|
0
|
|
|
|
|
|
my $title = $args{title}; |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
$link = $default unless defined $link; |
132
|
0
|
0
|
|
|
|
|
( $title = $default ) =~ s!.*/!! unless defined $title; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$self->add_item( |
135
|
|
|
|
|
|
|
title => $title, |
136
|
|
|
|
|
|
|
link => $link, |
137
|
|
|
|
|
|
|
media => { $enc->( 'thumbnail' ), $enc->( 'content' ), }, |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 C<< add_image >> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
An alias for C for backwards compatibility with |
144
|
|
|
|
|
|
|
previous versions. Use C in new code. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
0
|
1
|
|
sub add_image { goto &add_content } |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 C<< as_string >> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Gets a string containing the XML for the feed. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
157
|
|
|
|
|
|
|
__END__ |