From bd9f08157cc10619e9bb9dace6df43090dde44a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 22 Jan 2015 21:11:22 +0100 Subject: article view, fav list, archive list --- src/WallabagBundle/Controller/EntryController.php | 47 +++++++++- .../Repository/EntriesRepository.php | 32 +++++-- .../Resources/views/Entry/entries.html.twig | 43 +++++---- .../Resources/views/Entry/entry.html.twig | 104 +++++++++++++++++++++ src/WallabagBundle/Resources/views/_menu.html.twig | 17 ++++ src/WallabagBundle/Resources/views/_top.html.twig | 3 +- 6 files changed, 217 insertions(+), 29 deletions(-) create mode 100644 src/WallabagBundle/Resources/views/Entry/entry.html.twig create mode 100644 src/WallabagBundle/Resources/views/_menu.html.twig (limited to 'src/WallabagBundle') diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php index 0c0c1569..233a6c32 100644 --- a/src/WallabagBundle/Controller/EntryController.php +++ b/src/WallabagBundle/Controller/EntryController.php @@ -11,7 +11,7 @@ class EntryController extends Controller /** * @Route("/unread", name="unread") */ - public function unreadAction() + public function showUnreadAction() { $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); $entries = $repository->findUnreadByUser(1); @@ -22,4 +22,49 @@ class EntryController extends Controller ); } + + /** + * @Route("/archive", name="archive") + */ + public function showArchiveAction() + { + $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); + $entries = $repository->findArchiveByUser(1); + + return $this->render( + 'WallabagBundle:Entry:entries.html.twig', + array('entries' => $entries) + ); + + } + + /** + * @Route("/starred", name="starred") + */ + public function showStarredAction() + { + $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); + $entries = $repository->findStarredByUser(1); + + return $this->render( + 'WallabagBundle:Entry:entries.html.twig', + array('entries' => $entries) + ); + + } + + /** + * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") + */ + public function viewAction($id) + { + $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); + $entry = $repository->find($id); + + return $this->render( + 'WallabagBundle:Entry:entry.html.twig', + array('entry' => $entry) + ); + + } } diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php index 4c13c9c2..c355a012 100644 --- a/src/WallabagBundle/Repository/EntriesRepository.php +++ b/src/WallabagBundle/Repository/EntriesRepository.php @@ -13,14 +13,6 @@ use Doctrine\ORM\EntityRepository; */ class EntriesRepository extends EntityRepository { - /* public function findUnreadByUser($userId) - { - return $this->createQueryBuilder('e') - ->where('e.is_read = 0') - ->andWhere('e.user_id = :userId') - ->setParameter('userId', $userId) - ->getQuery(); - }*/ public function findUnreadByUser($userId) { $qb = $this->createQueryBuilder('e') @@ -32,4 +24,28 @@ class EntriesRepository extends EntityRepository return $qb; } + + public function findArchiveByUser($userId) + { + $qb = $this->createQueryBuilder('e') + ->select('e') + ->where('e.isRead = 1') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery() + ->getResult(Query::HYDRATE_ARRAY); + + return $qb; + } + + public function findStarredByUser($userId) + { + $qb = $this->createQueryBuilder('e') + ->select('e') + ->where('e.isFav = 1') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery() + ->getResult(Query::HYDRATE_ARRAY); + + return $qb; + } } diff --git a/src/WallabagBundle/Resources/views/Entry/entries.html.twig b/src/WallabagBundle/Resources/views/Entry/entries.html.twig index f4d7a7ab..81177298 100644 --- a/src/WallabagBundle/Resources/views/Entry/entries.html.twig +++ b/src/WallabagBundle/Resources/views/Entry/entries.html.twig @@ -2,25 +2,32 @@ {% block title "Unread" %} -{% block content_header '' %} +{% block menu %} + {% include "WallabagBundle::_menu.html.twig" %} +{% endblock %} {% block content %} - {% for entry in entries %} -
-

{{ entry.title|raw }}

- {% if entry.content| readingTime > 0 %} -
{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min
- {% else %} -
{% trans %}estimated reading time :{% endtrans %} < 1 min
- {% endif %} - -

{{ entry.content|striptags|slice(0, 300) }}...

-
- {% endfor %} + {% if entries is empty %} +

{% trans %}No articles found.{% endtrans %}

+ {% else %} + {% for entry in entries %} +
+

{{ entry.title|raw }}

+ {% if entry.content| readingTime > 0 %} +
{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min
+ {% else %} +
{% trans %}estimated reading time :{% endtrans %} < 1 min
+ {% endif %} + + +

{{ entry.content|striptags|slice(0, 300) }}...

+
+ {% endfor %} + {% endif %} {% endblock %} diff --git a/src/WallabagBundle/Resources/views/Entry/entry.html.twig b/src/WallabagBundle/Resources/views/Entry/entry.html.twig new file mode 100644 index 00000000..19d4650e --- /dev/null +++ b/src/WallabagBundle/Resources/views/Entry/entry.html.twig @@ -0,0 +1,104 @@ +{% extends "WallabagBundle::layout.html.twig" %} + +{% block title %}{{ entry.title|raw }} ({{ entry.url | e | domainName }}){% endblock %} + +{% block menu %} + {% include "WallabagBundle::_menu.html.twig" %} +{% endblock %} + +{% block content %} +
+ +
+
+
+

{{ entry.title|raw }}

+
+ +
+ {{ entry.content | raw }} +
+
+ + +{% endblock %} \ No newline at end of file diff --git a/src/WallabagBundle/Resources/views/_menu.html.twig b/src/WallabagBundle/Resources/views/_menu.html.twig new file mode 100644 index 00000000..b001aec5 --- /dev/null +++ b/src/WallabagBundle/Resources/views/_menu.html.twig @@ -0,0 +1,17 @@ + + + diff --git a/src/WallabagBundle/Resources/views/_top.html.twig b/src/WallabagBundle/Resources/views/_top.html.twig index 576df806..34d925df 100755 --- a/src/WallabagBundle/Resources/views/_top.html.twig +++ b/src/WallabagBundle/Resources/views/_top.html.twig @@ -1,6 +1,5 @@

- {% block logo %}wallabag logo{% endblock %} - + {% block logo %}wallabag logo{% endblock %}

-- cgit v1.2.3