]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add ability to manually define the reading speed 4053/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 8 Jul 2019 12:45:45 +0000 (14:45 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 8 Jul 2019 18:18:59 +0000 (20:18 +0200)
Instead of using a select, let the user decide its own speed.

22 files changed:
app/DoctrineMigrations/Version20190708122957.php [new file with mode: 0644]
src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php
src/Wallabag/CoreBundle/Form/Type/ConfigType.php
src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
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.ru.yml
src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_reading_time.html.twig
tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php

diff --git a/app/DoctrineMigrations/Version20190708122957.php b/app/DoctrineMigrations/Version20190708122957.php
new file mode 100644 (file)
index 0000000..9585e99
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Wallabag\CoreBundle\Doctrine\WallabagMigration;
+
+/**
+ * Change reading speed value.
+ */
+final class Version20190708122957 extends WallabagMigration
+{
+    public function up(Schema $schema): void
+    {
+        $this->addSql('UPDATE ' . $this->getTable('config', true) . ' SET reading_speed = reading_speed*200');
+    }
+
+    public function down(Schema $schema): void
+    {
+        $this->addSql('UPDATE ' . $this->getTable('config', true) . ' SET reading_speed = reading_speed/200');
+    }
+}
index c54e9f2c3fa1b9391fd97079728df4eda639c437..5e914965dc4ea8ac9128f69016f62ed8795fb679 100644 (file)
@@ -19,7 +19,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface
 
         $adminConfig->setTheme('material');
         $adminConfig->setItemsPerPage(30);
-        $adminConfig->setReadingSpeed(1);
+        $adminConfig->setReadingSpeed(200);
         $adminConfig->setLanguage('en');
         $adminConfig->setPocketConsumerKey('xxxxx');
         $adminConfig->setActionMarkAsRead(0);
@@ -32,7 +32,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface
         $bobConfig = new Config($this->getReference('bob-user'));
         $bobConfig->setTheme('default');
         $bobConfig->setItemsPerPage(10);
-        $bobConfig->setReadingSpeed(1);
+        $bobConfig->setReadingSpeed(200);
         $bobConfig->setLanguage('fr');
         $bobConfig->setPocketConsumerKey(null);
         $bobConfig->setActionMarkAsRead(1);
@@ -45,7 +45,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface
         $emptyConfig = new Config($this->getReference('empty-user'));
         $emptyConfig->setTheme('material');
         $emptyConfig->setItemsPerPage(10);
-        $emptyConfig->setReadingSpeed(1);
+        $emptyConfig->setReadingSpeed(200);
         $emptyConfig->setLanguage('en');
         $emptyConfig->setPocketConsumerKey(null);
         $emptyConfig->setActionMarkAsRead(0);
index 1714ce74aa549e2cdddcb9f231dc946148e0a75f..6901fa08e2f2755d3b0466c581c066bb80694795 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\IntegerType;
 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -37,19 +38,13 @@ class ConfigType extends AbstractType
                 'choices' => array_flip($this->themes),
                 'label' => 'config.form_settings.theme_label',
             ])
