feat(themes): add ViewThemes library to set views in root themes folder

app, admin, install and authentication views are now located in root themes/ folder
This commit is contained in:
Yassine Doghri 2021-09-02 16:34:25 +00:00
parent 58c8839902
commit 7a276764e6
155 changed files with 356 additions and 178 deletions

View File

@ -2,6 +2,9 @@
declare(strict_types=1);
use App\Libraries\View;
use ViewThemes\Theme;
/**
* The goal of this file is to allow developers a location where they can overwrite core procedural functions and
* replace them with their own. This file is loaded during the bootstrap process and is called during the frameworks
@ -12,3 +15,32 @@ declare(strict_types=1);
*
* @link: https://codeigniter4.github.io/CodeIgniter4/
*/
if (! function_exists('view')) {
/**
* Grabs the current RendererInterface-compatible class and tells it to render the specified view. Simply provides a
* convenience method that can be used in Controllers, libraries, and routed closures.
*
* NOTE: Does not provide any escaping of the data, so that must all be handled manually by the developer.
*
* @param array<string, mixed> $data
* @param array<string, mixed> $options Unused - reserved for third-party extensions.
*/
function view(string $name, array $data = [], array $options = []): string
{
$path = Theme::path();
/** @var CodeIgniter\View\View $renderer */
$renderer = single_service('renderer', $path);
$saveData = config(View::class)->saveData;
if (array_key_exists('saveData', $options)) {
$saveData = (bool) $options['saveData'];
unset($options['saveData']);
}
return $renderer->setData($data, 'raw')
->render($name, $options, $saveData);
}
}

View File

@ -51,6 +51,8 @@ class Autoload extends AutoloadConfig
'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/',
'Config' => APPPATH . 'Config/',
'ViewComponents' => APPPATH . 'Libraries/ViewComponents/',
'ViewThemes' => APPPATH . 'Libraries/ViewThemes/',
'Themes' => ROOTPATH . 'themes',
];
/**

View File

@ -9,14 +9,12 @@ use ViewComponents\Config\ViewComponents as ViewComponentsConfig;
class ViewComponents extends ViewComponentsConfig
{
/**
* @var array<string, string>
* @var string[]
*/
public array $lookupModules = [
APP_NAMESPACE => APPPATH,
'Modules\Admin' => ROOTPATH . 'modules/Admin/',
'Modules\Auth' => ROOTPATH . 'modules/Auth/',
'Modules\Analytics' => ROOTPATH . 'modules/Analytics/',
'Modules\Install' => ROOTPATH . 'modules/Install/',
'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/',
public array $lookupPaths = [
ROOTPATH . 'themes/cp_app/',
ROOTPATH . 'themes/cp_admin/',
ROOTPATH . 'themes/cp_auth/',
ROOTPATH . 'themes/cp_install/',
];
}

View File

@ -8,6 +8,7 @@ use CodeIgniter\Controller;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use ViewThemes\Theme;
/**
* Class BaseController
@ -19,14 +20,6 @@ use Psr\Log\LoggerInterface;
*/
class BaseController extends Controller
{
/**
* An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all
* other controllers that extend BaseController.
*
* @var string[]
*/
protected $helpers = ['auth', 'svg', 'components', 'misc'];
/**
* Constructor.
*/
@ -35,7 +28,11 @@ class BaseController extends Controller
ResponseInterface $response,
LoggerInterface $logger
): void {
$this->helpers = array_merge($this->helpers, ['auth', 'svg', 'components', 'misc']);
// Do Not Edit This Line
parent::initController($request, $response, $logger);
Theme::setTheme('app');
}
}

View File

@ -38,6 +38,7 @@ class HomeController extends BaseController
$data = [
'podcasts' => $allPodcasts,
];
return view('home', $data);
}
}

View File

@ -110,7 +110,7 @@ class View extends CodeIgniterView
}
$output = service('components')
->setCurrentView($view)
->setCurrentView($this->renderVars['file'])
->render($output);
$this->logPerformance($this->renderVars['start'], microtime(true), $this->renderVars['view']);

View File

