KT-personal-website/app/Controllers/Dev.php

94 lines
2.9 KiB
PHP
Raw Normal View History

2024-10-22 12:26:08 +02:00
<?php
namespace App\Controllers;
use App\Blogs\Blogs;
use App\Cache;
use App\Fetching\Gitea;
use App\Fetching\Shaarli;
use App\Utils\Debug;
use App\Utils\Config;
use App\Fetching\NanoGal;
class Dev {
private $title = null;
function index($params) {
ob_start();
$params = ['config' => Config::loadConfig()];
$params['config']['cron'] = true;
//Debug::n_print($params);
//Cache::clearCache('feed');
//Cache::clearCache('page');
//Cache::clearCache('post');
Cache::clearCache('posts');
$shaarli = new Shaarli($params);
if (Cache::isValidFeed('shaarli', $shaarli->shaarliFeedUpdate)) {
$shaarliCache = Cache::getCache('shaarli', 'feed');
$shaarliRegenCache = 'Shaarli : cache';
} else {
Cache::unValidateCache('shaarli', 'feed');
Cache::unValidateCache('/', 'page');
$shaarli->getLastBookmark();
$shaarliCache = $shaarli->makeList();
Cache::setCache('shaarli', $shaarliCache, 'feed');
$shaarliRegenCache = 'Shaarli : regen';
}
$nanogal = new NanoGal($params);
if (Cache::isValidFeed('nanogal', $nanogal->nanogalFeedUpdate)) {
$nanogalCache = Cache::getCache('nanogal', 'feed');
$nanogalRegenCache = 'Nanogal : cache';
} else {
Cache::unValidateCache('nanogal', 'feed');
Cache::unValidateCache('/', 'page');
$nanogal->getLastBookmark();
$nanogalCache = $nanogal->makeList();
Cache::setCache('nanogal', $nanogalCache, 'feed');
$nanogalRegenCache = 'Nanogal : regen';
}
$gitea = new Gitea($params);
$gitea->getLastRepo();
$repoCache = $gitea->makeList();
if (Cache::isValidApi('gitea', $gitea->giteaHash)) {
$repoCache = Cache::getCache('gitea', 'feed');
$giteaRegenCache = 'Gitea : cache';
} else {
Cache::unValidateCache('gitea', 'feed');
Cache::unValidateCache('/', 'page');
Cache::setCache('gitea', $repoCache, 'feed');
$giteaRegenCache = 'Gitea : regen';
}
$post = new Blogs($params);
$post->getLastPost();
$postCache = $post->makeList();
if (Cache::isValidApi('posts', $post->postsHash)) {
$postCache = Cache::getCache('posts', 'feed');
$postRegenCache = 'Post : cache';
} else {
Cache::unValidateCache('posts', 'feed');
Cache::unValidateCache('/', 'page');
Cache::setCache('posts', $postCache, 'feed');
$postRegenCache = 'Post : regen';
}
require __DIR__ . '/../../template/dev.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
function title() {
return $this->title;
}
}