1
0
mirror of https://github.com/moparisthebest/wallabag synced 2025-01-06 19:28:00 -05:00

[add] reading time for each entry

This commit is contained in:
Nicolas Lœuillet 2014-01-15 13:54:49 +01:00
parent f48427d34b
commit 0a7ecfd3c0
2 changed files with 13 additions and 0 deletions

View File

@ -27,6 +27,18 @@ $app['twig'] = $app->share($app->extend('twig', function($twig) {
return $twig;
}));
$app['twig'] = $app->share($app->extend('twig', function($twig) {
$twig->addFilter(new Twig_SimpleFilter('getReadingTime', function ($text) {
$word = str_word_count(strip_tags($text));
$minutes = floor($word / 200);
$seconds = floor($word % 200 / (200 / 60));
$time = array('minutes' => $minutes, 'seconds' => $seconds);
return $minutes;
}));
return $twig;
}));
$app->register(new ConsoleServiceProvider(), [
'console.name' => 'Poche console',
'console.version' => '0.1',

View File

@ -6,5 +6,6 @@
<li>{% if entry.bookmark == 1 %}<a href="{{ path('unstar_entry', {'id': entry.id}) }}">{{ 'unstar'|trans }}</a>{% else %}<a href="{{ path('star_entry', {'id': entry.id}) }}">{{ 'star'|trans }}</a>{% endif %}</li>
<li><a href="{{ path('remove_entry', {'id': entry.id}) }}">{{ 'delete'|trans }}</a></li>
<li><a href="{{ entry.url }}" class="external" title="{{ 'view original'|trans }}">{{ entry.url | getDomain }}</a></li>
<li>{{ entry.content | getReadingTime }} {{'min read'|trans}} </li>
</ul>
</article>