@ -137,26 +137,26 @@ class ComponentRenderer
private function locateView(string $name): string
{
// TODO: Is there a better way to locate components local to current module?
$modulesToDiscover = [];
$lookupModules = $this->config->lookupModules;
$modulesToDiscover = array_filter($lookupModules, function ($namespace): bool {
return str_starts_with($this->currentView, $namespace);
}, ARRAY_FILTER_USE_KEY);
$modulesToDiscover = array_values($modulesToDiscover);
$modulesToDiscover[] = $this->config->defaultLookupPath;
$pathsToDiscover = [];
$lookupPaths = $this->config->lookupPaths;
$pathsToDiscover = array_filter($lookupPaths, function ($path): bool {
return str_starts_with($this->currentView, $path);
});
$pathsToDiscover = array_values($pathsToDiscover);
$pathsToDiscover[] = $this->config->defaultLookupPath;
$namePath = str_replace('.', '/', $name);
foreach ($modulesToDiscover as $basePath) {
foreach ($pathsToDiscover as $basePath) {
// Look for a class component first
$filePath = $basePath . $this->config->classComponentsPath . '/' . $namePath . '.php';
$filePath = $basePath . $this->config->componentsDirectory . '/' . $namePath . '.php';
if (is_file($filePath)) {
return $filePath;
}
$camelCaseName = strtolower(preg_replace('~(?<!^)(?<!\/)[A-Z]~', '_$0', $namePath) ?? '');
$filePath = $basePath . $this->config->viewFileComponentsPath . '/' . $camelCaseName . '.php';
$snakeCaseName = strtolower(preg_replace('~(?<!^)(?<!\/)[A-Z]~', '_$0', $namePath) ?? '');
$filePath = $basePath . $this->config->componentsDirectory . '/' . $snakeCaseName . '.php';
if (is_file($filePath)) {
return $filePath;

View File

@ -8,17 +8,14 @@ use CodeIgniter\Config\BaseConfig;
class ViewComponents extends BaseConfig
{
public string $classComponentsPath = 'View/Components';
public string $viewFileComponentsPath = 'Views/components';
public string $componentsDirectory = 'Components';
/**
* Modules to look into for local components. Associative array with the module namespace as key and the module path
* as value.
* Paths to look into for local components. Will look for the $componentsDirectory inside.
*
* @var array<string, string>
* @var string[]
*/
public array $lookupModules = [];
public array $lookupPaths = [];
public string $defaultLookupPath = APPPATH;
public string $defaultLookupPath = APPPATH . 'Views/';
}

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace ViewThemes\Config;
use CodeIgniter\Config\BaseConfig;
class Themes extends BaseConfig
{
public string $themesDirectory = ROOTPATH . 'themes';
public string $manifestFilename = 'manifest.json';
/**
* @var array<string, string>
*/
public array $themes = [
'app' => 'cp_app',
'admin' => 'cp_admin',
'install' => 'cp_install',
'auth' => 'cp_auth',
];
}

View File

@ -0,0 +1,99 @@
<?php
declare(strict_types=1);
namespace ViewThemes;
use ViewThemes\Config\Themes;
/**
* Borrowed and adapted from https://github.com/lonnieezell/Bonfire2
*/
class Theme
{
protected Themes $config;
/**
* @var string
*/
protected static $defaultTheme = 'app';
/**
* @var string
*/
protected static $currentTheme;
/**
* Holds theme info retrieved
*
* @var array<int, array<string, mixed>>
*/
protected static array $info = [];
public function __construct()
{
$this->config = config('Themes');
}
/**
* Sets the active theme.
*/
public static function setTheme(string $theme): void
{
static::$currentTheme = $theme;
}
/**
* Returns the path to the specified theme folder. If no theme is provided, will use the current theme.
*/
public static function path(string $theme = null): string
{
if ($theme === null) {
$theme = static::current();
}
// Ensure we've pulled the theme info
if (static::$info === []) {
static::$info = self::available();
}
foreach (static::$info as $info) {
if ($info['name'] === $theme) {
return $info['path'];
}
}
return '';
}
/**
* Returns the name of the active theme.
*/
public static function current(): string
{
return static::$currentTheme !== null
? static::$currentTheme
: static::$defaultTheme;
}
/**
* Returns an array of all available themes and the paths to their directories.
*
* @return array<int, array<string, mixed>>
*/
public static function available(): array
{
$themes = [];
$config = config('Themes');
foreach ($config->themes as $name => $folder) {
$themes[] = [
'name' => $name,
'path' => $config->themesDirectory . '/' . $folder . '/',
];
}
return $themes;
}
}

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components;
namespace App\Views\Components;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components\Forms;
namespace App\Views\Components\Forms;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components\Forms;
namespace App\Views\Components\Forms;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components\Forms;
namespace App\Views\Components\Forms;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components\Forms;
namespace App\Views\Components\Forms;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components\Forms;
namespace App\Views\Components\Forms;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components\Forms;
namespace App\Views\Components\Forms;
use ViewComponents\Component;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\View\Components;
namespace App\Views\Components;
use Exception;
use ViewComponents\Component;

View File

@ -8,6 +8,7 @@ use CodeIgniter\Controller;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use ViewThemes\Theme;
/**
* Class BaseController
@ -20,14 +21,6 @@ use Psr\Log\LoggerInterface;
class BaseController extends Controller
{
/**
* An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all
* other controllers that extend BaseController.
*
* @var string[]
*/
protected $helpers = ['auth', 'breadcrumb', 'svg', 'components', 'misc'];
/**
* Constructor.
*/
@ -36,7 +29,11 @@ class BaseController extends Controller
ResponseInterface $response,
LoggerInterface $logger
): void {
$this->helpers = array_merge($this->helpers, ['auth', 'breadcrumb', 'svg', 'components', 'misc']);
// Do Not Edit This Line
parent::initController($request, $response, $logger);
Theme::setTheme('admin');
}
}

View File

@ -57,7 +57,7 @@ class ContributorController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\contributor\list', $data);
return view('contributor/list', $data);
}
public function view(): string
@ -70,7 +70,7 @@ class ContributorController extends BaseController
0 => $this->podcast->title,
1 => $this->user->username,
]);
return view('Modules\Admin\Views\contributor\view', $data);
return view('contributor/view', $data);
}
public function add(): string
@ -106,7 +106,7 @@ class ContributorController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\contributor\add', $data);
return view('contributor/add', $data);
}
public function attemptAdd(): RedirectResponse
@ -155,7 +155,7 @@ class ContributorController extends BaseController
0 => $this->podcast->title,
1 => $this->user->username,
]);
return view('Modules\Admin\Views\contributor\edit', $data);
return view('contributor/edit', $data);
}
public function attemptEdit(): RedirectResponse

