diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-03-18 14:30:38 +0100 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-03-18 14:30:38 +0100 |
commit | f39e94ace35c2a30e2079706bb3d27d8a16c91ec (patch) | |
tree | 2a149d5cd6486e7d07a8a912a14f47c9b94ac934 | |
parent | ec7c67badc46aaf36205f97d3aa326dc72c777b7 (diff) | |
parent | 1b64a84b782090d8748bef0e9c390f491669e30c (diff) | |
download | wallabag-f39e94ace35c2a30e2079706bb3d27d8a16c91ec.tar.gz wallabag-f39e94ace35c2a30e2079706bb3d27d8a16c91ec.tar.zst wallabag-f39e94ace35c2a30e2079706bb3d27d8a16c91ec.zip |
Merge pull request #1767 from wallabag/v2-setting-for-reading-time
Setting for reading time
15 files changed, 103 insertions, 7 deletions
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: | |||
44 | theme: material | 44 | theme: material |
45 | language: en | 45 | language: en |
46 | rss_limit: 50 | 46 | rss_limit: 50 |
47 | reading_speed: 1 | ||
47 | 48 | ||
48 | wallabag_import: | 49 | wallabag_import: |
49 | allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] | 50 | allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] |
diff --git a/docs/en/user/configuration.rst b/docs/en/user/configuration.rst index 70d960ff..f681d874 100644 --- a/docs/en/user/configuration.rst +++ b/docs/en/user/configuration.rst | |||
@@ -21,6 +21,12 @@ Items per page | |||
21 | 21 | ||
22 | You can change the number of articles displayed on each page. | 22 | You can change the number of articles displayed on each page. |
23 | 23 | ||
24 | Reading speed | ||
25 | ~~~~~~~~~~~~~ | ||
26 | |||
27 | wallabag calculates a reading time for each article. You can define here, thanks to this list, if you are | ||
28 | a fast or a slow reader. wallabag will recalculate the reading time for each article. | ||
29 | |||
24 | Language | 30 | Language |
25 | ~~~~~~~~ | 31 | ~~~~~~~~ |
26 | 32 | ||
diff --git a/docs/fr/user/configuration.rst b/docs/fr/user/configuration.rst index ee5be052..89305998 100644 --- a/docs/fr/user/configuration.rst +++ b/docs/fr/user/configuration.rst | |||
@@ -22,6 +22,11 @@ Nombre d'articles par page | |||
22 | 22 | ||
23 | Vous pouvez définir le nombre d'articles affichés sur chaque page. | 23 | Vous pouvez définir le nombre d'articles affichés sur chaque page. |
24 | 24 | ||
25 | Vitesse de lecture | ||
26 | ~~~~~~~~~~~~~~~~~~ | ||
27 | |||
28 | 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. | ||
29 | |||
25 | Langue | 30 | Langue |
26 | ~~~~~~ | 31 | ~~~~~~ |
27 | 32 | ||
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 | |||
222 | $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); | 222 | $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); |
223 | $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); | 223 | $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); |
224 | $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); | 224 | $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); |
225 | $config->setReadingSpeed($this->getContainer()->getParameter('wallabag_core.reading_speed')); | ||
225 | $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); | 226 | $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); |
226 | 227 | ||
227 | $em->persist($config); | 228 | $em->persist($config); |
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php index 85084960..5a376453 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 | |||
25 | 25 | ||
26 | $adminConfig->setTheme('material'); | 26 | $adminConfig->setTheme('material'); |
27 | $adminConfig->setItemsPerPage(30); | 27 | $adminConfig->setItemsPerPage(30); |
28 | $adminConfig->setReadingSpeed(1); | ||
28 | $adminConfig->setLanguage('en'); | 29 | $adminConfig->setLanguage('en'); |
29 | 30 | ||
30 | $manager->persist($adminConfig); | 31 | $manager->persist($adminConfig); |
@@ -34,6 +35,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface | |||
34 | $bobConfig = new Config($this->getReference('bob-user')); | 35 | $bobConfig = new Config($this->getReference('bob-user')); |
35 | $bobConfig->setTheme('default'); | 36 | $bobConfig->setTheme('default'); |
36 | $bobConfig->setItemsPerPage(10); | 37 | $bobConfig->setItemsPerPage(10); |
38 | $bobConfig->setReadingSpeed(1); | ||
37 | $bobConfig->setLanguage('fr'); | 39 | $bobConfig->setLanguage('fr'); |
38 | 40 | ||
39 | $manager->persist($bobConfig); | 41 | $manager->persist($bobConfig); |
@@ -43,6 +45,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface | |||
43 | $emptyConfig = new Config($this->getReference('empty-user')); | 45 | $emptyConfig = new Config($this->getReference('empty-user')); |
44 | $emptyConfig->setTheme('material'); | 46 | $emptyConfig->setTheme('material'); |
45 | $emptyConfig->setItemsPerPage(10); | 47 | $emptyConfig->setItemsPerPage(10); |
48 | $emptyConfig->setReadingSpeed(1); | ||
46 | $emptyConfig->setLanguage('en'); | 49 | $emptyConfig->setLanguage('en'); |
47 | 50 | ||
48 | $manager->persist($emptyConfig); | 51 | $manager->persist($emptyConfig); |
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index bc405fdc..d1bb9820 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php | |||
@@ -29,6 +29,9 @@ class Configuration implements ConfigurationInterface | |||
29 | ->integerNode('rss_limit') | 29 | ->integerNode('rss_limit') |
30 | ->defaultValue(50) | 30 | ->defaultValue(50) |
31 | ->end() | 31 | ->end() |
32 | ->integerNode('reading_speed') | ||
33 | ->defaultValue(1) | ||
34 | ->end() | ||
32 | ->scalarNode('version') | 35 | ->scalarNode('version') |
33 | ->end() | 36 | ->end() |
34 | ->scalarNode('paypal_url') | 37 | ->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 | |||
19 | $container->setParameter('wallabag_core.theme', $config['theme']); | 19 | $container->setParameter('wallabag_core.theme', $config['theme']); |
20 | $container->setParameter('wallabag_core.language', $config['language']); | 20 | $container->setParameter('wallabag_core.language', $config['language']); |
21 | $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); | 21 | $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); |
22 | $container->setParameter('wallabag_core.reading_speed', $config['reading_speed']); | ||
22 | $container->setParameter('wallabag_core.version', $config['version']); | 23 | $container->setParameter('wallabag_core.version', $config['version']); |
23 | $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); | 24 | $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); |
24 | 25 | ||
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index d3590f35..e18b543b 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php | |||
@@ -74,6 +74,13 @@ class Config | |||
74 | private $rssLimit; | 74 | private $rssLimit; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * @var float | ||
78 | * | ||
79 | * @ORM\Column(name="reading_speed", type="float", nullable=true) | ||
80 | */ | ||
81 | private $readingSpeed; | ||
82 | |||
83 | /** | ||
77 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") | 84 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") |
78 | */ | 85 | */ |
79 | private $user; | 86 | private $user; |
@@ -248,6 +255,30 @@ class Config | |||
248 | } | 255 | } |
249 | 256 | ||
250 | /** | 257 | /** |
258 | * Set readingSpeed. | ||
259 | * | ||
260 | * @param float $readingSpeed | ||
261 | * | ||
262 | * @return Config | ||
263 | */ | ||
264 | public function setReadingSpeed($readingSpeed) | ||
265 | { | ||
266 | $this->readingSpeed = $readingSpeed; | ||
267 | |||
268 | return $this; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * Get readingSpeed. | ||
273 | * | ||
274 | * @return float | ||
275 | */ | ||
276 | public function getReadingSpeed() | ||
277 | { | ||
278 | return $this->readingSpeed; | ||
279 | } | ||
280 | |||
281 | /** | ||
251 | * @param TaggingRule $rule | 282 | * @param TaggingRule $rule |
252 | * | 283 | * |
253 | * @return Config | 284 | * @return Config |
diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php index a139f2df..0a5ea6cc 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 | |||
35 | 'choices_as_values' => true, | 35 | 'choices_as_values' => true, |
36 | )) | 36 | )) |
37 | ->add('items_per_page') | 37 | ->add('items_per_page') |
38 | ->add('reading_speed', ChoiceType::class, array( | ||
39 | 'choices' => array( | ||
40 | 'I read ~100 words per minute' => '0.5', | ||
41 | 'I read ~200 words per minute' => '1', | ||
42 | 'I read ~300 words per minute' => '1.5', | ||
43 | 'I read ~400 words per minute' => '2', | ||
44 | ), | ||
45 | )) | ||
38 | ->add('language', ChoiceType::class, array( | 46 | ->add('language', ChoiceType::class, array( |
39 | 'choices' => array_flip($this->languages), | 47 | 'choices' => array_flip($this->languages), |
40 | 'choices_as_values' => true, | 48 | '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 b809f1ab..7c6ad07e 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' | |||
38 | Add a user: 'Créer un compte' | 38 | Add a user: 'Créer un compte' |
39 | Theme: 'Thème' | 39 | Theme: 'Thème' |
40 | Items per page: "Nombre d'articles par page" | 40 | Items per page: "Nombre d'articles par page" |
41 | Reading speed: "Vitesse de lecture" | ||
41 | Language: 'Langue' | 42 | Language: 'Langue' |
42 | Save: 'Enregistrer' | 43 | Save: 'Enregistrer' |
43 | RSS token: 'Jeton RSS' | 44 | RSS token: 'Jeton RSS' |
@@ -56,6 +57,12 @@ Repeat new password: 'Confirmez votre nouveau mot de passe' | |||
56 | Username: "Nom d'utilisateur" | 57 | Username: "Nom d'utilisateur" |
57 | Two factor authentication: "Double authentification" | 58 | Two factor authentication: "Double authentification" |
58 | "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." | 59 | "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." |
60 | "I read ~100 words per minute": "Je lis environ 100 mots par minute" | ||
61 | "I read ~200 words per minute": "Je lis environ 200 mots par minute" | ||
62 | "I read ~300 words per minute": "Je lis environ 300 mots par minute" | ||
63 | "I read ~400 words per minute": "Je lis environ 400 mots par minute" | ||
64 | "You can use online tools to estimate your reading speed": "Vous pouvez utiliser un outil en ligne pour estimer votre vitesse de lecture" | ||
65 | "like this one": "comme celui-ci" | ||
59 | 66 | ||
60 | # Tagging rules | 67 | # Tagging rules |
61 | Tagging rules: "Règles de tag automatiques" | 68 | 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 6ac6decb..54faa788 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 | |||
@@ -26,6 +26,15 @@ | |||
26 | 26 | ||
27 | <fieldset class="w500p inline"> | 27 | <fieldset class="w500p inline"> |
28 | <div class="row"> | 28 | <div class="row"> |
29 | {{ form_label(form.config.reading_speed) }} | ||
30 | {{ form_errors(form.config.reading_speed) }} | ||
31 | {{ form_widget(form.config.reading_speed) }} | ||
32 | <p>{% trans %}You can use online tools to estimate your reading speed{% endtrans %} (<a href="http://www.myreadspeed.com/calculate/">{% trans %}like this one{%endtrans%}</a>).</p> | ||
33 | </div> | ||
34 | </fieldset> | ||
35 | |||
36 | <fieldset class="w500p inline"> | ||
37 | <div class="row"> | ||
29 | {{ form_label(form.config.language) }} | 38 | {{ form_label(form.config.language) }} |
30 | {{ form_errors(form.config.language) }} | 39 | {{ form_errors(form.config.language) }} |
31 | {{ form_widget(form.config.language) }} | 40 | {{ form_widget(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 e388f2c8..2b0b0828 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 | |||
@@ -44,6 +44,15 @@ | |||
44 | 44 | ||
45 | <div class="row"> | 45 | <div class="row"> |
46 | <div class="input-field col s12"> | 46 | <div class="input-field col s12"> |
47 | {{ form_label(form.config.reading_speed) }} | ||
48 | {{ form_errors(form.config.reading_speed) }} | ||
49 | {{ form_widget(form.config.reading_speed) }} | ||
50 | <p>{% trans %}You can use online tools to estimate your reading speed{% endtrans %} (<a href="http://www.myreadspeed.com/calculate/">{% trans %}like this one{%endtrans%}</a>).</p> | ||
51 | </div> | ||
52 | </div> | ||
53 | |||
54 | <div class="row"> | ||
55 | <div class="input-field col s12"> | ||
47 | {{ form_label(form.config.language) }} | 56 | {{ form_label(form.config.language) }} |
48 | {{ form_errors(form.config.language) }} | 57 | {{ form_errors(form.config.language) }} |
49 | {{ form_widget(form.config.language) }} | 58 | {{ form_widget(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 @@ | |||
50 | 50 | ||
51 | <div class="estimatedTime grey-text"> | 51 | <div class="estimatedTime grey-text"> |
52 | <span class="tool reading-time"> | 52 | <span class="tool reading-time"> |
53 | {% if entry.readingTime > 0 %} | 53 | {% set readingTime = entry.readingTime / app.user.config.readingSpeed %} |
54 | {% trans with {'%readingTime%': entry.readingTime } %}estimated reading time: %readingTime% min{% endtrans %} | 54 | {% if readingTime > 0 %} |
55 | {% trans with {'%readingTime%': readingTime } %}estimated reading time: %readingTime% min{% endtrans %} | ||
55 | {% else %} | 56 | {% else %} |
56 | {% trans with {'%inferior%': '<small class="inferieur"><</small>'} %}estimated reading time: %inferior% 1 min{% endtrans %} | 57 | {% trans with {'%inferior%': '<small class="inferieur"><</small>'} %}estimated reading time: %inferior% 1 min{% endtrans %} |
57 | {% endif %} | 58 | {% endif %} |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 2af93ffe..51425fe1 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 | |||
46 | $data = array( | 46 | $data = array( |
47 | 'config[theme]' => 'baggy', | 47 | 'config[theme]' => 'baggy', |
48 | 'config[items_per_page]' => '30', | 48 | 'config[items_per_page]' => '30', |
49 | 'config[reading_speed]' => '0.5', | ||
49 | 'config[language]' => 'en', | 50 | 'config[language]' => 'en', |
50 | ); | 51 | ); |
51 | 52 | ||
diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php index 28b0dcdb..841338f4 100644 --- a/var/SymfonyRequirements.php +++ b/var/SymfonyRequirements.php | |||
@@ -425,11 +425,13 @@ class SymfonyRequirements extends RequirementCollection | |||
425 | 'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.' | 425 | 'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.' |
426 | ); | 426 | ); |
427 | 427 | ||
428 | $this->addPhpIniRequirement( | 428 | if (version_compare($installedPhpVersion, '7.0.0', '<')) { |
429 | 'date.timezone', true, false, | 429 | $this->addPhpIniRequirement( |
430 | 'date.timezone setting must be set', | 430 | 'date.timezone', true, false, |
431 | 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).' | 431 | 'date.timezone setting must be set', |
432 | ); | 432 | 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).' |
433 | ); | ||
434 | } | ||
433 | 435 | ||
434 | if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { | 436 | if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { |
435 | $timezones = array(); | 437 | $timezones = array(); |
@@ -677,6 +679,14 @@ class SymfonyRequirements extends RequirementCollection | |||
677 | 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).' | 679 | 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).' |
678 | ); | 680 | ); |
679 | 681 | ||
682 | if (class_exists('Symfony\Component\Intl\Intl')) { | ||
683 | $this->addRecommendation( | ||
684 | \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), | ||
685 | 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()), | ||
686 | '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.' | ||
687 | ); | ||
688 | } | ||
689 | |||
680 | $this->addPhpIniRecommendation( | 690 | $this->addPhpIniRecommendation( |
681 | 'intl.error_level', | 691 | 'intl.error_level', |
682 | create_function('$cfgValue', 'return (int) $cfgValue === 0;'), | 692 | create_function('$cfgValue', 'return (int) $cfgValue === 0;'), |