2021-12-07 13:46:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2020 Ad Aures
|
2021-12-07 13:46:08 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
use CodeIgniter\Controller;
|
|
|
|
use CodeIgniter\HTTP\Response;
|
|
|
|
|
|
|
|
class ColorsController extends Controller
|
|
|
|
{
|
2023-07-06 15:56:05 +00:00
|
|
|
/**
|
|
|
|
* Instance of the main response object.
|
|
|
|
*
|
|
|
|
* @var Response
|
|
|
|
*/
|
|
|
|
protected $response;
|
|
|
|
|
2021-12-07 13:46:08 +00:00
|
|
|
public function index(): Response
|
|
|
|
{
|
|
|
|
$cacheName = 'colors.css';
|
|
|
|
if (
|
|
|
|
! ($colorsCssBody = cache($cacheName))
|
|
|
|
) {
|
2024-04-28 16:39:01 +00:00
|
|
|
$colorThemes = config('Colors')
|
2021-12-07 13:46:08 +00:00
|
|
|
->themes;
|
|
|
|
|
|
|
|
$colorsCssBody = '';
|
|
|
|
foreach ($colorThemes as $name => $color) {
|
|
|
|
$colorsCssBody .= ".theme-{$name} {";
|
|
|
|
foreach ($color as $variable => $value) {
|
|
|
|
$colorsCssBody .= "--color-{$variable}: {$value[0]} {$value[1]}% {$value[2]}%;";
|
|
|
|
}
|
2022-03-04 14:33:48 +00:00
|
|
|
|
2021-12-07 13:46:08 +00:00
|
|
|
$colorsCssBody .= '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
cache()
|
|
|
|
->save($cacheName, $colorsCssBody, DECADE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->response->setHeader('Content-Type', 'text/css')
|
|
|
|
->setHeader('charset', 'UTF-8')
|
|
|
|
->setBody($colorsCssBody);
|
|
|
|
}
|
|
|
|
}
|