2022-01-30 18:02:52 -05:00
|
|
|
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
use App\Helpers\ErrorHandler;
|
|
|
|
use App\Helpers\Misc;
|
|
|
|
use App\Helpers\RSS;
|
|
|
|
use App\Models\FeedTemplate;
|
|
|
|
|
|
|
|
class TagController {
|
|
|
|
static public function get(string $name) {
|
|
|
|
$cursor = Misc::getCursor();
|
|
|
|
$api = Misc::api();
|
2022-02-16 09:20:35 -05:00
|
|
|
$feed = $api->getChallengeFeed($name, $cursor);
|
2022-01-30 18:02:52 -05:00
|
|
|
if ($feed->meta->success) {
|
|
|
|
$latte = Misc::latte();
|
|
|
|
$latte->render(Misc::getView('tag'), new FeedTemplate('Tag', $feed));
|
|
|
|
} else {
|
|
|
|
ErrorHandler::show($feed->meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static public function rss(string $name) {
|
|
|
|
$api = Misc::api();
|
2022-02-16 09:20:35 -05:00
|
|
|
$feed = $api->getChallengeFeed($name);
|
2022-01-30 18:02:52 -05:00
|
|
|
if ($feed->meta->success) {
|
2022-02-16 09:20:35 -05:00
|
|
|
$feed = RSS::build("/tag/{$name}", "{$name} Tag", $feed->info->detail->challenge->desc, $feed->items);
|
2022-01-30 18:02:52 -05:00
|
|
|
// Setup headers
|
|
|
|
RSS::setHeaders('tag.rss');
|
|
|
|
echo $feed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|