mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-28 23:57:59 +01:00
Implement appropriate behaviour to respond to tracks not being downloadable; fix album file size
This commit is contained in:
parent
30153bb69f
commit
a8cbe6d0b9
5 changed files with 29 additions and 7 deletions
|
@ -47,8 +47,13 @@
|
||||||
$album->view_count++;
|
$album->view_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$returned_album = Album::mapPublicAlbumShow($album);
|
||||||
|
if($returned_album['is_downloadable'] == 0) {
|
||||||
|
unset($returned_album['formats']);
|
||||||
|
}
|
||||||
|
|
||||||
return Response::json([
|
return Response::json([
|
||||||
'album' => Album::mapPublicAlbumShow($album)
|
'album' => $returned_album
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,12 @@
|
||||||
$track->view_count++;
|
$track->view_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json(['track' => Track::mapPublicTrackShow($track)], 200);
|
$returned_track = Track::mapPublicTrackShow($track);
|
||||||
|
if ($returned_track['is_downloadable'] != 1) {
|
||||||
|
unset($returned_track['formats']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::json(['track' => $returned_track], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIndex() {
|
public function getIndex() {
|
||||||
|
|
|
@ -76,11 +76,20 @@
|
||||||
$comments[] = Comment::mapPublic($comment);
|
$comments[] = Comment::mapPublic($comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_downloadable = 0;
|
||||||
|
foreach ($album->tracks as $track) {
|
||||||
|
if ($track->is_downloadable == 1) {
|
||||||
|
$is_downloadable = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = self::mapPublicAlbumSummary($album);
|
$data = self::mapPublicAlbumSummary($album);
|
||||||
$data['tracks'] = $tracks;
|
$data['tracks'] = $tracks;
|
||||||
$data['comments'] = $comments;
|
$data['comments'] = $comments;
|
||||||
$data['formats'] = $formats;
|
$data['formats'] = $formats;
|
||||||
$data['description'] = $album->description;
|
$data['description'] = $album->description;
|
||||||
|
$data['is_downloadable'] = $is_downloadable;
|
||||||
$data['share'] = [
|
$data['share'] = [
|
||||||
'url' => URL::to('/a' . $album->id),
|
'url' => URL::to('/a' . $album->id),
|
||||||
'tumblrUrl' => 'http://www.tumblr.com/share/link?url=' . urlencode($album->url) . '&name=' . urlencode($album->title) . '&description=' . urlencode($album->description),
|
'tumblrUrl' => 'http://www.tumblr.com/share/link?url=' . urlencode($album->url) . '&name=' . urlencode($album->title) . '&description=' . urlencode($album->description),
|
||||||
|
@ -160,7 +169,10 @@
|
||||||
return Cache::remember($this->getCacheKey('filesize-' . $format), 1440, function() use ($tracks, $format) {
|
return Cache::remember($this->getCacheKey('filesize-' . $format), 1440, function() use ($tracks, $format) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach ($tracks as $track) {
|
foreach ($tracks as $track) {
|
||||||
$size += $track->getFilesize($format);
|
// Ensure that only downloadable tracks are added onto the file size
|
||||||
|
if ($track->is_downloadable == 1) {
|
||||||
|
$size += $track->getFilesize($format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $size;
|
return $size;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<div class="resource-details album-details" bindonce="album">
|
<div class="resource-details album-details" bindonce="album">
|
||||||
<ul class="dropdowns">
|
<ul class="dropdowns">
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="btn btn-small btn-info dropdown-toggle">
|
<a href="#" class="btn btn-small btn-info dropdown-toggle" ng-disabled="album.is_downloadable == 0">
|
||||||
Downloads
|
Downloads
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu" ng-show="album.is_downloadable == 1">
|
||||||
<li bindonce ng-repeat="format in album.formats"><a target="_blank" bo-href="format.url"><span bo-text="format.name"></span> <small bo-text="'(' + format.size + ')'"></small></a></li>
|
<li bindonce ng-repeat="format in album.formats"><a target="_blank" bo-href="format.url"><span bo-text="format.name"></span> <small bo-text="'(' + format.size + ')'"></small></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<div class="resource-details track-details" bindonce="track">
|
<div class="resource-details track-details" bindonce="track">
|
||||||
<ul class="dropdowns">
|
<ul class="dropdowns">
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="btn btn-small btn-info dropdown-toggle">
|
<a href="#" class="btn btn-small btn-info dropdown-toggle" ng-disabled="track.is_downloadable == 0">
|
||||||
Downloads
|
Downloads
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu" ng-show="track.is_downloadable == 1">
|
||||||
<li bindonce ng-repeat="format in track.formats"><a target="_blank" bo-href="format.url"><span bo-text="format.name"></span> <small bo-text="'(' + format.size + ')'"></small></a></li>
|
<li bindonce ng-repeat="format in track.formats"><a target="_blank" bo-href="format.url"><span bo-text="format.name"></span> <small bo-text="'(' + format.size + ')'"></small></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in a new issue