View File

@ -77,7 +77,7 @@ class EpisodeController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\episode\list', $data);
return view('episode/list', $data);
}
public function view(): string
@ -91,7 +91,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\view', $data);
return view('episode/view', $data);
}
public function create(): string
@ -105,7 +105,7 @@ class EpisodeController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\episode\create', $data);
return view('episode/create', $data);
}
public function attemptCreate(): RedirectResponse
@ -230,7 +230,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\edit', $data);
return view('episode/edit', $data);
}
public function attemptEdit(): RedirectResponse
@ -404,7 +404,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\publish', $data);
return view('episode/publish', $data);
}
return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
@ -503,7 +503,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\publish_edit', $data);
return view('episode/publish_edit', $data);
}
return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
@ -632,7 +632,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\unpublish', $data);
return view('episode/unpublish', $data);
}
return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
@ -704,7 +704,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\soundbites', $data);
return view('episode/soundbites', $data);
}
public function soundbitesAttemptEdit(): RedirectResponse
@ -782,7 +782,7 @@ class EpisodeController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\embeddable_player', $data);
return view('episode/embeddable_player', $data);
}
public function attemptCommentCreate(): RedirectResponse

View File

@ -62,7 +62,7 @@ class EpisodePersonController extends BaseController
0 => $this->podcast->title,
1 => $this->episode->title,
]);
return view('Modules\Admin\Views\episode\persons', $data);
return view('episode/persons', $data);
}
public function attemptAdd(): RedirectResponse

