From bca5485946a72942c76dbb65c29e40818dca4976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 8 Mar 2016 16:44:25 +0100 Subject: Added setting to have a personal reading time --- src/Wallabag/CoreBundle/Command/InstallCommand.php | 1 + .../DependencyInjection/Configuration.php | 3 +++ .../DependencyInjection/WallabagCoreExtension.php | 1 + src/Wallabag/CoreBundle/Entity/Config.php | 31 ++++++++++++++++++++++ src/Wallabag/CoreBundle/Form/Type/ConfigType.php | 8 ++++++ .../views/themes/material/Config/index.html.twig | 8 ++++++ .../views/themes/material/Entry/entries.html.twig | 5 ++-- 7 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index e97ba46a..c9dad0df 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -222,6 +222,7 @@ class InstallCommand extends ContainerAwareCommand $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); + $config->setReadingSpeed($this->getContainer()->getParameter('wallabag_core.reading_speed')); $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); $em->persist($config); diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index bc405fdc..5f3c889b 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -29,6 +29,9 @@ class Configuration implements ConfigurationInterface ->integerNode('rss_limit') ->defaultValue(50) ->end() + ->integerNode('reading_speed') + ->defaultValue(200) + ->end() ->scalarNode('version') ->end() ->scalarNode('paypal_url') diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 9b4703e4..84599f0d 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -19,6 +19,7 @@ class WallabagCoreExtension extends Extension $container->setParameter('wallabag_core.theme', $config['theme']); $container->setParameter('wallabag_core.language', $config['language']); $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); + $container->setParameter('wallabag_core.reading_speed', $config['reading_speed']); $container->setParameter('wallabag_core.version', $config['version']); $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index d3590f35..e1a2090e 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -73,6 +73,13 @@ class Config */ private $rssLimit; + /** + * @var float + * + * @ORM\Column(name="reading_speed", type="float", nullable=true) + */ + private $readingSpeed; + /** * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") */ @@ -247,6 +254,30 @@ class Config return $this->rssLimit; } + /** + * Set readingSpeed. + * + * @param int $readingSpeed + * + * @return Config + */ + public function setReadingSpeed($readingSpeed) + { + $this->readingSpeed = $readingSpeed; + + return $this; + } + + /** + * Get readingSpeed. + * + * @return int + */ + public function getReadingSpeed() + { + return $this->readingSpeed; + } + /** * @param TaggingRule $rule * diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php index a139f2df..1218a933 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php @@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\RangeType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -35,6 +36,13 @@ class ConfigType extends AbstractType 'choices_as_values' => true, )) ->add('items_per_page') + ->add('reading_speed', RangeType::class, array( + 'attr' => array( + 'min' => 0.5, + 'max' => 2, + 'step' => 0.5, + ), + )) ->add('language', ChoiceType::class, array( 'choices' => array_flip($this->languages), 'choices_as_values' => true, diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index e388f2c8..31931ca2 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -42,6 +42,14 @@ +
+
+ {{ form_label(form.config.reading_speed) }} + {{ form_errors(form.config.reading_speed) }} + {{ form_widget(form.config.reading_speed) }} +
+
+
{{ form_label(form.config.language) }} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index c3fd4d28..371992df 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig @@ -50,8 +50,9 @@
- {% if entry.readingTime > 0 %} - {% trans with {'%readingTime%': entry.readingTime } %}estimated reading time: %readingTime% min{% endtrans %} + {% set readingTime = entry.readingTime / app.user.config.readingSpeed %} + {% if readingTime > 0 %} + {% trans with {'%readingTime%': readingTime } %}estimated reading time: %readingTime% min{% endtrans %} {% else %} {% trans with {'%inferior%': '<'} %}estimated reading time: %inferior% 1 min{% endtrans %} {% endif %} -- cgit v1.2.3 From 889c1cf328d50c032797a007ede313b1ab1b026b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 8 Mar 2016 16:48:30 +0100 Subject: Fixed fixtures for config --- src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php index 85084960..5a376453 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php @@ -25,6 +25,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $adminConfig->setTheme('material'); $adminConfig->setItemsPerPage(30); + $adminConfig->setReadingSpeed(1); $adminConfig->setLanguage('en'); $manager->persist($adminConfig); @@ -34,6 +35,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $bobConfig = new Config($this->getReference('bob-user')); $bobConfig->setTheme('default'); $bobConfig->setItemsPerPage(10); + $bobConfig->setReadingSpeed(1); $bobConfig->setLanguage('fr'); $manager->persist($bobConfig); @@ -43,6 +45,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $emptyConfig = new Config($this->getReference('empty-user')); $emptyConfig->setTheme('material'); $emptyConfig->setItemsPerPage(10); + $emptyConfig->setReadingSpeed(1); $emptyConfig->setLanguage('en'); $manager->persist($emptyConfig); -- cgit v1.2.3 From db1d4b1e19f58d332bb7d984344cd249eea767b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 10 Mar 2016 13:02:36 +0100 Subject: Fix default value and add baggy implementation --- src/Wallabag/CoreBundle/DependencyInjection/Configuration.php | 2 +- .../Resources/views/themes/baggy/Config/index.html.twig | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 5f3c889b..d1bb9820 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -30,7 +30,7 @@ class Configuration implements ConfigurationInterface ->defaultValue(50) ->end() ->integerNode('reading_speed') - ->defaultValue(200) + ->defaultValue(1) ->end() ->scalarNode('version') ->end() diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 6ac6decb..3ed96ab1 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -24,6 +24,15 @@
+
+
+ {{ form_label(form.config.reading_speed) }} + {{ form_errors(form.config.reading_speed) }} + {{ form_widget(form.config.reading_speed) }} +
+
+ +
{{ form_label(form.config.language) }} -- cgit v1.2.3 From 37b371726be4b8e1fbdd7061196d814c2dd7e811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 10 Mar 2016 13:18:59 +0100 Subject: Translation and documentation --- src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index b809f1ab..f6ac34fd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -38,6 +38,7 @@ RSS: 'RSS' Add a user: 'Créer un compte' Theme: 'Thème' Items per page: "Nombre d'articles par page" +Reading speed: "Vitesse de lecture" Language: 'Langue' Save: 'Enregistrer' RSS token: 'Jeton RSS' -- cgit v1.2.3 From 6432b9277ed5dcf269590e421bd0aac4ad66f09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 14 Mar 2016 13:49:47 +0100 Subject: Replace slider with select --- src/Wallabag/CoreBundle/Controller/DeveloperController.php | 2 +- src/Wallabag/CoreBundle/Form/Type/ConfigType.php | 12 ++++++------ .../CoreBundle/Resources/translations/messages.fr.yml | 6 ++++++ .../Resources/views/themes/material/Config/index.html.twig | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/Controller/DeveloperController.php b/src/Wallabag/CoreBundle/Controller/DeveloperController.php index f519bdbc..e5cfd83c 100644 --- a/src/Wallabag/CoreBundle/Controller/DeveloperController.php +++ b/src/Wallabag/CoreBundle/Controller/DeveloperController.php @@ -43,7 +43,7 @@ class DeveloperController extends Controller $clientForm->handleRequest($request); if ($clientForm->isValid()) { - $client->setAllowedGrantTypes(array('token', 'authorization_code', 'password','refresh_token')); + $client->setAllowedGrantTypes(array('token', 'authorization_code', 'password', 'refresh_token')); $em->persist($client); $em->flush(); diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php index 1218a933..0a5ea6cc 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php @@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\RangeType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -36,11 +35,12 @@ class ConfigType extends AbstractType 'choices_as_values' => true, )) ->add('items_per_page') - ->add('reading_speed', RangeType::class, array( - 'attr' => array( - 'min' => 0.5, - 'max' => 2, - 'step' => 0.5, + ->add('reading_speed', ChoiceType::class, array( + 'choices' => array( + 'I read ~100 words per minute' => '0.5', + 'I read ~200 words per minute' => '1', + 'I read ~300 words per minute' => '1.5', + 'I read ~400 words per minute' => '2', ), )) ->add('language', ChoiceType::class, array( diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index f6ac34fd..7c6ad07e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -57,6 +57,12 @@ Repeat new password: 'Confirmez votre nouveau mot de passe' Username: "Nom d'utilisateur" Two factor authentication: "Double authentification" "Enabling two factor authentication means you'll receive an email with a code on every new untrusted connexion": "Activer l'authentification double-facteur veut dire que vous allez recevoir un code par email à chaque nouvelle connexion non approuvée." +"I read ~100 words per minute": "Je lis environ 100 mots par minute" +"I read ~200 words per minute": "Je lis environ 200 mots par minute" +"I read ~300 words per minute": "Je lis environ 300 mots par minute" +"I read ~400 words per minute": "Je lis environ 400 mots par minute" +"You can use online tools to estimate your reading speed": "Vous pouvez utiliser un outil en ligne pour estimer votre vitesse de lecture" +"like this one": "comme celui-ci" # Tagging rules Tagging rules: "Règles de tag automatiques" diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 31931ca2..2b0b0828 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -47,6 +47,7 @@ {{ form_label(form.config.reading_speed) }} {{ form_errors(form.config.reading_speed) }} {{ form_widget(form.config.reading_speed) }} +

{% trans %}You can use online tools to estimate your reading speed{% endtrans %} ({% trans %}like this one{%endtrans%}).

-- cgit v1.2.3 From 78becd5401e9300fc8e1b54dc93422ddfcc4eb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Mar 2016 12:36:52 +0100 Subject: Fix documentation and add help message in Baggy --- .../CoreBundle/Resources/views/themes/baggy/Config/index.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 3ed96ab1..54faa788 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -29,10 +29,10 @@ {{ form_label(form.config.reading_speed) }} {{ form_errors(form.config.reading_speed) }} {{ form_widget(form.config.reading_speed) }} +

{% trans %}You can use online tools to estimate your reading speed{% endtrans %} ({% trans %}like this one{%endtrans%}).

-
{{ form_label(form.config.language) }} -- cgit v1.2.3 From 1b64a84b782090d8748bef0e9c390f491669e30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Mar 2016 13:12:09 +0100 Subject: Improved tests --- src/Wallabag/CoreBundle/Entity/Config.php | 4 ++-- src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle') diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index e1a2090e..e18b543b 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -257,7 +257,7 @@ class Config /** * Set readingSpeed. * - * @param int $readingSpeed + * @param float $readingSpeed * * @return Config */ @@ -271,7 +271,7 @@ class Config /** * Get readingSpeed. * - * @return int + * @return float */ public function getReadingSpeed() { diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 2af93ffe..51425fe1 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php @@ -46,6 +46,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $data = array( 'config[theme]' => 'baggy', 'config[items_per_page]' => '30', + 'config[reading_speed]' => '0.5', 'config[language]' => 'en', ); -- cgit v1.2.3