Browse Source

Add features, Cache Minify and Timeago

pull/475/head
Yaya Laressa 4 years ago
parent
commit
a72911293a
6 changed files with 93 additions and 35 deletions
  1. +3
    -1
      README.md
  2. +6
    -0
      config/config.ini.example
  3. +20
    -1
      system/admin/views/config-performance.html.php
  4. +20
    -1
      system/admin/views/config-reading.html.php
  5. +5
    -1
      system/includes/dispatch.php
  6. +39
    -31
      system/includes/functions.php

+ 3
- 1
README.md View File

@ -39,11 +39,13 @@ Features
- Responsive Design
- User Roles
- Online Backup
- File Caching (Auto Minify HTML support)
- File Caching
- Online Update
- Post Draft
- i18n
- Menu builder
- Caching Minify (optional)
- Posts Date display like Social Media (optional)
Requirements
------------


+ 6
- 0
config/config.ini.example View File

@ -93,6 +93,9 @@ teaser.char = "200"
; Description character count
description.char = "150"
; Post date display as, set "true" display as social media or set "false" as default
timeago.format = "false"
; RSS feed count
rss.count = "10"
@ -129,6 +132,9 @@ generation.time = "false"
; Switch on and off the cache timestamp. Options "false" and "true"
cache.timestamp = "false"
; Switch on and off the cache minify. Options "false" and "true"
cache.minify = "false"
; Set the theme here
views.root = "themes/twentyfifteen"


+ 20
- 1
system/admin/views/config-performance.html.php View File

@ -39,6 +39,25 @@
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('Cache_minify');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-cache.minify" id="cache.minify1" value="true" <?php if (config('cache.minify') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="cache.minify1">
<?php echo i18n('Enable_recommended');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-cache.minify" id="cache.minify2" value="false" <?php if (config('cache.minify') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="cache.minify2">
<?php echo i18n('Disable');?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('Cache_timestamp');?></label>
<div class="col-sm-10">
@ -56,7 +75,7 @@
</label>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('Page_generation_time');?></label>


+ 20
- 1
system/admin/views/config-reading.html.php View File

@ -75,7 +75,7 @@
</label>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="teaser.char" class="col-sm-2 col-form-label"><?php echo i18n('Summary_character');?></label>
@ -89,6 +89,25 @@
<input type="text" name="-config-read.more" class="form-control" id="read.more" value="<?php echo valueMaker(config('read.more'));?>" placeholder="<?php echo i18n('Read_more_text_placeholder');?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('Posts_date_displayed_as');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-timeago.format" id="timeago.format1" value="true" <?php if (config('timeago.format') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="timeago.format1">
<?php echo i18n('Timeago_format');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-timeago.format" id="timeago.format2" value="false" <?php if (config('timeago.format') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="timeago.format2">
<?php echo i18n('Default');?>
</label>
</div>
</div>
</div>
</div>
<br>
<h4><?php echo i18n('Posts_index_settings');?></h4>
<hr>


+ 5
- 1
system/includes/dispatch.php View File

@ -489,7 +489,11 @@ function render($view, $locals = null, $layout = null)
}
if (!$login && $view != '404') {
if (!file_exists($cachefile)) {
$content = minify_html(ob_get_contents()); // Minify HTML
if(config('cache.minify') == 'true') {
$content = minify_html(ob_get_contents()); // Minify HTML
} else {
$content = ob_get_contents(); // Un-Minify HTML
}
if (config('cache.timestamp') == 'true') {
$content .= "\n" . '<!-- Cached page generated on '.date('Y-m-d H:i:s').' -->';
}


+ 39
- 31
system/includes/functions.php View File

@ -3244,38 +3244,46 @@ function format_date($date)
$date_format = config('date.format');
if (!isset($date_format) || empty($date_format)) {
return strftime('%e %B %Y', $date);
// Timeago
if(config('timeago.format') == 'true') {
$time = time() - $date;
if ($time < 60) {
return ( $time > 1 ) ? $time . ' ' . i18n('Seconds_ago') : i18n('A_second_ago');
}
elseif ($time < 3600) {
$tmp = floor($time / 60);
return ($tmp > 1) ? $tmp . ' ' . i18n('Minutes_ago') : i18n('A_minute_ago');
}
elseif ($time < 86400) {
$tmp = floor($time / 3600);
return ($tmp > 1) ? $tmp . ' ' . i18n('Hours_ago') : i18n('An_hour_ago');
}
elseif ($time < 2592000) {
$tmp = floor($time / 86400);
return ($tmp > 1) ? $tmp . ' ' . i18n('Days_ago') : i18n('Yesterday');
}
elseif ($time < 946080000) {
if (!isset($date_format) || empty($date_format)) {
return strftime('%e %B %Y', $date);
} else {
return strftime($date_format, $date);
}
}
else {
$tmp = floor($time / 946080000);
if (!isset($date_format) || empty($date_format)) {
return strftime('%e %B %Y', $date);
} else {
return strftime($date_format, $date);
}
}
} else {
return strftime($date_format, $date);
}
}
// Function Timeago
function timeago($date){
$time = time() - $date;
if ($time < 60)
return ( $time > 1 ) ? $time . ' ' . i18n('Seconds_ago') : i18n('A_second_ago');
elseif ($time < 3600) {
$tmp = floor($time / 60);
return ($tmp > 1) ? $tmp . ' ' . i18n('Minutes_ago') : i18n('A_minute_ago');
}
elseif ($time < 86400) {
$tmp = floor($time / 3600);
return ($tmp > 1) ? $tmp . ' ' . i18n('Hours_ago') : i18n('An_hour_ago');
}
elseif ($time < 2592000) {
$tmp = floor($time / 86400);
return ($tmp > 1) ? $tmp . ' ' . i18n('Days_ago') : i18n('Yesterday');
}
elseif ($time < 946080000) {
return format_date($date);
}
else {
$tmp = floor($time / 946080000);
return format_date($date);
// Default
if (!isset($date_format) || empty($date_format)) {
return strftime('%e %B %Y', $date);
} else {
return strftime($date_format, $date);
}
}
}


Loading…
Cancel
Save