View File

@ -14,7 +14,7 @@ class FediverseController extends BaseController
{
public function dashboard(): string
{
return view('Modules\Admin\Views\fediverse\dashboard');
return view('fediverse/dashboard');
}
public function blockedActors(): string
@ -24,7 +24,7 @@ class FediverseController extends BaseController
$blockedActors = model('ActorModel')
->getBlockedActors();
return view('Modules\Admin\Views\fediverse\blocked_actors', [
return view('fediverse/blocked_actors', [
'blockedActors' => $blockedActors,
]);
}
@ -36,7 +36,7 @@ class FediverseController extends BaseController
$blockedDomains = model('BlockedDomainModel')
->getBlockedDomains();
return view('Modules\Admin\Views\fediverse\blocked_domains', [
return view('fediverse/blocked_domains', [
'blockedDomains' => $blockedDomains,
]);
}

View File

@ -18,14 +18,14 @@ class MyAccountController extends BaseController
{
public function index(): string
{
return view('Modules\Admin\Views\my_account\view');
return view('my_account\view');
}
public function changePassword(): string
{
helper('form');
return view('Modules\Admin\Views\my_account\change_password');
return view('my_account\change_password');
}
public function attemptChange(): RedirectResponse

View File

@ -38,12 +38,12 @@ class PageController extends BaseController
'pages' => (new PageModel())->findAll(),
];
return view('Modules\Admin\Views\page\list', $data);
return view('page/list', $data);
}
public function view(): string
{
return view('Modules\Admin\Views\page\view', [
return view('page/view', [
'page' => $this->page,
]);
}
@ -52,7 +52,7 @@ class PageController extends BaseController
{
helper('form');
return view('Modules\Admin\Views\page\create');
return view('page/create');
}
public function attemptCreate(): RedirectResponse
@ -86,7 +86,7 @@ class PageController extends BaseController
replace_breadcrumb_params([
0 => $this->page->title,
]);
return view('Modules\Admin\Views\page\edit', [
return view('page/edit', [
'page' => $this->page,
]);
}

View File

@ -41,7 +41,7 @@ class PersonController extends BaseController
'persons' => (new PersonModel())->findAll(),
];
return view('Modules\Admin\Views\person\list', $data);
return view('person/list', $data);
}
public function view(): string
@ -53,14 +53,14 @@ class PersonController extends BaseController
replace_breadcrumb_params([
0 => $this->person->full_name,
]);
return view('Modules\Admin\Views\person\view', $data);
return view('person/view', $data);
}
public function create(): string
{
helper(['form']);
return view('Modules\Admin\Views\person\create');
return view('person/create');
}
public function attemptCreate(): RedirectResponse
@ -113,7 +113,7 @@ class PersonController extends BaseController
replace_breadcrumb_params([
0 => $this->person->full_name,
]);
return view('Modules\Admin\Views\person\edit', $data);
return view('person/edit', $data);
}
public function attemptEdit(): RedirectResponse

View File

@ -53,7 +53,7 @@ class PodcastController extends BaseController
];
}
return view('Modules\Admin\Views\podcast\list', $data);
return view('podcast/list', $data);
}
public function view(): string
@ -65,7 +65,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\view', $data);
return view('podcast/view', $data);
}
public function viewAnalytics(): string
@ -77,7 +77,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\index', $data);
return view('podcast/analytics/index', $data);
}
public function viewAnalyticsWebpages(): string
@ -89,7 +89,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\webpages', $data);
return view('podcast/analytics/webpages', $data);
}
public function viewAnalyticsLocations(): string
@ -101,7 +101,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\locations', $data);
return view('podcast/analytics/locations', $data);
}
public function viewAnalyticsUniqueListeners(): string
@ -113,7 +113,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\unique_listeners', $data);
return view('podcast/analytics/unique_listeners', $data);
}
public function viewAnalyticsListeningTime(): string
@ -125,7 +125,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\listening_time', $data);
return view('podcast/analytics/listening_time', $data);
}
public function viewAnalyticsTimePeriods(): string
@ -137,7 +137,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\time_periods', $data);
return view('podcast/analytics/time_periods', $data);
}
public function viewAnalyticsPlayers(): string
@ -149,7 +149,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\analytics\players', $data);
return view('podcast/analytics/players', $data);
}
public function create(): string
@ -165,7 +165,7 @@ class PodcastController extends BaseController
'browserLang' => get_browser_language($this->request->getServer('HTTP_ACCEPT_LANGUAGE')),
];
return view('Modules\Admin\Views\podcast\create', $data);
return view('podcast/create', $data);
}
public function attemptCreate(): RedirectResponse
@ -274,7 +274,7 @@ class PodcastController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\edit', $data);
return view('podcast/edit', $data);
}
public function attemptEdit(): RedirectResponse
@ -357,15 +357,16 @@ class PodcastController extends BaseController
return redirect()->route('podcast-view', [$this->podcast->id]);
}
public function latestEpisodes(int $limit, int $podcast_id): string
public function latestEpisodes(int $limit, int $podcastId): string
{
$episodes = (new EpisodeModel())
->where('podcast_id', $podcast_id)
->where('podcast_id', $podcastId)
->orderBy('created_at', 'desc')
->findAll($limit);
return view('Modules\Admin\Views\podcast\latest_episodes', [
return view('podcast/latest_episodes', [
'episodes' => $episodes,
'podcast' => (new PodcastModel())->getPodcastById($podcastId),
]);
}

View File

@ -58,7 +58,7 @@ class PodcastImportController extends BaseController
'browserLang' => get_browser_language($this->request->getServer('HTTP_ACCEPT_LANGUAGE')),
];
return view('Modules\Admin\Views\podcast\import', $data);
return view('podcast/import', $data);
}
public function attemptImport(): RedirectResponse

