+ {{ post.text|markdown('app.point.markdown_parser') }}
+
+ diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index e666066..558421a 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -25,6 +25,7 @@ {% block header_navbar_menus %}
diff --git a/src/Skobkin/Bundle/PointToolsBundle/Controller/PublicFeedController.php b/src/Skobkin/Bundle/PointToolsBundle/Controller/PublicFeedController.php new file mode 100644 index 0000000..b858f65 --- /dev/null +++ b/src/Skobkin/Bundle/PointToolsBundle/Controller/PublicFeedController.php @@ -0,0 +1,37 @@ +getDoctrine()->getRepository(Post::class); + + $paginator = $this->get('knp_paginator'); + + $postsPagination = $paginator->paginate( + $postRepository->createPublicFeedPostsQuery(), + $request->query->getInt('page', 1), + self::POSTS_PER_PAGE + ); + + return $this->render( + 'SkobkinPointToolsBundle:Post:feed.html.twig', + [ + // @todo Move to translation + 'feed_title' => 'All', + 'posts' => $postsPagination, + // Special feed mark (to not show comments and other) + 'is_feed' => true, + ] + ); + } +} diff --git a/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php b/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php index 5fcf39d..a3704e5 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php @@ -3,13 +3,11 @@ namespace Skobkin\Bundle\PointToolsBundle\Controller; use Doctrine\ORM\EntityManager; -use Skobkin\Bundle\PointToolsBundle\DTO\DailyEvents; -use Skobkin\Bundle\PointToolsBundle\DTO\TopUserDTO; +use Skobkin\Bundle\PointToolsBundle\DTO\{DailyEvents, TopUserDTO}; use Skobkin\Bundle\PointToolsBundle\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Ob\HighchartsBundle\Highcharts\Highchart; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\{Request, Response}; class UserController extends Controller { diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php index 78af4cb..ed1a6c3 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php @@ -89,7 +89,7 @@ class Post private $files; /** - * @var Tag[]|ArrayCollection + * @var PostTag[]|ArrayCollection * * @ORM\OneToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostTag", mappedBy="post", fetch="EXTRA_LAZY", cascade={"persist"}, orphanRemoval=true) */ diff --git a/src/Skobkin/Bundle/PointToolsBundle/Repository/Blogs/PostRepository.php b/src/Skobkin/Bundle/PointToolsBundle/Repository/Blogs/PostRepository.php index 9921913..0c7cc71 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Repository/Blogs/PostRepository.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Repository/Blogs/PostRepository.php @@ -17,6 +17,7 @@ class PostRepository extends EntityRepository { /** @var QueryBuilder $qb */ $qb = $this->createQueryBuilder('p'); + return $qb ->select(['p', 'c', 'a']) ->leftJoin('p.comments', 'c') @@ -28,4 +29,19 @@ class PostRepository extends EntityRepository ->getQuery()->getOneOrNullResult() ; } + + public function createPublicFeedPostsQuery(): QueryBuilder + { + $qb = $this->createQueryBuilder('p'); + + return $qb + // @todo optimize hydration + ->select(['p', 'pa', 'pt', 'pf']) + ->innerJoin('p.author', 'pa') + ->leftJoin('p.postTags', 'pt') + ->leftJoin('p.files', 'pf') + ->where('p.private = FALSE') + ->andWhere('pa.public = TRUE') + ; + } } \ No newline at end of file diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/config/routing.yml b/src/Skobkin/Bundle/PointToolsBundle/Resources/config/routing.yml index 66c1ada..d20678a 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Resources/config/routing.yml +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/config/routing.yml @@ -36,6 +36,11 @@ events_last: defaults: { _controller: SkobkinPointToolsBundle:Events:last } methods: [GET] +feed_public: + path: /posts/all + defaults: { _controller: SkobkinPointToolsBundle:PublicFeed:index } + methods: [GET] + post_show: path: /{id} defaults: { _controller: SkobkinPointToolsBundle:Post:show } diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml b/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml index 00d9568..52a64b8 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml @@ -3,6 +3,7 @@ # Header Toggle navigation: Переключить навигацию Main: Главная +Public feed: Публичная лента Statistics: Статистика Report a bug: Сообщить об ошибке Telegram Bot: Бот в Telegram diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/views/Post/base_feed.html.twig b/src/Skobkin/Bundle/PointToolsBundle/Resources/views/Post/base_feed.html.twig new file mode 100644 index 0000000..09d59c3 --- /dev/null +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/views/Post/base_feed.html.twig @@ -0,0 +1,11 @@ +{% extends "::base.html.twig" %} + +{% block css %} + {{ parent() }} + +{% endblock %} +{% block footer_js %} + {{ parent() }} + + +{% endblock %} \ No newline at end of file diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/views/Post/feed.html.twig b/src/Skobkin/Bundle/PointToolsBundle/Resources/views/Post/feed.html.twig new file mode 100644 index 0000000..4f9832f --- /dev/null +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/views/Post/feed.html.twig @@ -0,0 +1,26 @@ +{% extends 'SkobkinPointToolsBundle:Post:base_feed.html.twig' %} + +{% block header_title %}{{ feed_title }} @ Point Tools{% endblock %} + +{% block content %} + {% if is_feed is defined %} + + {% endif %} + + {% for post in posts %} +