2022-01-30 18:02:52 -05:00
|
|
|
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
use App\Helpers\ErrorHandler;
|
|
|
|
use App\Helpers\Misc;
|
2022-03-29 13:30:31 -04:00
|
|
|
use App\Helpers\Wrappers;
|
2022-01-30 18:02:52 -05:00
|
|
|
use App\Models\FeedTemplate;
|
2022-03-29 13:30:31 -04:00
|
|
|
use App\Models\RSSTemplate;
|
2022-01-30 18:02:52 -05:00
|
|
|
|
|
|
|
class TagController {
|
|
|
|
static public function get(string $name) {
|
|
|
|
$cursor = Misc::getCursor();
|
2022-03-29 13:30:31 -04:00
|
|
|
$api = Wrappers::api();
|
2022-03-11 17:18:26 -05:00
|
|
|
$feed = $api->getHashtagFeed($name, $cursor);
|
2022-01-30 18:02:52 -05:00
|
|
|
if ($feed->meta->success) {
|
2022-03-29 13:30:31 -04:00
|
|
|
$latte = Wrappers::latte();
|
2022-01-30 18:02:52 -05:00
|
|
|
$latte->render(Misc::getView('tag'), new FeedTemplate('Tag', $feed));
|
|
|
|
} else {
|
|
|
|
ErrorHandler::show($feed->meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static public function rss(string $name) {
|
2022-03-29 13:30:31 -04:00
|
|
|
$api = Wrappers::api();
|
2022-03-11 17:18:26 -05:00
|
|
|
$feed = $api->getHashtagFeed($name);
|
2022-01-30 18:02:52 -05:00
|
|
|
if ($feed->meta->success) {
|
2022-03-29 13:30:31 -04:00
|
|
|
$latte = Wrappers::latte();
|
|
|
|
$latte->render(Misc::getView('rss'), new RSSTemplate($name, $feed->info->detail->desc, "/tag/{$name}", $feed->items));
|
2022-01-30 18:02:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|