From bca5485946a72942c76dbb65c29e40818dca4976 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 8 Mar 2016 16:44:25 +0100 Subject: [PATCH] Added setting to have a personal reading time --- app/config/config.yml | 1 + data/db/wallabag_test.sqlite-journal | Bin 0 -> 7736 bytes .../CoreBundle/Command/InstallCommand.php | 1 + .../DependencyInjection/Configuration.php | 3 ++ .../WallabagCoreExtension.php | 1 + src/Wallabag/CoreBundle/Entity/Config.php | 31 ++++++++++++++++++ .../CoreBundle/Form/Type/ConfigType.php | 8 +++++ .../themes/material/Config/index.html.twig | 8 +++++ .../themes/material/Entry/entries.html.twig | 5 +-- 9 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 data/db/wallabag_test.sqlite-journal diff --git a/app/config/config.yml b/app/config/config.yml index f0885d9d..5265be8a 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -44,6 +44,7 @@ wallabag_core: theme: material language: en rss_limit: 50 + reading_speed: 1 wallabag_import: allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] diff --git a/data/db/wallabag_test.sqlite-journal b/data/db/wallabag_test.sqlite-journal new file mode 100644 index 0000000000000000000000000000000000000000..153aa1871eda7b25ac07f1d158072b88be1ce8f2 GIT binary patch literal 7736 zcmeI1U2oe|7{~3Ht}E}bL0LD(A#AiE3-e1}oK)53Bu*FQt#OiW;l^@pw>5R_Vml-m znnbzaim$;vUw}`+4L4jMAwB{(lPaE*rEN@;bd`oQb$;TXUHdsc=Q)2LpYvEHh!ZQh z`Y&)6BZv?jUORCFe_dn+=H7zdk;JbAY_L1OeSiL2Ufdl&-d~zuTwW%By5}idrruLb zQ`u5>oFirtYF#xt1N1NQFRk%QF%-XGWaXmkct&S zYNL|ahG8Fxl-!+r@IsP}dfD)Fv~A|A$BtnPO0rmtIDDdhia6nw2Ura5N2X_ri)BCMzu`VXh2Vu?$(L|C}<;v+QiHdL#gPCSot%#-{t^5n*|2qLE=5a@h5S;!WA5!^mAf}`6e zMlj4x$C`(E;1HfSUgNQS4&e3w4)6tlXA26zABhoQ1;9DM+rT`4^MW^lH-H7;GJt2D zMc_l=1Kc1zt`Cet1M)BXVF1rGqu%GX4l1z>eeKdvwNH_rhIY z_jxX1^faEP<23KmJ>KQrogPoSd%d`A@0x0Kpjln6X*=HI=59^eY N6HiRI1o^;U{{kod?Wq6& literal 0 HcmV?d00001 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 %} -- 2.41.0