]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added a configuration to define the redirection after archiving an entry
authorNicolas Lœuillet <nicolas@loeuillet.org>
Sun, 6 Nov 2016 11:02:39 +0000 (12:02 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Wed, 16 Nov 2016 22:07:34 +0000 (23:07 +0100)
Fix #496

26 files changed:
app/DoctrineMigrations/Version20161106113822.php [new file with mode: 0644]
docs/de/user/configuration.rst
docs/en/user/configuration.rst
docs/fr/user/configuration.rst
src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php
src/Wallabag/CoreBundle/Entity/Config.php
src/Wallabag/CoreBundle/Form/Type/ConfigType.php
src/Wallabag/CoreBundle/Helper/Redirect.php
src/Wallabag/CoreBundle/Resources/config/services.yml
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
tests/Wallabag/CoreBundle/Helper/RedirectTest.php

diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php
new file mode 100644 (file)
index 0000000..41e64a4
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+
+class Version20161106113822 extends AbstractMigration
+{
+    /**
+     * @var ContainerInterface
+     */
+    private $container;
+
+    public function setContainer(ContainerInterface $container = null)
+    {
+        $this->container = $container;
+    }
+
+    private function getTable($tableName)
+    {
+        return $this->container->getParameter('database_table_prefix') . $tableName;
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->addSql('ALTER TABLE "'.$this->getTable('config').'" ADD action_mark_as_read INT DEFAULT 0');
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
+
+        $this->addSql('ALTER TABLE "'.$this->getTable('config').'" DROP action_mark_as_read');
+    }
+}
index 0b0793b11d219f603387926207df8ac4fc2d985d..7596a1d3ce91ee90c346c694fb40908aed3d3b81 100644 (file)
@@ -28,6 +28,15 @@ Lesegeschwindigkeit
 wallabag berechnet die Lesezeit für jeden Artikel. Du kannst hier definieren, dank dieser Liste, ob du
 ein schneller oder langsamer Leser bist. wallabag wird die Lesezeit für jeden Artikel neu berechnen.
 
+Where do you want to be redirected after mark an article as read?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Each time you'll do some actions (after marking an article as read/favorite,
+after deleting an article, after removing a tag from an entry), you can be redirected:
+
+- To the homepage
+- To the current page
+
 Sprache
 ~~~~~~~
 
index e7055a145abb7261ce7a0703a6e84b810e418216..e16af12c3eb4765bf2fbf7ffab1c69e24c6ed42a 100644 (file)
@@ -27,6 +27,15 @@ Reading speed
 wallabag calculates a reading time for each article. You can define here, thanks to this list, if you are
 a fast or a slow reader. wallabag will recalculate the reading time for each article.
 
+Where do you want to be redirected after mark an article as read?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Each time you'll do some actions (after marking an article as read/favorite,
+after deleting an article, after removing a tag from an entry), you can be redirected:
+
+- To the homepage
+- To the current page
+
 Language
 ~~~~~~~~
 
index 90eece112c5fa5960b217a0b788507621d988049..c533b5c5dc41b2429f31f2804b8359197ad61b54 100644 (file)
@@ -27,6 +27,15 @@ Vitesse de lecture
 
 wallabag calcule une durée de lecture pour chaque article. Vous pouvez définir ici, grâce à cette liste déroulante, si vous lisez plus ou moins vite. wallabag recalculera la durée de lecture de chaque article.
 
