Merge pull request #1767 from wallabag/v2-setting-for-reading-time

Setting for reading time
This commit is contained in:
Jeremy Benoist 2016-03-18 14:30:38 +01:00
commit f39e94ace3
15 changed files with 103 additions and 7 deletions

View file

@ -44,6 +44,7 @@ wallabag_core:
theme: material theme: material
language: en language: en
rss_limit: 50 rss_limit: 50
reading_speed: 1
wallabag_import: wallabag_import:
allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']

View file

@ -21,6 +21,12 @@ Items per page
You can change the number of articles displayed on each 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 Language
~~~~~~~~ ~~~~~~~~

View file

@ -22,6 +22,11 @@ Nombre d'articles par page
Vous pouvez définir le nombre d'articles affichés sur chaque 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 Langue
~~~~~~ ~~~~~~

View file

@ -222,6 +222,7 @@ class InstallCommand extends ContainerAwareCommand
$config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme'));
$config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page'));
$config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); $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')); $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language'));
$em->persist($config); $em->persist($config);

View file

@ -25,6 +25,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
$adminConfig->setTheme('material'); $adminConfig->setTheme('material');
$adminConfig->setItemsPerPage(30); $adminConfig->setItemsPerPage(30);
$adminConfig->setReadingSpeed(1);
$adminConfig->setLanguage('en'); $adminConfig->setLanguage('en');
$manager->persist($adminConfig); $manager->persist($adminConfig);
@ -34,6 +35,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
$bobConfig = new Config($this->getReference('bob-user')); $bobConfig = new Config($this->getReference('bob-user'));
$bobConfig->setTheme('default'); $bobConfig->setTheme('default');
$bobConfig->setItemsPerPage(10); $bobConfig->setItemsPerPage(10);
$bobConfig->setReadingSpeed(1);
$bobConfig->setLanguage('fr'); $bobConfig->setLanguage('fr');
$manager->persist($bobConfig); $manager->persist($bobConfig);
@ -43,6 +45,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
$emptyConfig = new Config($this->getReference('empty-user')); $emptyConfig = new Config($this->getReference('empty-user'));
$emptyConfig->setTheme('material'); $emptyConfig->setTheme('material');
$emptyConfig->setItemsPerPage(10); $emptyConfig->setItemsPerPage(10);
$emptyConfig->setReadingSpeed(1);
$emptyConfig->setLanguage('en'); $emptyConfig->setLanguage('en');
$manager->persist($emptyConfig); $manager->persist($emptyConfig);

View file

@ -29,6 +29,9 @@ class Configuration implements ConfigurationInterface
->integerNode('rss_limit') ->integerNode('rss_limit')
->defaultValue(50) ->defaultValue(50)
->end() ->end()
->integerNode('reading_speed')
->defaultValue(1)
->end()
->scalarNode('version') ->scalarNode('version')
->end() ->end()
->scalarNode('paypal_url') ->scalarNode('paypal_url')

View file

@ -19,6 +19,7 @@ class WallabagCoreExtension extends Extension
$container->setParameter('wallabag_core.theme', $config['theme']); $container->setParameter('wallabag_core.theme', $config['theme']);
$container->setParameter('wallabag_core.language', $config['language']); $container->setParameter('wallabag_core.language', $config['language']);
$container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); $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.version', $config['version']);
$container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']);

View file

@ -73,6 +73,13 @@ class Config
*/ */
private $rssLimit; private $rssLimit;
/**
* @var float
*
* @ORM\Column(name="reading_speed", type="float", nullable=true)
*/
private $readingSpeed;
/** /**
* @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config")
*/ */
@ -247,6 +254,30 @@ class Config
return $this->rssLimit; 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 * @param TaggingRule $rule
* *

View file

@ -35,6 +35,14 @@ class ConfigType extends AbstractType
'choices_as_values' => true, 'choices_as_values' => true,
)) ))
->add('items_per_page') ->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( ->add('language', ChoiceType::class, array(
'choices' => array_flip($this->languages), 'choices' => array_flip($this->languages),
'choices_as_values' => true, 'choices_as_values' => true,

View file

@ -38,6 +38,7 @@ RSS: 'RSS'
Add a user: 'Créer un compte' Add a user: 'Créer un compte'
Theme: 'Thème' Theme: 'Thème'
Items per page: "Nombre d'articles par page" Items per page: "Nombre d'articles par page"
Reading speed: "Vitesse de lecture"
Language: 'Langue' Language: 'Langue'
Save: 'Enregistrer' Save: 'Enregistrer'
RSS token: 'Jeton RSS' RSS token: 'Jeton RSS'
@ -56,6 +57,12 @@ Repeat new password: 'Confirmez votre nouveau mot de passe'
Username: "Nom d'utilisateur" Username: "Nom d'utilisateur"
Two factor authentication: "Double authentification" 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." "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
Tagging rules: "Règles de tag automatiques" Tagging rules: "Règles de tag automatiques"

View file

@ -24,6 +24,15 @@
</div> </div>
</fieldset> </fieldset>
<fieldset class="w500p inline">
<div class="row">
{{ form_label(form.config.reading_speed) }}
{{ form_errors(form.config.reading_speed) }}
{{ form_widget(form.config.reading_speed) }}
<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>
</div>
</fieldset>
<fieldset class="w500p inline"> <fieldset class="w500p inline">
<div class="row"> <div class="row">
{{ form_label(form.config.language) }} {{ form_label(form.config.language) }}

View file

@ -42,6 +42,15 @@
</div> </div>
</div> </div>
<div class="row">
<div class="input-field col s12">
{{ form_label(form.config.reading_speed) }}
{{ form_errors(form.config.reading_speed) }}
{{ form_widget(form.config.reading_speed) }}
<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>
</div>
</div>
<div class="row"> <div class="row">
<div class="input-field col s12"> <div class="input-field col s12">
{{ form_label(form.config.language) }} {{ form_label(form.config.language) }}

View file

@ -50,8 +50,9 @@
<div class="estimatedTime grey-text"> <div class="estimatedTime grey-text">
<span class="tool reading-time"> <span class="tool reading-time">
{% if entry.readingTime > 0 %} {% set readingTime = entry.readingTime / app.user.config.readingSpeed %}
{% trans with {'%readingTime%': entry.readingTime } %}estimated reading time: %readingTime% min{% endtrans %} {% if readingTime > 0 %}
{% trans with {'%readingTime%': readingTime } %}estimated reading time: %readingTime% min{% endtrans %}
{% else %} {% else %}
{% trans with {'%inferior%': '<small class="inferieur">&lt;</small>'} %}estimated reading time: %inferior% 1 min{% endtrans %} {% trans with {'%inferior%': '<small class="inferieur">&lt;</small>'} %}estimated reading time: %inferior% 1 min{% endtrans %}
{% endif %} {% endif %}

View file

@ -46,6 +46,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$data = array( $data = array(
'config[theme]' => 'baggy', 'config[theme]' => 'baggy',
'config[items_per_page]' => '30', 'config[items_per_page]' => '30',
'config[reading_speed]' => '0.5',
'config[language]' => 'en', 'config[language]' => 'en',
); );

View file

@ -425,11 +425,13 @@ class SymfonyRequirements extends RequirementCollection
'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.' 'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.'
); );
$this->addPhpIniRequirement( if (version_compare($installedPhpVersion, '7.0.0', '<')) {
'date.timezone', true, false, $this->addPhpIniRequirement(
'date.timezone setting must be set', 'date.timezone', true, false,
'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).' 'date.timezone setting must be set',
); 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).'
);
}
if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
$timezones = array(); $timezones = array();
@ -677,6 +679,14 @@ class SymfonyRequirements extends RequirementCollection
'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).' 'Upgrade your <strong>intl</strong> 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( $this->addPhpIniRecommendation(
'intl.error_level', 'intl.error_level',
create_function('$cfgValue', 'return (int) $cfgValue === 0;'), create_function('$cfgValue', 'return (int) $cfgValue === 0;'),