mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Start building API v2
This commit is contained in:
@@ -121,16 +121,7 @@ abstract class Capabilities
|
||||
*/
|
||||
public function getForMenu(): array
|
||||
{
|
||||
$serverroot = '';
|
||||
$https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on');
|
||||
|
||||
if (isset($_SERVER['SERVER_NAME'])) {
|
||||
$serverroot = (
|
||||
($https === true ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].
|
||||
(((int) $_SERVER['SERVER_PORT'] !== 80 && (int) $_SERVER['SERVER_PORT'] !== 443) ? ':'.$_SERVER['SERVER_PORT'] : '').
|
||||
WWW_TOP.'/'
|
||||
);
|
||||
}
|
||||
$serverroot = url('/');
|
||||
|
||||
return [
|
||||
'server' => [
|
||||
@@ -141,7 +132,7 @@ abstract class Capabilities
|
||||
'email' => Settings::settingValue('site.main.email'),
|
||||
'meta' => Settings::settingValue('site.main.metakeywords'),
|
||||
'url' => $serverroot,
|
||||
'image' => $serverroot.'assets/images/tmux_logo.png',
|
||||
'image' => $serverroot.'/assets/images/tmux_logo.png',
|
||||
],
|
||||
'limits' => [
|
||||
'max' => 100,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
2018-06-01 DariusIII
|
||||
* Chg: Start building API v2
|
||||
2018-05-31 DariusIII
|
||||
* Fix: Fix rsstoken references in Gentele and shared templates
|
||||
* Chg: Rename rsstoken column into api_token
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Extensions\util\Versions;
|
||||
use App\Models\Category;
|
||||
use App\Models\Settings;
|
||||
use App\Transformers\CategoryTransformer;
|
||||
use Blacklight\http\API;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ApiV2Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function capabilities()
|
||||
{
|
||||
$serverroot = url('/');
|
||||
$category = Category::getForMenu();
|
||||
|
||||
$capabilities = [
|
||||
'server' => [
|
||||
'appversion' => (new Versions())->getGitTagInFile(),
|
||||
'version' => (new Versions())->getGitTagInRepo(),
|
||||
'title' => Settings::settingValue('site.main.title'),
|
||||
'strapline' => Settings::settingValue('site.main.strapline'),
|
||||
'email' => Settings::settingValue('site.main.email'),
|
||||
'meta' => Settings::settingValue('site.main.metakeywords'),
|
||||
'url' => $serverroot,
|
||||
'image' => $serverroot.'/assets/images/tmux_logo.png',
|
||||
],
|
||||
'limits' => [
|
||||
'max' => 100,
|
||||
'default' => 100,
|
||||
],
|
||||
'registration' => [
|
||||
'available' => 'yes',
|
||||
'open' => (int) Settings::settingValue('..registerstatus') === 0 ? 'yes' : 'no',
|
||||
],
|
||||
'searching' => [
|
||||
'search' => ['available' => 'yes', 'supportedParams' => 'q'],
|
||||
'tv-search' => ['available' => 'yes', 'supportedParams' => 'q,vid,tvdbid,traktid,rid,tvmazeid,imdbid,tmdbid,season,ep'],
|
||||
'movie-search' => ['available' => 'yes', 'supportedParams' => 'q,imdbid'],
|
||||
'audio-search' => ['available' => 'no', 'supportedParams' => ''],
|
||||
],
|
||||
'categories' => $category,
|
||||
];
|
||||
|
||||
return response()->json($capabilities);
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class BasePageController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function paginate($query, $totalCount, $items, $page, $path, $reqQuery)
|
||||
public function paginate($query, $totalCount, $items, $page, $path, $reqQuery): LengthAwarePaginator
|
||||
{
|
||||
return new LengthAwarePaginator($query, $totalCount, $items, $page, ['path' => $path, 'query' => $reqQuery]);
|
||||
}
|
||||
|
||||
@@ -18,3 +18,10 @@ Route::prefix('v1')->group(function () {
|
||||
Route::post('api', 'ApiController@api');
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('v2')->middleware('auth:api')->group(function () {
|
||||
Route::namespace('Api')->group(function () {
|
||||
Route::get('capabilities', 'ApiV2Controller@capabilities');
|
||||
Route::post('capabilities', 'ApiV2Controller@capabilities');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user