mirror of
https://github.com/moparisthebest/wallabag
synced 2025-01-08 04:08:10 -05:00
[add] reading time for each entry
This commit is contained in:
parent
f48427d34b
commit
0a7ecfd3c0
12
app/app.php
12
app/app.php
@ -27,6 +27,18 @@ $app['twig'] = $app->share($app->extend('twig', function($twig) {
|
|||||||
return $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(), [
|
$app->register(new ConsoleServiceProvider(), [
|
||||||
'console.name' => 'Poche console',
|
'console.name' => 'Poche console',
|
||||||
'console.version' => '0.1',
|
'console.version' => '0.1',
|
||||||
|
@ -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>{% 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="{{ 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><a href="{{ entry.url }}" class="external" title="{{ 'view original'|trans }}">{{ entry.url | getDomain }}</a></li>
|
||||||
|
<li>{{ entry.content | getReadingTime }} {{'min read'|trans}} </li>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
Loading…
Reference in New Issue
Block a user