Add templates
This commit is contained in:
parent
e038467a4b
commit
c1d2651879
@ -7,6 +7,9 @@ use Slim\Factory\AppFactory;
|
||||
use League\Config\Configuration;
|
||||
use DI\Container;
|
||||
use DI\ContainerBuilder;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
use Slovocast\Routes;
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
@ -52,10 +55,7 @@ class Bootstrap
|
||||
*/
|
||||
protected static function establishRoutes(App $app): void
|
||||
{
|
||||
$app->get('/', function ($req, $res) {
|
||||
$res->getBody()->write(json_encode([ 'message' => "hello!" ]));
|
||||
return $res->withHeader("Content-Type", "application/json");
|
||||
});
|
||||
Routes::init($app);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,6 +67,10 @@ class Bootstrap
|
||||
protected static function establishMiddleware(App $app): void
|
||||
{
|
||||
$app->addErrorMiddleware(true, true, true);
|
||||
|
||||
// Twig
|
||||
$twig = Twig::create(__DIR__ . "../templates", [ 'cache' => false ]);
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
}
|
||||
|
||||
/**
|
||||
|
14
code/src/Controller/HomePage.php
Normal file
14
code/src/Controller/HomePage.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
class HomePage extends Controller
|
||||
{
|
||||
public function respond(Request $request, Response $response): Response
|
||||
{
|
||||
return $this->render('home');
|
||||
}
|
||||
}
|
@ -9,6 +9,6 @@ class RegisterUserAction extends Controller
|
||||
{
|
||||
public function respond(): Response
|
||||
{
|
||||
return $this->respond('user/register/success');
|
||||
return $this->respond('users/register/success');
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ class RegisterUserPage extends Controller
|
||||
{
|
||||
public function respond(): Response
|
||||
{
|
||||
return $this->render('user/register');
|
||||
return $this->render('users/register');
|
||||
}
|
||||
}
|
||||
|
7
code/templates/home.twig
Normal file
7
code/templates/home.twig
Normal file
@ -0,0 +1,7 @@
|
||||
{% extends 'layouts/skeleton' %}
|
||||
|
||||
{% block "content" %}
|
||||
<div>
|
||||
<h1>Slovocast</h1>
|
||||
</div>
|
||||
{% endblock %}
|
21
code/templates/layouts/skeleton.twig
Normal file
21
code/templates/layouts/skeleton.twig
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{% block "page_title" %}{% endblock %}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
{% block "header" %}{% endblock %}
|
||||
</header>
|
||||
|
||||
<main>
|
||||
{% block "content" %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
{% blcok "footer" %}{% endblock %}
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
10
code/templates/users/register.twig
Normal file
10
code/templates/users/register.twig
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends 'layouts/skeleton' %}
|
||||
|
||||
{% block "content" %}
|
||||
<div>
|
||||
<form action="/users/register" method="post">
|
||||
|
||||
<input type="submit" label="Submit">
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user