{% if title_links %}{% endif %}{{ post.title }}{% if title_links %}{% endif %}
+{{ post.createdAt|date('m-d-Y :: H:i') }} by {{ post.user.name }}
+ {{ post.content|insert_code_chunks }} +diff --git a/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php b/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php index d55ee03..40920f0 100644 --- a/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php +++ b/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php @@ -4,6 +4,7 @@ namespace GergelyPolonkai\FrontBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Doctrine\ORM\Tools\Pagination\Paginator; use GergelyPolonkai\FrontBundle\Entity\Post; @@ -16,6 +17,36 @@ use GergelyPolonkai\FrontBundle\Entity\Post; */ class BlogController extends Controller { + /** + * @Route("/", name="GergelyPolonkaiFrontBundle_blogListing") + * @Route("/page/{cPage}", name="GergelyPolonkaiFrontBundle_blogListingPage", requirements={"cPage": "\d+"}) + * @Template + */ + public function listAction($cPage = 1) + { + // TODO: Make this a config parameter + $postsPerPage = 10; + --$cPage; + + $query = $this + ->getDoctrine() + ->getEntityManager() + ->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p WHERE p.draft = FALSE ORDER BY p.createdAt DESC") + ->setFirstResult($cPage * $postsPerPage) + ->setMaxResults($postsPerPage); + + $paginator = new Paginator($query, $fetchJoinCollection = true); + $count = $paginator->count(); + $pageCount = ceil($count / $postsPerPage); + + return array( + 'cpage' => $cPage, + 'count' => $pageCount, + 'posts' => $paginator, + 'perPage' => $postsPerPage, + ); + } + /** * @Route("/{year}/{month}/{day}/{slug}.html", name="GergelyPolonkaiFront_blogViewPost") * @Template diff --git a/src/GergelyPolonkai/FrontBundle/Resources/public/css/blog.css b/src/GergelyPolonkai/FrontBundle/Resources/public/css/blog.css new file mode 100644 index 0000000..2378a51 --- /dev/null +++ b/src/GergelyPolonkai/FrontBundle/Resources/public/css/blog.css @@ -0,0 +1,21 @@ +/* + Document : blog + Created on : 2012.09.14., 14:53:34 + Author : polonkai.gergely + Description: + Purpose of the stylesheet follows. +*/ + +.post { + margin-bottom: 2em; +} + +p.article-date { + text-indent: 0; + font-size: 80%; + color: #7f7f7f; +} + +.paginator { + margin: .5em 0; +} \ No newline at end of file diff --git a/src/GergelyPolonkai/FrontBundle/Resources/public/css/front.css b/src/GergelyPolonkai/FrontBundle/Resources/public/css/front.css index 21c4324..d8226bc 100644 --- a/src/GergelyPolonkai/FrontBundle/Resources/public/css/front.css +++ b/src/GergelyPolonkai/FrontBundle/Resources/public/css/front.css @@ -110,12 +110,6 @@ body { text-decoration: underline; } -#content p.article-date { - text-indent: 0; - font-size: 80%; - color: #7f7f7f; -} - dt { font-weight: normal; text-decoration: underline; @@ -168,3 +162,7 @@ dd p { text-decoration: underline; } +#more-posts { + margin-top: 1em; + text-align: right; +} \ No newline at end of file diff --git a/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/list.html.twig b/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/list.html.twig new file mode 100644 index 0000000..c35fd9f --- /dev/null +++ b/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/list.html.twig @@ -0,0 +1,33 @@ +{% extends 'GergelyPolonkaiFrontBundle:Default:front_base.html.twig' %} + +{% block title %} - Blog{% endblock %} + +{% block paginator %} +{% if count > 1 %} +
{{ post.createdAt|date('m-d-Y :: H:i') }} by {{ post.user.name }}
-{{ post.content|insert_code_chunks }} +{{ post.createdAt|date('m-d-Y :: H:i') }} by {{ post.user.name }}
+ {{ post.content|insert_code_chunks }} +