Apache-MP3-Skin

 view release on metacpan or  search on metacpan

Skin.pm  view on Meta::CPAN

package Apache::MP3::Skin;
# Subclasses Apache::MP3::Playlist and through the magic
# of HTML::Template allows Apache::MP3 to be skinned.

use strict;
use HTML::Template;
use Apache::Constants qw(:common REDIRECT HTTP_NO_CONTENT DIR_MAGIC_TYPE);
use constant COVERIMAGE   => 'cover.jpg';
use CGI qw(param escape);
use Apache::MP3::Playlist;
use Apache::File ();
use Apache::URI ();
use File::Basename 'dirname','basename';


use vars qw(@ISA $VERSION);
@ISA = 'Apache::MP3::Playlist';

$VERSION = '0.91';

Skin.pm  view on Meta::CPAN

  if (param('Play All') and param('playlist')) {
    return HTTP_NO_CONTENT unless @playlist;
    return $self->send_playlist(\@playlist);
  }

  if ($changed) {
    my $c = CGI::Cookie->new(-name  => 'playlist',
			     -value => \@playlist);
    tied(%{$r->err_headers_out})->add('Set-Cookie' => $c);
    (my $uri = $r->uri) =~ s!playlist\.m3u$!!;
    $self->path_escape(\$uri);
    $r->err_header_out(Location => $uri);
    return REDIRECT;
  }

  $self->playlist(@playlist);
  return;
}


sub run {

Skin.pm  view on Meta::CPAN

    }

    if ($p =~ m/^__\S*__$/) {
        $params{$_} = $self->set_loop_params($p,$count);
    } elsif (($p eq "is_dir") && (not $on_playlist)) {
  	    $params{$_} = "0";
    } elsif (($p eq "is_mp3") && (not $on_playlist)) {
  	    $params{$_} = "1";
    } elsif ($p eq "fetch_url") {
        if ($self->download_ok) {
        	$params{$_} = ($on_playlist) ? escape($song_file) : $uri.escape($song_file);
		} else {
		    $params{$_} = "";
		}
    } elsif (($p eq "add_to_playlist_url") && (not $on_playlist)) {
        $params{$_} = $self->r->uri."playlist.m3u?Add+to+Playlist=1;file=".$uri.escape($song_file);
	} elsif (($p eq "remove_from_playlist_url") && ($on_playlist)) {
	    $params{$_} = $self->r->uri."playlist.m3u?Clear+Selected=1;playlist=1;file=".escape($song_file);
    } elsif ($p eq "play_url") {
        if ($self->stream_ok) {
            $params{$_} = ($on_playlist) ?  escape($song_file)."?play=1;" : $uri . escape($song_file) . "?play=1;";
            $params{$_} =~ s/(\.[^.]+)?$/.m3u?play=1/;
		} else {
		    $params{$_} = "";
        }
	} elsif ($p eq "checkbox") {
	    $params{$_} = ($on_playlist) ? "<input type=\"checkbox\" name=\"pl\"  value=\"$song_file\" />":
	                                   "<input type=\"checkbox\" name=\"mp3\" value=\"$uri/$song_file\" />";
    } else {
        $params{$_} = $self->set_context_params($p, $template, $dir, $uri, $directories, $mp3s, $inner_loops);    
    }

Skin.pm  view on Meta::CPAN

to keep all your skins in the BaseDir, but it is possible to have a different skin for each 
directory.

Complete documentation on these tags can be found at L<HTML::Template>, but
enough to get you started follows.

=over 4

=item <TMPL_VAR [ESCAPE="HTML" | ESCAPE="URL"] NAME=variable>

Tag is replace with the value of variable and optionally escaped making it html
or url compliant.

=item <TMPL_IF NAME=variable> html here 
	[ <TMPL_ELSE>  more here ] 
</TMPL_IF>

The value or variable is evaluated, and if it is not empty or "0" it is 
considered true and "some html" is outputed to the browser.  A <TMPL_ELSE>
can optionaly be specified.

apache_mp3/apache_mp3_skin.js  view on Meta::CPAN


function play_selected_playlist() {    
    location = "playlist.m3u?Play+Selected=1;playlist=1;" + _get_files("pl",true);
}

function _get_files(name, selected_only) {
    var out = "";
    var f=document.apache_mp3_skin;
    for (var x=0; x<f.elements.length; x++) { 
      if ((f.elements[x].name == name) && ((!selected_only) || (f.elements[x].checked))) {
           out += "file="+escape(f.elements[x].value)+";";
        }
    }
    return out;

}


function select_all_playlist () {
	_select("pl",true);
    



( run in 0.418 second using v1.01-cache-2.11-cpan-c21f80fb71c )