From bdaa255e982be3541aecdb7fbfdcfb68a478bc1b Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 14 Jan 2021 18:02:05 +0100 Subject: [PATCH] Add sidebar --- assets/scss/app.scss | 15 +++++++++ config/packages/framework.yaml | 2 +- src/Controller/AdminController.php | 44 +++++++++++++++++++++++++ src/Controller/CategoryController.php | 9 +++++ src/Controller/CommentController.php | 9 +++++ templates/admin/base-admin.html.twig | 47 +++++++++++++++++++++++++++ templates/admin/index.html.twig | 20 ++++++++++++ templates/base.html.twig | 20 ++++++------ templates/category_summary.html.twig | 6 ++++ templates/recent_comment.html.twig | 16 +++++++++ 10 files changed, 177 insertions(+), 11 deletions(-) create mode 100644 src/Controller/AdminController.php create mode 100644 templates/admin/base-admin.html.twig create mode 100644 templates/admin/index.html.twig create mode 100644 templates/category_summary.html.twig create mode 100644 templates/recent_comment.html.twig diff --git a/assets/scss/app.scss b/assets/scss/app.scss index 45f0625..693138b 100644 --- a/assets/scss/app.scss +++ b/assets/scss/app.scss @@ -1 +1,16 @@ @import '~mdb-ui-kit/src/scss/mdb.free'; + +#body { + width: 80vw; +} + +.sidebar { + position: fixed; + top: 0; + right: 0; + overflow: auto; + transition: all .3s ease-in; + width: 20vw; + height: 100%; + z-index: 7; +} diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index cad7f78..a0198cc 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -12,6 +12,6 @@ framework: cookie_samesite: lax #esi: true - #fragments: true + fragments: { path: /_fragment } php_errors: log: true diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php new file mode 100644 index 0000000..4b0934f --- /dev/null +++ b/src/Controller/AdminController.php @@ -0,0 +1,44 @@ +render('admin/index.html.twig', [ + 'controller_name' => 'AdminController', + ]); + } + + /** + * @Route("/admin/posts", name="posts") + */ + public function posts(): Response + { + + } + + /** + * @Route("/admin/categories", name="categories") + */ + public function categories(): Response + { + + } + + /** + * @Route("/admin/comments", name="comments") + */ + public function comments(): Response + { + + } +} diff --git a/src/Controller/CategoryController.php b/src/Controller/CategoryController.php index 5877329..76c1de7 100644 --- a/src/Controller/CategoryController.php +++ b/src/Controller/CategoryController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Entity\Category; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -17,4 +18,12 @@ class CategoryController extends AbstractController 'controller_name' => 'CategoryController', ]); } + + public function categorySummary(): Response + { + return $this->render('category_summary.html.twig', [ + 'controller_name' => 'CategoryController', + 'Categories' => array_filter($this->getDoctrine()->getRepository(Category::class)->findAll(), static function ($c) {return count($c->getPosts())>=1;}) + ]); + } } diff --git a/src/Controller/CommentController.php b/src/Controller/CommentController.php index 7e7e4bc..d02dc53 100644 --- a/src/Controller/CommentController.php +++ b/src/Controller/CommentController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Entity\Comment; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -17,4 +18,12 @@ class CommentController extends AbstractController 'controller_name' => 'CommentController', ]); } + + public function recentComment(): Response + { + return $this->render('recent_comment.html.twig', [ + 'controller_name' => 'CommentController', + 'comments' => $this->getDoctrine()->getRepository(Comment::class)->findBy(array('valid' => true), array('createdAt' => 'DESC'), 5, 0) + ]); + } } diff --git a/templates/admin/base-admin.html.twig b/templates/admin/base-admin.html.twig new file mode 100644 index 0000000..64c4a81 --- /dev/null +++ b/templates/admin/base-admin.html.twig @@ -0,0 +1,47 @@ + + + + + {% block title %}Welcome!{% endblock %} + {% block stylesheets %} + {{ encore_entry_link_tags('app') }} + {% endblock %} + + + + {% block body %}{% endblock %} + {% block javascripts %} + {{ encore_entry_script_tags('app') }} + {% endblock %} + + diff --git a/templates/admin/index.html.twig b/templates/admin/index.html.twig new file mode 100644 index 0000000..234e045 --- /dev/null +++ b/templates/admin/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'admin/base-admin.html.twig' %} + +{% block title %}Hello AdminController!{% endblock %} + +{% block body %} + + +
+

Hello {{ controller_name }}! ✅

+ + This friendly message is coming from: + +
+{% endblock %} diff --git a/templates/base.html.twig b/templates/base.html.twig index 86d6ebc..0e0c665 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -6,7 +6,6 @@ {% block stylesheets %} {{ encore_entry_link_tags('app') }} {% endblock %} - {% set admin = false %} - {% block body %}{% endblock %} + +
+ {% block body %}{% endblock %} +
{% block javascripts %} {{ encore_entry_script_tags('app') }} {% endblock %} diff --git a/templates/category_summary.html.twig b/templates/category_summary.html.twig new file mode 100644 index 0000000..20c9189 --- /dev/null +++ b/templates/category_summary.html.twig @@ -0,0 +1,6 @@ +

Categories summary

+ diff --git a/templates/recent_comment.html.twig b/templates/recent_comment.html.twig new file mode 100644 index 0000000..fb45131 --- /dev/null +++ b/templates/recent_comment.html.twig @@ -0,0 +1,16 @@ +

Recent comments

+
+ {% for comment in comments %} +
+ +

+ +

+
+
{{ comment.content }}
+
+
+ {% endfor %} +