Added footer page

This commit is contained in:
Jeroen De Meerleer 2023-03-22 14:44:40 +01:00
parent 8df7870753
commit 9e03804a64
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
4 changed files with 18 additions and 5 deletions

View File

@ -19,7 +19,7 @@ class DefaultController extends AbstractController
'header' => $return['header'], 'header' => $return['header'],
'content' => $return['content'], 'content' => $return['content'],
'title' => $return['title'], 'title' => $return['title'],
'nineties' => (isset($_COOKIE['nineties'])) 'footer' => $return['footer'],
], $response); ], $response);
} }
@ -32,7 +32,7 @@ class DefaultController extends AbstractController
'header' => $return['header'], 'header' => $return['header'],
'content' => $return['content'], 'content' => $return['content'],
'title' => $return['title'], 'title' => $return['title'],
'nineties' => (isset($_COOKIE['nineties'])) 'footer' => $return['footer'],
], $response); ], $response);
} }
} }

View File

@ -27,6 +27,14 @@ class Page
throw new NotFoundHttpException('Some required files were not found'); throw new NotFoundHttpException('Some required files were not found');
} }
if(file_exists($kernel->getCacheDir() . '/pages/_footer.md')) {
$return['footer'] = $parsedown->text(file_get_contents($kernel->getCacheDir() . '/pages/_footer.md'));
} elseif(file_exists($kernel->getCacheDir() . '/pages/_footer.html')) {
$return['footer'] = file_get_contents($kernel->getCacheDir() . '/pages/_footer.html');
} else {
throw new NotFoundHttpException('Some required files were not found');
}
if(file_exists($kernel->getCacheDir() . '/pages/' . $page . '.md')) { if(file_exists($kernel->getCacheDir() . '/pages/' . $page . '.md')) {
$return['content'] = $parsedown->text(file_get_contents($kernel->getCacheDir() . '/pages/' . $page . '.md')); $return['content'] = $parsedown->text(file_get_contents($kernel->getCacheDir() . '/pages/' . $page . '.md'));
} elseif(file_exists($kernel->getCacheDir() . '/pages/' . $page . '.html')) { } elseif(file_exists($kernel->getCacheDir() . '/pages/' . $page . '.html')) {
@ -35,6 +43,8 @@ class Page
throw new NotFoundHttpException('Some required files were not found'); throw new NotFoundHttpException('Some required files were not found');
} }
$titles = json_decode(file_get_contents($kernel->getCacheDir() . '/pages/titles.json'), true); $titles = json_decode(file_get_contents($kernel->getCacheDir() . '/pages/titles.json'), true);
$return['title'] = $titles[$page] ?? ''; $return['title'] = $titles[$page] ?? '';
$return['status'] = '200'; $return['status'] = '200';

View File

@ -15,9 +15,7 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% block extrahtml %}{% endblock %} {% block extrahtml %}{% endblock %}
<footer class="footer"> <footer class="footer">
<div class="container"> {% block footer %}{% endblock %}
<span class="text-muted">Design inspired by Dall-E 2</span>
</div>
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -25,3 +25,8 @@
{% block scripts %} {% block scripts %}
{{ encore_entry_script_tags('page') }} {{ encore_entry_script_tags('page') }}
{% endblock %} {% endblock %}
{% block footer %}
{{ footer | raw }}
{% endblock %}