View File

@ -49,7 +49,7 @@ class PodcastPersonController extends BaseController
replace_breadcrumb_params([
0 => $this->podcast->title,
]);
return view('Modules\Admin\Views\podcast\persons', $data);
return view('podcast/persons', $data);
}
public function attemptAdd(): RedirectResponse

View File

@ -39,7 +39,7 @@ class PodcastPlatformController extends BaseController
public function index(): string
{
return view('Modules\Admin\Views\podcast\platforms\dashboard');
return view('podcast/platforms\dashboard');
}
public function platforms(string $platformType): string
@ -56,9 +56,7 @@ class PodcastPlatformController extends BaseController
0 => $this->podcast->title,
]);
$view = view('Modules\Admin\Views\podcast\platforms', $data);
return $view;
return view('podcast/platforms', $data);
}
public function attemptPlatformsUpdate(string $platformType): RedirectResponse

View File

@ -40,7 +40,7 @@ class UserController extends BaseController
'users' => (new UserModel())->findAll(),
];
return view('Modules\Admin\Views\user\list', $data);
return view('user/list', $data);
}
public function view(): string
@ -52,7 +52,7 @@ class UserController extends BaseController
replace_breadcrumb_params([
0 => $this->user->username,
]);
return view('Modules\Admin\Views\user\view', $data);
return view('user/view', $data);
}
public function create(): string
@ -63,7 +63,7 @@ class UserController extends BaseController
'roles' => (new GroupModel())->getUserRoles(),
];
return view('Modules\Admin\Views\user\create', $data);
return view('user/create', $data);
}
public function attemptCreate(): RedirectResponse
@ -135,7 +135,7 @@ class UserController extends BaseController
replace_breadcrumb_params([
0 => $this->user->username,
]);
return view('Modules\Admin\Views\user\edit', $data);
return view('user/edit', $data);
}
public function attemptEdit(): RedirectResponse

View File

