From 9f01d0fde09fa055a7db9f26e77c5e6b3d6c2224 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 28 Nov 2016 11:02:10 +0100 Subject: [PATCH] Added list view --- .../Version20161128084725.php | 49 ++++++++++++++++++ .../static/themes/_global/img/list.png | Bin 0 -> 201 bytes .../static/themes/_global/img/table.png | Bin 0 -> 229 bytes .../static/themes/baggy/css/main.css | 15 +++--- .../static/themes/material/css/main.css | 10 +++- .../Controller/ConfigController.php | 21 ++++++++ src/Wallabag/CoreBundle/Entity/Config.php | 27 ++++++++++ .../themes/baggy/Entry/entries.html.twig | 6 ++- .../material/Entry/_card_list.html.twig | 14 +++++ .../themes/material/Entry/entries.html.twig | 8 ++- .../themes/baggy/css/style.min.css | 2 +- .../themes/material/css/style.min.css | 4 +- 12 files changed, 139 insertions(+), 17 deletions(-) create mode 100644 app/DoctrineMigrations/Version20161128084725.php create mode 100755 app/Resources/static/themes/_global/img/list.png create mode 100755 app/Resources/static/themes/_global/img/table.png create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig diff --git a/app/DoctrineMigrations/Version20161128084725.php b/app/DoctrineMigrations/Version20161128084725.php new file mode 100644 index 00000000..347a4256 --- /dev/null +++ b/app/DoctrineMigrations/Version20161128084725.php @@ -0,0 +1,49 @@ +container = $container; + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix').$tableName; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $configTable = $schema->getTable($this->getTable('config')); + $this->skipIf($configTable->hasColumn('view_mode'), 'It seems that you already played this migration.'); + + $configTable->addColumn('view_mode', 'integer'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $configTable = $schema->getTable($this->getTable('config')); + $configTable->dropColumn('view_mode'); + } +} diff --git a/app/Resources/static/themes/_global/img/list.png b/app/Resources/static/themes/_global/img/list.png new file mode 100755 index 0000000000000000000000000000000000000000..bd5aff5ae99ccc7aa59d0e166ba16817d7378d3d GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i$*k|AR$Xcyt_c_>U|K_!q5E$Cc{MywQO1o`KqoMGy85}Sb4q9e0N>_HPXGV_ literal 0 HcmV?d00001 diff --git a/app/Resources/static/themes/baggy/css/main.css b/app/Resources/static/themes/baggy/css/main.css index 4f48f8ca..126c451b 100755 --- a/app/Resources/static/themes/baggy/css/main.css +++ b/app/Resources/static/themes/baggy/css/main.css @@ -297,18 +297,14 @@ h2::after { text-decoration: none; } -#listmode a:hover { - opacity: 1; -} - #listmode.tablemode { - background-image: url("../img/baggy/table.png"); + background-image: url("../../_global/img/table.png"); background-repeat: no-repeat; background-position: bottom; } #listmode.listmode { - background-image: url("../img/baggy/list.png"); + background-image: url("../../_global/img/list.png"); background-repeat: no-repeat; background-position: bottom; } @@ -352,9 +348,9 @@ footer a { letter-spacing: -5px; } -.listmode .entry { - width: 100% !important; - margin-left: 0 !important; +.listmode.entry { + width: 100%; + height: inherit; } .card-entry-labels { @@ -588,6 +584,7 @@ div.pagination ul { text-align: left; font-style: italic; color: #999; + display: inline-flex; } div.pagination ul > * { diff --git a/app/Resources/static/themes/material/css/main.css b/app/Resources/static/themes/material/css/main.css index 82a74c23..76423409 100755 --- a/app/Resources/static/themes/material/css/main.css +++ b/app/Resources/static/themes/material/css/main.css @@ -194,7 +194,6 @@ main, .results { height: 1em; - line-height: 30px; } .results .nb-results, @@ -203,6 +202,14 @@ main, margin-bottom: 0; } +.results .nb-results { + display: inline-flex; +} + +.results a { + color: #444; +} + .pagination { float: right; } @@ -593,6 +600,7 @@ a.original { background-position: 50%; } + /* ========================================================================== 5 = Article ========================================================================== */ 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) %}