From 8d704ae5c89bd49daa0ddeccc694a6547caa278e Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 27 Mar 2018 00:44:14 -0500 Subject: [PATCH] Inital commit with gulp and base asset setup --- .gitignore | 18 +- app/Services/Helpers/AssetHashService.php | 128 + gulpfile.js | 84 + package.json | 31 +- .../js/frontend/files/filemanager.min.js.map | 2 +- resources/assets/pterodactyl/css/main.css | 27 + tailwind.js | 925 ++++ yarn.lock | 4589 +++++++++++++++++ 8 files changed, 5786 insertions(+), 18 deletions(-) create mode 100644 app/Services/Helpers/AssetHashService.php create mode 100644 gulpfile.js create mode 100644 resources/assets/pterodactyl/css/main.css create mode 100644 tailwind.js create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index 8c2fb9405..f49c95e55 100644 --- a/.gitignore +++ b/.gitignore @@ -7,25 +7,15 @@ storage/framework/* /.idea /nbproject -package-lock.json -composer.lock node_modules - -_ide_helper_models.php +*.log _ide_helper.php - -sami.phar -/.sami +.phpstorm.meta.php +.php_cs.cache +public/assets/* # For local development with docker # Remove if we ever put the Dockerfile in the repo .dockerignore Dockerfile docker-compose.yml -# for image related files -misc -.phpstorm.meta.php -.php_cs.cache - -# Vagrant -*.log diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php new file mode 100644 index 000000000..181e84fd1 --- /dev/null +++ b/app/Services/Helpers/AssetHashService.php @@ -0,0 +1,128 @@ +application = $application; + $this->cache = $cache; + $this->filesystem = $filesystem->createLocalDriver(['root' => public_path()]); + } + + /** + * Modify a URL to append the asset hash. + * + * @param string $resource + * @return string + * + * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException + */ + public function getUrl(string $resource): string + { + $file = last(explode('/', $resource)); + + return '/' . ltrim(str_replace($file, array_get($this->getManifest(), $file, $file), $resource), '/'); + } + + /** + * Get the asset manifest and store it in the cache for quicker lookups. + * + * @return array + * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException + */ + public function getManifest(): array + { + if (! is_null(self::$manifest)) { + return self::$manifest; + } + + // Skip checking the cache if we are not in production. + if ($this->application->environment() === 'production') { + $stored = $this->cache->get('Core:AssetManifest'); + if (! is_null($stored)) { + return self::$manifest = $stored; + } + } + + $contents = json_decode($this->filesystem->get(self::MANIFEST_PATH), true); + $this->cache->put('Core:AssetManifest', $contents, 1440); + + 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 ''; + } + + /** + * @param string $resource + * @return string + * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException + */ + public static function js(string $resource): string + { + $path = self::url($resource); + + return '