Reading time improves

This commit is contained in:
Diego Najar 2018-02-15 20:08:00 +01:00
parent 8807414d1b
commit ea7f24b53a
5 changed files with 14 additions and 6 deletions

View File

@ -65,8 +65,7 @@ function table($status, $icon='arrow-circle-o-down') {
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '</tr>';
foreach ($page->children() as $childKey) {
$child = buildPage($childKey);
foreach ($page->children() as $child) {
if ($child->published()) {
echo '<tr>
<td class="child-title">

View File

@ -487,13 +487,19 @@ class Page {
// Returns the amount of minutes takes to read the page
public function readingTime() {
global $Language;
$words = $this->content(true);
$words = strip_tags($words);
$words = str_word_count($words);
$average = $words / 200;
$minutes = round($average);
return $minutes;
if ($minutes>0) {
return $minutes.' '.$Language->get('minutes');
}
return '~1 '.$Language->get('minute');
}
// Returns relative time (e.g. "1 minute ago")

View File

@ -280,5 +280,8 @@
"plugins-position": "Plugin position",
"plugins-position-changed": "Plugin position changed",
"drag-and-drop-to-set-the-position-of-the-plugin": "Drag and Drop to set the position of the plugins",
"change-the-position-of-the-plugins": "Change the position of the plugins"
"change-the-position-of-the-plugins": "Change the position of the plugins",
"reading-time": "Reading time",
"minutes": "minutes",
"minute": "minute"
}

View File

@ -15,7 +15,7 @@
</a>
<!-- Creation date -->
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?></h6>
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() . $Language->get('minutes') ?></h6>
<!-- Breaked content -->
<?php echo $page->contentBreak(); ?>

View File

@ -14,7 +14,7 @@
<?php if (!$page->static()): ?>
<!-- Creation date -->
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?></h6>
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() ?></h6>
<?php endif ?>
<!-- Full content -->