-            ->add('items_per_page', null, [
+            ->add('items_per_page', IntegerType::class, [
                 'label' => 'config.form_settings.items_per_page_label',
                 'property_path' => 'itemsPerPage',
             ])
-            ->add('reading_speed', ChoiceType::class, [
+            ->add('reading_speed', IntegerType::class, [
                 'label' => 'config.form_settings.reading_speed.label',
                 'property_path' => 'readingSpeed',
-                'choices' => [
-                    'config.form_settings.reading_speed.100_word' => '0.5',
-                    'config.form_settings.reading_speed.200_word' => '1',
-                    'config.form_settings.reading_speed.300_word' => '1.5',
-                    'config.form_settings.reading_speed.400_word' => '2',
-                ],
             ])
             ->add('action_mark_as_read', ChoiceType::class, [
                 'label' => 'config.form_settings.action_mark_as_read.label',
index 37d0640a63e6a36b94ec9e5034db9235e69fe6d0..8a575b68058fbdb799f7321b65d659987e417232 100644 (file)
@@ -54,8 +54,8 @@ class EntryFilterType extends AbstractType
                     $lower = $values['value']['left_number'][0];
                     $upper = $values['value']['right_number'][0];
 
-                    $min = (int) ($lower * $this->user->getConfig()->getReadingSpeed());
-                    $max = (int) ($upper * $this->user->getConfig()->getReadingSpeed());
+                    $min = (int) ($lower * $this->user->getConfig()->getReadingSpeed() / 200);
+                    $max = (int) ($upper * $this->user->getConfig()->getReadingSpeed() / 200);
 
                     if (null === $lower && null === $upper) {
                         // no value? no filter
index 5c4ca29cefc80e112b55d66dfd23b04bf774d6eb..065d281c761477798f166812cf037b1593b42d26 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Poster pr. side'
         language_label: 'Sprog'
         reading_speed:
-            # label: 'Reading speed'
+            # label: 'Reading speed (words per minute)'
             # help_message: 'You can use online tools to estimate your reading speed:'
-            # 100_word: 'I read ~100 words per minute'
-            # 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 to after marking an article as read?'
             # redirect_homepage: 'To the homepage'
index a21bd0f10e4525b81ae3c49a5f655a9e9ac78665..ef9099785f13b1a53ff38f059896099e33aaa54d 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Einträge pro Seite'
         language_label: 'Sprache'
         reading_speed:
-            label: 'Lesegeschwindigkeit'
+            label: 'Lesegeschwindigkeit (Wörter pro Minute)'
             help_message: 'Du kannst Online-Tools nutzen, um deine Lesegeschwindigkeit herauszufinden.'
-            100_word: 'Ich lese ~100 Wörter pro Minute'
-            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: 'Wohin soll nach dem Gelesenmarkieren eines Artikels weitergeleitet werden?'
             redirect_homepage: 'Zur Homepage'
index 2f310246b97b70586b841e495ef765bd290af43d..dc12015f390a810dc85884ad27c30e20206ce3fc 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Items per page'
         language_label: 'Language'
         reading_speed:
-            label: 'Reading speed'
+            label: 'Reading speed (words per minute)'
             help_message: 'You can use online tools to estimate your reading speed:'
-            100_word: 'I read ~100 words per minute'
-            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: 'What to do after removing, starring or marking as read an article?'
             redirect_homepage: 'Go to the homepage'
index c194041a5aaccde6828370d56c4fe89e266ffbdf..6eb5498dcb264cef11bb59024b44cdb7da251ed7 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Número de artículos por página'
         language_label: 'Idioma'
         reading_speed:
-            label: 'Velocidad de lectura'
+            label: 'Velocidad de lectura (palabras por minuto)'
             help_message: 'Puede utilizar herramientas en línea para calcular su velocidad de lectura:'
-            100_word: 'Leo ~100 palabras por minuto'
-            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: '¿Dónde quieres ser redirigido después de marcar un artículo como leído?'
             redirect_homepage: 'A la página de inicio'
index 9aef7ddec2b53b5652b2350c945281ff1f3faeb7..659331c67f31090ffbaa9dde7a0ef0fcb56e723a 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'تعداد مقاله در هر صفحه'
         language_label: 'زبان'
         reading_speed:
-            label: 'سرعت خواندن'
+            # label: 'Reading speed (words per minute)'
             help_message: 'سرعت خواندن‌تان را با ابزارهای آنلاین تخمین بزنید:'
-            100_word: 'من تقریباً ۱۰۰ واژه را در دقیقه می‌خوانم'
-            200_word: 'من تقریباً ۲۰۰ واژه را در دقیقه می‌خوانم'
-            300_word: 'من تقریباً ۳۰۰ واژه را در دقیقه می‌خوانم'
-            400_word: 'من تقریباً ۴۰۰ واژه را در دقیقه می‌خوانم'
         action_mark_as_read:
             # label: 'Where do you want to be redirected to after marking an article as read?'
             # redirect_homepage: 'To the homepage'
index 9848ed9ae6744e4339ac827712d43e572dbcef55..f19d8c4cc91eb0012fa6459347c815bb41b5bd17 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: "Nombre d’articles par page"
         language_label: "Langue"
         reading_speed:
-            label: "Vitesse de lecture"
+            label: "Vitesse de lecture (mots par minute)"
             help_message: "Vous pouvez utiliser un outil en ligne pour estimer votre vitesse de lecture :"
-            100_word: "Je lis environ 100 mots par minute"
-            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: "Que faire lorsqu'un article est supprimé, marqué comme lu ou marqué comme favoris ?"
             redirect_homepage: "Retourner à la page d’accueil"
index efbf062b1c469653b32597fc67326e2eb3797757..700a37d2a26baa5db0c3bd6443ba2a058a40bd13 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Elementi per pagina'
         language_label: 'Lingua'
         reading_speed:
-            label: 'Velocità di lettura'
+            label: 'Velocità di lettura (parole al minuto)'
             help_message: 'Puoi utilizzare degli strumenti online per valutare la tua velocità di lettura:'
-            100_word: 'Leggo ~100 parole al minuto'
-            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: "Dove vuoi essere reindirizzato dopo aver segnato l'articolo come già letto?"
             redirect_homepage: 'Alla homepage'
index 86ce464496604285373a287678fef2159b698e91..023aa2e50a07b07b8dd7f4324d26f18bc95e9491 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: "Nombre d'articles per pagina"
         language_label: 'Lenga'
         reading_speed:
-            label: 'Velocitat  de lectura'
+            label: 'Velocitat  de lectura (mots per minuta)'
             help_message: 'Podètz utilizar una aisina en linha per estimar vòstra velocitat de lectura :'
-            100_word: "Legissi a l'entorn de 100 mots per minuta"
-            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: 'Ont volètz èsser menat aprèp aver marcat un article coma legit ?'
             redirect_homepage: "A la pagina d’acuèlh"
index 9ebe02360dc535c9657fa6ccfa44b7bd35c5ec22..876db24a2a9e55e25792f30724d96090da420b6f 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Ilość elementów na stronie'
         language_label: 'Język'
         reading_speed:
-            label: 'Prędkość czytania'
+            label: 'Prędkość czytania (słów na minutę)'
             help_message: 'Możesz skorzystać z narzędzi online do określenia twojej prędkości czytania:'
-            100_word: 'Czytam ~100 słów na minutę'
-            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: 'Gdzie zostaniesz przekierowany po oznaczeniu artukuły jako przeczytanego'
             redirect_homepage: 'do strony głównej'
index d310e016f06bed218392b08f96010663818d2c8e..786288c1d5522e3e3f69cfc52084696e1e3bd826 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Itens por página'
         language_label: 'Idioma'
         reading_speed:
-            label: 'Velocidade de leitura'
+            label: 'Velocidade de leitura (palavras por minuto)'
             help_message: 'Você pode usar ferramentas online para estimar sua velocidade de leitura:'
-            100_word: 'Posso ler ~100 palavras por minuto'
-            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 want to be redirected to after marking an article as read?'
             # redirect_homepage: 'To the homepage'
index c11ff0b8ab7adc2b5f92abd2460bb7d2b389c272..0d8904fe8a15d9efb9a94632113b249d9c4065e0 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Articole pe pagină'
         language_label: 'Limbă'
         reading_speed:
-            # label: 'Reading speed'
+            # label: 'Reading speed (words per minute)'
             # help_message: 'You can use online tools to estimate your reading speed:'
-            # 100_word: 'I read ~100 words per minute'
-            # 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 to after marking an article as read?'
             # redirect_homepage: 'To the homepage'
index 9fe7536958807765ef2e95f5ec9f8df76c2ebc1e..04daf8551daa1763b1200790007a4303149942e1 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Записей на странице'
         language_label: 'Язык'
         reading_speed:
-            label: 'Скорость чтения'
+            label: 'Скорость чтения (слов в минуту)'
             help_message: 'Вы можете использовать онлайн-инструменты для оценки скорости чтения:'
-            100_word: 'Я читаю ~100 слов в минуту'
-            200_word: 'Я читаю ~200 слов в минуту'
-            300_word: 'Я читаю ~300 слов в минуту'
-            400_word: 'Я читаю ~400 слов в минуту'
         action_mark_as_read:
             label: 'Куда Вы хотите быть перенаправлены, после пометки записи, как прочитанная?'
             redirect_homepage: 'На домашнюю страницу'
index 672dcbf0106f74e133ea17cc966b9e8d5cb56618..66642029ae5e95a4ac44545849aea6afd7c94581 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'ไอเทมต่อหน้า'
         language_label: 'ภาษา'
         reading_speed:
-            label: 'การอ่านแบบด่วน'
+            label: 'การอ่านแบบด่วน (คำต่อนาที)'
             help_message: 'คุณสามารถใช้เครื่องมือออนไลน์เพื่อประเมินการอ่านแบบด่วน:'
-            100_word: 'ฉันอ่าน ~100 คำต่อนาที'
-            200_word: 'ฉันอ่าน ~200 คำต่อนาท'
-            300_word: 'ฉันอ่าน ~300 คำต่อนาท'
-            400_word: 'ฉันอ่าน ~400 คำต่อนาท'
         action_mark_as_read:
             label: 'คุณต้องการเปลี่ยนทิศทางหลังจากระบุเครื่องหมายรายการอ่านที่ไหน?'
             redirect_homepage: 'ไปยังโฮมเพจ'
index c2ad854d252ea010071362d3e473948439eae2c0..6ee723f1c981955fddf60ebf287092491d7a49b0 100644 (file)
@@ -68,12 +68,8 @@ config:
         items_per_page_label: 'Sayfa başına makale sayısı'
         language_label: 'Dil'
         reading_speed:
-            # label: 'Reading speed'
+            # label: 'Reading speed (words per minute)'
             # help_message: 'You can use online tools to estimate your reading speed:'
-            # 100_word: 'I read ~100 words per minute'
-            # 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 to after marking an article as read?'
             # redirect_homepage: 'To the homepage'
index 6c5d260160ced8a769089640d5fb625bb411837c..d8b39160016dd8311cbcd95923c2a7b0ade83d60 100644 (file)
@@ -46,7 +46,7 @@
         <div id="entry-{{ entry.id|e }}" class="{% if listMode == 0 %}entry{% else %}listmode entry{% endif %}">
             <h2><a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title|e|raw }}">{{ entry.title | striptags | truncate(80, true, '…') | default('entry.default_title'|trans) | raw }}</a></h2>
 
-            {% set readingTime = entry.readingTime / app.user.config.readingSpeed %}
+            {% set readingTime = entry.readingTime / app.user.config.readingSpeed * 200 %}
             <div class="estimatedTime">
                     <span class="tool reading-time">
             {% if readingTime > 0 %}
index e87ba201a957ebcfd0feccf8d7890c88002e704e..7616cf4ceedea2a72cb7719262260febc506cfa8 100644 (file)
@@ -62,7 +62,7 @@
             {% endif %}
 
             <i class="tool icon icon-time">
-                {% set readingTime = entry.readingTime / app.user.config.readingSpeed %}
+                {% set readingTime = entry.readingTime / app.user.config.readingSpeed * 200 %}
                 {% if readingTime > 0 %}
                     {{ 'entry.list.reading_time_minutes_short'|trans({'%readingTime%': readingTime|round}) }}
                 {% else %}
index 6ba187684f864f53968d6b5439636658a98a798b..b7167e958a7525dd1d9d3e21af2b275a00971bb6 100644 (file)
@@ -1,4 +1,4 @@
-{% set readingTime = entry.readingTime / app.user.config.readingSpeed %}
+{% set readingTime = entry.readingTime / app.user.config.readingSpeed * 200 %}
 <i class="material-icons">timer</i>
 {% if readingTime > 0 %}
     <span>{{ 'entry.list.reading_time_minutes_short'|trans({'%readingTime%': readingTime|round}) }}</span>
index b9e0bed25118c27faaddcd223617fe572f4132f4..2c428fa0fdf6925598c7234b0322fde83633fb08 100644 (file)
@@ -50,7 +50,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
         $data = [
             'config[theme]' => 'baggy',
             'config[items_per_page]' => '30',
-            'config[reading_speed]' => '0.5',
+            'config[reading_speed]' => '100',
             'config[action_mark_as_read]' => '0',
             'config[language]' => 'en',
         ];
@@ -91,7 +91,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
         $crawler = $client->request('GET', '/config');
         $form = $crawler->filter('button[id=config_save]')->form();
         $data = [
-            'config[reading_speed]' => '2',
+            'config[reading_speed]' => '400',
         ];
         $client->submit($form, $data);
 
@@ -105,7 +105,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
         $crawler = $client->request('GET', '/config');
         $form = $crawler->filter('button[id=config_save]')->form();
         $data = [
-            'config[reading_speed]' => '0.5',
+            'config[reading_speed]' => '100',
         ];
         $client->submit($form, $data);
     }