From 9f01d0fde09fa055a7db9f26e77c5e6b3d6c2224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 28 Nov 2016 11:02:10 +0100 Subject: Added list view --- .../CoreBundle/Controller/ConfigController.php | 21 +++++++++++++++++ src/Wallabag/CoreBundle/Entity/Config.php | 27 ++++++++++++++++++++++ .../views/themes/baggy/Entry/entries.html.twig | 6 +++-- .../themes/material/Entry/_card_list.html.twig | 14 +++++++++++ .../views/themes/material/Entry/entries.html.twig | 8 +++++-- 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 52a03070..ea7cd883 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -363,4 +363,25 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('fos_user_security_login')); } + + /** + * Switch view mode for current user. + * + * @Route("/config/view-mode", name="switch_view_mode") + * + * @param Request $request + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function changeViewModeAction(Request $request) + { + $user = $this->getUser(); + $user->getConfig()->setViewMode(!$user->getConfig()->getViewMode()); + + $em = $this->getDoctrine()->getManager(); + $em->persist($user); + $em->flush(); + + return $this->redirect($request->headers->get('referer')); + } } diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index e04f0a7b..70364ab6 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -97,6 +97,13 @@ class Config */ private $actionMarkAsRead; + /** + * @var int + * + * @ORM\Column(name="view_mode", type="integer", nullable=true) + */ + private $viewMode; + /** * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") */ @@ -339,6 +346,26 @@ class Config return $this; } + /** + * @return int + */ + public function getViewMode() + { + return $this->viewMode; + } + + /** + * @param int $viewMode + * + * @return Config + */ + public function setViewMode($viewMode) + { + $this->viewMode = $viewMode; + + return $this; + } + /** * @param TaggingRule $rule * diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index a13fe903..3df990a3 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig @@ -13,9 +13,11 @@ {% block content %} + {% set viewMode = app.user.config.viewMode %}
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
{% for entry in entries %} -
+

{{ entry.title|raw }}

{% set readingTime = entry.readingTime / app.user.config.readingSpeed %} @@ -50,7 +52,7 @@
  • {{ 'entry.list.delete'|trans }}
  • {{ entry.domainName|removeWww }}
  • - {% if entry.previewPicture is null %} + {% if (entry.previewPicture is null or viewMode == 1) %}