Apache2-EmbedMP3
view release on metacpan or search on metacpan
lib/Apache2/EmbedMP3/Template.pm view on Meta::CPAN
font-size: 3em;
font-weight: bold;
line-height: 1em;
}
.video{
text-align:center;
}
</style>
<div id="header">
<h1>Apache2::EmbedMP3</h1>
<h2>[% artist %] - [% title %]</h2>
<h3>[% album %] ([% year %])</h3>
</div>
<div id="posts">
<div class="post">
<div class="video">
[% player %]
</div>
</div>
<div class="post">
<pre>
[% lyrics %]
</pre>
</div>
</div>
<p align="center">Apache2::EmbedMP3 - <a href="http://axiombox.com/apache2-embedmp3">http://axiombox.com/apache2-embedmp3</a></p>
</body></html>
EOF
my $player = <<EOF;
<script type="text/javascript" src="%%% js %%%"></script>
<object
type="application/x-shockwave-flash"
data="%%% wpaudioplayer %%%"
id="audioplayer1"
height="24"
width="290">
<param
name="movie"
value="%%% wpaudioplayer %%%">
<param
name="FlashVars"
value="playerID=1&soundFile=%%% url %%%">
<param
name="quality" value="high">
<param
name="menu" value="false">
<param
name="wmode" value="transparent">
</object>
EOF
sub new {
my $self = shift;
return bless {};
}
sub process {
my($self, %opts) = @_;
my $opts = \%opts;
if($opts->{template} and -r $opts->{template}) {
open my $fh, "<", $opts->{template} or die $!;
$default_template = "";
while(<$fh>) {
$default_template .= $_;
}
close $fh;
}
my $wpaudioplayer = "/wpaudioplayer.swf";
$wpaudioplayer = $opts->{wpaudioplayer} if $opts->{wpaudioplayer};
my $js = "/wpaudioplayer.js";
$js = $opts->{js} if $opts->{js};
my $url = $opts->{uri}."?".$opts->{md5};
$player =~ s/%%% url %%%/$url/g;
$player =~ s/%%% js %%%/$js/g;
$player =~ s/%%% wpaudioplayer %%%/$wpaudioplayer/g;
my $tt = Template->new;
my $output;
$tt->process(\$default_template, {
player => $player,
artist => $opts->{artist},
title => $opts->{title},
year => $opts->{year},
album => $opts->{album},
lyrics => $opts->{lyrics},
}, \$output);
return $output;
}
1;
__DATA__
( run in 1.321 second using v1.01-cache-2.11-cpan-39bf76dae61 )