mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 17:34:45 +02:00
Remove get_fonts
, Fix docker container console font selection (#1329)
* Update `get_fonts` This should fix docker, Has to be changed as we use alpine for docker which does not support GLOB_BRACE * #2? * #3 * FINAL BOSS FIGHT Fixes Docker image <3 * Update resources/views/filament/components/server-console.blade.php Co-authored-by: Lance Pioch <git@lance.sh> --------- Co-authored-by: Lance Pioch <git@lance.sh>
This commit is contained in:
parent
7f0266be5e
commit
2d581c7cbd
@ -79,14 +79,15 @@ RUN chown root:www-data ./ \
|
||||
&& chmod 750 ./ \
|
||||
# Files should not have execute set, but directories need it
|
||||
&& find ./ -type d -exec chmod 750 {} \; \
|
||||
# Create necessary directories
|
||||
# Create necessary directories
|
||||
&& mkdir -p /pelican-data/storage /var/www/html/storage/app/public /var/run/supervisord /etc/supercronic \
|
||||
# Symlinks for env, database, and avatars
|
||||
&& ln -s /pelican-data/.env ./.env \
|
||||
&& ln -s /pelican-data/database/database.sqlite ./database/database.sqlite \
|
||||
&& ln -sf /var/www/html/storage/app/public /var/www/html/public/storage \
|
||||
&& ln -s /pelican-data/storage/avatars /var/www/html/storage/app/public/avatars \
|
||||
# Allow www-data write permissions where necessary
|
||||
&& ln -s /pelican-data/storage/fonts /var/www/html/storage/app/public/fonts \
|
||||
# Allow www-data write permissions where necessary
|
||||
&& chown -R www-data:www-data /pelican-data ./storage ./bootstrap/cache /var/run/supervisord /var/www/html/public/storage \
|
||||
&& chmod -R u+rwX,g+rwX,o-rwx /pelican-data ./storage ./bootstrap/cache /var/run/supervisord
|
||||
|
||||
|
@ -39,6 +39,7 @@ use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
@ -375,7 +376,17 @@ class EditProfile extends BaseEditProfile
|
||||
->default(30),
|
||||
Select::make('console_font')
|
||||
->label(trans('profile.font'))
|
||||
->options(fn () => get_fonts(storage_path('app\public\fonts')))
|
||||
->options(function () {
|
||||
$fonts = [];
|
||||
foreach (File::allFiles(public_path('storage/fonts')) as $file) {
|
||||
if ($file->getExtension() === 'ttf') {
|
||||
$name = pathinfo($file->getFilename(), PATHINFO_FILENAME);
|
||||
$fonts[$name] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(fn ($state, callable $set) => $set('font_preview', $state)),
|
||||
Placeholder::make('font_preview')
|
||||
@ -383,7 +394,7 @@ class EditProfile extends BaseEditProfile
|
||||
->content(function (Get $get) {
|
||||
$fontName = $get('console_font') ?? 'No font selected.';
|
||||
|
||||
$fontUrl = asset("fonts/{$fontName}.ttf");
|
||||
$fontUrl = asset("storage/fonts/{$fontName}.ttf");
|
||||
$fontSize = $get('console_font_size') . 'px';
|
||||
|
||||
return new HtmlString(<<<HTML
|
||||
|
@ -67,17 +67,3 @@ if (!function_exists('resolve_path')) {
|
||||
return implode('/', $absolutes);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_fonts')) {
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
function get_fonts(?string $directory = null): array
|
||||
{
|
||||
$directory ??= public_path('fonts');
|
||||
|
||||
return collect(glob($directory . '/*.ttf', GLOB_BRACE) ?: [])
|
||||
->mapWithKeys(fn ($file) => [$name = pathinfo($file, PATHINFO_FILENAME) => $name])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,18 @@
|
||||
$userFontSize = auth()->user()->getCustomization()['console_font_size'] ?? 14;
|
||||
$userRows = auth()->user()->getCustomization()['console_rows'] ?? 30;
|
||||
@endphp
|
||||
|
||||
@if ($userFont === 'ComicMono')
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/comic-mono@0.0.1/index.css">
|
||||
@else
|
||||
<link rel="preload" href="{{ asset("storage/fonts/{$userFont}.ttf") }}" as="font" crossorigin>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: '{{ $userFont }}';
|
||||
src: url('{{ asset("storage/fonts/{$userFont}.ttf") }}');
|
||||
}
|
||||
</style>
|
||||
@endif
|
||||
<script src="https://cdn.jsdelivr.net/npm/@xterm/xterm/lib/xterm.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-fit/lib/addon-fit.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-web-links/lib/addon-web-links.min.js"></script>
|
||||
@ -12,14 +24,6 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-search-bar/lib/xterm-addon-search-bar.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xterm/xterm/css/xterm.min.css">
|
||||
<link rel="stylesheet" href="{{ asset('/css/filament/server/console.css') }}">
|
||||
<link rel="preload" href="{{ asset("storage/fonts/{$userFont}.ttf") }}" as="font" crossorigin>
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: '{{ $userFont }}';
|
||||
src: url('{{ asset("storage/fonts/{$userFont}.ttf") }}');
|
||||
}
|
||||
</style>
|
||||
@endassets
|
||||
|
||||
<div id="terminal" wire:ignore></div>
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user