diff --git a/public_html/dispatch.php b/public_html/dispatch.php index 2884d34f..57ab3284 100644 --- a/public_html/dispatch.php +++ b/public_html/dispatch.php @@ -45,6 +45,11 @@ $context->simpleActionName = null; $context->simpleActionName); }); +\Chibi\Router::register(['StaticPagesController', 'mainPageView'], 'GET', ''); +\Chibi\Router::register(['StaticPagesController', 'mainPageView'], 'GET', '/index'); +\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help'); +\Chibi\Router::register(['StaticPagesController', 'helpView'], 'GET', '/help/{tab}'); + \Chibi\Router::register(['AuthController', 'loginView'], 'GET', '/auth/login'); \Chibi\Router::register(['AuthController', 'loginAction'], 'POST', '/auth/login'); \Chibi\Router::register(['AuthController', 'logoutAction'], 'POST', '/auth/logout'); @@ -81,10 +86,6 @@ $postValidation = foreach (['GET', 'POST'] as $method) { - \Chibi\Router::register(['IndexController', 'indexAction'], $method, ''); - \Chibi\Router::register(['IndexController', 'indexAction'], $method, '/index'); - \Chibi\Router::register(['IndexController', 'helpAction'], $method, '/help'); - \Chibi\Router::register(['IndexController', 'helpAction'], $method, '/help/{tab}'); \Chibi\Router::register(['LogController', 'listAction'], $method, '/logs'); \Chibi\Router::register(['LogController', 'viewAction'], $method, '/log/{name}', ['name' => '[0-9a-zA-Z._-]+']); \Chibi\Router::register(['LogController', 'viewAction'], $method, '/log/{name}/{page}', ['name' => '[0-9a-zA-Z._-]+', 'page' => '\d*']); diff --git a/public_html/media/css/index-help.css b/public_html/media/css/static-help.css similarity index 100% rename from public_html/media/css/index-help.css rename to public_html/media/css/static-help.css diff --git a/public_html/media/css/index-index.css b/public_html/media/css/static-main.css similarity index 100% rename from public_html/media/css/index-index.css rename to public_html/media/css/static-main.css diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index 35f2e9dd..b6f37de1 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -46,6 +46,6 @@ class AuthController unset($_SESSION['login-redirect-url']); return; } - \Chibi\Util\Url::forward(\Chibi\Router::linkTo(['IndexController', 'indexAction'])); + \Chibi\Util\Url::forward(\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView'])); } } diff --git a/src/Controllers/IndexController.php b/src/Controllers/StaticPagesController.php similarity index 89% rename from src/Controllers/IndexController.php rename to src/Controllers/StaticPagesController.php index a76726dc..c98d5dec 100644 --- a/src/Controllers/IndexController.php +++ b/src/Controllers/StaticPagesController.php @@ -1,10 +1,11 @@ transport->postCount = PostModel::getCount(); + $context->viewName = 'static-main'; $featuredPost = $this->getFeaturedPost(); if ($featuredPost) @@ -17,15 +18,19 @@ class IndexController } } - public function helpAction($tab = null) + public function helpView($tab = null) { $config = getConfig(); $context = getContext(); + if (empty($config->help->paths) or empty($config->help->title)) throw new SimpleException('Help is disabled'); + $tab = $tab ?: array_keys($config->help->subTitles)[0]; if (!isset($config->help->paths[$tab])) throw new SimpleException('Invalid tab'); + + $context->viewName = 'static-help'; $context->path = TextHelper::absolutePath($config->help->paths[$tab]); $context->tab = $tab; } diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 7eb25bd4..ab61f5ea 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -126,7 +126,7 @@ class UserController if ($oldId == Auth::getCurrentUser()->id) Auth::logOut(); - \Chibi\Util\Url::forward(\Chibi\Router::linkTo(['IndexController', 'indexAction'])); + \Chibi\Util\Url::forward(\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView'])); LogHelper::log('{user} removed {subject}\'s account', ['subject' => TextHelper::reprUser($name)]); } @@ -347,7 +347,7 @@ class UserController //check if already logged in if (Auth::isLoggedIn()) { - \Chibi\Util\Url::forward(\Chibi\Router::linkTo(['IndexController', 'indexAction'])); + \Chibi\Util\Url::forward(\Chibi\Router::linkTo(['StaticPagesController', 'mainPageView'])); return; } diff --git a/src/Views/post-view.phtml b/src/Views/post-view.phtml index 910b36f4..be4be760 100644 --- a/src/Views/post-view.phtml +++ b/src/Views/post-view.phtml @@ -283,7 +283,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0; ['PostController', 'featureAction'], ['id' => $this->context->transport->post->id]), 'data-confirm-text' => 'Are you sure you want to feature this post on the main page?', - 'data-redirect-url' => \Chibi\Router::linkTo(['IndexController', 'indexAction']), + 'data-redirect-url' => \Chibi\Router::linkTo(['StaticPagesController', 'mainPageView']), ]; } diff --git a/src/Views/index-help.phtml b/src/Views/static-help.phtml similarity index 89% rename from src/Views/index-help.phtml rename to src/Views/static-help.phtml index d4e39177..2821706d 100644 --- a/src/Views/index-help.phtml +++ b/src/Views/static-help.phtml @@ -1,6 +1,6 @@ help->subTitles; $firstTab = !empty($tabs) ? array_keys($tabs)[0] : null; @@ -17,7 +17,7 @@ $showTabs = count($tabs) > 1;