Maybe fixed mobile issue

This commit is contained in:
nelsonlaquet 2013-09-01 17:51:51 -05:00
parent 0000c4297d
commit 1617b605f6
19 changed files with 98 additions and 39 deletions

View file

@ -20,7 +20,7 @@
->explicitFilter() ->explicitFilter()
->published() ->published()
->orderBy('published_at', 'desc') ->orderBy('published_at', 'desc')
->take(20); ->take(30);
$recentTracks = []; $recentTracks = [];

View file

@ -66,16 +66,29 @@
return Redirect::action('TracksController@getTrack', [$id, $track->slug]); return Redirect::action('TracksController@getTrack', [$id, $track->slug]);
} }
public function getStream($id) { public function getStream($id, $extension) {
$track = Track::find($id); $track = Track::find($id);
if (!$track || !$track->canView(Auth::user())) if (!$track || !$track->canView(Auth::user()))
App::abort(404); App::abort(404);
$format = Track::$Formats['MP3']; $format = null;
$formatName = null;
foreach (Track::$Formats as $name => $item) {
if ($item['extension'] == $extension) {
$format = $item;
$formatName = $name;
break;
}
}
if ($format == null)
App::abort(404);
ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $format['index']); ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $format['index']);
$response = Response::make('', 200); $response = Response::make('', 200);
$filename = $track->getFileFor('MP3'); $filename = $track->getFileFor($formatName);
if (Config::get('app.sendfile')) { if (Config::get('app.sendfile')) {
$response->header('X-Sendfile', $filename); $response->header('X-Sendfile', $filename);

View file

@ -38,11 +38,11 @@
Log::listen(function($level, $message, $context) use ($profiler) { Log::listen(function($level, $message, $context) use ($profiler) {
$profiler->log($level, $message, $context); $profiler->log($level, $message, $context);
}); });
}
App::error(function($exception) { App::error(function($exception) {
return Response::view('errors.404', array(), 404); return Response::view('errors.500', array(), 404);
}); });
}
App::missing(function($exception) { App::missing(function($exception) {
return Response::view('errors.404', array(), 404); return Response::view('errors.404', array(), 404);

View file

@ -8,6 +8,7 @@
use Helpers; use Helpers;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\URL;
@ -54,7 +55,7 @@
} }
public static function popular($count, $allowExplicit = false) { public static function popular($count, $allowExplicit = false) {
$trackIds = Cache::remember('popular_tracks-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit) { $trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit, $count) {
$query = static $query = static
::published() ::published()
->join(DB::raw(' ->join(DB::raw('
@ -65,7 +66,7 @@
'tracks.id', '=', 'ranged_plays.track_id') 'tracks.id', '=', 'ranged_plays.track_id')
->groupBy('id') ->groupBy('id')
->orderBy('plays', 'desc') ->orderBy('plays', 'desc')
->take(20); ->take($count);
if (!$allowExplicit) if (!$allowExplicit)
$query->whereIsExplicit(false); $query->whereIsExplicit(false);
@ -197,7 +198,9 @@
'normal' => $track->getCoverUrl(Image::NORMAL) 'normal' => $track->getCoverUrl(Image::NORMAL)
], ],
'streams' => [ 'streams' => [
'mp3' => $track->getStreamUrl('MP3') 'mp3' => $track->getStreamUrl('MP3'),
'aac' => (!Config::get('app.debug') || is_file($track->getFileFor('AAC')) ) ? $track->getStreamUrl('AAC') : null,
'ogg' => ( Config::get('app.debug') || is_file($track->getFileFor('OGG Vorbis'))) ? $track->getStreamUrl('OGG Vorbis') : null
], ],
'user_data' => $userData, 'user_data' => $userData,
'permissions' => [ 'permissions' => [
@ -350,8 +353,8 @@
return $this->cover->getUrl($type); return $this->cover->getUrl($type);
} }
public function getStreamUrl() { public function getStreamUrl($format = 'MP3') {
return URL::to('/t' . $this->id . '/stream'); return URL::to('/t' . $this->id . '/stream.' . self::$Formats[$format]['extension']);
} }
public function getDirectory() { public function getDirectory() {

View file

@ -23,7 +23,7 @@
Route::get('tracks/{id}-{slug}', 'TracksController@getTrack'); Route::get('tracks/{id}-{slug}', 'TracksController@getTrack');
Route::get('t{id}', 'TracksController@getShortlink' ); Route::get('t{id}', 'TracksController@getShortlink' );
Route::get('t{id}/embed', 'TracksController@getEmbed' ); Route::get('t{id}/embed', 'TracksController@getEmbed' );
Route::get('t{id}/stream', 'TracksController@getStream' ); Route::get('t{id}/stream.{extension}', 'TracksController@getStream' );
Route::get('t{id}/dl.{extension}', 'TracksController@getDownload' ); Route::get('t{id}/dl.{extension}', 'TracksController@getDownload' );
Route::get('albums', 'AlbumsController@getIndex'); Route::get('albums', 'AlbumsController@getIndex');

View file

@ -1,17 +1,22 @@
angular.module('ponyfm').directive 'pfmSrcLoader', () -> angular.module('ponyfm').directive 'pfmSrcLoader', () ->
(scope, element, attrs) -> (scope, element, attrs) ->
size = attrs.pfmSrcSize || 'normal' size = attrs.pfmSrcSize || 'normal'
url = attrs.pfmSrcLoader element.css {opacity: .5}
element.attr 'src', '/images/icons/loading_' + size + '.png' update = (val) ->
element.attr 'src', '/images/icons/loading_' + size + '.png'
image = element.clone() image = element.clone()
image.removeAttr 'pfm-src-loader' image.removeAttr 'pfm-src-loader'
image.removeAttr 'pfm-src-size' image.removeAttr 'pfm-src-size'
image[0].onload = -> image[0].onload = ->
element.replaceWith image element.attr 'src', val
image.css {opacity: 0} element.css {opacity: 0}
image.animate {opacity: 1}, 250 element.animate {opacity: 1}, 250
image[0].src = url image[0].src = val
update scope.$eval attrs.pfmSrcLoader
scope.$watch attrs.pfmSrcLoader, update

View file

@ -6,8 +6,18 @@ angular.module('ponyfm').factory('player', [
play = (track) -> play = (track) ->
self.currentTrack = track self.currentTrack = track
$rootScope.$broadcast 'player-starting-track', track $rootScope.$broadcast 'player-starting-track', track
streams = []
streams.push track.streams.mp3
streams.push track.streams.ogg if track.streams.ogg
streams.push track.streams.aac if track.streams.aac
track.progress = 0
track.progressSeconds = 0
track.loadingProgress = 0
self.currentSound = soundManager.createSound self.currentSound = soundManager.createSound
url: track.streams.mp3, url: streams,
volume: self.volume volume: self.volume
whileloading: () -> $rootScope.safeApply -> whileloading: () -> $rootScope.safeApply ->
@ -83,7 +93,8 @@ angular.module('ponyfm').factory('player', [
self.currentSound.stop() if self.currentSound != null self.currentSound.stop() if self.currentSound != null
self.playlistIndex-- self.playlistIndex--
if self.playlistIndex <= 0
if self.playlistIndex < 0
self.playlist.length = 0 self.playlist.length = 0
self.currentTrack = null self.currentTrack = null
self.currentSong = null self.currentSong = null

View file

@ -14,13 +14,39 @@ body.is-logged {
float: left; float: left;
width: 43px; width: 43px;
height: 43px; height: 43px;
position: relative;
overflow: hidden;
padding: 1px;
img { img {
.img-polaroid(); .img-polaroid();
.box-shadow(none);
display: block; display: block;
width: 100%; width: 40px;
height: 40px;
padding: 1px; padding: 1px;
} }
.loader {
.transition(top 250ms linear);
z-index: 1000;
background: rgba(0, 0, 0, .6);
color: #fff;
position: absolute;
top: -50px;
left: 2px;
width: 42px;
height: 42px;
line-height: 43px;
text-align: center;
font-size: 16px;
&.showing {
top: 2px;
}
}
} }
.inner { .inner {
@ -51,7 +77,7 @@ body.is-logged {
} }
.transport { .transport {
background: @pfm-light-grey; background: #aaa;
height: 8px; height: 8px;
position: relative; position: relative;
cursor: pointer; cursor: pointer;

View file

@ -12,7 +12,7 @@
<ul class="account-albums-listing stretch-to-bottom"> <ul class="account-albums-listing stretch-to-bottom">
<li ng-repeat="album in albums" ng-class="{selected: album.id == data.selectedAlbum.id}"> <li ng-repeat="album in albums" ng-class="{selected: album.id == data.selectedAlbum.id}">
<a href="/account/albums/edit/{{album.id}}"> <a href="/account/albums/edit/{{album.id}}">
<img pfm-src-loader="{{album.covers.normal}}" pfm-src-size="normal" class="image" /> <img pfm-src-loader="album.covers.normal" pfm-src-size="normal" class="image" />
<span class="title">{{album.title}}</span> <span class="title">{{album.title}}</span>
<span class="published">{{album.created_at | pfmdate:'MM/dd/yyyy'}}</span> <span class="published">{{album.created_at | pfmdate:'MM/dd/yyyy'}}</span>
</a> </a>

View file

@ -22,7 +22,7 @@
<div class="stretch-to-bottom details-columns"> <div class="stretch-to-bottom details-columns">
<div class="right"> <div class="right">
<img class="cover" pfm-src-loader="{{album.covers.normal}}" pfm-src-size="normal" /> <img class="cover" pfm-src-loader="album.covers.normal" pfm-src-size="normal" />
<div class="share-buttons" pfm-share-buttons> <div class="share-buttons" pfm-share-buttons>
<a class="tumblr" bo-href="album.share.tumblrUrl" title="Share on Tumblr" style="display:inline-block; overflow:hidden; width:20px; height:20px; background:url('/images/tumblr-share.png') top left no-repeat transparent;"></a> <a class="tumblr" bo-href="album.share.tumblrUrl" title="Share on Tumblr" style="display:inline-block; overflow:hidden; width:20px; height:20px; background:url('/images/tumblr-share.png') top left no-repeat transparent;"></a>

View file

@ -2,7 +2,7 @@
<ul class="artist-listing"> <ul class="artist-listing">
<li ng-repeat="artist in artists" bindonce> <li ng-repeat="artist in artists" bindonce>
<a href="{{artist.url}}"> <a href="{{artist.url}}">
<img class="image" pfm-src-loader="{{artist.avatars.small}}" pfm-src-size="small" /> <img class="image" pfm-src-loader="artist.avatars.small" pfm-src-size="small" />
<span class="info"> <span class="info">
<span class="title" bo-text="artist.name"></span> <span class="title" bo-text="artist.name"></span>
<span class="published"> <span class="published">

View file

@ -1,7 +1,7 @@
<ul class="albums-listing {{class}}"> <ul class="albums-listing {{class}}">
<li ng-repeat="album in albums" bindonce> <li ng-repeat="album in albums" bindonce>
<a bo-href="album.url"> <a bo-href="album.url">
<img class="image" pfm-src-loader="{{album.covers.small}}" pfm-src-size="small" /> <img class="image" pfm-src-loader="album.covers.small" pfm-src-size="small" />
<span class="info"> <span class="info">
<span class="title" bo-text="album.title"></span> <span class="title" bo-text="album.title"></span>
<span class="published"> <span class="published">

View file

@ -10,7 +10,7 @@
There are no comments yet! There are no comments yet!
</li> </li>
<li bindonce ng-repeat="comment in resource.comments"> <li bindonce ng-repeat="comment in resource.comments">
<img pfm-src-loader="{{comment.user.avatars.thumbnail}}" pfm-src-size="thumbnail" /> <img pfm-src-loader="comment.user.avatars.thumbnail" pfm-src-size="thumbnail" />
<div class="content"> <div class="content">
<a bo-href="comment.user.url" bo-text="comment.user.name"></a> <a bo-href="comment.user.url" bo-text="comment.user.name"></a>
<span bo-text="comment.content"></span> <span bo-text="comment.content"></span>

View file

@ -22,7 +22,8 @@
</li> </li>
</ul> </ul>
<div class="image"> <div class="image">
<img pfm-src-loader="{{player.currentTrack.covers.thumbnail}}" pfm-src-size="thumbnail" /> <div class="loader" ng-class="{showing: player.currentTrack.loadingProgress == 0}"><i class="icon-spin icon-rotate-right"></i></div>
<img pfm-src-loader="player.currentTrack.covers.thumbnail" pfm-src-size="thumbnail" />
</div> </div>
<div class="inner"> <div class="inner">
<div class="title"> <div class="title">

View file

@ -1,7 +1,7 @@
<ul class="playlists-listing {{class}}"> <ul class="playlists-listing {{class}}">
<li ng-repeat="playlist in playlists" bindonce> <li ng-repeat="playlist in playlists" bindonce>
<a href="{{playlist.url}}"> <a href="{{playlist.url}}">
<img class="image" pfm-src-loader="{{playlist.covers.small}}" pfm-src-size="small" /> <img class="image" pfm-src-loader="playlist.covers.small" pfm-src-size="small" />
<span class="info"> <span class="info">
<span class="title">{{playlist.title}}</span> <span class="title">{{playlist.title}}</span>
<span class="published"> <span class="published">

View file

@ -3,5 +3,5 @@
<i class="icon-play" ng-show="!track.isPlaying"></i> <i class="icon-play" ng-show="!track.isPlaying"></i>
<i class="icon-pause" ng-hide="!track.isPlaying"></i> <i class="icon-pause" ng-hide="!track.isPlaying"></i>
</a> </a>
<img pfm-src-loader="{{track.covers.thumbnail}}" pfm-src-size="thumbnail" /> <img pfm-src-loader="track.covers.thumbnail" pfm-src-size="thumbnail" />
</div> </div>

View file

@ -5,7 +5,7 @@
<i class="icon-play" ng-show="!track.isPlaying"></i> <i class="icon-play" ng-show="!track.isPlaying"></i>
<i class="icon-pause" ng-hide="!track.isPlaying"></i> <i class="icon-pause" ng-hide="!track.isPlaying"></i>
</a> </a>
<img pfm-src-loader="{{track.covers.thumbnail}}" pfm-src-size="thumbnail" /> <img pfm-src-loader="track.covers.thumbnail" pfm-src-size="thumbnail" />
</div> </div>
<div class="icons"> <div class="icons">
<span><i ng-class="{'icon-microphone-off': !track.is_vocal, 'icon-microphone': track.is_vocal}"></i></span> <span><i ng-class="{'icon-microphone-off': !track.is_vocal, 'icon-microphone': track.is_vocal}"></i></span>

View file

@ -21,7 +21,7 @@
<div class="stretch-to-bottom details-columns"> <div class="stretch-to-bottom details-columns">
<div class="right"> <div class="right">
<img class="cover" pfm-src-loader="{{playlist.covers.normal}}" pfm-src-size="normal" /> <img class="cover" pfm-src-loader="playlist.covers.normal" pfm-src-size="normal" />
<div class="share-buttons" pfm-share-buttons> <div class="share-buttons" pfm-share-buttons>
<a class="tumblr" bo-href="playlist.share.tumblrUrl" title="Share on Tumblr" style="display:inline-block; overflow:hidden; width:20px; height:20px; background:url('/images/tumblr-share.png') top left no-repeat transparent;"></a> <a class="tumblr" bo-href="playlist.share.tumblrUrl" title="Share on Tumblr" style="display:inline-block; overflow:hidden; width:20px; height:20px; background:url('/images/tumblr-share.png') top left no-repeat transparent;"></a>

View file

@ -41,7 +41,7 @@
<div class="stretch-to-bottom details-columns"> <div class="stretch-to-bottom details-columns">
<div class="right"> <div class="right">
<img class="cover" pfm-src-loader="{{track.covers.normal}}" pfm-src-size="normal" /> <img class="cover" pfm-src-loader="track.covers.normal" pfm-src-size="normal" />
<div class="share-buttons" pfm-share-buttons> <div class="share-buttons" pfm-share-buttons>
<a class="tumblr" bo-href="track.share.tumblrUrl" title="Share on Tumblr" style="display:inline-block; overflow:hidden; width:20px; height:20px; background:url('/images/tumblr-share.png') top left no-repeat transparent;"></a> <a class="tumblr" bo-href="track.share.tumblrUrl" title="Share on Tumblr" style="display:inline-block; overflow:hidden; width:20px; height:20px; background:url('/images/tumblr-share.png') top left no-repeat transparent;"></a>