[L6] Temporarily hack around theme system to maintain views without having to edit tons of code
This commit is contained in:
parent
0d6cf54314
commit
a9976c723e
5 changed files with 43 additions and 63 deletions
16
app/Extensions/Facades/Theme.php
Normal file
16
app/Extensions/Facades/Theme.php
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Pterodactyl\Extensions\Facades;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class Theme extends Facade
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'extensions.themes';
|
||||||
|
}
|
||||||
|
}
|
21
app/Extensions/Themes/Theme.php
Normal file
21
app/Extensions/Themes/Theme.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Pterodactyl\Extensions\Themes;
|
||||||
|
|
||||||
|
class Theme
|
||||||
|
{
|
||||||
|
public function js($path)
|
||||||
|
{
|
||||||
|
return sprintf('<script src="%s"></script>' . PHP_EOL, $this->getUrl($path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function css($path)
|
||||||
|
{
|
||||||
|
return sprintf('<link media="all" type="text/css" rel="stylesheet" href="%s"/>' . PHP_EOL, $this->getUrl($path));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUrl($path)
|
||||||
|
{
|
||||||
|
return '/themes/pterodactyl/' . ltrim($path, '/');
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ use Pterodactyl\Models\Subuser;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Pterodactyl\Observers\UserObserver;
|
use Pterodactyl\Observers\UserObserver;
|
||||||
|
use Pterodactyl\Extensions\Themes\Theme;
|
||||||
use Pterodactyl\Observers\ServerObserver;
|
use Pterodactyl\Observers\ServerObserver;
|
||||||
use Pterodactyl\Observers\SubuserObserver;
|
use Pterodactyl\Observers\SubuserObserver;
|
||||||
|
|
||||||
|
@ -40,6 +41,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
if (! config('pterodactyl.load_environment_only', false) && $this->app->environment() !== 'testing') {
|
if (! config('pterodactyl.load_environment_only', false) && $this->app->environment() !== 'testing') {
|
||||||
$this->app->register(SettingsServiceProvider::class);
|
$this->app->register(SettingsServiceProvider::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->app->singleton('extensions.themes', function () {
|
||||||
|
return new Theme;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -234,6 +234,7 @@ return [
|
||||||
'Schema' => Illuminate\Support\Facades\Schema::class,
|
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||||
'Session' => Illuminate\Support\Facades\Session::class,
|
'Session' => Illuminate\Support\Facades\Session::class,
|
||||||
'Storage' => Illuminate\Support\Facades\Storage::class,
|
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||||
|
'Theme' => Pterodactyl\Extensions\Facades\Theme::class,
|
||||||
'URL' => Illuminate\Support\Facades\URL::class,
|
'URL' => Illuminate\Support\Facades\URL::class,
|
||||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
'View' => Illuminate\Support\Facades\View::class,
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'enabled' => true,
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Root path where theme Views will be located.
|
|
||||||
| Can be outside default views path e.g.: resources/themes
|
|
||||||
| Leave it null if you will put your themes in the default views folder
|
|
||||||
| (as defined in config\views.php)
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
'themes_path' => realpath(base_path('resources/themes')),
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Set behavior if an asset is not found in a Theme hierarchy.
|
|
||||||
| Available options: THROW_EXCEPTION | LOG_ERROR | IGNORE
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
'asset_not_found' => 'LOG_ERROR',
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Do we want a theme activated by default? Can be set at runtime with:
|
|
||||||
| Theme::set('theme-name');
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
'default' => env('APP_THEME', 'pterodactyl'),
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Cache theme.json configuration files that are located in each theme's folder
|
|
||||||
| in order to avoid searching theme settings in the filesystem for each request
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
'cache' => true,
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Define available themes. Format:
|
|
||||||
|
|
|
||||||
| 'theme-name' => [
|
|
||||||
| 'extends' => 'theme-to-extend', // optional
|
|
||||||
| 'views-path' => 'path-to-views', // defaults to: resources/views/theme-name
|
|
||||||
| 'asset-path' => 'path-to-assets', // defaults to: public/theme-name
|
|
||||||
|
|
|
||||||
| // You can add your own custom keys
|
|
||||||
| // Use Theme::getSetting('key') & Theme::setSetting('key', 'value') to access them
|
|
||||||
| 'key' => 'value',
|
|
||||||
| ],
|
|
||||||
|
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
'themes' => [
|
|
||||||
'pterodactyl' => [
|
|
||||||
'extends' => null,
|
|
||||||
'views-path' => 'pterodactyl',
|
|
||||||
'asset-path' => 'themes/pterodactyl',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
Loading…
Reference in a new issue