aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-03-18 14:30:38 +0100
committerJeremy Benoist <j0k3r@users.noreply.github.com>2016-03-18 14:30:38 +0100
commitf39e94ace35c2a30e2079706bb3d27d8a16c91ec (patch)
tree2a149d5cd6486e7d07a8a912a14f47c9b94ac934 /src
parentec7c67badc46aaf36205f97d3aa326dc72c777b7 (diff)
parent1b64a84b782090d8748bef0e9c390f491669e30c (diff)
downloadwallabag-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
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php1
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php3
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/Configuration.php3
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php1
-rw-r--r--src/Wallabag/CoreBundle/Entity/Config.php31
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ConfigType.php8
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml7
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig9
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig9
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig5
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php1
11 files changed, 76 insertions, 2 deletions
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'
38Add a user: 'Créer un compte' 38Add a user: 'Créer un compte'
39Theme: 'Thème' 39Theme: 'Thème'
40Items per page: "Nombre d'articles par page" 40Items per page: "Nombre d'articles par page"
41Reading speed: "Vitesse de lecture"
41Language: 'Langue' 42Language: 'Langue'
42Save: 'Enregistrer' 43Save: 'Enregistrer'
43RSS token: 'Jeton RSS' 44RSS token: 'Jeton RSS'
@@ -56,6 +57,12 @@ Repeat new password: 'Confirmez votre nouveau mot de passe'
56Username: "Nom d'utilisateur" 57Username: "Nom d'utilisateur"
57Two factor authentication: "Double authentification" 58Two 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
61Tagging rules: "Règles de tag automatiques" 68Tagging 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">&lt;</small>'} %}estimated reading time: %inferior% 1 min{% endtrans %} 57 {% trans with {'%inferior%': '<small class="inferieur">&lt;</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