Nicer error display
This commit is contained in:
parent
96fb2fd428
commit
38557fafa6
|
@ -38,7 +38,6 @@ Apply to: Main window (address bar)
|
||||||
* Fix embed styling
|
* Fix embed styling
|
||||||
* Fix crash when invalid vm.tiktok.com/CODE or www.tiktok.com/t/CODE is provided
|
* Fix crash when invalid vm.tiktok.com/CODE or www.tiktok.com/t/CODE is provided
|
||||||
* Add custom amount of videos per page
|
* Add custom amount of videos per page
|
||||||
* Discover does not work
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
[@TheFrenchGhosty](https://github.com/TheFrenchGhosty): Initial Dockerfile and fixes to a usable state. You can check his Docker image [here](https://github.com/PussTheCat-org/docker-proxitok-quay) on Github or [here](https://quay.io/repository/pussthecatorg/proxitok) on Quay
|
[@TheFrenchGhosty](https://github.com/TheFrenchGhosty): Initial Dockerfile and fixes to a usable state. You can check his Docker image [here](https://github.com/PussTheCat-org/docker-proxitok-quay) on Github or [here](https://quay.io/repository/pussthecatorg/proxitok) on Quay
|
||||||
|
|
|
@ -14,7 +14,7 @@ class DiscoverController {
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('discover'), new FeedTemplate('Discover', $feed));
|
$latte->render(Misc::getView('discover'), new FeedTemplate('Discover', $feed));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($feed->meta);
|
ErrorHandler::showMeta($feed->meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,14 @@ use App\Models\VideoTemplate;
|
||||||
class EmbedController {
|
class EmbedController {
|
||||||
static public function v2(int $id) {
|
static public function v2(int $id) {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$feed = $api->getVideoByID($id);
|
$video = $api->video($id);
|
||||||
if ($feed->meta->success) {
|
$video->feed();
|
||||||
|
if ($video->ok()) {
|
||||||
|
$data = $video->getFull();
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('video'), new VideoTemplate($feed->items[0], $feed->info->detail, true));
|
$latte->render(Misc::getView('video'), new VideoTemplate($data->feed->items[0], $data->info->detail, true));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($feed->meta);
|
ErrorHandler::showMeta($video->error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class MusicController {
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('music'), new FullTemplate('Music', $data));
|
$latte->render(Misc::getView('music'), new FullTemplate('Music', $data));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($music->error());
|
ErrorHandler::showMeta($music->error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ class RedirectController {
|
||||||
case 'url':
|
case 'url':
|
||||||
$endpoint = self::to_endpoint($term);
|
$endpoint = self::to_endpoint($term);
|
||||||
if (!$endpoint) {
|
if (!$endpoint) {
|
||||||
echo 'Invalid or unknown TikTok URL format';
|
ErrorHandler::showText(400, 'Invalid TikTok URL');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TagController {
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('tag'), new FullTemplate('Tag', $data));
|
$latte->render(Misc::getView('tag'), new FullTemplate('Tag', $data));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($hashtag->error());
|
ErrorHandler::showMeta($hashtag->error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class TrendingController {
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('trending'), new FeedTemplate('Trending', $feed));
|
$latte->render(Misc::getView('trending'), new FeedTemplate('Trending', $feed));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($trending->error());
|
ErrorHandler::showMeta($trending->error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,13 @@ class UserController {
|
||||||
if ($user->ok()) {
|
if ($user->ok()) {
|
||||||
$data = $user->getFull();
|
$data = $user->getFull();
|
||||||
if ($data->info->detail->privateAccount) {
|
if ($data->info->detail->privateAccount) {
|
||||||
http_response_code(403);
|
ErrorHandler::showText(401, "Private account detected! Not supported");
|
||||||
echo 'Private account detected! Not supported';
|
return;
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('user'), new FullTemplate($data->info->detail->nickname, $data));
|
$latte->render(Misc::getView('user'), new FullTemplate($data->info->detail->nickname, $data));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($user->error());
|
ErrorHandler::showMeta($user->error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ class UserController {
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('video'), new VideoTemplate($data->feed->items[0], $data->info->detail));
|
$latte->render(Misc::getView('video'), new VideoTemplate($data->feed->items[0], $data->info->detail));
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler::show($video->error());
|
ErrorHandler::showMeta($video->error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,15 @@ use App\Models\ErrorTemplate;
|
||||||
use TikScraper\Models\Meta;
|
use TikScraper\Models\Meta;
|
||||||
|
|
||||||
class ErrorHandler {
|
class ErrorHandler {
|
||||||
static public function show(Meta $meta) {
|
static public function showMeta(Meta $meta) {
|
||||||
http_response_code($meta->http_code);
|
http_response_code($meta->http_code);
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('error'), new ErrorTemplate($meta));
|
$latte->render(Misc::getView('error'), new ErrorTemplate($meta->http_code, $meta->tiktok_msg, $meta->tiktok_code));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function showText(int $code, string $msg) {
|
||||||
|
http_response_code($code);
|
||||||
|
$latte = Wrappers::latte();
|
||||||
|
$latte->render(Misc::getView('error'), new ErrorTemplate($code, $msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use TikScraper\Models\Meta;
|
|
||||||
|
|
||||||
class ErrorTemplate extends BaseTemplate {
|
class ErrorTemplate extends BaseTemplate {
|
||||||
public Meta $error;
|
public int $http_code = 502;
|
||||||
|
public ?int $tiktok_code = -1;
|
||||||
|
public string $msg = '';
|
||||||
|
|
||||||
function __construct(object $error) {
|
|
||||||
|
function __construct(int $http_code, string $msg, ?int $tiktok_code = null) {
|
||||||
parent::__construct('Error');
|
parent::__construct('Error');
|
||||||
$this->error = $error;
|
$this->http_code = $http_code;
|
||||||
|
$this->msg = $msg;
|
||||||
|
$this->tiktok_code = $tiktok_code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
|
<a href="{path('/')}" class="navbar-item">ProxiTok</a>
|
||||||
<a role="button" id="navbar-burger" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
<a role="button" id="navbar-burger" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||||
<span aria-hidden="true"></span>
|
<span aria-hidden="true"></span>
|
||||||
<span aria-hidden="true"></span>
|
<span aria-hidden="true"></span>
|
||||||
|
@ -9,9 +10,6 @@
|
||||||
|
|
||||||
<div id="navbar-menu" class="navbar-menu">
|
<div id="navbar-menu" class="navbar-menu">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
<a href="{path('/')}" class="navbar-item">
|
|
||||||
{include './icon.latte', icon: 'home', text: 'Home'}
|
|
||||||
</a>
|
|
||||||
<a href="{path('/settings')}" class="navbar-item">Settings</a>
|
<a href="{path('/settings')}" class="navbar-item">Settings</a>
|
||||||
<a href="{path('/about')}" class="navbar-item">
|
<a href="{path('/about')}" class="navbar-item">
|
||||||
{include './icon.latte', icon: 'info', text: 'About'}
|
{include './icon.latte', icon: 'info', text: 'About'}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "pablouser1/proxitok",
|
"name": "pablouser1/proxitok",
|
||||||
"description": "An alternative frontend for TikTok",
|
"description": "An alternative frontend for TikTok",
|
||||||
"version": "2.4.1.0",
|
"version": "2.4.2.0",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
2
composer.lock
generated
2
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "a7e4990ac4c1935a8cdc93939bf26dc9",
|
"content-hash": "ec01a866b0314de1e8345a625b066075",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bramus/router",
|
"name": "bramus/router",
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/** @var \Bramus\Router\Router $router */
|
/** @var \Bramus\Router\Router $router */
|
||||||
|
|
||||||
|
use App\Helpers\ErrorHandler;
|
||||||
use App\Helpers\Misc;
|
use App\Helpers\Misc;
|
||||||
use App\Helpers\Wrappers;
|
use App\Helpers\Wrappers;
|
||||||
use App\Models\BaseTemplate;
|
use App\Models\BaseTemplate;
|
||||||
|
|
||||||
|
$router->set404(function () {
|
||||||
|
ErrorHandler::showText(404, "That endpoint doesn't exist");
|
||||||
|
});
|
||||||
|
|
||||||
$router->get('/', function () {
|
$router->get('/', function () {
|
||||||
$latte = Wrappers::latte();
|
$latte = Wrappers::latte();
|
||||||
$latte->render(Misc::getView('home'), new BaseTemplate('Home'));
|
$latte->render(Misc::getView('home'), new BaseTemplate('Home'));
|
||||||
|
|
|
@ -2,9 +2,17 @@
|
||||||
|
|
||||||
{block content}
|
{block content}
|
||||||
<p class="title">There was an error processing your request!</p>
|
<p class="title">There was an error processing your request!</p>
|
||||||
<p class="subtitle">HTTP Code: {$error->http_code}</p>
|
<div class="content">
|
||||||
<p class="subtitle">API error code {$error->tiktok_code} ({$error->tiktok_msg})</p>
|
<p>HTTP Code: {$http_code}</p>
|
||||||
{if $error->tiktok_code === 10000 || $error->tiktok_code === -1}
|
{if isset($tiktok_code)}
|
||||||
|
<p>
|
||||||
|
<span>API error code {$tiktok_code} ({$msg})</span>
|
||||||
|
{if $tiktok_code === 10000 || $tiktok_code === -1}
|
||||||
<a href="{path('/verify')}">What does this mean?</a>
|
<a href="{path('/verify')}">What does this mean?</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
</p>
|
||||||
|
{else}
|
||||||
|
<p>{$msg}</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
|
|
Loading…
Reference in a new issue