diff --git a/app/config/config.yml b/app/config/config.yml index f0885d9d1..5265be8af 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/docs/en/user/configuration.rst b/docs/en/user/configuration.rst index 70d960ff0..f681d8745 100644 --- a/docs/en/user/configuration.rst +++ b/docs/en/user/configuration.rst @@ -21,6 +21,12 @@ Items per page You can change the number of articles displayed on each page. +Reading speed +~~~~~~~~~~~~~ + +wallabag calculates a reading time for each article. You can define here, thanks to this list, if you are +a fast or a slow reader. wallabag will recalculate the reading time for each article. + Language ~~~~~~~~ diff --git a/docs/fr/user/configuration.rst b/docs/fr/user/configuration.rst index ee5be0521..893059989 100644 --- a/docs/fr/user/configuration.rst +++ b/docs/fr/user/configuration.rst @@ -22,6 +22,11 @@ Nombre d'articles par page Vous pouvez définir le nombre d'articles affichés sur chaque page. +Vitesse de lecture +~~~~~~~~~~~~~~~~~~ + +wallabag calcule une durée de lecture pour chaque article. Vous pouvez définir ici, grâce à cette liste déroulante, si vous lisez plus ou moins vite. wallabag recalculera la durée de lecture de chaque article. + Langue ~~~~~~ diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index e97ba46ad..c9dad0df7 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/DataFixtures/ORM/LoadConfigData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php index 850849600..5a3764538 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); diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index bc405fdca..d1bb9820b 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(1) + ->end() ->scalarNode('version') ->end() ->scalarNode('paypal_url') diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 9b4703e43..84599f0d7 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 d3590f35f..e18b543b1 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 float $readingSpeed + * + * @return Config + */ + public function setReadingSpeed($readingSpeed) + { + $this->readingSpeed = $readingSpeed; + + return $this; + } + + /** + * Get readingSpeed. + * + * @return float + */ + 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 a139f2df0..0a5ea6cc8 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php @@ -35,6 +35,14 @@ class ConfigType extends AbstractType 'choices_as_values' => true, )) ->add('items_per_page') + ->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( 'choices' => array_flip($this->languages), 'choices_as_values' => true, diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index b809f1ab8..7c6ad07e8 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' @@ -56,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/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 6ac6decb9..54faa788c 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) }} +

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

+
+
+
{{ form_label(form.config.language) }} 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 e388f2c88..2b0b08289 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,15 @@
+
+
+ {{ 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) }} 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 c3fd4d286..371992df4 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 %} diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 2af93ffec..51425fe1c 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', ); diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php index 28b0dcdbf..841338f44 100644 --- a/var/SymfonyRequirements.php +++ b/var/SymfonyRequirements.php @@ -425,11 +425,13 @@ class SymfonyRequirements extends RequirementCollection 'Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.' ); - $this->addPhpIniRequirement( - 'date.timezone', true, false, - 'date.timezone setting must be set', - 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' - ); + if (version_compare($installedPhpVersion, '7.0.0', '<')) { + $this->addPhpIniRequirement( + 'date.timezone', true, false, + 'date.timezone setting must be set', + 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' + ); + } if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { $timezones = array(); @@ -677,6 +679,14 @@ class SymfonyRequirements extends RequirementCollection 'Upgrade your intl extension with a newer ICU version (4+).' ); + if (class_exists('Symfony\Component\Intl\Intl')) { + $this->addRecommendation( + \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), + sprintf('intl ICU version installed on your system (%s) should match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), + 'In most cases you should be fine, but please verify there is no inconsistencies between data provided by Symfony and the intl extension. See https://github.com/symfony/symfony/issues/15007 for an example of inconsistencies you might run into.' + ); + } + $this->addPhpIniRecommendation( 'intl.error_level', create_function('$cfgValue', 'return (int) $cfgValue === 0;'),