mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-26 09:30:30 +00:00
Added a configuration to define the redirection after archiving an entry
Fix #496
This commit is contained in:
parent
e042a5d78f
commit
a42f38d9fb
26 changed files with 184 additions and 3 deletions
42
app/DoctrineMigrations/Version20161106113822.php
Normal file
42
app/DoctrineMigrations/Version20161106113822.php
Normal file
|
@ -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');
|
||||
}
|
||||
}
|
|
@ -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
|
||||
~~~~~~~
|
||||
|
||||
|
|
|
@ -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
|
||||
~~~~~~~~
|
||||
|
||||
|
|
|
@ -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
|
||||
~~~~~~
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -36,6 +36,14 @@
|
|||
</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) }}
|
||||
|
|
|
@ -51,6 +51,14 @@
|
|||
</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) }}
|
||||
|
|
|
@ -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',
|
||||
];
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue