Skip to content
Browse files

Adding the ability to add individual songs to the playlist

  • Loading branch information...
1 parent 7f99345 commit cdb61eca09dedf9b501c06bc9ccbec9d34ba6e4c @reyjrar committed Jun 24, 2012
View
1 lib/MusicManager.pm
@@ -66,6 +66,7 @@ sub startup {
$r->route('/library')->to('library#artists');
$r->route('/library/artists')->to('library#artists');
$r->route('/library/artist/:artist')->to('library#artist');
+ $r->route('/library/album/:album')->to('library#album');
# Now Playing
$r->route('/nowplaying/add/artist/:artist')->to(controller => 'NowPlaying', action => 'add_artist');
View
13 lib/MusicManager/Controller/Library.pm
@@ -22,4 +22,17 @@ sub artist {
$self->render();
}
+sub album {
+ my $self = shift;
+
+ # Grab the artist
+ my $album = $self->stash('album');
+
+ my @songs = sort mm_sort_smart $self->app->mpd->collection->songs_from_album( $album );
+ $self->stash( songs => \@songs );
+
+ $self->render();
+}
+
+
1;
View
5 lib/MusicManager/Controller/NowPlaying.pm
@@ -111,6 +111,11 @@ sub replace_artist_album {
$self->redirect_to('/');
}
+sub add_song {
+ my $self = shift;
+ my $mpd = $self->app->mpd;
+}
+
sub del_song {
my $self = shift;
my $id = $self->stash('song_id');
View
11 lib/MusicManager/Model/Files.pm
@@ -6,7 +6,7 @@ use File::Find::Rule;
has 'media_dir';
-my %_valid_media_exts = map { $_ => 1 } qw(mp3 ogg aac);
+my %_valid_media_exts = map { $_ => 1 } qw(mp3 Mp3 MP3 ogg OGG aac AAC);
sub songs_from_path {
my ($self,@dirs) = @_;
@@ -20,3 +20,12 @@ sub songs_from_path {
return wantarray ? @files : \@files;
}
+
+sub song_at {
+ my ($self,$path) = @_;
+
+ my @path = File::Spec->split_path( $path );
+ my @safe = File::Spec->no_upwards( @path );
+ my $safe_path = File::Spec->catfile( @safe );
+
+}
View
26 templates/library/album.html.ep
@@ -0,0 +1,26 @@
+% layout 'default';
+% title "MusicManager :: Album :: $album";
+
+<table class="table">
+<thead>
+ <tr>
+ <th>Arist</th>
+ <th>Album</th>
+ <th>Title</th>
+ <th>Functions</th>
+ </tr>
+</thead>
+<tbody>
+% foreach my $song (@$songs) {
+% my $song_id = $song->file;
+<tr>
+ <td><%== $song->artist %></td>
+ <td><%== $song->album %></td>
+ <td><%== $song->title %></td>
+ <td><a href="<%= url_for "/nowplaying/add/song/$song_id" %>"
+ class="btn btn-success"><i class="icon-plus icon-white"></i> add song</a>
+ </td>
+</tr>
+% }
+</tbody>
+</table>
View
2 templates/library/artist.html.ep
@@ -18,7 +18,7 @@
class="btn btn-success"><i class="icon-plus icon-white"></i> add album</a>
<a href="<%= url_for "/nowplaying/replace/album/$artist/$album" %>"
class="btn btn-primary"><i class="icon-play icon-white"></i> play album</a>
- <a href="<%= url_for "/library/album/$artist" %>"
+ <a href="<%= url_for "/library/album/$album" %>"
class="btn"><i class="icon-zoom-in"></i> view</a>
</td>
</tr>

0 comments on commit cdb61ec

Please sign in to comment.
Something went wrong with that request. Please try again.