mirror of
https://github.com/danpros/htmly.git
synced 2026-04-17 11:16:00 +05:30
Add setting and performance tweak
Add config on how the teaser behave. Saving the IOPS
This commit is contained in:
parent
007869f334
commit
0fba77f175
5 changed files with 104 additions and 27 deletions
|
|
@ -7,7 +7,8 @@ timezone = "Asia/Jakarta"
|
|||
; Date format.
|
||||
date.format = "d F Y"
|
||||
|
||||
; Your language (example "en_US" for English or "de_DE" for German. See lang directory for available language)
|
||||
; Your language (example "en_US" for English or "de_DE" for German.
|
||||
; See lang directory for available language)
|
||||
language = "en_US"
|
||||
|
||||
; Blog info
|
||||
|
|
@ -90,11 +91,15 @@ popular.count = "5"
|
|||
; Tagcloud
|
||||
tagcloud.count = "40"
|
||||
|
||||
; Read more link text for "full" teaser type
|
||||
read.more = "Read more"
|
||||
|
||||
; Teaser type: set "trimmed" or "full".
|
||||
teaser.type = "full"
|
||||
|
||||
; Read more link text for "full" teaser type
|
||||
read.more = "Read more"
|
||||
; In summary mode, whether check the shortcode first or not before trim the content to x char
|
||||
; Options: "default" and "check"
|
||||
teaser.behave = "default"
|
||||
|
||||
; Teaser character count
|
||||
teaser.char = "200"
|
||||
|
|
@ -108,10 +113,12 @@ rss.count = "10"
|
|||
; RSS feed description length. If left empty we will use full page.
|
||||
rss.char = "200"
|
||||
|
||||
; Enable views Counter, the options is "true" and "false". If set to "true", you can see the Counts in Admin page and popular posts.
|
||||
; Enable views Counter, the options is "true" and "false".
|
||||
; If set to "true", you can see the Counts in Admin page and popular posts.
|
||||
views.counter = "false"
|
||||
|
||||
; Sitemap priorities between "0.0" and "1.0". Set "false" to disable a sitemap for the given type. (See /sitemap.xml)
|
||||
; Sitemap priorities between "0.0" and "1.0".
|
||||
; Set "false" to disable a sitemap for the given type. (See /sitemap.xml)
|
||||
sitemap.priority.base = "1.0"
|
||||
sitemap.priority.post = "0.5"
|
||||
sitemap.priority.static = "0.5"
|
||||
|
|
|
|||
|
|
@ -1009,6 +1009,13 @@ function find_draft_page($static = null)
|
|||
$posts = get_draft_pages();
|
||||
|
||||
$tmp = array();
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$viewsFile = "content/data/views.json";
|
||||
if (file_exists($viewsFile)) {
|
||||
$views = json_decode(file_get_contents($viewsFile), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($posts)) {
|
||||
|
||||
|
|
@ -1046,7 +1053,7 @@ function find_draft_page($static = null)
|
|||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$post->views = get_views('page_' . $post->slug, $post->file);
|
||||
$post->views = get_views('page_' . $post->slug, $post->file, $views);
|
||||
} else {
|
||||
$post->views = null;
|
||||
}
|
||||
|
|
@ -1070,6 +1077,13 @@ function find_draft_subpage($static = null, $sub_static = null)
|
|||
$posts = get_draft_subpages($static);
|
||||
|
||||
$tmp = array();
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$viewsFile = "content/data/views.json";
|
||||
if (file_exists($viewsFile)) {
|
||||
$views = json_decode(file_get_contents($viewsFile), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($posts)) {
|
||||
|
||||
|
|
@ -1116,7 +1130,7 @@ function find_draft_subpage($static = null, $sub_static = null)
|
|||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file);
|
||||
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views);
|
||||
} else {
|
||||
$post->views = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,26 @@
|
|||
<input type="number" name="-config-teaser.char" class="form-control" id="teaser.char" value="<?php echo config('teaser.char');?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">Summary behavior</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-10">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="-config-teaser.behave" id="teaser.behave1" value="default" <?php if (config('teaser.behave') === 'default' || is_null(config('teaser.behave'))):?>checked<?php endif;?>>
|
||||
<label class="form-check-label" for="teaser.behave1">
|
||||
Default
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="-config-teaser.behave" id="teaser.behave2" value="check" <?php if (config('teaser.behave') === 'check'):?>checked<?php endif;?>>
|
||||
<label class="form-check-label" for="teaser.behave2">
|
||||
Check shortcode
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<small><em>In summary mode, whether check the shortcode first or not before trim the content to x char</em></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="read.more" class="col-sm-2 col-form-label"><?php echo i18n('Read_more_text');?></label>
|
||||
<div class="col-sm-10">
|
||||
|
|
|
|||
|
|
@ -43,8 +43,9 @@
|
|||
"recent.count",
|
||||
"popular.count",
|
||||
"tagcloud.count",
|
||||
"teaser.type",
|
||||
"read.more",
|
||||
"teaser.type",
|
||||
"teaser.behave",
|
||||
"teaser.char",
|
||||
"description.char",
|
||||
"rss.count",
|
||||
|
|
|
|||
|
|
@ -394,6 +394,13 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
$posts = array_slice($posts, ($page - 1) * $perpage, $perpage);
|
||||
|
||||
$cList = category_list(true);
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$viewsFile = "content/data/views.json";
|
||||
if (file_exists($viewsFile)) {
|
||||
$views = json_decode(file_get_contents($viewsFile), true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($posts as $index => $v) {
|
||||
|
||||
|
|
@ -540,7 +547,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
}
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$post->views = get_views('post_' . $post->slug, $post->file);
|
||||
$post->views = get_views('post_' . $post->slug, $post->file, $views);
|
||||
} else {
|
||||
$post->views = null;
|
||||
}
|
||||
|
|
@ -558,6 +565,13 @@ function get_pages($pages, $page = 1, $perpage = 0)
|
|||
}
|
||||
|
||||
$tmp = array();
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$viewsFile = "content/data/views.json";
|
||||
if (file_exists($viewsFile)) {
|
||||
$views = json_decode(file_get_contents($viewsFile), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Extract a specific page with results
|
||||
$pages = array_slice($pages, ($page - 1) * $perpage, $perpage);
|
||||
|
|
@ -609,7 +623,7 @@ function get_pages($pages, $page = 1, $perpage = 0)
|
|||
}
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$post->views = get_views('page_' . $post->slug, $post->file);
|
||||
$post->views = get_views('page_' . $post->slug, $post->file, $views);
|
||||
} else {
|
||||
$post->views = null;
|
||||
}
|
||||
|
|
@ -628,6 +642,13 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
|
|||
}
|
||||
|
||||
$tmp = array();
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$viewsFile = "content/data/views.json";
|
||||
if (file_exists($viewsFile)) {
|
||||
$views = json_decode(file_get_contents($viewsFile), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Extract a specific page with results
|
||||
$sub_pages = array_slice($sub_pages, ($page - 1) * $perpage, $perpage);
|
||||
|
|
@ -689,7 +710,7 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
|
|||
}
|
||||
|
||||
if (config('views.counter') == 'true') {
|
||||
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file);
|
||||
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views);
|
||||
} else {
|
||||
$post->views = null;
|
||||
}
|
||||
|
|
@ -2210,10 +2231,15 @@ function get_teaser($string, $url = null, $char = null)
|
|||
return $string;
|
||||
}
|
||||
} else {
|
||||
$readMore = explode('<!--more-->', $string);
|
||||
if (isset($readMore['1'])) {
|
||||
$string = shorten($readMore[0]);
|
||||
return $string;
|
||||
if (config('teaser.behave') === 'check') {
|
||||
$readMore = explode('<!--more-->', $string);
|
||||
if (isset($readMore['1'])) {
|
||||
$string = shorten($readMore[0]);
|
||||
return $string;
|
||||
} else {
|
||||
$string = shorten($string, $char);
|
||||
return $string;
|
||||
}
|
||||
} else {
|
||||
$string = shorten($string, $char);
|
||||
return $string;
|
||||
|
|
@ -3440,27 +3466,36 @@ function add_view($page)
|
|||
}
|
||||
|
||||
// Get the page views count
|
||||
function get_views($page, $oldID = null)
|
||||
function get_views($page, $oldID = null, $views = null)
|
||||
{
|
||||
$_views = array();
|
||||
$filename = "content/data/views.json";
|
||||
if (file_exists($filename)) {
|
||||
$_views = json_decode(file_get_contents($filename), true);
|
||||
|
||||
if (is_null($views)) {
|
||||
if (file_exists($filename)) {
|
||||
$views = json_decode(file_get_contents($filename), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($oldID)) {
|
||||
if (isset($_views[$oldID])) {
|
||||
$arr = replace_key($_views, $oldID, $page);
|
||||
save_json_pretty($filename, $arr);
|
||||
return $_views[$oldID];
|
||||
if (isset($views[$oldID])) {
|
||||
if (file_exists($filename)) {
|
||||
$views = json_decode(file_get_data($filename), true);
|
||||
}
|
||||
if (isset($views['flock_fail'])) {
|
||||
return -1;
|
||||
} else {
|
||||
$arr = replace_key($views, $oldID, $page);
|
||||
save_json_pretty($filename, $arr);
|
||||
}
|
||||
return $views[$oldID];
|
||||
} else {
|
||||
if (isset($_views[$page])) {
|
||||
return $_views[$page];
|
||||
if (isset($views[$page])) {
|
||||
return $views[$page];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($_views[$page])) {
|
||||
return $_views[$page];
|
||||
if (isset($views[$page])) {
|
||||
return $views[$page];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue