EmbedFLV/Template.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 54 CC 3 SCAR 18.4
CC
3
Cov
0%
process
12.0
new
2.0
BEGIN
2.0
CRAP 6.3
1 package Apache2::EmbedFLV::Template;
2  
3 use strict;
4 use warnings;
5  
6 use Template;
7  
8 my $default_template=<<EOF;
9 <html>
10 <head>
11 </head>
12 <body>
13 <style media="screen" type="text/css">
14 body {
15 background:#262523 none repeat scroll 0 0;
16 color:#DDDDCC;
17 font-family:"Trebuchet MS",Helvetica,Arial,sans-serif;
18 font-size:14px;
19 font-size-adjust:none;
20 font-stretch:normal;
21 font-style:normal;
22 font-variant:normal;
23 font-weight:normal;
24 line-height:1.5em;
25 }
26 /* Header */
27 #header {
28 margin: 1em auto;
29 width: 40em;
30 }
31  
32 #header a, #header a:visited, #header a:active {
33 color: #eef;
34 text-decoration: none;
35 }
36  
37 #header a:hover {
38 color: #ccb;
39 }
40 #posts {
41 margin: 0 auto;
42 width: 42em;
43 }
44  
45 .post {
46 background-color:#363B39;
47 border:1px solid #494949;
48 margin: 1.5em 0;
49 padding: 1em;
50 }
51
52  
53 h1 {
54 font-size: 3em;
55 font-weight: bold;
56 line-height: 1em;
57 }
58 .video{
59 text-align:center;
60 }
61 </style>
62 <div id="header">
63 <h1>Apache2::EmbedFLV</h1>
64 </div>
65  
66 <div id="posts">
67 <div class="post">
68 <div class="video">
69 [% video %]
70 </div>
71 </div>
72 </div>
73  
74 <p align="center">Apache2::EmbedFLV - <a href="http://axiombox.com/apache2-embedflv">http://axiombox.com/apache2-embedflv</a></p>
75
76 </body></html>
77 EOF
78  
79 my $video = <<EOF;
80 <script type="text/javascript">
81 %%% js %%%
82 </script>
83  
84 <a
85 href="%%% url %%%"
86 style="display:block;width:425px;height:300px;text-align:center;"
87 id="player">
88 </a>
89  
90 <script language="JavaScript">
91 flowplayer("player", "%%% flowplayer %%%");
92 </script>
93 EOF
94  
95 sub new {
96 my $self = shift;
97 return bless {};
98 }
99  
100 sub process {
101 my($self, %opts) = @_;
102 my $opts = \%opts;
103  
104 if($opts->{template} and -r $opts->{template}) {
105 open my $fh, "<", $opts->{template} or die $!;
106 $default_template = "";
107 while(<$fh>) {
108 $default_template .= $_;
109 }
110 close $fh;
111 }
112  
113 my $flowplayer = "/flowplayer.swf";
114 $flowplayer = $opts->{flowplayer} if $opts->{flowplayer};
115  
116 my $js = do {local $/;<DATA>};
117  
118 my $url = $opts->{uri}."?".$opts->{md5};
119 $video =~ s/%%% url %%%/$url/;
120 $video =~ s/%%% js %%%/$js/;
121 $video =~ s/%%% flowplayer %%%/$flowplayer/;
122  
123 my $tt = Template->new;
124 my $output;
125  
126 $tt->process(\$default_template, {
127 video => $video,
128 }, \$output);
129
130 return $output;
131  
132 }
133  
134 1;
135  
136 __DATA__