This commit is contained in:
Kekskurse 2021-02-09 01:04:17 +01:00
parent 1f6fd5d2d9
commit 08dc50dfdf
5 changed files with 94 additions and 19 deletions

View File

@ -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();
}
}

View File

@ -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;

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class ThemeController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function previewImage($typ, $name) {
$img = file_get_contents(__DIR__."/../../../resources/views/themes/".$typ."/".$name."/image.png");
return response($img)->header('Content-type','image/png');
}
}

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class Server extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -36,6 +36,7 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class, \App\Http\Middle
Route::get("/s/theme", [\App\Http\Controllers\TenantController::class, 'tenantThemeView']);
Route::get("/s/theme/set", [\App\Http\Controllers\TenantController::class, 'tenantThemeSet']);
Route::get("/s/theme/set-gallery", [\App\Http\Controllers\TenantController::class, 'tenantGalleryDefaultTemplateSet']);
Route::get("/s/theme/{typ}/{name}.png", [\App\Http\Controllers\ThemeController::class, "previewImage"]);
Route::get("/g", [\App\Http\Controllers\GalleryController::class, 'listView']);
Route::get("/g/new", [\App\Http\Controllers\GalleryController::class, 'newView']);
@ -58,6 +59,8 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class, \App\Http\Middle
Route::get("a/themes", [\App\Http\Controllers\AdminController::class, "themesView"]);
Route::post("a/themes", [\App\Http\Controllers\AdminController::class, "themesSettings"]);
});
Route::get("/{name}.json", [\App\Http\Controllers\PublicController::class, 'listGalleriesViewAPI'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);