|
|
@@ -11,7 +11,7 @@ $app = AppFactory::create(); |
|
|
|
function addNavBar($response) |
|
|
|
{ |
|
|
|
|
|
|
|
$response->getBody()->write("<html><head></head><body>"); |
|
|
|
$response->getBody()->write('<html><head><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"></head><body>'); |
|
|
|
if (isset($_SESSION['username'])) { |
|
|
|
$response->getBody()->write('<div><a href="/">Index</a> | <a href="/blog/create">Create Blog</a> | <a href="/logout">Logout</a></div>'); |
|
|
|
} else { |
|
|
@@ -63,9 +63,11 @@ $app->get('/', function (Request $request, Response $response, array $args) { |
|
|
|
$app->get('/blog/{slug}', function (Request $request, Response $response, array $args) { |
|
|
|
|
|
|
|
addNavBar($response); |
|
|
|
$title= $args['slug']; |
|
|
|
$response->getBody()->write("<h1>$title</h1>"); |
|
|
|
|
|
|
|
foreach ($_SESSION['blogs'] as $art) { |
|
|
|
if ($art['slug'] == $args['slug']) { |
|
|
|
$response->getBody()->write("<h1>" . $art['title'] . "</h1>"); |
|
|
|
} |
|
|
|
} |
|
|
|
addFooter($response); |
|
|
|
|
|
|
|
return $response; |