@ -16,12 +16,12 @@ class Auth extends MythAuthConfig
* @var array<string, string>
*/
public $views = [
'login' => 'Modules\Auth\Views\login',
'register' => 'Modules\Auth\Views\register',
'forgot' => 'Modules\Auth\Views\forgot',
'reset' => 'Modules\Auth\Views\reset',
'emailForgot' => 'Modules\Auth\Views\emails\forgot',
'emailActivation' => 'Modules\Auth\Views\emails\activation',
'login' => 'login',
'register' => 'register',
'forgot' => 'forgot',
'reset' => 'reset',
'emailForgot' => 'emails/forgot',
'emailActivation' => 'emails/activation',
];
/**
@ -31,7 +31,7 @@ class Auth extends MythAuthConfig
*
* @var string
*/
public $viewLayout = 'Modules\Auth\Views\_layout';
public $viewLayout = '_layout';
/**
* --------------------------------------------------------------------------

View File

@ -13,6 +13,7 @@ namespace Modules\Auth\Controllers;
use CodeIgniter\HTTP\RedirectResponse;
use Modules\Auth\Entities\User;
use Myth\Auth\Controllers\AuthController as MythAuthController;
use ViewThemes\Theme;
class AuthController extends MythAuthController
{
@ -23,6 +24,13 @@ class AuthController extends MythAuthController
*/
protected $helpers = ['components'];
public function __construct()
{
parent::__construct();
Theme::setTheme('auth');
}
/**
* Attempt to register a new user.
*/

View File

@ -24,6 +24,7 @@ use Dotenv\Exception\ValidationException;
use Modules\Auth\Entities\User;
use Psr\Log\LoggerInterface;
use Throwable;
use ViewThemes\Theme;
class InstallController extends Controller
{
@ -42,6 +43,8 @@ class InstallController extends Controller
): void {
// Do Not Edit This Line
parent::initController($request, $response, $logger);
Theme::setTheme('install');
}
/**
@ -58,7 +61,7 @@ class InstallController extends Controller
fclose($envFile);
} catch (Throwable) {
// Could not create the .env file, redirect to a view with instructions on how to add it manually
return view('Modules\Install\Views\manual_config');
return view('manual_config');
}
}
@ -106,7 +109,7 @@ class InstallController extends Controller
'cache.handler',
]);
} catch (ValidationException) {
return view('Modules\Install\Views\manual_config');
return view('manual_config');
}
}
@ -127,7 +130,7 @@ class InstallController extends Controller
session()
->setFlashdata('error', lang('Install.messages.databaseConnectError'));
return view('Modules\Install\Views\database_config');
return view('database_config');
}
// migrate if no user has been created
@ -141,7 +144,7 @@ class InstallController extends Controller
public function instanceConfig(): string
{
return view('Modules\Install\Views\instance_config');
return view('instance_config');
}
public function attemptInstanceConfig(): RedirectResponse
@ -178,7 +181,7 @@ class InstallController extends Controller
public function databaseConfig(): string
{
return view('Modules\Install\Views\database_config');
return view('database_config');
}
public function attemptDatabaseConfig(): RedirectResponse
@ -210,7 +213,7 @@ class InstallController extends Controller
public function cacheConfig(): string
{
return view('Modules\Install\Views\cache_config');
return view('cache_config');
}
public function attemptCacheConfig(): RedirectResponse
@ -268,7 +271,7 @@ class InstallController extends Controller
*/
public function createSuperAdmin(): string
{
return view('Modules\Install\Views\create_superadmin');
return view('create_superadmin');
}
/**

View File

@ -16,6 +16,7 @@ parameters:
- app/Libraries/Router.php
- app/Views/*
- modules/*/Views/*
- themes/*
ignoreErrors:
- '#This property type might be inlined to PHP. Do you have confidence it is correct\? Put it here#'
- '#^Cognitive complexity for#'
@ -31,3 +32,4 @@ parameters:
message: '#Function "function_exists\(\)" cannot be used/left in the code#'
paths:
- app/Helpers
- app/Common.php

View File

@ -6,6 +6,7 @@ module.exports = {
"./app/Views/**/*.php",
"./app/View/Components/**/*.php",
"./modules/**/Views/**/*.php",
"./themes/**/*.php",
"./app/Helpers/*.php",
"./app/Resources/**/*.ts",
],

View File

@ -17,9 +17,9 @@
<div id="sidebar-backdrop" role="button" tabIndex="0" aria-label="Close" class="fixed z-50 hidden w-full h-full bg-gray-900 bg-opacity-50 md:hidden"></div>
<aside id="admin-sidebar" class="sticky top-0 z-50 flex flex-col max-h-screen transition duration-200 ease-in-out transform -translate-x-full bg-white border-r w-80 holy-grail-sidebar md:translate-x-0">
<?php if (isset($podcast)): ?>
<?= $this->include('Modules\Admin\Views\podcast\_sidebar') ?>
<?= $this->include('podcast/_sidebar') ?>
<?php else: ?>
<?= $this->include('Modules\Admin\Views\_sidebar') ?>
<?= $this->include('_sidebar') ?>
<?php endif; ?>
</aside>
<main class="holy-grail-main">
@ -40,7 +40,7 @@
</div>
</header>
<div class="container px-2 py-8 mx-auto md:px-12">
<?= view('_message_block') ?>
<!-- view('App\Views\_message_block') -->
<?= $this->renderSection('content') ?>
</div>
</main>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Contributor.add_contributor', [$podcast->title]) ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Contributor.edit_role', [$user->username]) ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Contributor.podcast_contributors') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Contributor.view', [

View File

@ -1,5 +1,5 @@
<?= helper('components') ?>
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Admin.dashboard') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.create') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.edit') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.embeddable_player.title') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.all_podcast_episodes') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Person.episode_form.title') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.publish') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.publish_edit') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.soundbites_form.title') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Episode.unpublish') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $episode->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Fediverse.blocked_actors') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Fediverse.blocked_domains') ?>

View File

@ -0,0 +1,4 @@
{
"name": "Castopod Admin",
"description": "Castopod's default theme for admin"
}

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('MyAccount.changePassword') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('MyAccount.info') ?>
@ -11,6 +11,6 @@
<?= $this->section('content') ?>
<?= view('Modules\Admin\Views\_partials/_user_info.php', ['user' => user()]) ?>
<?= view('_partials/_user_info.php', ['user' => user()]) ?>
<?= $this->endSection() ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Page.create') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Page.edit') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Page.all_pages') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $page->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Person.create') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Person.edit') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Person.all_persons') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $person->full_name ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>

View File

@ -1,7 +1,7 @@
<?php
?>
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Podcast.create') ?>

View File

@ -1,7 +1,7 @@
<?php
?>
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Podcast.edit') ?>
@ -363,7 +363,7 @@ lang('Podcast.form.classification_section_subtitle'),
<?= form_section_close() ?>
<Button variant="primary" type="submit" class="self-end" iconLeft="heart">
<Button variant="primary" type="submit" class="self-end">
<?= lang('Podcast.form.submit_edit') ?>
</Button>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Podcast.import') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Podcast.all_podcasts') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Person.podcast_form.title') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Platforms.title') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('Podcast.platforms.title') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= $podcast->title ?>
@ -29,7 +29,7 @@
<?= view_cell('Modules\Admin\Controllers\PodcastController::latestEpisodes', [
'limit' => 5,
'podcast_id' => $podcast->id,
'podcastId' => $podcast->id,
]) ?>
<?= $this->endSection() ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('User.create') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('User.edit_roles', ['username' => $user->username]) ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('User.all_users') ?>

View File

@ -1,4 +1,4 @@
<?= $this->extend('Modules\Admin\Views\_layout') ?>
<?= $this->extend('_layout') ?>
<?= $this->section('title') ?>
<?= lang('User.view', ['username' => $user->username]) ?>
@ -7,6 +7,6 @@
<?= $this->section('content') ?>
<?= view('Modules\Admin\Views\_partials/_user_info.php', ['user' => $user]) ?>
<?= view('_partials/_user_info.php', ['user' => $user]) ?>
<?= $this->endSection() ?>

View File

@ -0,0 +1,4 @@
{
"name": "Castopod App",
"description": "Castopod's default theme for app"
}

Some files were not shown because too many files have changed in this diff Show More