From 78fe44070c741655a2fe1548d6d480c6fda3292e Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Thu, 26 Jan 2023 19:21:14 +0100 Subject: [PATCH] Fixed Trending and normalized Discover --- app/Controllers/DiscoverController.php | 10 +++++----- app/Models/DiscoverTemplate.php | 13 +++++++++++++ app/Models/FeedTemplate.php | 10 +++++----- composer.json | 2 +- composer.lock | 14 +++++++------- templates/components/themes/common/controls.latte | 2 +- templates/views/discover.latte | 2 +- 7 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 app/Models/DiscoverTemplate.php diff --git a/app/Controllers/DiscoverController.php b/app/Controllers/DiscoverController.php index 052e668..a2d033b 100644 --- a/app/Controllers/DiscoverController.php +++ b/app/Controllers/DiscoverController.php @@ -3,16 +3,16 @@ namespace App\Controllers; use App\Helpers\ErrorHandler; use App\Helpers\Wrappers; -use App\Models\FeedTemplate; +use App\Models\DiscoverTemplate; class DiscoverController { static public function get() { $api = Wrappers::api(); - $feed = $api->discover(); - if ($feed->meta->success) { - Wrappers::latte('discover', new FeedTemplate('Discover', $feed)); + $data = $api->discover(); + if ($data->meta->success) { + Wrappers::latte('discover', new DiscoverTemplate($data)); } else { - ErrorHandler::showMeta($feed->meta); + ErrorHandler::showMeta($data->meta); } } } diff --git a/app/Models/DiscoverTemplate.php b/app/Models/DiscoverTemplate.php new file mode 100644 index 0000000..46a9387 --- /dev/null +++ b/app/Models/DiscoverTemplate.php @@ -0,0 +1,13 @@ +data = $data; + } +} diff --git a/app/Models/FeedTemplate.php b/app/Models/FeedTemplate.php index f933ed3..a26e490 100644 --- a/app/Models/FeedTemplate.php +++ b/app/Models/FeedTemplate.php @@ -1,16 +1,16 @@ data = (object) [ - 'feed' => $feed - ]; + $this->feed = $feed; } } diff --git a/composer.json b/composer.json index b6654a1..50cb54b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "pablouser1/proxitok", "description": "An alternative frontend for TikTok", - "version": "2.4.4.3", + "version": "2.4.5.0", "license": "AGPL-3.0-or-later", "type": "project", "authors": [ diff --git a/composer.lock b/composer.lock index 9cc1f04..c734b47 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "acb47eb00001b55dbf6825b0ce79cd0b", + "content-hash": "818a3e623705c076822f3d895a0d99ca", "packages": [ { "name": "bramus/router", @@ -263,16 +263,16 @@ }, { "name": "pablouser1/tikscraper", - "version": "v2.3.3.5", + "version": "v2.3.4.0", "source": { "type": "git", "url": "https://github.com/pablouser1/TikScraperPHP.git", - "reference": "d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef" + "reference": "8ee7efd58892d0a6e536b7cc29de200202916394" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef", - "reference": "d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef", + "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/8ee7efd58892d0a6e536b7cc29de200202916394", + "reference": "8ee7efd58892d0a6e536b7cc29de200202916394", "shasum": "" }, "require": { @@ -305,9 +305,9 @@ "description": "Get data from TikTok API", "support": { "issues": "https://github.com/pablouser1/TikScraperPHP/issues", - "source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.3.5" + "source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.4.0" }, - "time": "2023-01-26T16:19:23+00:00" + "time": "2023-01-26T18:18:34+00:00" }, { "name": "php-webdriver/webdriver", diff --git a/templates/components/themes/common/controls.latte b/templates/components/themes/common/controls.latte index caa5b9f..b2ad592 100644 --- a/templates/components/themes/common/controls.latte +++ b/templates/components/themes/common/controls.latte @@ -1,4 +1,4 @@ -
+
{* is_numeric is used to avoid having a back button with ttwid cursors *} {if isset($_GET['cursor']) && is_numeric($_GET['cursor']) && $_GET['cursor'] != 0} First diff --git a/templates/views/discover.latte b/templates/views/discover.latte index 93b61eb..ea2d65d 100644 --- a/templates/views/discover.latte +++ b/templates/views/discover.latte @@ -5,7 +5,7 @@ {/block} {block content} - {foreach $data->feed->items as $type => $items} + {foreach $data->items as $type => $items}

{$type|firstUpper}

{foreach $items as $item}