[ROUTES] Add redirect from root to main/all, link from header to root, and change parameter order on RouteLoader::connect

This commit is contained in:
Hugo Sales 2020-08-09 13:25:48 +00:00 committed by Hugo Sales
parent 365168d03e
commit cd89cf04ff
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 8 additions and 6 deletions

View File

@ -78,7 +78,7 @@ class RouteLoader extends Loader
* 'fragment', 'http-methods', 'locale', 'methods', 'schemes'] * 'fragment', 'http-methods', 'locale', 'methods', 'schemes']
* 'http-methods' and 'methods' are aliases * 'http-methods' and 'methods' are aliases
*/ */
public function connect(string $id, string $uri_path, $target, ?array $param_reqs = [], ?array $options = []) public function connect(string $id, string $uri_path, $target, ?array $options = [], ?array $param_reqs = [])
{ {
$this->rc->add($id, $this->rc->add($id,
new Route( new Route(
@ -94,7 +94,8 @@ class RouteLoader extends Loader
'_locale' => $options['locale'] ?? 'en', '_locale' => $options['locale'] ?? 'en',
'template' => $options['template'] ?? '', 'template' => $options['template'] ?? '',
], ],
$options['defaults'] ?? []), $options['defaults'] ?? []
),
// requirements = [] -- param => regex // requirements = [] -- param => regex
$param_reqs, $param_reqs,
// options = [] -- possible keys: compiler_class:, utf8 // options = [] -- possible keys: compiler_class:, utf8

View File

@ -46,6 +46,7 @@ abstract class Main
$r->connect('logout', '/logout', [C\Security::class, 'logout']); $r->connect('logout', '/logout', [C\Security::class, 'logout']);
$r->connect('register', '/register', [C\Security::class, 'register']); $r->connect('register', '/register', [C\Security::class, 'register']);
$r->connect('root', '/', RedirectController::class, ['defaults' => ['route' => 'main_all']]);
$r->connect('main_all', '/main/all', C\NetworkPublic::class); $r->connect('main_all', '/main/all', C\NetworkPublic::class);
$r->connect('panel', '/panel', [C\AdminPanel::class, 'site']); $r->connect('panel', '/panel', [C\AdminPanel::class, 'site']);
@ -53,15 +54,15 @@ abstract class Main
// FAQ static pages // FAQ static pages
foreach (['faq', 'contact', 'tags', 'groups', 'openid'] as $s) { foreach (['faq', 'contact', 'tags', 'groups', 'openid'] as $s) {
$r->connect('doc_' . $s, '/doc/' . $s, TemplateController::class, [], ['defaults' => ['template' => 'doc/faq/' . $s . '.html.twig']]); $r->connect('doc_' . $s, '/doc/' . $s, TemplateController::class, ['defaults' => ['template' => 'doc/faq/' . $s . '.html.twig']]);
} }
foreach (['privacy', 'tos', 'version', 'source'] as $s) { foreach (['privacy', 'tos', 'version', 'source'] as $s) {
$r->connect('doc_' . $s, '/doc/' . $s, TemplateController::class, [], ['defaults' => ['template' => 'doc/' . $s . '.html.twig']]); $r->connect('doc_' . $s, '/doc/' . $s, TemplateController::class, ['defaults' => ['template' => 'doc/' . $s . '.html.twig']]);
} }
// Settings pages // Settings pages
$r->connect('settings', '/settings', RedirectController::class, [], ['defaults' => ['route' => 'settings_personal_info']]); $r->connect('settings', '/settings', RedirectController::class, ['defaults' => ['route' => 'settings_personal_info']]);
foreach (['personal_info', 'avatar', 'notifications', 'account'] as $s) { foreach (['personal_info', 'avatar', 'notifications', 'account'] as $s) {
$r->connect('settings_' . $s, '/settings/' . $s, [C\UserPanel::class, $s]); $r->connect('settings_' . $s, '/settings/' . $s, [C\UserPanel::class, $s]);
} }

View File

@ -57,7 +57,7 @@
{% block left %} {% block left %}
{% endblock left %} {% endblock left %}
<nav id='instance'> <nav id='instance'>
<a href="#"> <a href="/">
<svg class="icon icon-logo"> <svg class="icon icon-logo">
<use xlink:href="#icon-logo"></use> <use xlink:href="#icon-logo"></use>
</svg><b>GNU social</b> </svg><b>GNU social</b>