Pony.fm/routes/web.php

275 lines
15 KiB
PHP
Raw Normal View History

2015-08-30 13:22:00 +02:00
<?php
2021-02-14 20:46:05 +01:00
use App\Http\Controllers\AccountController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AlbumsController;
use App\Http\Controllers\Api\Mobile;
use App\Http\Controllers\Api\V1;
use App\Http\Controllers\Api\Web;
use App\Http\Controllers\ArtistsController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\ContentController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ImagesController;
use App\Http\Controllers\NotificationsController;
use App\Http\Controllers\PlaylistsController;
use App\Http\Controllers\StatsController;
use App\Http\Controllers\TracksController;
use App\Http\Controllers\UploaderController;
use Illuminate\Support\Facades\Route;
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0.
*
* 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/>.
*/
2015-08-30 13:22:00 +02:00
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
2021-02-14 20:46:05 +01:00
Route::get('/dashboard', [TracksController::class, 'getIndex']);
Route::get('/tracks', [TracksController::class, 'getIndex'])->name('tracks.discover');
Route::get('/tracks/popular', [TracksController::class, 'getIndex']);
Route::get('/tracks/random', [TracksController::class, 'getIndex']);
Route::get('tracks/{id}-{slug}', [TracksController::class, 'getTrack']);
Route::get('tracks/{id}-{slug}/edit', [TracksController::class, 'getEdit']);
Route::get('tracks/{id}-{slug}/stats', [StatsController::class, 'getIndex']);
Route::get('t{id}', [TracksController::class, 'getShortlink'])->where('id', '\d+');
Route::get('t{id}/embed', [TracksController::class, 'getEmbed']);
Route::get('t{id}/stream.{extension}', [TracksController::class, 'getStream']);
Route::get('t{id}/dl.{extension}', [TracksController::class, 'getDownload']);
Route::get('albums', [AlbumsController::class, 'getIndex']);
Route::get('albums/{id}-{slug}', [AlbumsController::class, 'getShow']);
Route::get('a{id}', [AlbumsController::class, 'getShortlink'])->where('id', '\d+');
Route::get('a{id}/dl.{extension}', [AlbumsController::class, 'getDownload']);
Route::get('artists', [ArtistsController::class, 'getIndex']);
Route::get('playlists', [PlaylistsController::class, 'getIndex']);
Route::get('/register', [AccountController::class, 'getRegister']);
Route::get('/login', [AuthController::class, 'getLogin']);
Route::post('/auth/logout', [AuthController::class, 'postLogout']);
Route::get('/auth/oauth', [AuthController::class, 'getOAuth']);
Route::post('/auth/poniverse-sync', [AuthController::class, 'postPoniverseAccountSync'])->middleware('throttle:60,1');
2015-09-05 16:59:36 +02:00
Laravel 5.2 Update (#106) * Adopt PSR-2 coding style The Laravel framework adopts the PSR-2 coding style in version 5.1. Laravel apps *should* adopt this coding style as well. Read the [PSR-2 coding style guide][1] for more details and check out [PHPCS][2] to use as a code formatting tool. [1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md [2]: https://github.com/squizlabs/PHP_CodeSniffer * Adopt PHP short array syntax Laravel 5 adopted the short array syntax which became available in PHP 5.4. * Remove SelfHandling from Jobs Jobs are self handling by default in Laravel 5.2. * Add new exceptions to `$dontReport` property * Shift core files * Shift Middleware Laravel 5.2 adjusts the `Guard` object used within middleware. In addition, new `can` and `throttles` middleware were added. * Shift Input to Request facade Laravel 5.2 no longer registers the `Input` facade by default. Laravel now prefers using the `Request` facade or the `$request` object within *Controllers* instead. Review the [HTTP Requests][1] documentation for more details. [1]: https://laravel.com/docs/5.2/requests * Shift configuration Laravel 5.2 introduces the `env` app configuration option and removes the `pretend` mail configuration option. In addition, a few of the default `providers` and `aliases` bindings were removed. * Shift Laravel dependencies * Shift cleanup * Updated composer.lock * Updated Middleware to 5.2 * Config update for Laravel 5.2 * [Laravel 5.2] Updated validation strings * Updated auth config * Updated to use middleware groups * Added laravel 5.2 sessions migration
2016-09-30 00:26:31 +02:00
Route::get('/about', function () {
return View::make('pages.about');
});
Route::get('/faq', function () {
return View::make('pages.faq');
});
Route::get('/mlpforums-advertising-program', function () {
return View::make('pages.mlpforums-advertising-program');
});
2015-09-05 16:59:36 +02:00
2016-11-21 01:42:43 +01:00
Route::get('/hwc2016-rules', function () {
return View::make('pages.hwc-terms');
});
2021-02-14 20:46:05 +01:00
Route::get('i{id}/{type}.{extension}', [ImagesController::class, 'getImage'])->where('id', '\d+');
2015-09-05 16:59:36 +02:00
2021-02-14 20:46:05 +01:00
Route::get('playlist/{id}-{slug}', [PlaylistsController::class, 'getPlaylist']);
Route::get('p{id}', [PlaylistsController::class, 'getShortlink'])->where('id', '\d+');
Route::get('p{id}/dl.{extension}', [PlaylistsController::class, 'getDownload']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:46:05 +01:00
Route::get('notifications', [AccountController::class, 'getNotifications']);
2016-05-27 21:38:59 +02:00
Route::prefix('notifications/email')->group(function () {
2021-02-14 20:46:05 +01:00
Route::get('/unsubscribe/{subscriptionKey}', [NotificationsController::class, 'getEmailUnsubscribe'])->name('email:unsubscribe');
Route::get('/unsubscribed', [NotificationsController::class, 'getEmailUnsubscribePage'])->name('email:confirm-unsubscribed');
Route::get('/click/{emailKey}', [NotificationsController::class, 'getEmailClick'])->name('email:click');
});
2021-02-14 20:46:05 +01:00
Route::get('oembed', [TracksController::class, 'getOembed']);
2015-11-09 20:35:30 +01:00
Route::prefix('api/v1')->middleware('json-exceptions')->group(function () {
2021-02-14 20:58:59 +01:00
Route::get('/tracks/radio-details/{hash}', [V1\TracksController::class, 'getTrackRadioDetails']);
Route::post('/tracks/radio-details/{hash}', [V1\TracksController::class, 'getTrackRadioDetails']);
Route::get('/tracks/{id}', [V1\TracksController::class, 'getTrackDetails'])->where('id', '\d+');
2015-11-09 20:35:30 +01:00
Route::middleware('auth.oauth:ponyfm:tracks:upload')->group(function () {
2021-02-14 20:58:59 +01:00
Route::post('tracks', [V1\TracksController::class, 'postUploadTrack']);
Route::get('/tracks/{id}/upload-status', [V1\TracksController::class, 'getUploadStatus']);
2015-11-09 20:35:30 +01:00
});
2015-09-05 16:59:36 +02:00
});
Route::prefix('api/web')->middleware('cors')->group(function () {
2021-02-14 20:58:59 +01:00
Route::post('/alexa', [Web\AlexaController::class, 'handle']);
2016-09-30 03:36:44 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/taxonomies/all', [Web\TaxonomiesController::class, 'getAll']);
Route::get('/search', [Web\SearchController::class, 'getSearch']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/tracks', [Web\TracksController::class, 'getIndex']);
Route::get('/tracks/{id}', [Web\TracksController::class, 'getShow'])->where('id', '\d+');
Route::get('/tracks/cached/{id}/{format}', [Web\TracksController::class, 'getCachedTrack'])->where(['id' => '\d+', 'format' => '.+']);
Route::get('/tracks/{id}/stats', [Web\StatsController::class, 'getTrackStats'])->where('id', '\d+');
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/albums', [Web\AlbumsController::class, 'getIndex']);
Route::get('/albums/{id}', [Web\AlbumsController::class, 'getShow'])->where('id', '\d+');
Route::get('/albums/cached/{id}/{format}', [Web\AlbumsController::class, 'getCachedAlbum'])->where(['id' => '\d+', 'format' => '.+']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/playlists', [Web\PlaylistsController::class, 'getIndex']);
Route::get('/playlists/show/{id}', [Web\PlaylistsController::class, 'getShow']);
Route::get('/playlists/{id}', [Web\PlaylistsController::class, 'getShow'])->where('id', '\d+');
Route::get('/playlists/cached/{id}/{format}', [Web\PlaylistsController::class, 'getCachedPlaylist'])->where(['id' => '\d+', 'format' => '.+']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/comments/{type}/{id}', [Web\CommentsController::class, 'getIndex'])->where('id', '\d+');
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/artists', [Web\ArtistsController::class, 'getIndex']);
Route::post('/artists', [Web\ArtistsController::class, 'postIndex']);
Route::get('/artists/{slug}', [Web\ArtistsController::class, 'getShow']);
Route::get('/artists/{slug}/content', [Web\ArtistsController::class, 'getContent']);
Route::get('/artists/{slug}/favourites', [Web\ArtistsController::class, 'getFavourites']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/dashboard', [Web\DashboardController::class, 'getIndex']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/announcements', [Web\AnnouncementsController::class, 'getIndex']);
2016-11-11 20:39:31 +01:00
Route::middleware('auth')->group(function () {
2021-02-14 20:58:59 +01:00
Route::post('/tracks/upload', [Web\TracksController::class, 'postUpload']);
Route::get('/tracks/{id}/upload-status', [Web\TracksController::class, 'getUploadStatus']);
Route::post('/tracks/delete/{id}', [Web\TracksController::class, 'postDelete']);
Route::post('/tracks/edit/{id}', [Web\TracksController::class, 'postEdit']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/tracks/{id}/version-upload', [Web\TracksController::class, 'postUploadNewVersion']);
Route::get('/tracks/{id}/version-change/{version}', [Web\TracksController::class, 'getChangeVersion']);
Route::get('/tracks/{id}/version-upload-status', [Web\TracksController::class, 'getVersionUploadStatus']);
Route::get('/tracks/{id}/versions', [Web\TracksController::class, 'getVersionList']);
2021-02-14 20:58:59 +01:00
Route::post('/albums/create', [Web\AlbumsController::class, 'postCreate']);
Route::post('/albums/delete/{id}', [Web\AlbumsController::class, 'postDelete']);
Route::post('/albums/edit/{id}', [Web\AlbumsController::class, 'postEdit']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/playlists/create', [Web\PlaylistsController::class, 'postCreate']);
Route::post('/playlists/delete/{id}', [Web\PlaylistsController::class, 'postDelete']);
Route::post('/playlists/edit/{id}', [Web\PlaylistsController::class, 'postEdit']);
Route::post('/playlists/{id}/add-track', [Web\PlaylistsController::class, 'postAddTrack']);
Route::post('/playlists/{id}/remove-track', [Web\PlaylistsController::class, 'postRemoveTrack']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/comments/{type}/{id}', [Web\CommentsController::class, 'postCreate'])->where('id', '\d+');
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/account/settings/save/{userSlug}', [Web\AccountController::class, 'postSave']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/favourites/toggle', [Web\FavouritesController::class, 'postToggle']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/follow/toggle', [Web\FollowController::class, 'postToggle']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::post('/dashboard/read-news', [Web\DashboardController::class, 'postReadNews']);
Route::get('/account/settings/{slug}', [Web\AccountController::class, 'getSettings']);
2016-06-10 03:19:16 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/notifications', [Web\NotificationsController::class, 'getNotifications']);
Route::put('/notifications/mark-as-read', [Web\NotificationsController::class, 'putMarkAsRead']);
Route::post('/notifications/subscribe', [Web\NotificationsController::class, 'postSubscribe']);
Route::post('/notifications/unsubscribe', [Web\NotificationsController::class, 'postUnsubscribe']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/tracks/edit/{id}', [Web\TracksController::class, 'getEdit']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/users/{userId}', [Web\AccountController::class, 'getUser'])->where('userId', '\d+');
2021-02-14 20:58:59 +01:00
Route::get('/users/{userId}/tracks', [Web\TracksController::class, 'getOwned'])->where('userId', '\d+');
Route::get('/users/{userSlug}/tracks', [Web\TracksController::class, 'getOwned']);
2021-02-14 20:58:59 +01:00
Route::get('/users/{userId}/albums', [Web\AlbumsController::class, 'getOwned'])->where('userId', '\d+');
Route::get('/users/{userSlug}/albums', [Web\AlbumsController::class, 'getOwned']);
2021-02-14 20:58:59 +01:00
Route::get('/users/{userId}/images', [Web\ImagesController::class, 'getOwned'])->where('userId', '\d+');
Route::get('/users/{userSlug}/images', [Web\ImagesController::class, 'getOwned']);
2021-02-14 20:58:59 +01:00
Route::get('/users/{userId}/playlists', [Web\PlaylistsController::class, 'getOwned'])->where('userId', '\d+');
Route::get('/users/{userSlug}/playlists', [Web\PlaylistsController::class, 'getOwned']);
2021-02-14 20:58:59 +01:00
Route::get('/albums/edit/{id}', [Web\AlbumsController::class, 'getEdit']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/playlists/pinned', [Web\PlaylistsController::class, 'getPinned']);
2015-09-05 16:59:36 +02:00
2021-02-14 20:58:59 +01:00
Route::get('/favourites/tracks', [Web\FavouritesController::class, 'getTracks']);
Route::get('/favourites/albums', [Web\FavouritesController::class, 'getAlbums']);
Route::get('/favourites/playlists', [Web\FavouritesController::class, 'getPlaylists']);
2015-09-05 16:59:36 +02:00
});
2021-02-14 20:58:59 +01:00
Route::prefix('admin')->middleware(['auth', 'can:access-admin-area'])->group(function () {
Route::get('/genres', [Web\GenresController::class, 'getIndex']);
Route::post('/genres', [Web\GenresController::class, 'postCreate']);
Route::put('/genres/{id}', [Web\GenresController::class, 'putRename'])->where('id', '\d+');
Route::delete('/genres/{id}', [Web\GenresController::class, 'deleteGenre'])->where('id', '\d+');
Route::get('/showsongs', [Web\ShowSongsController::class, 'getIndex']);
Route::post('/showsongs', [Web\ShowSongsController::class, 'postCreate']);
Route::put('/showsongs/{id}', [Web\ShowSongsController::class, 'putRename'])->where('id', '\d+');
Route::delete('/showsongs/{id}', [Web\ShowSongsController::class, 'deleteSong'])->where('id', '\d+');
Route::get('/tracks', [Web\TracksController::class, 'getAllTracks']);
Route::get('/tracks/unclassified', [Web\TracksController::class, 'getClassifierQueue']);
Route::get('/announcements', [Web\AnnouncementsController::class, 'getAdminIndex']);
Route::get('/announcements/{id}', [Web\AnnouncementsController::class, 'getItemById'])->where('id', '\d+');
Route::post('/announcements', [Web\AnnouncementsController::class, 'postCreate']);
Route::put('/announcements/{id}', [Web\AnnouncementsController::class, 'putUpdate'])->where('id', '\d+');
Route::delete('/announcements/{id}', [Web\AnnouncementsController::class, 'deleteItem'])->where('id', '\d+');
});
2021-02-14 20:58:59 +01:00
Route::get('/auth/current', [Web\AccountController::class, 'getCurrentUser']);
Route::post('/auth/logout', [Web\AuthController::class, 'postLogout']);
2015-09-05 16:59:36 +02:00
});
2021-02-14 20:58:59 +01:00
Route::prefix('admin')->middleware(['auth', 'can:access-admin-area'])->group(function () {
2021-02-14 20:46:05 +01:00
Route::get('/genres', [AdminController::class, 'getGenres']);
Route::get('/tracks', [AdminController::class, 'getTracks']);
Route::get('/tracks/unclassified', [AdminController::class, 'getClassifierQueue']);
Route::get('/show-songs', [AdminController::class, 'getShowSongs']);
Route::get('/users', [AdminController::class, 'getUsers']);
Route::get('/announcements', [AdminController::class, 'getAnnouncements']);
Route::get('/', [AdminController::class, 'getIndex']);
});
2021-02-14 20:46:05 +01:00
Route::get('u{id}', [ArtistsController::class, 'getShortlink'])->where('id', '\d+');
Route::get('users/{id}-{slug}', [ArtistsController::class, 'getShortlink'])->where('id', '\d+');
Route::prefix('{slug}')->group(function () {
2021-02-14 20:46:05 +01:00
Route::get('/', [ArtistsController::class, 'getProfile']);
Route::get('/content', [ArtistsController::class, 'getContent']);
Route::get('/favourites', [ArtistsController::class, 'getFavourites']);
Route::prefix('account')->middleware('auth')->group(function () {
2021-02-14 20:46:05 +01:00
Route::get('/tracks', [ContentController::class, 'getTracks']);
Route::get('/tracks/edit/{id}', [ContentController::class, 'getTracks']);
Route::get('/albums', [ContentController::class, 'getAlbums']);
Route::get('/albums/edit/{id}', [ContentController::class, 'getAlbums']);
Route::get('/albums/create', [ContentController::class, 'getAlbums']);
Route::get('/playlists', [ContentController::class, 'getPlaylists']);
2021-02-14 20:46:05 +01:00
Route::get('/uploader', [UploaderController::class, 'getIndex']);
2021-02-14 20:46:05 +01:00
Route::get('/', [AccountController::class, 'getIndex'])->name('account:settings');
});
});
2015-09-05 16:59:36 +02:00
2021-02-14 20:46:05 +01:00
Route::get('/', [HomeController::class, 'getIndex']);
2015-09-05 16:59:36 +02:00
Route::domain('api.pony.fm')->group(function () {
2021-02-14 20:58:59 +01:00
Route::get('tracks/latest', [Mobile\TracksController::class, 'latest']);
Route::get('tracks/popular', [Mobile\TracksController::class, 'popular']);
});