Reading time improves
This commit is contained in:
parent
8807414d1b
commit
ea7f24b53a
|
@ -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">
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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(); ?>
|
||||
|
|
|
@ -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 -->
|
||||
|
|
Loading…
Reference in New Issue