mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27: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++;
|
||||
}
|
||||
|
||||
$returned_album = Album::mapPublicAlbumShow($album);
|
||||
if($returned_album['is_downloadable'] == 0) {
|
||||
unset($returned_album['formats']);
|
||||
}
|
||||
|
||||
return Response::json([
|
||||
'album' => Album::mapPublicAlbumShow($album)
|
||||
'album' => $returned_album
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,12 @@
|
|||
$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() {
|
||||
|
|
|
@ -76,11 +76,20 @@
|
|||
$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['tracks'] = $tracks;
|
||||
$data['comments'] = $comments;
|
||||
$data['formats'] = $formats;
|
||||
$data['description'] = $album->description;
|
||||
$data['is_downloadable'] = $is_downloadable;
|
||||
$data['share'] = [
|
||||
'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),
|
||||
|
@ -160,7 +169,10 @@
|
|||
return Cache::remember($this->getCacheKey('filesize-' . $format), 1440, function() use ($tracks, $format) {
|
||||
$size = 0;
|
||||
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;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="resource-details album-details" bindonce="album">
|
||||
<ul class="dropdowns">
|
||||
<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
|
||||
</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>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="resource-details track-details" bindonce="track">
|
||||
<ul class="dropdowns">
|
||||
<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
|
||||
</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>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue