File Coverage

blib/lib/HTML/WebMake/Media.pm
Criterion Covered Total %
statement 15 33 45.4
branch 0 2 0.0
condition 0 3 0.0
subroutine 5 9 55.5
pod 0 4 0.0
total 20 51 39.2


line stmt bran cond sub pod time code
1             #
2              
3             package HTML::WebMake::Media;
4              
5              
6 1     1   5 use HTML::WebMake::DataSource;
  1         1  
  1         25  
7 1     1   478 use HTML::WebMake::MediaContent;
  1         46  
  1         37  
8 1     1   14 use Carp;
  1         1  
  1         84  
9 1     1   4 use strict;
  1         2  
  1         35  
10              
11 1         358 use vars qw{
12             @ISA
13 1     1   5 };
  1         2  
14              
15             @ISA = qw(HTML::WebMake::DataSource);
16              
17              
18             ###########################################################################
19              
20             sub new ($$$$$) {
21 0     0 0   my $class = shift;
22 0   0       $class = ref($class) || $class;
23 0           my ($main, $src, $name, $attrs) = @_;
24 0           my $self = $class->SUPER::new (@_);
25              
26 0 0         if(defined $attrs->{'map'}) {
27 0           $self->{'map'} = $main->{util}->parse_boolean ($attrs->{'map'});
28             } else {
29 0           $self->{'map'} = $main->{metadata}->get_attrdefault ('map');
30             }
31              
32 0           bless ($self, $class);
33 0           $self;
34             }
35              
36             # -------------------------------------------------------------------------
37              
38             sub add_text {
39 0     0 0   my ($self, $name, $text, $location, $lastmod) = @_;
40              
41             # the tag can only be used to refer to binary media, such
42             # as images, which can be accessed by a web browser. Therefore
43             # trying to load media from a database or delimiter-separated-values
44             # file is pointless, as the web browser cannot load media from there.
45 0           carp "cannot use tag with the $self->{proto} protocol\n";
46             }
47              
48             # -------------------------------------------------------------------------
49              
50             sub add_location {
51 0     0 0   my ($self, $name, $location, $lastmod) = @_;
52              
53 0           my $url = $self->{hdlr}->get_location_url ($location);
54 0           $self->{main}->add_url ($name, $url);
55              
56             # add a placeholder piece of content with the same name so
57             # that metadata can be attached to Media items.
58             # this is code formerly separated to Main::add_media_placeholder_content
59             # but here it can read media object atributes
60              
61 0           my $cont = new HTML::WebMake::MediaContent ($self->{main}, $name, {
62             'format' => 'text/html',
63             'map' => $self->{'map'},
64             });
65              
66 0           $cont->add_ref_from_url ($url);
67             }
68              
69             # -------------------------------------------------------------------------
70              
71             sub as_string {
72 0     0 0   my ($self) = @_;
73 0           "";
74             }
75              
76             # -------------------------------------------------------------------------
77              
78             1;