+Où souhaitez-vous être redirigé après avoir marqué un article comme lu ?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Chaque fois que vous ferez certaines actions (après avoir marqué un article comme lu / comme favori,
+après avoir supprimé un article, après avoir retiré un tag d'un article), vous pouvez être redirigé :
+
+- sur la page d'accueil
+- sur la page courante
+
 Langue
 ~~~~~~
 
index 921c739fff1ba44b130e763161e3e5283542b410..4535802279019a95d57982c4afde5133b01f5a9d 100644 (file)
@@ -21,6 +21,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
         $adminConfig->setReadingSpeed(1);
         $adminConfig->setLanguage('en');
         $adminConfig->setPocketConsumerKey('xxxxx');
+        $adminConfig->setActionMarkAsRead(0);
 
         $manager->persist($adminConfig);
 
@@ -32,6 +33,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
         $bobConfig->setReadingSpeed(1);
         $bobConfig->setLanguage('fr');
         $bobConfig->setPocketConsumerKey(null);
+        $bobConfig->setActionMarkAsRead(1);
 
         $manager->persist($bobConfig);
 
@@ -43,6 +45,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
         $emptyConfig->setReadingSpeed(1);
         $emptyConfig->setLanguage('en');
         $emptyConfig->setPocketConsumerKey(null);
+        $emptyConfig->setActionMarkAsRead(0);
 
         $manager->persist($emptyConfig);
 
index d0f0e3f38809dc00331327a1f6e9706fcd405572..c40d1535f1a62cb013e08e7ece264ed657a3a08f 100644 (file)
@@ -87,6 +87,13 @@ class Config
      */
     private $pocketConsumerKey;
 
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="action_mark_as_read", type="integer", nullable=true)
+     */
+    private $actionMarkAsRead;
+
     /**
      * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config")
      */
@@ -309,6 +316,26 @@ class Config
         return $this->pocketConsumerKey;
     }
 
