From 08dc50dfdfb7a5be44aee111d5c50445e930a458 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Tue, 9 Feb 2021 01:04:17 +0100 Subject: [PATCH] Stuff --- app/Console/Commands/ThemesScann.php | 64 +++++++++++++------ app/Console/Kernel.php | 1 + app/Http/Controllers/ThemeController.php | 17 +++++ .../migrations/2021_02_08_234053_server.php | 28 ++++++++ routes/web.php | 3 + 5 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 app/Http/Controllers/ThemeController.php create mode 100644 database/migrations/2021_02_08_234053_server.php diff --git a/app/Console/Commands/ThemesScann.php b/app/Console/Commands/ThemesScann.php index db3e69c..3d63aff 100644 --- a/app/Console/Commands/ThemesScann.php +++ b/app/Console/Commands/ThemesScann.php @@ -38,43 +38,69 @@ class ThemesScann extends Command */ public function handle() { - $themesGallery = scandir(__DIR__."/../../../resources/views/themes/gallery"); - foreach ($themesGallery as $theme) { - if(substr($theme, 0, 1) == ".") { - continue; - } - $themeModel = Theme::query()->where("name", "=", $theme)->where("typ", "=", "gallery")->first(); - if(!is_null($themeModel)) { - continue; - } - - $this->info("Found new Theme: ".$theme); - - $themeModel = new Theme(); - $themeModel->typ = "gallery"; - $themeModel->name = $theme; - $themeModel->status = "private"; - $themeModel->saveOrFail(); - } - $themesGallery = scandir(__DIR__."/../../../resources/views/themes/tenant"); foreach ($themesGallery as $theme) { $this->info("Check Theme: ".$theme); if(substr($theme, 0, 1) == ".") { continue; } + + $settings = json_decode(file_get_contents(__DIR__."/../../../resources/views/themes/tenant/".$theme."/settings.json")); $themeModel = Theme::query()->where("name", "=", $theme)->where("typ", "=", "tenant")->first(); if(!is_null($themeModel)) { $this->info("Themes already exists: ".$theme); continue; } + $this->info("Found new Theme: ".$theme); $themeModel = new Theme(); $themeModel->typ = "tenant"; $themeModel->name = $theme; $themeModel->status = "private"; + if($settings->public) { + $themeModel->status = "public"; + } + + $themeModel->img_pixel = $settings->usesSize->pixel; + $themeModel->img_small = $settings->usesSize->small; + $themeModel->img_medium = $settings->usesSize->medium; + $themeModel->img_big = $settings->usesSize->big; + + $themeModel->saveOrFail(); + } + + $themesGallery = scandir(__DIR__."/../../../resources/views/themes/gallery"); + foreach ($themesGallery as $theme) { + $this->info("Check Theme: ".$theme); + if(substr($theme, 0, 1) == ".") { + continue; + } + + $settings = json_decode(file_get_contents(__DIR__."/../../../resources/views/themes/gallery/".$theme."/settings.json")); + $themeModel = Theme::query()->where("name", "=", $theme)->where("typ", "=", "gallery")->first(); + if(!is_null($themeModel)) { + $this->info("Themes already exists: ".$theme); + continue; + } + + + $this->info("Found new Theme: ".$theme); + + $themeModel = new Theme(); + $themeModel->typ = "gallery"; + $themeModel->name = $theme; + $themeModel->status = "private"; + if($settings->public) { + $themeModel->status = "public"; + } + + $themeModel->img_pixel = $settings->usesSize->pixel; + $themeModel->img_small = $settings->usesSize->small; + $themeModel->img_medium = $settings->usesSize->medium; + $themeModel->img_big = $settings->usesSize->big; + $themeModel->saveOrFail(); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 1cacf04..49feb83 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -7,6 +7,7 @@ use App\Console\Commands\CalculateTraffic; use App\Console\Commands\EXIFRead; use App\Console\Commands\ImageCacheAll; use App\Console\Commands\ThemesScann; +use App\Console\Commands\ThemesScannTenant; use App\Console\Commands\UserAdmin; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; diff --git a/app/Http/Controllers/ThemeController.php b/app/Http/Controllers/ThemeController.php new file mode 100644 index 0000000..b5eb76c --- /dev/null +++ b/app/Http/Controllers/ThemeController.php @@ -0,0 +1,17 @@ +header('Content-type','image/png'); + } +} diff --git a/database/migrations/2021_02_08_234053_server.php b/database/migrations/2021_02_08_234053_server.php new file mode 100644 index 0000000..63cd045 --- /dev/null +++ b/database/migrations/2021_02_08_234053_server.php @@ -0,0 +1,28 @@ +middleware([\App\Http\Middleware\TenanMiddleware::class]);