mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Updated URL generation to use Laravel 5's helpers.
This commit is contained in:
parent
fe1133e99e
commit
e6c31a1500
12 changed files with 19 additions and 94 deletions
|
@ -28,7 +28,6 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
|||
use Auth;
|
||||
use Cache;
|
||||
use Poniverse\Ponyfm\Traits\TrackCollection;
|
||||
use URL;
|
||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
|
||||
|
@ -131,7 +130,7 @@ class Album extends Model
|
|||
$data['description'] = $album->description;
|
||||
$data['is_downloadable'] = $is_downloadable;
|
||||
$data['share'] = [
|
||||
'url' => URL::to('/a' . $album->id),
|
||||
'url' => action('AlbumsController@getShortlink', ['id' => $album->id]),
|
||||
'tumblrUrl' => 'http://www.tumblr.com/share/link?url=' . urlencode($album->url) . '&name=' . urlencode($album->title) . '&description=' . urlencode($album->description),
|
||||
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $album->title . ' by ' . $album->user->display_name . ' on Pony.fm'
|
||||
];
|
||||
|
@ -198,12 +197,12 @@ class Album extends Model
|
|||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return URL::to('albums/' . $this->id . '-' . $this->slug);
|
||||
return action('AlbumsController@getShow', ['id' => $this->id, 'slug' => $this->slug]);
|
||||
}
|
||||
|
||||
public function getDownloadUrl($format)
|
||||
{
|
||||
return URL::to('a' . $this->id . '/dl.' . Track::$Formats[$format]['extension']);
|
||||
return action('AlbumsController@getDownload', ['id' => $this->id, 'extension' => Track::$Formats[$format]['extension']]);
|
||||
}
|
||||
|
||||
public function getFilesize($format)
|
||||
|
|
|
@ -25,7 +25,6 @@ use Illuminate\Database\Eloquent\Relations\Relation;
|
|||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use URL;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
|
||||
class Genre extends Model
|
||||
|
@ -75,6 +74,6 @@ class Genre extends Model
|
|||
* @return string relative, Angular-friendly URL to this genre
|
||||
*/
|
||||
public function getUrlAttribute() {
|
||||
return URL::route('tracks.discover', ['filter' => "genres-{$this->id}"], false);
|
||||
return route('tracks.discover', ['filter' => "genres-{$this->id}"], false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ use DB;
|
|||
use Input;
|
||||
use Poniverse;
|
||||
use Redirect;
|
||||
use URL;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
@ -36,7 +35,7 @@ class AuthController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->poniverse = new Poniverse(Config::get('poniverse.client_id'), Config::get('poniverse.secret'));
|
||||
$this->poniverse->setRedirectUri(URL::to('/auth/oauth'));
|
||||
$this->poniverse->setRedirectUri(action('AuthController@getOAuth'));
|
||||
}
|
||||
|
||||
public function getLogin()
|
||||
|
@ -62,7 +61,7 @@ class AuthController extends Controller
|
|||
'authorization_code',
|
||||
[
|
||||
'code' => Input::query('code'),
|
||||
'redirect_uri' => URL::to('/auth/oauth')
|
||||
'redirect_uri' => action('AuthController@getOAuth')
|
||||
]);
|
||||
|
||||
if ($code['code'] != 200) {
|
||||
|
|
|
@ -25,7 +25,6 @@ use Config;
|
|||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Response;
|
||||
use URL;
|
||||
|
||||
class ImagesController extends Controller
|
||||
{
|
||||
|
@ -46,7 +45,7 @@ class ImagesController extends Controller
|
|||
$filename = $image->getFile($coverType['id']);
|
||||
|
||||
if (!is_file($filename)) {
|
||||
$redirect = URL::to('/images/icons/profile_' . Image::$ImageTypes[$coverType['id']]['name'] . '.png');
|
||||
$redirect = url('/images/icons/profile_' . Image::$ImageTypes[$coverType['id']]['name'] . '.png');
|
||||
|
||||
return Redirect::to($redirect);
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pony.fm - A community for pony fan music.
|
||||
* Copyright (C) 2015 Peter Deltchev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Poniverse\Ponyfm\Http\Controllers;
|
||||
|
||||
use Poniverse\Ponyfm\User;
|
||||
use File;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
public function getAvatar($id, $type)
|
||||
{
|
||||
$coverType = Cover::getCoverFromName($type);
|
||||
|
||||
if ($coverType == null) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
$user = User::find($id);
|
||||
if (!$user) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
return File::inline($user->getAvatarFile($coverType['id']), 'image/png', 'cover.png');
|
||||
}
|
||||
}
|
|
@ -62,8 +62,6 @@ Route::get('/mlpforums-advertising-program', function() { return View::make('pag
|
|||
|
||||
Route::get('i{id}/{type}.png', 'ImagesController@getImage')->where('id', '\d+');
|
||||
|
||||
Route::get('u{id}/avatar_{type}.png', 'UsersController@getAvatar')->where('id', '\d+');
|
||||
|
||||
Route::get('playlist/{id}-{slug}', 'PlaylistsController@getPlaylist');
|
||||
Route::get('p{id}', 'PlaylistsController@getShortlink')->where('id', '\d+');
|
||||
Route::get('p{id}/dl.{extension}', 'PlaylistsController@getDownload' );
|
||||
|
|
|
@ -22,8 +22,7 @@ namespace Poniverse\Ponyfm;
|
|||
|
||||
use External;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Config;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class Image extends Model
|
||||
|
@ -101,7 +100,7 @@ class Image extends Model
|
|||
{
|
||||
$type = self::$ImageTypes[$type];
|
||||
|
||||
return URL::to('i' . $this->id . '/' . $type['name'] . '.png');
|
||||
return action('ImagesController@getImage', ['id' => $this->id, 'type' => $type['name']]);
|
||||
}
|
||||
|
||||
public function getFile($type = self::NORMAL)
|
||||
|
|
|
@ -27,7 +27,6 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
|||
use Auth;
|
||||
use Cache;
|
||||
use Poniverse\Ponyfm\Traits\TrackCollection;
|
||||
use URL;
|
||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
|
||||
|
@ -88,7 +87,7 @@ class Playlist extends Model
|
|||
$data['comments'] = $comments;
|
||||
$data['formats'] = $formats;
|
||||
$data['share'] = [
|
||||
'url' => URL::to('/p' . $playlist->id),
|
||||
'url' => action('PlaylistsController@getShortlink', ['id' => $playlist->id]),
|
||||
'tumblrUrl' => 'http://www.tumblr.com/share/link?url=' . urlencode($playlist->url) . '&name=' . urlencode($playlist->title) . '&description=' . urlencode($playlist->description),
|
||||
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $playlist->title . ' by ' . $playlist->user->display_name . ' on Pony.fm'
|
||||
];
|
||||
|
@ -202,12 +201,12 @@ class Playlist extends Model
|
|||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return URL::to('/playlist/' . $this->id . '-' . $this->slug);
|
||||
return action('PlaylistsController@getPlaylist', ['id' => $this->id, 'slug' => $this->slug]);
|
||||
}
|
||||
|
||||
public function getDownloadUrl($format)
|
||||
{
|
||||
return URL::to('p' . $this->id . '/dl.' . Track::$Formats[$format]['extension']);
|
||||
return action('PlaylistsController@getDownload', ['id' => $this->id]);
|
||||
}
|
||||
|
||||
public function getFilesize($format)
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
|
||||
namespace Poniverse\Ponyfm\Providers;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Illuminate\Auth\Guard;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
// use PFMAuth;
|
||||
use PfmValidator;
|
||||
use Validator;
|
||||
|
||||
|
@ -37,12 +33,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
/*
|
||||
Auth::extend('pfm', function() {
|
||||
return new Guard(new PFMAuth(), App::make('session.store'));
|
||||
});
|
||||
*/
|
||||
|
||||
Validator::resolver(function($translator, $data, $rules, $messages)
|
||||
{
|
||||
return new PfmValidator($translator, $data, $rules, $messages);
|
||||
|
|
|
@ -33,7 +33,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use URL;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
|
||||
class Track extends Model
|
||||
|
@ -257,8 +256,8 @@ class Track extends Model
|
|||
}
|
||||
|
||||
$returnValue['share'] = [
|
||||
'url' => URL::to('/t' . $track->id),
|
||||
'html' => '<iframe src="' . URL::to('t' . $track->id . '/embed') . '" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
|
||||
'url' => action('TracksController@getShortlink', ['id' => $track->id]),
|
||||
'html' => '<iframe src="' . action('TracksController@getEmbed', ['id' => $track->id]) . '" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
|
||||
'bbcode' => '[url=' . $track->url . '][img]' . $track->getCoverUrl() . '[/img][/url]',
|
||||
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $track->title . ' by ' . $track->user->display_name . ' on Pony.fm'
|
||||
];
|
||||
|
@ -477,7 +476,7 @@ class Track extends Model
|
|||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return URL::to('/tracks/' . $this->id . '-' . $this->slug);
|
||||
return action('TracksController@getTrack', ['id' => $this->id, 'slug' => $this->slug]);
|
||||
}
|
||||
|
||||
public function getDownloadDirectoryAttribute()
|
||||
|
@ -537,7 +536,7 @@ class Track extends Model
|
|||
|
||||
public function getStreamUrl($format = 'MP3')
|
||||
{
|
||||
return URL::to('/t' . $this->id . '/stream.' . self::$Formats[$format]['extension']);
|
||||
return action('TracksController@getStream', ['id' => $this->id, 'extension' => self::$Formats[$format]['extension']]);
|
||||
}
|
||||
|
||||
public function getDirectory()
|
||||
|
@ -605,7 +604,7 @@ class Track extends Model
|
|||
|
||||
$format = self::$Formats[$format];
|
||||
|
||||
return URL::to('/t' . $this->id . '/dl.' . $format['extension']);
|
||||
return action('TracksController@getDownload', ['id' => $this->id, 'extension' => $format['extension']]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use Helpers;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use App;
|
||||
use File;
|
||||
use URL;
|
||||
|
||||
class TrackFile extends Model
|
||||
{
|
||||
|
@ -88,7 +87,7 @@ class TrackFile extends Model
|
|||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return URL::to('/t' . $this->track_id . '/dl.' . $this->extension);
|
||||
return action('TracksController@getDownload', ['id' => $this->track_id, 'extension' => $this->extension]);
|
||||
}
|
||||
|
||||
public function getSizeAttribute()
|
||||
|
|
13
app/User.php
13
app/User.php
|
@ -85,7 +85,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return URL::to('/' . $this->slug);
|
||||
return action('ArtistsController@getProfile', $this->slug);
|
||||
}
|
||||
|
||||
public function getMessageUrlAttribute()
|
||||
|
@ -133,17 +133,6 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
return Gravatar::getUrl($email, Image::$ImageTypes[$type]['width']);
|
||||
}
|
||||
|
||||
public function getAvatarFile($type = Image::NORMAL)
|
||||
{
|
||||
if ($this->uses_gravatar) {
|
||||
throw new Exception('Cannot get avatar file if this user is configured to use Gravatar!');
|
||||
}
|
||||
|
||||
$imageType = Image::$ImageTypes[$type];
|
||||
|
||||
return URL::to('t' . $this->id . '/cover_' . $imageType['name'] . '.png?' . $this->cover_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token value for the "remember me" session.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue