]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #4053 from wallabag/feature/manual-input-reading-speed
authorJérémy Benoist <j0k3r@users.noreply.github.com>
Tue, 9 Jul 2019 09:53:20 +0000 (11:53 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Jul 2019 09:53:20 +0000 (11:53 +0200)
Add ability to manually define the reading 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 fab05835b6515dbd9102ff0199a32d7f6975a8b0..2db283ae6705859af02e508750e12b75f5f6ec3e 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 6ba464d04be4abe00da45dc02e64cc74d689d0fc..db01272f4468da9f6cc0cb022508353ad5dbca10 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 a7c32f115f4036a0950d3231db9adef4ab846c33..6d00631085b01c8ae6c2c4494e1d1924f6d2c060 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 093c585748afeb942c72bdce08c5f6f8bbfc6ffd..0eb743964c2edfedc9b74c8aaac6d7a88f1d7b00 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 00caa0ac0c8808ef4642273b615aeb971d025523..35afdbf43f6e4417b36c750ef719e8d777278ee4 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 ca66acde783f1997f837852ca8d2838c6ecda228..8a79b02ff31233f7c0e8ab8b55c9d8d30c24521b 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 85720ef8c454195040b38b8fce0a61a499d23d87..859bbb146d30eb49cefea5c8c47333b484401293 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 18d1173bd5db208c774664d5c53aa64485d4733e..7d92861319d29a0caa2b8700a006748adba7f2fd 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 6528a5623a46fa46e34c4a8563753354ce6490eb..8e7ad7f2566aad7ac205a418e4f1d7121ca9b6b6 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 3f1c7a68929d21f9513aba6a21e292ce4b612759..ee45c0857022f0786e12705b5ea0c7d9e4a144ee 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 d82e9377a7ef7c94eafd2ac4994289b4aca64d67..edfc77a25a60c629d0dcb2b280175a4977eb2c90 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 23d31333569b118bda13346efa2f7c60f9700484..c99da444f9e1915bab6eab1e5a19204a32f8cc47 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 d7f47904adf3e84240bd0497bd22e749f6c5b129..9927d059878bba961c4d24dd600ba14e9bd7bbdc 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 a444cadbd1d4394299425da46414a57a0f7681f9..60fa44d5945a6278a3cd3caa526d538447081526 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 d8b5f38357c39ed4504552ab056122ca44897863..46c90075cd80635f4e0f314c2ff7d4a22b1799f0 100644 (file)
@@ -51,7 +51,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',
         ];
@@ -92,7 +92,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);
 
@@ -106,7 +106,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);
     }