That... Could have gone better

This commit is contained in:
Pablo Ferreiro 2022-03-11 23:18:26 +01:00
parent 605e204453
commit c62df9d631
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
11 changed files with 32 additions and 39 deletions

View file

@ -24,6 +24,11 @@ class JSONCache {
return false;
}
public function exists(string $cache_key): bool {
$filename = $this->cache_path . '/' . $cache_key . '.json';
return is_file($filename);
}
public function set(string $cache_key, mixed $data, $timeout = 3600) {
file_put_contents($this->cache_path . '/' . $cache_key . '.json', json_encode([
'data' => $data,

View file

@ -27,7 +27,11 @@ class RedisCache {
return null;
}
public function set(string $cache_key, array $data, $timeout = 3600) {
$this->client->set($cache_key, json_encode($data), $timeout);
public function exists(string $cache_key): bool {
return $this->client->exists($cache_key);
}
public function set(string $cache_key, string $data, $timeout = 3600) {
$this->client->set($cache_key, $data, $timeout);
}
}

View file

@ -10,7 +10,7 @@ class TagController {
static public function get(string $name) {
$cursor = Misc::getCursor();
$api = Misc::api();
$feed = $api->getChallengeFeed($name, $cursor);
$feed = $api->getHashtagFeed($name, $cursor);
if ($feed->meta->success) {
$latte = Misc::latte();
$latte->render(Misc::getView('tag'), new FeedTemplate('Tag', $feed));
@ -21,9 +21,9 @@ class TagController {
static public function rss(string $name) {
$api = Misc::api();
$feed = $api->getChallengeFeed($name);
$feed = $api->getHashtagFeed($name);
if ($feed->meta->success) {
$feed = RSS::build("/tag/{$name}", "{$name} Tag", $feed->info->detail->challenge->desc, $feed->items);
$feed = RSS::build("/tag/{$name}", "{$name} Tag", $feed->info->detail->desc, $feed->items);
// Setup headers
RSS::setHeaders('tag.rss');
echo $feed;

View file

@ -18,7 +18,7 @@ class UserController {
exit;
}
$latte = Misc::latte();
$latte->render(Misc::getView('user'), new FeedTemplate($feed->info->detail->user->nickname, $feed));
$latte->render(Misc::getView('user'), new FeedTemplate($feed->info->detail->nickname, $feed));
} else {
ErrorHandler::show($feed->meta);
}
@ -28,7 +28,7 @@ class UserController {
$api = Misc::api();
$feed = $api->getUserFeed($username);
if ($feed->meta->success) {
$feed = RSS::build('/@'.$username, $feed->info->detail->user->nickname, $feed->info->detail->user->signature, $feed->items);
$feed = RSS::build('/@'.$username, $feed->info->detail->nickname, $feed->info->detail->signature, $feed->items);
// Setup headers
RSS::setHeaders('user.rss');
echo $feed;