+    /**
+     * @return int
+     */
+    public function getActionMarkAsRead()
+    {
+        return $this->actionMarkAsRead;
+    }
+
+    /**
+     * @param int $actionMarkAsRead
+     *
+     * @return Config
+     */
+    public function setActionMarkAsRead($actionMarkAsRead)
+    {
+        $this->actionMarkAsRead = $actionMarkAsRead;
+
+        return $this;
+    }
+
     /**
      * @param TaggingRule $rule
      *
index 0bac28740a99c0784f00d664a57458726e7a297f..3b1a8026979eb878358f57ded695e262e2cb7725 100644 (file)
@@ -48,6 +48,13 @@ class ConfigType extends AbstractType
                     'config.form_settings.reading_speed.400_word' => '2',
                 ],
             ])
+            ->add('action_mark_as_read', ChoiceType::class, [
+                'label' => 'config.form_settings.action_mark_as_read.label',
+                'choices' => [
+                    'config.form_settings.action_mark_as_read.redirect_homepage' => '0',
+                    'config.form_settings.action_mark_as_read.redirect_current_page' => '1',
+                ],
+            ])
             ->add('language', ChoiceType::class, [
                 'choices' => array_flip($this->languages),
                 'label' => 'config.form_settings.language_label',
index c14c79d11bd1f6a46312160174c177ae0fca3e14..918d926616a517fa26b2e1d9c02cdcad709cf3a7 100644 (file)
@@ -3,6 +3,7 @@
 namespace Wallabag\CoreBundle\Helper;
 
 use Symfony\Component\Routing\Router;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
 
 /**
  * Manage redirections to avoid redirecting to empty routes.
@@ -10,10 +11,12 @@ use Symfony\Component\Routing\Router;
 class Redirect
 {
     private $router;
+    private $actionMarkAsRead;
 
-    public function __construct(Router $router)
+    public function __construct(Router $router, TokenStorage $token)
     {
         $this->router = $router;
+        $this->actionMarkAsRead = $token->getToken()->getUser()->getConfig()->getActionMarkAsRead();
     }
 
     /**
@@ -24,6 +27,10 @@ class Redirect
      */
     public function to($url, $fallback = '')
     {
+        if ($this->actionMarkAsRead == 0) {
+            return $this->router->generate('homepage');
+        }
+
         if (null !== $url) {
             return $url;
         }
index 9786ac279d8e5475c4754048fbf51f7a7fd3b3ed..dad9bd421f42cbc5d0566f34621c6c92766d3e2e 100644 (file)
@@ -109,6 +109,7 @@ services:
         class: Wallabag\CoreBundle\Helper\Redirect
         arguments:
             - "@router"
+            - "@security.token_storage"
 
     wallabag_core.helper.prepare_pager_for_entries:
         class: Wallabag\CoreBundle\Helper\PreparePagerForEntries
index b66aa3ea53285a76b4792c932cac9b3a845d809d..c24c59653232be995bbce4150240135af38b52b5 100644 (file)
@@ -70,6 +70,10 @@ config:
             # 200_word: 'I read ~200 words per minute'
             # 300_word: 'I read ~300 words per minute'
             # 400_word: 'I read ~400 words per minute'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: Brugers nøgle til Pocket for at importere materialer
         # android_configuration: Configure your Android application
     form_rss:
index 9e19dcc4a7ffaa6c28f5435eafaaf82487c0db92..1b0bc026b6f22bc13a88d292d2f59ac8ac913a82 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'Ich lese ~200 Wörter pro Minute'
             300_word: 'Ich lese ~300 Wörter pro Minute'
             400_word: 'Ich lese ~400 Wörter pro Minute'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: Consumer-Key für Pocket, um Inhalte zu importieren
         # android_configuration: Configure your Android application
     form_rss:
index 7516bbd5cf30857de81e0390f18cd58a15a628c7..b11dc778a830cb44b03392d2e4e7f66a0d8c7649 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'I read ~200 words per minute'
             300_word: 'I read ~300 words per minute'
             400_word: 'I read ~400 words per minute'
+        action_mark_as_read:
+            label: 'Where do you want to be redirected after mark an article as read?'
+            redirect_homepage: 'To the homepage'
+            redirect_current_page: 'To the current page'
         pocket_consumer_key_label: Consumer key for Pocket to import contents
         android_configuration: Configure your Android application
     form_rss:
index 208982d9bbe4070ff83a43bae43d56c635ce5166..15d0c3cf0496f81aa6c6d5314675b1e25217ee52 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'Leo ~200 palabras por minuto'
             300_word: 'Leo ~300 palabras por minuto'
             400_word: 'Leo ~400 palabras por minuto'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         # pocket_consumer_key_label: Consumer key for Pocket to import contents
         # android_configuration: Configure your Android application
     form_rss:
index c443b21c5812154030456be64a73b137035bde6a..e7fa4f8667792f1bba2e1aa9240800ccf0429b49 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'من تقریباً ۲۰۰ واژه را در دقیقه می‌خوانم'
             300_word: 'من تقریباً ۳۰۰ واژه را در دقیقه می‌خوانم'
             400_word: 'من تقریباً ۴۰۰ واژه را در دقیقه می‌خوانم'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: کلید کاربری Pocket برای درون‌ریزی مطالب
         # android_configuration: Configure your Android application
     form_rss:
index ea759dd30a962c31b6a23a5b31b4a68261dbbab5..f85a797d19e7c59d9107d8e87548ace936223395 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: "Je lis environ 200 mots par minute"
             300_word: "Je lis environ 300 mots par minute"
             400_word: "Je lis environ 400 mots par minute"
+        action_mark_as_read:
+            label: 'Où souhaitez-vous être redirigé après avoir marqué un article comme lu ?'
+            redirect_homepage: "À la page d'accueil"
+            redirect_current_page: 'À la page courante'
         pocket_consumer_key_label: Clé d’authentification Pocket pour importer les données
         android_configuration: Configurez votre application Android
     form_rss:
index b3bc573bd028f6b5b9f33d3fff09c0a8322940b6..8a8469d2c7d57d668f329c4ce64b5dfb42dee3be 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'Leggo ~200 parole al minuto'
             300_word: 'Leggo ~300 parole al minuto'
             400_word: 'Leggo ~400 parole al minuto'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: Consumer key per Pocket per importare i contenuti
         # android_configuration: Configure your Android application
     form_rss:
index 97b5f4a9ff4c78c2e805776f7436b059307f7221..d37dc724eabd9bc81f3766329b3f349ccbff38a8 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: "Legissi a l'entorn de 200 mots per minuta"
             300_word: "Legissi a l'entorn de 300 mots per minuta"
             400_word: "Legissi a l'entorn de 400 mots per minuta"
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: Clau d'autentificacion Pocket per importar las donadas
         android_configuration: Configuratz vòstra aplicacion Android
     form_rss:
index b4212b830a14d50a1042128a355b000c452d22b0..117a1e127f5ef0c03b4619c84eced43baeb07484 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'Czytam ~200 słów na minutę'
             300_word: 'Czytam ~300 słów na minutę'
             400_word: 'Czytam ~400 słów na minutę'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: 'Klucz klienta Pocket do importu zawartości'
         android_configuration: Skonfiguruj swoją androidową aplikację
     form_rss:
index d8fc9d5c628f10c8c75e4e8ef6cfc07fd60bfde8..5d2607af5073fee8f4f1512dda384754c838c2f4 100644 (file)
@@ -70,6 +70,10 @@ config:
             200_word: 'Posso ler ~200 palavras por minuto'
             300_word: 'Posso ler ~300 palavras por minuto'
             400_word: 'Posso ler ~400 palavras por minuto'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: 'Chave do consumidor do Pocket para importar conteúdo'
         # android_configuration: Configure your Android application
     form_rss:
index d130e431fc66c09f1c19eff40b4d2ccb324da3cc..6b51d9ceb01ad25c8128d2caac309201ad2863f8 100644 (file)
@@ -70,6 +70,10 @@ config:
             # 200_word: 'I read ~200 words per minute'
             # 300_word: 'I read ~300 words per minute'
             # 400_word: 'I read ~400 words per minute'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         pocket_consumer_key_label: Cheie consumator pentru importarea contentului din Pocket
         # android_configuration: Configure your Android application
     form_rss:
index f67d8beec09fb9d88d48d0a578472e473666d2c8..9c392433608bfb10c0ccb5c6252c76ced56f318c 100644 (file)
@@ -70,6 +70,10 @@ config:
             # 200_word: 'I read ~200 words per minute'
             # 300_word: 'I read ~300 words per minute'
             # 400_word: 'I read ~400 words per minute'
+        action_mark_as_read:
+            # label: 'Where do you to be redirected after mark an article as read?'
+            # redirect_homepage: 'To the homepage'
+            # redirect_current_page: 'To the current page'
         # pocket_consumer_key_label: Consumer key for Pocket to import contents
         # android_configuration: Configure your Android application
     form_rss:
index ec3b23c83640eb2dce03620e0f01ce3d87d7fce2..4c01b128db3a29cdafa98221c21af1a7f43b1a78 100644 (file)
             </div>
         </fieldset>
 
+        <fieldset class="w500p inline">
+            <div class="row">
+                {{ form_label(form.config.action_mark_as_read) }}
+                {{ form_errors(form.config.action_mark_as_read) }}
+                {{ form_widget(form.config.action_mark_as_read) }}
+            </div>
+        </fieldset>
+
         <fieldset class="w500p inline">
             <div class="row">
                 {{ form_label(form.config.language) }}
index f69d158f4e56636caf6b03c30ace2e4d9bded2bf..e774795b9f94b696e68b8858aaf1f5d80bb3a18f 100644 (file)
                                 </div>
                             </div>
 
+                        <div class="row">
+                            <div class="input-field col s12">
+                                {{ form_label(form.config.action_mark_as_read) }}
+                                {{ form_errors(form.config.action_mark_as_read) }}
+                                {{ form_widget(form.config.action_mark_as_read) }}
+                            </div>
+                        </div>
+
                             <div class="row">
                                 <div class="input-field col s12">
                                     {{ form_label(form.config.language) }}
index 568576a3312a7480d219740cd34f508655ca2139..a2863014fcc82d8cdf4b9f7cebec6800d49bbdcd 100644 (file)
@@ -51,6 +51,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
             'config[theme]' => 'baggy',
             'config[items_per_page]' => '30',
             'config[reading_speed]' => '0.5',
+            'config[action_mark_as_read]' => '0',
             'config[language]' => 'en',
         ];
 
index 920c21d99e06364d064213ad520abfaa910103de..85f12d87b27277f7f8a543fc0d947798d35c82ce 100644 (file)
@@ -3,7 +3,6 @@
 namespace Tests\Wallabag\CoreBundle\Helper;
 
 use Wallabag\CoreBundle\Helper\DownloadImages;
-use Psr\Log\NullLogger;
 use Monolog\Logger;
 use Monolog\Handler\TestHandler;
 use GuzzleHttp\Client;
index f339f75e80f07fe65f9768a6525602e467799102..825e8d53f2cb651cee70bfb1f2c9c2329a6b102b 100644 (file)
@@ -15,7 +15,10 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
     public function setUp()
     {
         $this->routerMock = $this->getRouterMock();
-        $this->redirect = new Redirect($this->routerMock);
+        $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->redirect = new Redirect($this->routerMock, $tokenStorage);
     }
 
     public function testRedirectToNullWithFallback()