normalized url routing and cleaned up templating structure
parent
cf752fd8c0
commit
f3f2a6502b
@ -1,18 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
include "brain/data/Book.inc.php";
|
||||
include "brain/data/Auth.inc.php";
|
||||
|
||||
class DashControl
|
||||
{
|
||||
public function getPages($section)
|
||||
{
|
||||
$book = new Book("content/pages");
|
||||
switch ($section) {
|
||||
public static function start(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$view = Twig::fromRequest($request);
|
||||
$pageOptions = [];
|
||||
$auth = new Auth();
|
||||
switch (isset($args["second"]) ? $args["second"] : "index") {
|
||||
case "pages":
|
||||
$content = [];
|
||||
break;
|
||||
default:
|
||||
return $book->getContents();
|
||||
$book = new Book("content/pages");
|
||||
$pageOptions = [
|
||||
"title" => "Fipamo Dashboard",
|
||||
"status" => $auth->sessionStatus(),
|
||||
"pages" => $book->getContents(),
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $view->render($response, "dash/start.twig", $pageOptions);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class IndexControl
|
||||
{
|
||||
private $secret = 'not very secretish';
|
||||
|
||||
public function getSecret()
|
||||
{
|
||||
return $this->secret;
|
||||
}
|
||||
|
||||
}
|
||||
public static function start(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$view = Twig::fromRequest($request);
|
||||
|
||||
return $view->render($response, "front/start.twig", [
|
||||
"title" => "Fipamo Dash",
|
||||
"status" => false,
|
||||
"pages" => [],
|
||||
"totalPages" => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
include "brain/controller/IndexControl.inc.php";
|
||||
include "brain/controller/DashControl.inc.php";
|
||||
|
||||
class RouteControl
|
||||
{
|
||||
public function get(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
switch (isset($args["first"]) ? $args["first"] : "index") {
|
||||
case "dashboard":
|
||||
return DashControl::start($request, $response, $args);
|
||||
break;
|
||||
default:
|
||||
return IndexControl::start($request, $response, $args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
</title>
|
||||
{% block stylesheets %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<div id="main-content" class="main-container"> {% block mainContent %}{% endblock %}
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
{% if options['showFooter'] is defined %}
|
||||
<!-- NO FOOTER -->
|
||||
{% else %}
|
||||
<div class="inner">
|
||||
<div class="columns">
|
||||
<div id="footer_left" class="column">
|
||||
<a href="#">About</a><br/>
|
||||
</div>
|
||||
<div id="footer_right " class="column">
|
||||
<a href="#">FAQ</a><br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</footer>
|
||||
{% block javascripts %}{% endblock %}</body></html>
|
@ -0,0 +1,17 @@
|
||||
{% extends "front/_frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" type="text/css" href="/public/assets/css/base.css">
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
This is the index page, boss
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="/public/assets/scripts/dash.min.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue