diff --git a/app/controllers/Api/Web/AlbumsController.php b/app/controllers/Api/Web/AlbumsController.php
new file mode 100644
index 00000000..c03ef96a
--- /dev/null
+++ b/app/controllers/Api/Web/AlbumsController.php
@@ -0,0 +1,66 @@
+where('user_id', \Auth::user()->id);
+ return Response::json($query->get(), 200);
+ }
+
+ public function getEdit($id) {
+ $track = Track::with('showSongs')->find($id);
+ if (!$track)
+ return $this->notFound('Track ' . $id . ' not found!');
+
+ if ($track->user_id != Auth::user()->id)
+ return $this->notAuthorized();
+
+ $showSongs = [];
+ foreach ($track->showSongs as $showSong) {
+ $showSongs[] = ['id' => $showSong->id, 'title' => $showSong->title];
+ }
+
+ return Response::json([
+ 'id' => $track->id,
+ 'title' => $track->title,
+ 'user_id' => $track->user_id,
+ 'slug' => $track->slug,
+ 'is_vocal' => (bool)$track->is_vocal,
+ 'is_explicit' => (bool)$track->is_explicit,
+ 'is_downloadable' => !$track->isPublished() ? true : (bool)$track->is_downloadable,
+ 'is_published' => $track->published_at != null,
+ 'created_at' => $track->created_at,
+ 'published_at' => $track->published_at,
+ 'duration' => $track->duration,
+ 'genre_id' => $track->genre_id,
+ 'track_type_id' => $track->track_type_id,
+ 'license_id' => $track->license_id != null ? $track->license_id : 3,
+ 'description' => $track->description,
+ 'lyrics' => $track->lyrics,
+ 'released_at' => $track->released_at,
+ 'cover_url' => $track->hasCover() ? $track->getCoverUrl(Image::NORMAL) : null,
+ 'real_cover_url' => $track->getCoverUrl(Image::NORMAL),
+ 'show_songs' => $showSongs
+ ], 200);
+ }
+
+ public function postDelete($id) {
+ return $this->execute(new DeleteTrackCommand($id));
+ }
+
+ public function putEdit($id) {
+ return $this->execute(new EditTrackCommand($id, Input::all()));
+ }
+ }
\ No newline at end of file
diff --git a/app/database/migrations/2013_06_27_015259_create_tracks_table.php b/app/database/migrations/2013_06_27_015259_create_tracks_table.php
index 32e4d4a9..88b0b749 100644
--- a/app/database/migrations/2013_06_27_015259_create_tracks_table.php
+++ b/app/database/migrations/2013_06_27_015259_create_tracks_table.php
@@ -39,6 +39,7 @@ class CreateTracksTable extends Migration {
$table->text('lyrics')->nullable();
$table->boolean('is_vocal');
$table->boolean('is_explicit');
+ $table->integer('cover_id')->unsigned()->nullable();
$table->boolean('is_downloadable');
$table->float('duration')->unsigned();
diff --git a/app/database/migrations/2013_07_28_060804_create_albums.php b/app/database/migrations/2013_07_28_060804_create_albums.php
new file mode 100644
index 00000000..5d52df51
--- /dev/null
+++ b/app/database/migrations/2013_07_28_060804_create_albums.php
@@ -0,0 +1,38 @@
+increments('id');
+ $table->integer('user_id')->unsigned();
+ $table->string('title')->index();
+ $table->string('slug')->index();
+ $table->text('description');
+ $table->integer('cover_id')->unsigned()->nullable();
+ $table->timestamps();
+ $table->timestamp('deleted_at')->nullable()->index();
+
+ $table->foreign('cover_id')->references('id')->on('images');
+ $table->foreign('user_id')->references('id')->on('users');
+ });
+
+ Schema::table('tracks', function($table) {
+ $table->integer('album_id')->unsigned()->nullable();
+ $table->integer('track_number')->unsigned()->nullable();
+
+ $table->foreign('album_id')->references('id')->on('albums');
+ });
+ }
+
+ public function down() {
+ Schema::table('tracks', function($table) {
+ $table->dropForeign('tracks_album_id_foreign');
+ $table->dropColumn('album_id');
+ $table->dropColumn('track_number');
+ });
+
+ Schema::drop('albums');
+ }
+}
\ No newline at end of file
diff --git a/app/models/Entities/Album.php b/app/models/Entities/Album.php
new file mode 100644
index 00000000..238e2bb1
--- /dev/null
+++ b/app/models/Entities/Album.php
@@ -0,0 +1,52 @@
+belongsTo('Entities\User');
+ }
+
+ public function cover() {
+ return $this->belongsTo('Entities\Image');
+ }
+
+ public function hasCover() {
+ return $this->cover_id != null;
+ }
+
+ public function getCoverUrl($type = Image::NORMAL) {
+ if (!$this->hasCover())
+ return $this->user->getAvatarUrl($type);
+
+ return $this->cover->getUrl($type);
+ }
+
+ public function getDirectory() {
+ $dir = (string) ( floor( $this->id / 100 ) * 100 );
+ return \Config::get('app.files_directory') . '/tracks/' . $dir;
+ }
+
+ public function getDates() {
+ return ['created_at', 'deleted_at', 'published_at'];
+ }
+
+ public function getFilenameFor($format) {
+ if (!isset(Track::$Formats[$format]))
+ throw new Exception("$format is not a valid format!");
+
+ $format = Track::$Formats[$format];
+ return "{$this->id}.{$format['extension']}.zip";
+ }
+ }
\ No newline at end of file
diff --git a/app/models/Entities/Track.php b/app/models/Entities/Track.php
index a044ba54..ef9c0112 100644
--- a/app/models/Entities/Track.php
+++ b/app/models/Entities/Track.php
@@ -45,7 +45,7 @@
return $this->published_at != null && $this->deleted_at == null;
}
- public function getCoverUrl($type = Cover::NORMAL) {
+ public function getCoverUrl($type = Image::NORMAL) {
if (!$this->hasCover())
return $this->user->getAvatarUrl($type);
diff --git a/app/routes.php b/app/routes.php
index e96b4296..2155420c 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -40,8 +40,12 @@
Route::group(['before' => 'auth'], function() {
Route::get('/images/owned', 'Api\Web\ImagesController@getOwned');
+
Route::get('/tracks/owned', 'Api\Web\TracksController@getOwned');
Route::get('/tracks/edit/{id}', 'Api\Web\TracksController@getEdit');
+
+ Route::get('/albums/owned', 'Api\Web\AlbumsController@getOwned');
+ Route::get('/albums/edit/{id}', 'Api\Web\AlbumsController@getEdit');
});
Route::group(['before' => 'csrf'], function(){
@@ -52,14 +56,16 @@
Route::group(['prefix' => 'account'], function() {
Route::group(['before' => 'auth'], function(){
- Route::get('/favourites', 'FavouritesController@getTracks');
+ Route::get('/favourites/tracks', 'FavouritesController@getTracks');
Route::get('/favourites/albums', 'FavouritesController@getAlbums');
Route::get('/favourites/playlists', 'FavouritesController@getPlaylists');
- Route::get('/content/tracks', 'ContentController@getTracks');
- Route::get('/content/tracks/{id}', 'ContentController@getTracks');
- Route::get('/content/albums', 'ContentController@getAlbums');
- Route::get('/content/playlists', 'ContentController@getPlaylists');
+ Route::get('/tracks', 'ContentController@getTracks');
+ Route::get('/tracks/edit/{id}', 'ContentController@getTracks');
+ Route::get('/albums', 'ContentController@getAlbums');
+ Route::get('/albums/edit/{id}', 'ContentController@getAlbums');
+ Route::get('/albums/create', 'ContentController@getAlbums');
+ Route::get('/playlists', 'ContentController@getPlaylists');
Route::get('/', 'AccountController@getIndex');
});
diff --git a/app/views/shared/_app_layout.blade.php b/app/views/shared/_app_layout.blade.php
index 93cb8ed7..e069a3b1 100644
--- a/app/views/shared/_app_layout.blade.php
+++ b/app/views/shared/_app_layout.blade.php
@@ -43,7 +43,7 @@
Account
Favourites
- Your Content
+ Your Content
Settings
@endif
diff --git a/public/scripts/app/app.coffee b/public/scripts/app/app.coffee
index dd273d13..5dfd2736 100644
--- a/public/scripts/app/app.coffee
+++ b/public/scripts/app/app.coffee
@@ -10,21 +10,32 @@ angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date'], [
controller: 'account-settings'
state.state 'account-content',
- url: '/account/content'
+ url: '/account'
abstract: true
templateUrl: '/templates/account/content/_layout.html'
state.state 'account-content.tracks',
url: '/tracks'
templateUrl: '/templates/account/content/tracks.html'
- controller: 'account-content-tracks'
+ controller: 'account-tracks'
state.state 'account-content.tracks.edit',
- url: '/:track_id'
+ url: '/edit/:track_id'
state.state 'account-content.albums',
url: '/albums'
templateUrl: '/templates/account/content/albums.html'
+ controller: 'account-albums'
+
+ state.state 'account-content.albums.create',
+ url: '/create'
+ templateUrl: '/templates/account/content/album.html'
+ controller: 'account-albums-edit'
+
+ state.state 'account-content.albums.edit',
+ url: '/edit/:album_id'
+ templateUrl: '/templates/account/content/album.html'
+ controller: 'account-albums-edit'
state.state 'account-content.playlists',
url: '/playlists'
diff --git a/public/scripts/app/controllers/account-albums-edit.coffee b/public/scripts/app/controllers/account-albums-edit.coffee
new file mode 100644
index 00000000..7afb28df
--- /dev/null
+++ b/public/scripts/app/controllers/account-albums-edit.coffee
@@ -0,0 +1,17 @@
+angular.module('ponyfm').controller "account-albums-edit", [
+ '$scope', '$state', 'taxonomies', '$dialog', 'lightbox'
+ ($scope, $state, taxonomies, $dialog, lightbox) ->
+ $scope.isNew = $state.params.album_id == null
+ $scope.data.isEditorOpen = true
+ $scope.errors = {}
+ $scope.isDirty = false
+
+ $scope.touchModel = -> $scope.isDirty = true
+
+ if $scope.isNew
+ $scope.album =
+ title: ''
+ description: ''
+
+ $scope.$on '$destroy', -> $scope.data.isEditorOpen = false
+]
\ No newline at end of file
diff --git a/public/scripts/app/controllers/account-albums.coffee b/public/scripts/app/controllers/account-albums.coffee
new file mode 100644
index 00000000..e338fbcf
--- /dev/null
+++ b/public/scripts/app/controllers/account-albums.coffee
@@ -0,0 +1,19 @@
+angular.module('ponyfm').controller "account-albums", [
+ '$scope', '$state', 'taxonomies', '$dialog', 'lightbox'
+ ($scope, $state, taxonomies, $dialog, lightbox) ->
+ refreshList = () ->
+ $.getJSON('/api/web/albums/owned')
+ .done (albums) ->
+ $scope.albums = albums
+
+ refreshList()
+ $scope.data =
+ isEditorOpen: false
+ selectedAlbum: null
+
+ $scope.$on '$stateChangeSuccess', () ->
+ if $state.params.album_id
+ selectAlbum albumsDb[$state.params.album_id]
+ else
+ selectAlbum null
+]
\ No newline at end of file
diff --git a/public/scripts/app/controllers/account-content-tracks.coffee b/public/scripts/app/controllers/account-tracks.coffee
similarity index 99%
rename from public/scripts/app/controllers/account-content-tracks.coffee
rename to public/scripts/app/controllers/account-tracks.coffee
index e1c7f9c9..9d37b13a 100644
--- a/public/scripts/app/controllers/account-content-tracks.coffee
+++ b/public/scripts/app/controllers/account-tracks.coffee
@@ -1,4 +1,4 @@
-angular.module('ponyfm').controller "account-content-tracks", [
+angular.module('ponyfm').controller "account-tracks", [
'$scope', '$state', 'taxonomies', '$dialog', 'lightbox'
($scope, $state, taxonomies, $dialog, lightbox) ->
$('#coverPreview').load () ->
diff --git a/public/scripts/app/directives/image-upload.coffee b/public/scripts/app/directives/image-upload.coffee
new file mode 100644
index 00000000..139ecc59
--- /dev/null
+++ b/public/scripts/app/directives/image-upload.coffee
@@ -0,0 +1,9 @@
+angular.module('ponyfm').directive 'pfmImageUpload',
+ restrict: 'E'
+ scope:
+ setUploadedImage: '&'
+ setGalleryImage: '&'
+ controller: [
+ 'upload'
+ (upload) -> (scope) ->
+ ]
\ No newline at end of file
diff --git a/public/styles/account-tracks.less b/public/styles/account-content.less
similarity index 95%
rename from public/styles/account-tracks.less
rename to public/styles/account-content.less
index 11a13047..681d7a40 100644
--- a/public/styles/account-tracks.less
+++ b/public/styles/account-content.less
@@ -47,7 +47,7 @@
}
}
-.account-tracks-listing {
+.account-tracks-listing, .account-albums-listing {
overflow-y: auto;
margin: 0px;
padding: 0px;
@@ -60,6 +60,15 @@
margin: 0px;
line-height: normal;
+ &.empty {
+ .alert();
+ float: none !important;
+ width: auto !important;
+ display: block;
+ padding: 5px;
+ font-size: 9pt;
+ }
+
&.is-published a {
background: transparent;
}
@@ -329,12 +338,15 @@
}
&.closed {
- .account-tracks-listing {
+ .account-tracks-listing, .account-albums-listing {
.clearfix();
li {
float: left;
width: 25%;
+
+ &.empty {
+ }
}
}
}
diff --git a/public/styles/app.less b/public/styles/app.less
index 0359db71..302dd3dc 100644
--- a/public/styles/app.less
+++ b/public/styles/app.less
@@ -3,5 +3,5 @@
@import 'mixins';
@import 'layout';
@import 'home';
-@import 'account-tracks';
+@import 'account-content';
@import 'components';
\ No newline at end of file
diff --git a/public/templates/account/content/_layout.html b/public/templates/account/content/_layout.html
index 0374331c..f9d61f8f 100644
--- a/public/templates/account/content/_layout.html
+++ b/public/templates/account/content/_layout.html
@@ -1,8 +1,8 @@
diff --git a/public/templates/account/content/album.html b/public/templates/account/content/album.html
new file mode 100644
index 00000000..2a146e6b
--- /dev/null
+++ b/public/templates/account/content/album.html
@@ -0,0 +1,46 @@
+
\ No newline at end of file
diff --git a/public/templates/account/content/albums.html b/public/templates/account/content/albums.html
index bd170654..d39ba33a 100644
--- a/public/templates/account/content/albums.html
+++ b/public/templates/account/content/albums.html
@@ -1 +1,27 @@
-
Your Albums
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/public/templates/account/content/tracks.html b/public/templates/account/content/tracks.html
index bf3e87a5..e1fd6a21 100644
--- a/public/templates/account/content/tracks.html
+++ b/public/templates/account/content/tracks.html
@@ -45,8 +45,8 @@
-
-
-
+
+
{{track.title}}
{{track.created_at | pfmdate:'MM/dd/yyyy'}}
@@ -135,7 +135,7 @@
diff --git a/vendor/autoload.php b/vendor/autoload.php
index c1ebec6a..e89787bc 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
-return ComposerAutoloaderInita1fb7abacafe9eba7b46e2d4ded6e3a5::getLoader();
+return ComposerAutoloaderInit68362e9063d9f6e829919d3debf84f51::getLoader();
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
index c567ddf8..bfb819fe 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -130,6 +130,7 @@ return array(
'Commands\\EditTrackCommand' => $baseDir . '/app/models/Commands/EditTrackCommand.php',
'Commands\\UploadTrackCommand' => $baseDir . '/app/models/Commands/UploadTrackCommand.php',
'ContentController' => $baseDir . '/app/controllers/ContentController.php',
+ 'CreateAlbums' => $baseDir . '/app/database/migrations/2013_07_28_060804_create_albums.php',
'CreateImagesTable' => $baseDir . '/app/database/migrations/2013_07_26_230827_create_images_table.php',
'CreateSongsTable' => $baseDir . '/app/database/migrations/2013_07_28_034328_create_songs_table.php',
'CreateTracksTable' => $baseDir . '/app/database/migrations/2013_06_27_015259_create_tracks_table.php',
@@ -403,6 +404,7 @@ return array(
'Entities\\Genre' => $baseDir . '/app/models/Entities/Genre.php',
'Entities\\Image' => $baseDir . '/app/models/Entities/Image.php',
'Entities\\License' => $baseDir . '/app/models/Entities/License.php',
+ 'Entities\\ShowSong' => $baseDir . '/app/models/Entities/ShowSong.php',
'Entities\\Track' => $baseDir . '/app/models/Entities/Track.php',
'Entities\\TrackType' => $baseDir . '/app/models/Entities/TrackType.php',
'Entities\\User' => $baseDir . '/app/models/Entities/User.php',
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 3f36c6f0..6d69f38f 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php generated by Composer
-class ComposerAutoloaderInita1fb7abacafe9eba7b46e2d4ded6e3a5
+class ComposerAutoloaderInit68362e9063d9f6e829919d3debf84f51
{
private static $loader;
@@ -19,9 +19,9 @@ class ComposerAutoloaderInita1fb7abacafe9eba7b46e2d4ded6e3a5
return self::$loader;
}
- spl_autoload_register(array('ComposerAutoloaderInita1fb7abacafe9eba7b46e2d4ded6e3a5', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInit68362e9063d9f6e829919d3debf84f51', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
- spl_autoload_unregister(array('ComposerAutoloaderInita1fb7abacafe9eba7b46e2d4ded6e3a5', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInit68362e9063d9f6e829919d3debf84f51', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);