page routing rework

routing needed more nuance than what was possible in the web routing
controller, so a new RouteContoller was created to identify requests and
then sending them to the correct controller to get the appropriatie page

this was necessary because routing the previous was erroring out because
when the system was looking for pages to display with dynamic page
creation it would get confused with prexisting routes and choose to
display whatever the Start Controller was capturing, ignoring routes
defined in the web controller.

but that's been cleaned up without having to re-write everything and
continues to use existing controllers
This commit is contained in:
ro 2024-05-06 13:37:26 -06:00
parent 6cb9631a46
commit ceeb4a2573
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
5 changed files with 110 additions and 31 deletions

View file

@ -27,6 +27,34 @@ class IndexController extends Controller
$this->sort = $sortingService;
}
public function init($second, $third, $fourth)
{
switch ($second) {
case 'settings':
return $this->settings();
break;
case 'navigation':
return $this->navigavtion();
break;
case 'pages':
($third == null) ? $third = 'all' : $third = $third;
($fourth == null) ? $fourth = 1 : $fourth = $fourth;
return $this->book($third, $fourth);
break;
case 'page':
return $this->page($third, $fourth);
break;
case 'logout':
session()->flush();
return redirect()->intended('dashboard');
break;
default:
return $this->start();
break;
}
}
public function login()
{
if ($this->auth::status()) {

View file

@ -2,21 +2,35 @@
namespace App\Http\Controllers\Front;
use App\Services\SettingsService;
use App\Http\Controllers\Controller;
use App\Services\AuthService;
class StartController extends Controller
{
protected $settings;
protected $auth;
public function __construct()
public function __construct(SettingsService $settingsService, AuthService $authService)
{
$this->settings = $settingsService;
$this->auth = $authService;
}
public function index()
public function index($first = 00, $second = 00, $third = 00)
{
$global = $this->settings->getGlobal();
//check if configs are present
if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) {
if ($global['dynamicRender'] == 'true') {
if (is_numeric($first)) {
dd('index');
} else {
dd('pages');
}
} else {
return response()->file('../public/index.html');
}
} else {
return view('back.init', ["status" => false, "title" => "Set Up"]);
}

View file

@ -0,0 +1,61 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Dash\IndexController;
use App\Http\Controllers\Dash\AuthController;
use App\Http\Controllers\Theming\ThemeController;
use Illuminate\Http\Request;
class RouteController extends Controller
{
protected $dash;
protected $auth;
protected $theme;
public function __construct(
IndexController $indexController,
AuthController $authController,
ThemeController $themeController,
) {
$this->dash = $indexController;
$this->auth = $authController;
$this->theme = $themeController;
}
public function get($first = null, $second = null, $third = null, $fourth = null)
{
if (isset($first) && !is_numeric($first)) {
switch ($first) {
case 'dashboard':
if (isset($second)) {
return $this->dash->init($second, $third, $fourth);
} else {
return $this->dash->login();
}
break;
case 'theme':
if (isset($second)) {
return $this->theme->getView($third);
} else {
return $this->theme->start();
}
break;
default:
dd('$first' . $first);
break;
}
} else {
dd('index');
}
}
public function post(Request $request)
{
switch ($request->path()) {
case 'login':
return $this->auth->enter($request);
break;
}
}
}

View file

@ -178,7 +178,6 @@ main > section {
display: grid;
grid-template-columns: 50% 50%;
padding: 0 10%;
max-width: 1000px;
color: var(--primary);
}

View file

@ -1,10 +1,7 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Dash\IndexController;
use App\Http\Controllers\Dash\AuthController;
use App\Http\Controllers\Front\StartController;
use App\Http\Controllers\Theming\ThemeController;
use App\Http\Controllers\RouteController;
/*
|--------------------------------------------------------------------------
@ -17,26 +14,6 @@ use App\Http\Controllers\Theming\ThemeController;
|
*/
Route::get("/", [StartController::class, 'index']);
//DASHBOARD
//login stuff
Route::get("/dashboard", [IndexController::class, 'login']);
Route::post("/login", [AuthController::class, 'enter']);
//back
Route::group(['prefix' => 'dashboard', 'middleware' => 'member.check'], function () {
Route::get("/start", [IndexController::class, 'start'])->name('start');
Route::get("/pages/{pageFilter?}/{pageNum?}", [IndexController::class, 'book']);
Route::get("/page/{mode}/{uuid}", [IndexController::class, 'page']);
Route::get("/settings", [IndexController::class, 'settings']);
Route::get("/navigation", [IndexController::class, 'navigation']);
Route::get("/logout", [AuthController::class, 'exit']);
});
//theme kit
Route::group(['prefix' => 'theme', 'middleware' => 'member.check'], function () {
Route::get("/", [ThemeController::class, 'start']);
Route::get("/view/{view?}", [ThemeController::class, 'getView']);
});
//routing needs a bit more nuance, so requests are sent to a controller to sort traffic
Route::get("/{first?}/{second?}/{third?}/{four?}", [RouteController::class, 'get']);
Route::post("/{first?}/{second?}/{third?}", [RouteController::class, 'post']);