mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-02 20:35:50 -05:00
Added a configurable panel company/brand logo.
## Extra Details:
- New logo is used for:
- Login page
- Navigation bar
- Page Favicon
- Panel Falls back to the default Ptero logo when no custom one is set.
- Supported File Formats: PNG, JPEG, WebP, AVIF, ICO, and safe SVG
files.
---
## Preview:
<img width="912" height="151"
alt="{67E9647B-AD26-41F8-8272-8B7F4D1CDFB7}"
src="https://github.com/user-attachments/assets/1af9c52b-ad4a-4f82-bb67-14a2b662beb2"
/>
<img width="916" height="256"
alt="{F49323AE-974C-4C16-B129-D60D3494BA0F}"
src="https://github.com/user-attachments/assets/3e35d7f1-c95b-4007-bf1f-69e2ce9891a2"
/>
<img width="1749" height="940"
alt="{252E88D0-BA45-43C8-99E2-5B31E81B739E}"
src="https://github.com/user-attachments/assets/2e807035-bbd0-48ca-823a-4510a9be696e"
/>
<img width="996" height="452" alt="image"
src="https://github.com/user-attachments/assets/c0bef229-285c-4cda-9291-7295e70b2189"
/>
79 lines
2.7 KiB
PHP
79 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Http\ViewComposers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\View\View;
|
|
use Pterodactyl\Services\Extensions\ExtensionHeadTags;
|
|
use Pterodactyl\Services\Extensions\ExtensionRepository;
|
|
use Pterodactyl\Services\Helpers\AssetHashService;
|
|
use Pterodactyl\Services\Helpers\BrandingLogoService;
|
|
use Pterodactyl\Services\Themes\ThemeResolver;
|
|
use Throwable;
|
|
|
|
class AssetComposer
|
|
{
|
|
/**
|
|
* AssetComposer constructor.
|
|
*/
|
|
public function __construct(
|
|
private readonly AssetHashService $assetHashService,
|
|
private readonly ExtensionRepository $extensions,
|
|
private readonly ExtensionHeadTags $extensionHeadTags,
|
|
private readonly BrandingLogoService $brandingLogo,
|
|
private readonly ThemeResolver $themes,
|
|
private readonly Request $request,
|
|
) {}
|
|
|
|
/**
|
|
* Provide access to the asset service in the views.
|
|
*/
|
|
public function compose(View $view): void
|
|
{
|
|
$theme = $this->themes->document($this->request);
|
|
|
|
$view->with('asset', $this->assetHashService);
|
|
// Rendered lazily by the layout; resolving the tags never throws.
|
|
$view->with('extensionHead', $this->extensionHeadTags);
|
|
$view->with('theme', $theme);
|
|
$view->with('siteConfiguration', [
|
|
'name' => config('app.name', 'Pterodactyl'),
|
|
'logo' => $this->brandingLogo->url(),
|
|
'locale' => config('app.locale', 'en'),
|
|
'userAvatarsEnabled' => config('pterodactyl.client_features.avatars.enabled', false),
|
|
'recaptcha' => [
|
|
'enabled' => config('recaptcha.enabled', false),
|
|
'siteKey' => config('recaptcha.website_key', ''),
|
|
],
|
|
// Safe mode loads no extension bundles at all.
|
|
'extensions' => $theme->safeMode ? [] : $this->extensionPayload(array_column($theme->chain, 'id')),
|
|
'theme' => $theme->bootstrap(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* The enabled frontend extensions the SPA boot loader should import, with their
|
|
* frontend settings for signed-in users and only the public ones for guests, and
|
|
* the themes of the chain the page renders with. Never allowed to break page
|
|
* rendering - worst case the SPA sees no extensions.
|
|
*
|
|
* @param list<string> $themes
|
|
* @return array<int, array{id: string, version?: string, entry: string}>
|
|
*/
|
|
private function extensionPayload(array $themes): array
|
|
{
|
|
if (! config('extensions.enabled')) {
|
|
return [];
|
|
}
|
|
|
|
try {
|
|
return $this->extensions->frontendPayload(authenticated: Auth::check(), themes: $themes);
|
|
} catch (Throwable) {
|
|
return [];
|
|
}
|
|
}
|
|
}
|