WIP embed.js support and robots.txt

This commit is contained in:
Pablo Ferreiro 2022-04-10 12:10:48 +02:00
parent 5368c08039
commit d0d36c26f3
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
15 changed files with 108 additions and 44 deletions

View file

@ -0,0 +1,20 @@
<?php
namespace App\Controllers;
use App\Helpers\ErrorHandler;
use App\Helpers\Misc;
use App\Helpers\Wrappers;
use App\Models\VideoTemplate;
class EmbedController {
static public function v2(int $id) {
$api = Wrappers::api();
$feed = $api->getVideoByID($id);
if ($feed->meta->success) {
$latte = Wrappers::latte();
$latte->render(Misc::getView('video'), new VideoTemplate($feed->items[0], $feed->info->detail, true));
} else {
ErrorHandler::show($feed->meta);
}
}
}

View file

@ -6,6 +6,7 @@ use App\Helpers\Misc;
use App\Helpers\Wrappers;
use App\Models\FeedTemplate;
use App\Models\RSSTemplate;
use App\Models\VideoTemplate;
class UserController {
static public function get(string $username) {
@ -30,7 +31,7 @@ class UserController {
$feed = $api->getVideoByID($video_id);
if ($feed->meta->success) {
$latte = Wrappers::latte();
$latte->render(Misc::getView('video'), new FeedTemplate('Video', $feed));
$latte->render(Misc::getView('video'), new VideoTemplate($feed->items[0], $feed->info->detail));
} else {
ErrorHandler::show($feed->meta);
}

View file

@ -0,0 +1,22 @@
<?php
namespace App\Models;
/**
* Base for templates with a feed
*/
class VideoTemplate extends BaseTemplate {
public object $item;
public object $detail;
public string $layout = 'hero';
function __construct(object $item, object $detail, bool $isEmbed = false) {
parent::__construct('Video');
$this->item = $item;
$this->detail = $detail;
if ($isEmbed) {
$this->layout = 'embed';
} else {
$this->layout = 'hero';
}
}
}