Replaced Moment with Carbon #84

Merged
Ghost merged 148 commits from develop into beta 2022-09-22 05:53:36 +02:00
5 changed files with 85 additions and 9 deletions
Showing only changes of commit cb99c44a33 - Show all commits

View file

@ -5,29 +5,63 @@ namespace App\Http\Controllers\Front;
use App\Services\SettingsService;
use App\Http\Controllers\Controller;
use App\Services\AuthService;
use App\Interfaces\PageRepositoryInterface;
use App\Services\SortingService;
use App\Services\AssetService;
use function _\find;
class StartController extends Controller
{
protected $settings;
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->auth = $authService;
$this->assets = $assetService;
$this->sort = $sortService;
}
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
if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) {
if ($global['dynamicRender'] == 'true') {
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 {
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 {
return response()->file('../public/index.html');
}
@ -35,4 +69,31 @@ class StartController extends Controller
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);
}
}

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
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 Illuminate\Http\Request;
@ -12,15 +13,18 @@ class RouteController extends Controller
protected $dash;
protected $auth;
protected $theme;
protected $front;
public function __construct(
IndexController $indexController,
AuthController $authController,
ThemeController $themeController,
StartController $startContoller,
) {
$this->dash = $indexController;
$this->auth = $authController;
$this->theme = $themeController;
$this->front = $startContoller;
}
public function get($first = null, $second = null, $third = null, $fourth = null)
@ -41,12 +45,13 @@ class RouteController extends Controller
return $this->theme->start();
}
break;
default:
dd('$first' . $first);
case 'tags':
case 'archives':
return $this->front->page($first, $second, $third);
break;
}
} else {
dd('index');
return $this->front->index($first, $second, $third);
}
}

View file

@ -40,7 +40,7 @@ class ThemeController extends Controller
"pages" => $this->themes->getCustomViews('page')
]);
} else {
return redirect('back.login');
return redirect('dashboard');
}
}

View file

@ -8,6 +8,8 @@ interface PageRepositoryInterface
public function getByID($uuid);
public function getBySlug($slug);
public function delete($uuid);
public function create($page);

View file

@ -51,6 +51,14 @@ class PageRepository implements PageRepositoryInterface
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)
{
}