Get things into a somewhat working state on the login form

This commit is contained in:
Dane Everitt 2018-03-31 15:52:11 -05:00
parent 7de2c8684c
commit 791cbaa5ce
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
15 changed files with 450 additions and 132 deletions

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Services\Helpers;
use Illuminate\Container\Container;
use Illuminate\Filesystem\FilesystemManager;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Cache\Repository as CacheRepository;
@ -56,20 +55,47 @@ class AssetHashService
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getUrl(string $resource): string
public function url(string $resource): string
{
$file = last(explode('/', $resource));
return '/' . ltrim(str_replace($file, array_get($this->getManifest(), $file, $file), $resource), '/');
return '/' . ltrim(str_replace($file, array_get($this->manifest(), $file, $file), $resource), '/');
}
/**
* Return a built CSS import using the provided URL.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function css(string $resource): string
{
return '<link href="' . $this->url($resource) . '" rel="stylesheet preload" crossorigin="anonymous" referrerpolicy="no-referrer">';
}
/**
* Return a built JS import using the provided URL.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function js(string $resource): string
{
return '<script src="' . $this->url($resource) . '" crossorigin="anonymous"></script>';
}
/**
* Get the asset manifest and store it in the cache for quicker lookups.
*
* @return array
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getManifest(): array
protected function manifest(): array
{
if (! is_null(self::$manifest)) {
return self::$manifest;
@ -88,41 +114,4 @@ class AssetHashService
return self::$manifest = $contents;
}
/**
* Get the URL for a resource in a static context.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public static function url(string $resource): string
{
return Container::getInstance()->make(self::class)->getUrl($resource);
}
/**
* @param string $resource
* @return string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public static function css(string $resource): string
{
$path = self::url($resource);
return '<link href="' . $path . '" rel="stylesheet preload" crossorigin="anonymous" referrerpolicy="no-referrer">';
}
/**
* @param string $resource
* @return string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public static function js(string $resource): string
{
$path = self::url($resource);
return '<script src="' . $path . '" crossorigin="anonymous">';
}
}