Apache-MP3
view release on metacpan or search on metacpan
sub x { # maketext plus maybe escape. The "x" for "xlate"
my $x = (my $lh = shift->{'lh'})->maketext(@_);
$x =~ s/([^\x00-\x7f])/'&#'.ord($1).';'/eg
if $x =~ m/[^\x00-\x7f]/ and $lh->must_escape;
return $x;
}
sub lh { return shift->{lh} } # language handle
sub aright { -align => shift->{lh}->right }
# align "right" (or, in case of Arabic (etc), really left).
sub aleft { -align => shift->{lh}->left }
# align "light" (or, in case of Arabic (etc), really right).
sub r { return shift->{r} }
sub html_content_type {
my $self = shift;
return 'text/html; charset=' . $self->lh->encoding
}
sub help_screen {
my $self = shift;
$self->r->content_type( $self->html_content_type );
return OK if $self->r->header_only;
print start_html(
-lang => $self->lh->language_tag,
-title => $self->x('Quick Help Summary'),
-dir => $self->lh->direction,
-head => meta({-http_equiv => 'Content-Type',
-content => $self->html_content_type
}
),
-script =>{-src=>$self->default_dir.'/functions.js'},
);
my $help_img_url = $self->help_img_url; # URL for the image
my ($url,$width,$height) = $help_img_url=~/(.+):(\d+)x(\d+)/;
$url ||= $help_img_url;
$width ||= 500;
$height ||= 400;
print img({-src => $url,
-alt => "",
-height => $height,
-width => $width,
$self->aleft,
}), "\n";
print join "\n".br(),
$self->help_figure_list
;
print "\n", end_html();
return;
}
sub help_figure_list {
my $self = shift;
# Provide a legend for the items in the figure
return(
b("A"). $self->x("= Stream all songs"),
b("B"). $self->x("= Shuffle-play all Songs"),
b("C"). $self->x("= Stream all songs"),
b("D"). $self->x("= Go to earlier directory"),
b("E"). $self->x("= Stream contents"),
b("F"). $self->x("= Enter directory"),
b("G"). $self->x("= Stream this song"),
b("H"). $self->x("= Select for streaming"),
b("I"). $self->x("= Download this song"),
b("J"). $self->x("= Stream this song"),
b("K"). $self->x("= Sort by field"),
);
}
sub run {
my $self = shift;
my $r = $self->r;
my(undef,$uribase) = fileparse($r->uri);
my(undef,$filebase) = fileparse($r->filename);
my $local = $self->playlocal_ok && $self->is_local;
my $base = $self->stream_base;
local $CGI::XHTML = 0;
# check that we aren't running under PerlSetupEnv Off
if ($ENV{MOD_PERL} && !$ENV{SCRIPT_FILENAME}) {
warn "CGI.pm cannot run with 'PerlSetupEnv Off', please set it to On";
}
# this is called to show a help screen
return $self->help_screen if param('help_screen');
# generate directory listing
return $self->process_directory($r->filename)
if -d $r->filename; # should be $r->finfo, but STILL problems with this
# simple download of file
return $self->download_file($r->filename) unless param;
# this is called to stream a file
if(param('stream')){
return $self->stream;
}
# this is called to generate a playlist on the current directory
return $self->send_playlist($self->find_mp3s)
if param('Play All');
# this is called to generate a playlist on the current directory
# and everything beneath
return $self->send_playlist($self->find_mp3s('recursive'))
if param('Play All Recursive') ;
# this is called to generate a shuffled playlist of current directory
return $self->send_playlist($self->find_mp3s,'shuffle')
if param('Shuffle');
( run in 2.920 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )