implemented dynamic page rendering
html page rendering works, so the next step was to get dynamic page rendering up and running, meaning instead of pages being exported to html, they are instead rendered on the fly when the corresponding URL is hit. the StartController that handles page routing needs to be organized a bit better as there is some confusion between index and regular page files so it's clear where requests are going and what is the expected response
This commit is contained in:
parent
ceeb4a2573
commit
cb99c44a33
5 changed files with 85 additions and 9 deletions
|
@ -5,29 +5,63 @@ namespace App\Http\Controllers\Front;
|
||||||
use App\Services\SettingsService;
|
use App\Services\SettingsService;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Services\AuthService;
|
use App\Services\AuthService;
|
||||||
|
use App\Interfaces\PageRepositoryInterface;
|
||||||
|
use App\Services\SortingService;
|
||||||
|
use App\Services\AssetService;
|
||||||
|
|
||||||
|
use function _\find;
|
||||||
|
|
||||||
class StartController extends Controller
|
class StartController extends Controller
|
||||||
{
|
{
|
||||||
protected $settings;
|
protected $settings;
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
protected PageRepositoryInterface $pages;
|
||||||
|
protected AssetService $assets;
|
||||||
|
protected SortingService $sort;
|
||||||
|
|
||||||
public function __construct(SettingsService $settingsService, AuthService $authService)
|
public function __construct(
|
||||||
{
|
PageRepositoryInterface $pageRepository,
|
||||||
|
SettingsService $settingsService,
|
||||||
|
AuthService $authService,
|
||||||
|
AssetService $assetService,
|
||||||
|
SortingService $sortService,
|
||||||
|
) {
|
||||||
|
$this->pages = $pageRepository;
|
||||||
$this->settings = $settingsService;
|
$this->settings = $settingsService;
|
||||||
$this->auth = $authService;
|
$this->auth = $authService;
|
||||||
|
$this->assets = $assetService;
|
||||||
|
$this->sort = $sortService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index($first = 00, $second = 00, $third = 00)
|
public function index($first = 00, $second = 00, $third = 00)
|
||||||
{
|
{
|
||||||
$global = $this->settings->getGlobal();
|
$global = $this->settings->getGlobal();
|
||||||
|
$currentTheme = $this->assets->getCurrentTheme();
|
||||||
|
$template;
|
||||||
|
$pageData = [];
|
||||||
|
$pages = $this->pages->getAll();
|
||||||
//check if configs are present
|
//check if configs are present
|
||||||
if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) {
|
if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) {
|
||||||
if ($global['dynamicRender'] == 'true') {
|
if ($global['dynamicRender'] == 'true') {
|
||||||
if (is_numeric($first)) {
|
if (is_numeric($first)) {
|
||||||
dd('index');
|
if ($first == 00 || !isset($first)) {
|
||||||
|
$page = $pages->where('id', 1)->first();
|
||||||
|
$pageData = $this->sort->page($page);
|
||||||
|
$template = $currentTheme . '.index';
|
||||||
|
} else {
|
||||||
|
$page = $this->pages->getBySlug($third);
|
||||||
|
$pageData = $this->sort->page($page);
|
||||||
|
$template = $currentTheme . '.' . $page['layout'];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dd('pages');
|
if ($first == null || $first == '') {
|
||||||
|
$page = $pages->where('id', 1)->first();
|
||||||
|
$pageData = $this->sort->page($page);
|
||||||
|
$template = $currentTheme . '.index';
|
||||||
|
} else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return view($template, $pageData);
|
||||||
} else {
|
} else {
|
||||||
return response()->file('../public/index.html');
|
return response()->file('../public/index.html');
|
||||||
}
|
}
|
||||||
|
@ -35,4 +69,31 @@ class StartController extends Controller
|
||||||
return view('back.init', ["status" => false, "title" => "Set Up"]);
|
return view('back.init', ["status" => false, "title" => "Set Up"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function page($first = 00, $second = 00, $third = 00)
|
||||||
|
{
|
||||||
|
$currentTheme = $this->assets->getCurrentTheme();
|
||||||
|
switch ($first) {
|
||||||
|
case 'archive':
|
||||||
|
case 'archives':
|
||||||
|
$template = $currentTheme . '.archive';
|
||||||
|
$pageData = $this->sort->archive();
|
||||||
|
break;
|
||||||
|
case 'tags':
|
||||||
|
$template = $currentTheme . '.tags';
|
||||||
|
$tags = $this->sort->tags(false);
|
||||||
|
$tagData = find($tags['tags'], ['tag_name' => $second]);
|
||||||
|
$pageData = [
|
||||||
|
'theme' => $currentTheme, // for theme kit
|
||||||
|
'title' => 'Pages Tagged as ' . $second,
|
||||||
|
'dynamicRender' => $tags['dynamicRender'],
|
||||||
|
'info' => $tags['info'],
|
||||||
|
'menu' => $tags['menu'],
|
||||||
|
'pages' => $tagData['pages'],
|
||||||
|
'media' => $tags['media'],
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return view($template, $pageData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Controllers\Dash\IndexController;
|
use App\Http\Controllers\Dash\IndexController;
|
||||||
use App\Http\Controllers\Dash\AuthController;
|
use App\Http\Controllers\Dash\AuthController;
|
||||||
|
use App\Http\Controllers\Front\StartController;
|
||||||
use App\Http\Controllers\Theming\ThemeController;
|
use App\Http\Controllers\Theming\ThemeController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
@ -12,15 +13,18 @@ class RouteController extends Controller
|
||||||
protected $dash;
|
protected $dash;
|
||||||
protected $auth;
|
protected $auth;
|
||||||
protected $theme;
|
protected $theme;
|
||||||
|
protected $front;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IndexController $indexController,
|
IndexController $indexController,
|
||||||
AuthController $authController,
|
AuthController $authController,
|
||||||
ThemeController $themeController,
|
ThemeController $themeController,
|
||||||
|
StartController $startContoller,
|
||||||
) {
|
) {
|
||||||
$this->dash = $indexController;
|
$this->dash = $indexController;
|
||||||
$this->auth = $authController;
|
$this->auth = $authController;
|
||||||
$this->theme = $themeController;
|
$this->theme = $themeController;
|
||||||
|
$this->front = $startContoller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($first = null, $second = null, $third = null, $fourth = null)
|
public function get($first = null, $second = null, $third = null, $fourth = null)
|
||||||
|
@ -41,12 +45,13 @@ class RouteController extends Controller
|
||||||
return $this->theme->start();
|
return $this->theme->start();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case 'tags':
|
||||||
dd('$first' . $first);
|
case 'archives':
|
||||||
|
return $this->front->page($first, $second, $third);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dd('index');
|
return $this->front->index($first, $second, $third);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ThemeController extends Controller
|
||||||
"pages" => $this->themes->getCustomViews('page')
|
"pages" => $this->themes->getCustomViews('page')
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
return redirect('back.login');
|
return redirect('dashboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ interface PageRepositoryInterface
|
||||||
|
|
||||||
public function getByID($uuid);
|
public function getByID($uuid);
|
||||||
|
|
||||||
|
public function getBySlug($slug);
|
||||||
|
|
||||||
public function delete($uuid);
|
public function delete($uuid);
|
||||||
|
|
||||||
public function create($page);
|
public function create($page);
|
||||||
|
|
|
@ -51,6 +51,14 @@ class PageRepository implements PageRepositoryInterface
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBySlug($slug)
|
||||||
|
{
|
||||||
|
$page = $this->pages->where('slug', $slug)->first();
|
||||||
|
//quick check to see if layout is set
|
||||||
|
$page['layout'] == '' ? $page['layout'] = 'page' : $page['layout'] = $page['layout'];
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
public function delete($uuid)
|
public function delete($uuid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue