]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added setting to have a personal reading time
authorNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 8 Mar 2016 15:44:25 +0000 (16:44 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 14 Mar 2016 12:01:31 +0000 (13:01 +0100)
app/config/config.yml
data/db/wallabag_test.sqlite-journal [new file with mode: 0644]
src/Wallabag/CoreBundle/Command/InstallCommand.php
src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
src/Wallabag/CoreBundle/Entity/Config.php
src/Wallabag/CoreBundle/Form/Type/ConfigType.php
src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig

index f0885d9d1d9c19c8bd28c7430e4bc96fcf470648..5265be8afa7ec18cf37b7cc03ea14f5073ae9dbe 100644 (file)
@@ -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 (file)
index 0000000..153aa18
Binary files /dev/null and b/data/db/wallabag_test.sqlite-journal differ
index e97ba46adfa597febeb1f1c66b05660f71e1523d..c9dad0df71eff039030eb6aea08ac663ec1325f6 100644 (file)
@@ -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);
index bc405fdca095bd8cd430d46238f68774e723a4a9..5f3c889bdf57586a10ab271b9d59cc41cb89a8bd 100644 (file)
@@ -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')
index 9b4703e4370f7bcda0e5241453250d804dbfd5f7..84599f0d7b3d5eb7956e15a5a3c62f9f481171f2 100644 (file)
@@ -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']);
 
index d3590f35f0945495ef6f07697ebb83a96afe44e1..e1a2090e54e68cfc0e235b59fbc9cb41f9abe734 100644 (file)
@@ -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
      *
index a139f2df0f076bd4ec5af45aa90f5d610f1260b6..1218a933106eef666df37bf018c05bf04df332ab 100644 (file)
@@ -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,
index e388f2c88f8261dc5156becbadef02fcdd807829..31931ca2e728efc7cd1413f6b7cdf7a8f97fca52 100644 (file)
                                 </div>
                             </div>
 
+                            <div class="row">
+                                <div class="input-field col s12">
+                                    {{ form_label(form.config.reading_speed) }}
+                                    {{ form_errors(form.config.reading_speed) }}
+                                    {{ form_widget(form.config.reading_speed) }}
+                                </div>
+                            </div>
+
                             <div class="row">
                                 <div class="input-field col s12">
                                     {{ form_label(form.config.language) }}
index c3fd4d286d46510469a90aac198e7ceed2734953..371992df41aad59aea17aebf337e06f475c52559 100644 (file)
@@ -50,8 +50,9 @@
 
                             <div class="estimatedTime grey-text">
                                 <span class="tool reading-time">
-                                    {% 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%': '<small class="inferieur">&lt;</small>'} %}estimated reading time: %inferior% 1 min{% endtrans %}
                                     {% endif %}