From 9c9aeabf30f59829437262474640562b0301e34a Mon Sep 17 00:00:00 2001 From: nelsonlaquet Date: Sun, 28 Jul 2013 16:51:35 -0500 Subject: [PATCH] Just some styling --- .../Api/Web/DashboardController.php | 58 + app/controllers/Api/Web/TracksController.php | 43 +- app/library/Assets.php | 1 + app/models/Entities/Track.php | 5 + app/models/Entities/User.php | 10 + app/routes.php | 5 + app/views/shared/_app_layout.blade.php | 6 + app/views/shared/_layout.blade.php | 4 +- public/images/octavia.png | Bin 0 -> 140282 bytes public/images/vinyl.png | Bin 0 -> 189974 bytes public/scripts/app/app.coffee | 26 +- .../app/controllers/account-playlists.coffee | 1 - .../scripts/app/controllers/dashboard.coffee | 14 + public/scripts/app/controllers/sidebar.coffee | 1 - public/scripts/app/controllers/tracks.coffee | 12 + .../app/filters/moment-from-now.coffee | 3 + public/scripts/base/moment.js | 1662 +++++++++++++++++ public/scripts/shared/layout.coffee | 6 + public/styles/account-content.less | 1 - public/styles/app.less | 3 +- public/styles/components.less | 3 +- public/styles/forms.less | 5 + public/styles/layout.less | 92 +- public/styles/tracks.less | 81 + public/templates/account/content/album.html | 2 +- public/templates/dashboard.html | 53 + public/templates/tracks/_layout.html | 14 - public/templates/tracks/index.html | 53 +- 28 files changed, 2102 insertions(+), 62 deletions(-) create mode 100644 app/controllers/Api/Web/DashboardController.php create mode 100644 public/images/octavia.png create mode 100644 public/images/vinyl.png create mode 100644 public/scripts/app/controllers/dashboard.coffee create mode 100644 public/scripts/app/controllers/tracks.coffee create mode 100644 public/scripts/app/filters/moment-from-now.coffee create mode 100644 public/scripts/base/moment.js create mode 100644 public/styles/tracks.less create mode 100644 public/templates/dashboard.html delete mode 100644 public/templates/tracks/_layout.html diff --git a/app/controllers/Api/Web/DashboardController.php b/app/controllers/Api/Web/DashboardController.php new file mode 100644 index 00000000..7fba4712 --- /dev/null +++ b/app/controllers/Api/Web/DashboardController.php @@ -0,0 +1,58 @@ +with(['genre', 'user', 'cover'])->whereNotNull('published_at')->orderBy('published_at', 'desc')->take(15); + if (!Auth::check() || !Auth::user()->can_see_explicit_content) + $query->whereIsExplicit(false); + + $tracks = []; + + foreach ($query->get() as $track) { + $tracks[] = [ + 'id' => $track->id, + 'title' => $track->title, + 'user' => [ + 'id' => $track->user->id, + 'name' => $track->user->display_name, + 'url' => $track->user->url + ], + 'url' => $track->url, + 'slug' => $track->slug, + 'is_vocal' => $track->is_vocal, + 'is_explicit' => $track->is_explicit, + 'is_downloadable' => $track->is_downloadable, + 'is_published' => $track->isPublished(), + 'published_at' => $track->published_at, + 'duration' => $track->duration, + 'genre' => [ + 'id' => $track->genre->id, + 'slug' => $track->genre->slug, + 'name' => $track->genre->name + ], + 'track_type_id' => $track->track_type_id, + 'covers' => [ + 'thumbnail' => $track->getCoverUrl(Image::THUMBNAIL), + 'small' => $track->getCoverUrl(Image::SMALL), + 'normal' => $track->getCoverUrl(Image::NORMAL) + ] + ]; + } + + return Response::json([ + 'recent_tracks' => $tracks, + 'popular_tracks' => $tracks], 200); + } + } \ No newline at end of file diff --git a/app/controllers/Api/Web/TracksController.php b/app/controllers/Api/Web/TracksController.php index d1cd9e8e..a689645e 100644 --- a/app/controllers/Api/Web/TracksController.php +++ b/app/controllers/Api/Web/TracksController.php @@ -26,8 +26,49 @@ return $this->execute(new EditTrackCommand($id, Input::all())); } + public function getRecent() { + $query = Track::summary()->with(['genre', 'user', 'cover'])->whereNotNull('published_at')->orderBy('published_at', 'desc')->take(15); + if (!Auth::check() || !Auth::user()->can_see_explicit_content) + $query->whereIsExplicit(false); + + $tracks = []; + + foreach ($query->get() as $track) { + $tracks[] = [ + 'id' => $track->id, + 'title' => $track->title, + 'user' => [ + 'id' => $track->user->id, + 'name' => $track->user->display_name, + 'url' => $track->user->url + ], + 'url' => $track->url, + 'slug' => $track->slug, + 'is_vocal' => $track->is_vocal, + 'is_explicit' => $track->is_explicit, + 'is_downloadable' => $track->is_downloadable, + 'is_published' => $track->isPublished(), + 'published_at' => $track->published_at, + 'duration' => $track->duration, + 'genre' => [ + 'id' => $track->genre->id, + 'slug' => $track->genre->slug, + 'name' => $track->genre->name + ], + 'track_type_id' => $track->track_type_id, + 'covers' => [ + 'thumbnail' => $track->getCoverUrl(Image::THUMBNAIL), + 'small' => $track->getCoverUrl(Image::SMALL), + 'normal' => $track->getCoverUrl(Image::NORMAL) + ] + ]; + } + + return Response::json($tracks, 200); + } + public function getOwned() { - $query = Track::summary()->whereNull('deleted_at')->where('user_id', \Auth::user()->id); + $query = Track::summary()->where('user_id', \Auth::user()->id); if (Input::has('published')) { $published = \Input::get('published'); diff --git a/app/library/Assets.php b/app/library/Assets.php index 5f57129b..b0427ab6 100644 --- a/app/library/Assets.php +++ b/app/library/Assets.php @@ -47,6 +47,7 @@ new FileAsset('scripts/base/jquery-ui.js'), new FileAsset('scripts/base/jquery.colorbox.js'), new FileAsset('scripts/base/underscore.js'), + new FileAsset('scripts/base/moment.js'), new FileAsset('scripts/base/angular.js'), new FileAsset('scripts/base/ui-bootstrap-tpls-0.4.0.js'), new FileAsset('scripts/base/angular-ui-sortable.js'), diff --git a/app/models/Entities/Track.php b/app/models/Entities/Track.php index 4870ce1d..c64e012c 100644 --- a/app/models/Entities/Track.php +++ b/app/models/Entities/Track.php @@ -6,6 +6,7 @@ use External; use getid3_writetags; use Illuminate\Support\Facades\Log; + use Illuminate\Support\Facades\URL; use Illuminate\Support\Str; use Whoops\Example\Exception; use Traits\SlugTrait; @@ -53,6 +54,10 @@ return date('Y', strtotime($this->release_date)); } + public function getUrlAttribute() { + return URL::to('/tracks/' . $this->id . '/' . $this->slug); + } + public function getReleaseDate() { if($this->attributes['released_at'] !== NULL) return $this->attributes['released_at']; diff --git a/app/models/Entities/User.php b/app/models/Entities/User.php index fc9166e8..465912df 100644 --- a/app/models/Entities/User.php +++ b/app/models/Entities/User.php @@ -7,6 +7,7 @@ use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; use Illuminate\Support\Facades\URL; + use Illuminate\Support\Str; use Ratchet\Wamp\Exception; class User extends \Eloquent implements UserInterface, RemindableInterface { @@ -17,6 +18,10 @@ return $this->belongsTo('Entities\Image'); } + public function getUrlAttribute() { + return URL::to('/' . $this->slug); + } + public function getAuthIdentifier() { return $this->getKey(); } @@ -29,6 +34,11 @@ return $this->email; } + public function setDisplayName($value) { + $this->attributes['display_name'] = $value; + $this->attributes['slug'] = Str::slug($value); + } + public function getAvatarUrl($type = Image::NORMAL) { if (!$this->uses_gravatar) return $this->avatar->getUrl(); diff --git a/app/routes.php b/app/routes.php index 8810836f..d8a20de4 100644 --- a/app/routes.php +++ b/app/routes.php @@ -11,6 +11,7 @@ | */ + Route::get('/dashboard', 'TracksController@getIndex'); Route::get('/tracks', 'TracksController@getIndex'); Route::get('/tracks/popular', 'TracksController@getIndex'); Route::get('/tracks/random', 'TracksController@getIndex'); @@ -38,6 +39,10 @@ Route::get('/playlists/show/{id}', 'Api\Web\PlaylistsController@getShow'); + Route::get('/tracks/recent', 'Api\Web\TracksController@getRecent'); + + Route::get('/dashboard', 'Api\Web\DashboardController@getIndex'); + Route::group(['before' => 'auth|csrf'], function() { Route::post('/tracks/upload', 'Api\Web\TracksController@postUpload'); Route::post('/tracks/delete/{id}', 'Api\Web\TracksController@postDelete'); diff --git a/app/views/shared/_app_layout.blade.php b/app/views/shared/_app_layout.blade.php index a74434f7..3bb24a27 100644 --- a/app/views/shared/_app_layout.blade.php +++ b/app/views/shared/_app_layout.blade.php @@ -29,6 +29,12 @@