2022-01-30 18:02:52 -05:00
|
|
|
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
use App\Helpers\ErrorHandler;
|
|
|
|
use App\Helpers\Misc;
|
2022-11-04 15:08:19 -04:00
|
|
|
use App\Helpers\UrlBuilder;
|
2022-03-29 13:30:31 -04:00
|
|
|
use App\Helpers\Wrappers;
|
2022-05-24 08:10:41 -04:00
|
|
|
use App\Models\FullTemplate;
|
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-05-24 08:10:41 -04:00
|
|
|
$hashtag = $api->hashtag($name);
|
|
|
|
$hashtag->feed($cursor);
|
|
|
|
if ($hashtag->ok()) {
|
2022-11-26 17:28:59 -05:00
|
|
|
$info = $hashtag->getInfo();
|
|
|
|
$feed = $hashtag->getFeed();
|
|
|
|
Wrappers::latte('tag', new FullTemplate($info->detail->title, $info, $feed));
|
2022-01-30 18:02:52 -05:00
|
|
|
} else {
|
2022-09-03 08:01:03 -04:00
|
|
|
ErrorHandler::showMeta($hashtag->error());
|
2022-01-30 18:02:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static public function rss(string $name) {
|
2022-03-29 13:30:31 -04:00
|
|
|
$api = Wrappers::api();
|
2022-05-24 08:10:41 -04:00
|
|
|
$hashtag = $api->hashtag($name);
|
|
|
|
$hashtag->feed();
|
|
|
|
if ($hashtag->ok()) {
|
|
|
|
$data = $hashtag->getFull();
|
2022-11-04 15:08:19 -04:00
|
|
|
Misc::rss($name);
|
|
|
|
Wrappers::latte('rss', new RSSTemplate($name, $data->info->detail->desc, UrlBuilder::tag($name), $data->feed->items));
|
2022-01-30 18:02:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|