mirror of
https://github.com/danpros/htmly.git
synced 2026-04-20 04:26:22 +05:30
Improving template engine
Improving template engine for more flexible theming. Add cache.expiration.
This commit is contained in:
parent
7e73666725
commit
96a250274e
6 changed files with 339 additions and 42 deletions
|
|
@ -131,6 +131,10 @@ OpenShift
|
||||||
---------
|
---------
|
||||||
Need a free server to test HTMLy? try [OpenShift](https://www.openshift.com) using the [HTMLy OpenShift QuickStart](https://github.com/danpros/htmly-openshift) for easy deployment.
|
Need a free server to test HTMLy? try [OpenShift](https://www.openshift.com) using the [HTMLy OpenShift QuickStart](https://github.com/danpros/htmly-openshift) for easy deployment.
|
||||||
|
|
||||||
|
**Quick install:**
|
||||||
|
|
||||||
|
[](https://hub.openshift.com/quickstarts/deploy/219-htmly)
|
||||||
|
|
||||||
|
|
||||||
Making a secure password
|
Making a secure password
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
||||||
2
cache/installedVersion.json
vendored
2
cache/installedVersion.json
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"id": 782014,
|
"id": 782014,
|
||||||
"tag_name": "v2.6.7"
|
"tag_name": "v2.6.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
; The URL of your blog. Include the http or https if you are using Facebook or Disqus comments.
|
; The URL of your blog. Include the http or https if you are using Facebook or Disqus comment.
|
||||||
site.url = ""
|
site.url = ""
|
||||||
|
|
||||||
; Your timezone
|
; Your timezone
|
||||||
|
|
@ -103,8 +103,8 @@ rss.char = "200"
|
||||||
img.thumbnail = "false"
|
img.thumbnail = "false"
|
||||||
default.thumbnail = ""
|
default.thumbnail = ""
|
||||||
|
|
||||||
; Enable view Counter, the options is "true" and "false". If set to "true", you can see the Counts in Admin page.
|
; 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 = "true"
|
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.base = "1.0"
|
||||||
|
|
@ -120,6 +120,9 @@ sitemap.priority.author = "0.5"
|
||||||
; Also install pre-release
|
; Also install pre-release
|
||||||
prerelease = "false"
|
prerelease = "false"
|
||||||
|
|
||||||
|
; Cache expiration in hour. Eg. "6", "12". Default 6 hours.
|
||||||
|
cache.expiration = "6"
|
||||||
|
|
||||||
; Switch on and off the file cache for development purposes. Options "false" and "true"
|
; Switch on and off the file cache for development purposes. Options "false" and "true"
|
||||||
cache.off = "false"
|
cache.off = "false"
|
||||||
|
|
||||||
|
|
|
||||||
340
system/htmly.php
340
system/htmly.php
|
|
@ -13,10 +13,25 @@ if (config('timezone')) {
|
||||||
// The front page of the blog
|
// The front page of the blog
|
||||||
get('/index', function () {
|
get('/index', function () {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--front.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--front';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (config('static.frontpage') == 'true') {
|
if (config('static.frontpage') == 'true') {
|
||||||
|
|
||||||
$front = get_frontpage();
|
$front = get_frontpage();
|
||||||
|
|
@ -28,8 +43,15 @@ get('/index', function () {
|
||||||
} else {
|
} else {
|
||||||
$tagline = '';
|
$tagline = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/static--front.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'static--front';
|
||||||
|
} else {
|
||||||
|
$pview = 'static';
|
||||||
|
}
|
||||||
|
|
||||||
render('static', array(
|
render($pview, array(
|
||||||
'title' => blog_title() . $tagline,
|
'title' => blog_title() . $tagline,
|
||||||
'description' => blog_description(),
|
'description' => blog_description(),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
|
|
@ -38,11 +60,11 @@ get('/index', function () {
|
||||||
'p' => $front,
|
'p' => $front,
|
||||||
'type' => 'staticPage',
|
'type' => 'staticPage',
|
||||||
'is_front' => true,
|
'is_front' => true,
|
||||||
));
|
), $layout);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$page = from($_GET, 'page');
|
$page = from($_GET, 'page');
|
||||||
$page = $page ? (int)$page : 1;
|
$page = $page ? (int)$page : 1;
|
||||||
$perpage = config('posts.perpage');
|
$perpage = config('posts.perpage');
|
||||||
|
|
@ -58,6 +80,13 @@ get('/index', function () {
|
||||||
} else {
|
} else {
|
||||||
$tagline = '';
|
$tagline = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/main--front.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'main--front';
|
||||||
|
} else {
|
||||||
|
$pview = 'main';
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($posts) || $page < 1) {
|
if (empty($posts) || $page < 1) {
|
||||||
|
|
||||||
|
|
@ -68,12 +97,12 @@ get('/index', function () {
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'bodyclass' => 'noposts',
|
'bodyclass' => 'noposts',
|
||||||
'is_front' => true,
|
'is_front' => true,
|
||||||
));
|
), $layout);
|
||||||
|
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
render('main', array(
|
render($pview, array(
|
||||||
'title' => blog_title() . $tagline,
|
'title' => blog_title() . $tagline,
|
||||||
'description' => blog_description(),
|
'description' => blog_description(),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
|
|
@ -83,7 +112,7 @@ get('/index', function () {
|
||||||
'breadcrumb' => '',
|
'breadcrumb' => '',
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_front' => true,
|
'is_front' => true,
|
||||||
));
|
), $layout);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -147,6 +176,12 @@ post('/login', function () {
|
||||||
// Show the author page
|
// Show the author page
|
||||||
get('/author/:name', function ($name) {
|
get('/author/:name', function ($name) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
@ -166,9 +201,28 @@ get('/author/:name', function ($name) {
|
||||||
} else {
|
} else {
|
||||||
$author = default_profile($name);
|
$author = default_profile($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--profile--' . strtolower($name) . '.html.php';
|
||||||
|
$ls = $vroot . '/layout--profile.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--profile--' . strtolower($name);
|
||||||
|
} else if (file_exists($ls)) {
|
||||||
|
$layout = 'layout--profile';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/profile--'. strtolower($name) .'.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'profile--'. strtolower($name);
|
||||||
|
} else {
|
||||||
|
$pview = 'profile';
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($posts) || $page < 1) {
|
if (empty($posts) || $page < 1) {
|
||||||
render('profile', array(
|
render($pview, array(
|
||||||
'title' => 'Profile for: ' . $author->name . ' - ' . blog_title(),
|
'title' => 'Profile for: ' . $author->name . ' - ' . blog_title(),
|
||||||
'description' => 'Profile page and all posts by ' . $author->name . ' on ' . blog_title() . '.',
|
'description' => 'Profile page and all posts by ' . $author->name . ' on ' . blog_title() . '.',
|
||||||
'canonical' => site_url() . 'author/' . $name,
|
'canonical' => site_url() . 'author/' . $name,
|
||||||
|
|
@ -180,11 +234,11 @@ get('/author/:name', function ($name) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Profile for: ' . $author->name,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Profile for: ' . $author->name,
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_profile' => true,
|
'is_profile' => true,
|
||||||
));
|
), $layout);
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
render('profile', array(
|
render($pview, array(
|
||||||
'title' => 'Profile for: ' . $author->name . ' - ' . blog_title(),
|
'title' => 'Profile for: ' . $author->name . ' - ' . blog_title(),
|
||||||
'description' => 'Profile page and all posts by ' . $author->name . ' on ' . blog_title() . '.',
|
'description' => 'Profile page and all posts by ' . $author->name . ' on ' . blog_title() . '.',
|
||||||
'canonical' => site_url() . 'author/' . $name,
|
'canonical' => site_url() . 'author/' . $name,
|
||||||
|
|
@ -196,7 +250,7 @@ get('/author/:name', function ($name) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Profile for: ' . $author->name,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Profile for: ' . $author->name,
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_profile' => true,
|
'is_profile' => true,
|
||||||
));
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edit the profile
|
// Edit the profile
|
||||||
|
|
@ -1267,6 +1321,12 @@ get('/admin/categories', function () {
|
||||||
// Show the category page
|
// Show the category page
|
||||||
get('/category/:category', function ($category) {
|
get('/category/:category', function ($category) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
@ -1293,7 +1353,30 @@ get('/category/:category', function ($category) {
|
||||||
// a non-existing page
|
// a non-existing page
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
render('main', array(
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--category--'. strtolower($category) .'.html.php';
|
||||||
|
$ls = $vroot . '/layout--category.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--category--' . strtolower($category);
|
||||||
|
} else if (file_exists($ls)) {
|
||||||
|
$layout = 'layout--category';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/main--category--'. strtolower($category) .'.html.php';
|
||||||
|
$ps = $vroot . '/main--category.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'main--category--' . strtolower($category);
|
||||||
|
} else if (file_exists($ps)) {
|
||||||
|
$pview = 'main--category';
|
||||||
|
} else {
|
||||||
|
$pview = 'main';
|
||||||
|
}
|
||||||
|
|
||||||
|
render($pview, array(
|
||||||
'title' => $desc->title . ' - ' . blog_title(),
|
'title' => $desc->title . ' - ' . blog_title(),
|
||||||
'description' => $desc->description,
|
'description' => $desc->description,
|
||||||
'canonical' => $desc->url,
|
'canonical' => $desc->url,
|
||||||
|
|
@ -1304,7 +1387,7 @@ get('/category/:category', function ($category) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . $desc->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . $desc->title,
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_category' => true,
|
'is_category' => true,
|
||||||
));
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show edit the category page
|
// Show edit the category page
|
||||||
|
|
@ -1430,6 +1513,12 @@ post('/category/:category/delete', function () {
|
||||||
// Show the tag page
|
// Show the tag page
|
||||||
get('/tag/:tag', function ($tag) {
|
get('/tag/:tag', function ($tag) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
@ -1449,7 +1538,30 @@ get('/tag/:tag', function ($tag) {
|
||||||
// a non-existing page
|
// a non-existing page
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
render('main', array(
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--tag--' . strtolower($tag) . '.html.php';
|
||||||
|
$ls = $vroot . '/layout--tag.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--tag--' . strtolower($tag);
|
||||||
|
} else if (file_exists($ls)) {
|
||||||
|
$layout = 'layout--tag';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/main--tag--' . strtolower($tag) . '.html.php';
|
||||||
|
$ps = $vroot . '/main--tag.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'main--tag--' . strtolower($tag);
|
||||||
|
} elseif (file_exists($ps)) {
|
||||||
|
$pview = 'main--tag';
|
||||||
|
} else {
|
||||||
|
$pview = 'main';
|
||||||
|
}
|
||||||
|
|
||||||
|
render($pview, array(
|
||||||
'title' => 'Posts tagged: ' . tag_i18n($tag) . ' - ' . blog_title(),
|
'title' => 'Posts tagged: ' . tag_i18n($tag) . ' - ' . blog_title(),
|
||||||
'description' => 'All posts tagged: ' . tag_i18n($tag) . ' on ' . blog_title() . '.',
|
'description' => 'All posts tagged: ' . tag_i18n($tag) . ' on ' . blog_title() . '.',
|
||||||
'canonical' => site_url() . 'tag/' . strtolower($tag),
|
'canonical' => site_url() . 'tag/' . strtolower($tag),
|
||||||
|
|
@ -1460,12 +1572,18 @@ get('/tag/:tag', function ($tag) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Posts tagged: ' . tag_i18n($tag),
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Posts tagged: ' . tag_i18n($tag),
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_tag' => true,
|
'is_tag' => true,
|
||||||
));
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show the archive page
|
// Show the archive page
|
||||||
get('/archive/:req', function ($req) {
|
get('/archive/:req', function ($req) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
@ -1501,8 +1619,24 @@ get('/archive/:req', function ($req) {
|
||||||
// a non-existing page
|
// a non-existing page
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--archive.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--archive';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/main--archive.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'main--archive';
|
||||||
|
} else {
|
||||||
|
$pview = 'main';
|
||||||
|
}
|
||||||
|
|
||||||
render('main', array(
|
render($pview, array(
|
||||||
'title' => 'Archive for: ' . $timestamp . ' - ' . blog_title(),
|
'title' => 'Archive for: ' . $timestamp . ' - ' . blog_title(),
|
||||||
'description' => 'Archive page for: ' . $timestamp . ' on ' . blog_title() . '.',
|
'description' => 'Archive page for: ' . $timestamp . ' on ' . blog_title() . '.',
|
||||||
'canonical' => site_url() . 'archive/' . $req,
|
'canonical' => site_url() . 'archive/' . $req,
|
||||||
|
|
@ -1513,12 +1647,18 @@ get('/archive/:req', function ($req) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Archive for: ' . $timestamp,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Archive for: ' . $timestamp,
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_archive' => true,
|
'is_archive' => true,
|
||||||
));
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show the search page
|
// Show the search page
|
||||||
get('/search/:keyword', function ($keyword) {
|
get('/search/:keyword', function ($keyword) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
@ -1531,6 +1671,15 @@ get('/search/:keyword', function ($keyword) {
|
||||||
|
|
||||||
$tsearch = new stdClass;
|
$tsearch = new stdClass;
|
||||||
$tsearch->title = $keyword;
|
$tsearch->title = $keyword;
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--search.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--search';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (!$posts || $page < 1) {
|
if (!$posts || $page < 1) {
|
||||||
// a non-existing page or no search result
|
// a non-existing page or no search result
|
||||||
|
|
@ -1542,13 +1691,20 @@ get('/search/:keyword', function ($keyword) {
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'bodyclass' => 'error-404-search',
|
'bodyclass' => 'error-404-search',
|
||||||
'is_404search' => true,
|
'is_404search' => true,
|
||||||
));
|
), $layout);
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = keyword_count($keyword);
|
$total = keyword_count($keyword);
|
||||||
|
|
||||||
|
$pv = $vroot . '/main--search.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'main--search';
|
||||||
|
} else {
|
||||||
|
$pview = 'main';
|
||||||
|
}
|
||||||
|
|
||||||
render('main', array(
|
render($pview, array(
|
||||||
'title' => 'Search results for: ' . tag_i18n($keyword) . ' - ' . blog_title(),
|
'title' => 'Search results for: ' . tag_i18n($keyword) . ' - ' . blog_title(),
|
||||||
'description' => 'Search results for: ' . tag_i18n($keyword) . ' on ' . blog_title() . '.',
|
'description' => 'Search results for: ' . tag_i18n($keyword) . ' on ' . blog_title() . '.',
|
||||||
'canonical' => site_url() . 'search/' . strtolower($keyword),
|
'canonical' => site_url() . 'search/' . strtolower($keyword),
|
||||||
|
|
@ -1559,7 +1715,7 @@ get('/search/:keyword', function ($keyword) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Search results for: ' . tag_i18n($keyword),
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Search results for: ' . tag_i18n($keyword),
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_search' => true,
|
'is_search' => true,
|
||||||
));
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// The JSON API
|
// The JSON API
|
||||||
|
|
@ -1595,6 +1751,12 @@ get('/feed/opml', function () {
|
||||||
// Show blog post without year-month
|
// Show blog post without year-month
|
||||||
get('/post/:name', function ($name) {
|
get('/post/:name', function ($name) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (config('permalink.type') != 'post') {
|
if (config('permalink.type') != 'post') {
|
||||||
$post = find_post(null, null, $name);
|
$post = find_post(null, null, $name);
|
||||||
$current = $post['current'];
|
$current = $post['current'];
|
||||||
|
|
@ -1663,8 +1825,27 @@ get('/post/:name', function ($name) {
|
||||||
} else {
|
} else {
|
||||||
$blog = '';
|
$blog = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--post--' . $current->ct . '.html.php';
|
||||||
|
$ls = $vroot . '/layout--post.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--post--' . $current->ct;
|
||||||
|
} elseif (file_exists($ls)) {
|
||||||
|
$layout = 'layout--post';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/post--' . $current->ct . '.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'post--' . $current->ct;
|
||||||
|
} else {
|
||||||
|
$pview = 'post';
|
||||||
|
}
|
||||||
|
|
||||||
render('post', array(
|
render($pview, array(
|
||||||
'title' => $current->title . ' - ' . blog_title(),
|
'title' => $current->title . ' - ' . blog_title(),
|
||||||
'description' => $current->description,
|
'description' => $current->description,
|
||||||
'canonical' => $current->url,
|
'canonical' => $current->url,
|
||||||
|
|
@ -1676,7 +1857,7 @@ get('/post/:name', function ($name) {
|
||||||
'next' => has_next($next),
|
'next' => has_next($next),
|
||||||
'type' => $var,
|
'type' => $var,
|
||||||
'is_post' => true,
|
'is_post' => true,
|
||||||
));
|
), $layout);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1943,6 +2124,12 @@ post('/post/:name/delete', function () {
|
||||||
// Show various page (top-level), admin, login, sitemap, static page.
|
// Show various page (top-level), admin, login, sitemap, static page.
|
||||||
get('/:static', function ($static) {
|
get('/:static', function ($static) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if ($static === 'sitemap.xml' || $static === 'sitemap.base.xml' || $static === 'sitemap.post.xml' || $static === 'sitemap.static.xml' || $static === 'sitemap.tag.xml' || $static === 'sitemap.archive.xml' || $static === 'sitemap.author.xml' || $static === 'sitemap.category.xml') {
|
if ($static === 'sitemap.xml' || $static === 'sitemap.base.xml' || $static === 'sitemap.post.xml' || $static === 'sitemap.static.xml' || $static === 'sitemap.tag.xml' || $static === 'sitemap.archive.xml' || $static === 'sitemap.author.xml' || $static === 'sitemap.category.xml') {
|
||||||
|
|
||||||
header('Content-Type: text/xml');
|
header('Content-Type: text/xml');
|
||||||
|
|
@ -2029,6 +2216,22 @@ get('/:static', function ($static) {
|
||||||
} else {
|
} else {
|
||||||
$tagline = '';
|
$tagline = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--blog.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--blog';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/main--blog.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'main--blog';
|
||||||
|
} else {
|
||||||
|
$pview = 'main';
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($posts) || $page < 1) {
|
if (empty($posts) || $page < 1) {
|
||||||
|
|
||||||
|
|
@ -2039,12 +2242,12 @@ get('/:static', function ($static) {
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'bodyclass' => 'noposts',
|
'bodyclass' => 'noposts',
|
||||||
'is_front' => true,
|
'is_front' => true,
|
||||||
));
|
), $layout);
|
||||||
|
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
render('main', array(
|
render($pview, array(
|
||||||
'title' => 'Blog - ' . blog_title(),
|
'title' => 'Blog - ' . blog_title(),
|
||||||
'description' => blog_title() . ' Blog Homepage',
|
'description' => blog_title() . ' Blog Homepage',
|
||||||
'canonical' => site_url() . 'blog',
|
'canonical' => site_url() . 'blog',
|
||||||
|
|
@ -2054,7 +2257,7 @@ get('/:static', function ($static) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Blog',
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Blog',
|
||||||
'pagination' => has_pagination($total, $perpage, $page),
|
'pagination' => has_pagination($total, $perpage, $page),
|
||||||
'is_blog' => true,
|
'is_blog' => true,
|
||||||
));
|
), $layout);
|
||||||
} elseif ($static === 'front') {
|
} elseif ($static === 'front') {
|
||||||
|
|
||||||
$redir = site_url();
|
$redir = site_url();
|
||||||
|
|
@ -2082,8 +2285,27 @@ get('/:static', function ($static) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--' . strtolower($static) . '.html.php';
|
||||||
|
$ls = $vroot . '/layout--static.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--' . strtolower($static);
|
||||||
|
} else if (file_exists($ls)) {
|
||||||
|
$layout = 'layout--static';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/static--' . strtolower($static) . '.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'static--' . strtolower($static);
|
||||||
|
} else {
|
||||||
|
$pview = 'static';
|
||||||
|
}
|
||||||
|
|
||||||
render('static', array(
|
render($pview, array(
|
||||||
'title' => $post->title . ' - ' . blog_title(),
|
'title' => $post->title . ' - ' . blog_title(),
|
||||||
'description' => $post->description,
|
'description' => $post->description,
|
||||||
'canonical' => $post->url,
|
'canonical' => $post->url,
|
||||||
|
|
@ -2092,7 +2314,7 @@ get('/:static', function ($static) {
|
||||||
'p' => $post,
|
'p' => $post,
|
||||||
'type' => 'staticPage',
|
'type' => 'staticPage',
|
||||||
'is_page' => true,
|
'is_page' => true,
|
||||||
));
|
), $layout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -2290,6 +2512,12 @@ post('/:static/delete', function () {
|
||||||
// Show the sb static page
|
// Show the sb static page
|
||||||
get('/:static/:sub', function ($static, $sub) {
|
get('/:static/:sub', function ($static, $sub) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
$father_post = get_static_post($static);
|
$father_post = get_static_post($static);
|
||||||
if (!$father_post) {
|
if (!$father_post) {
|
||||||
not_found();
|
not_found();
|
||||||
|
|
@ -2307,8 +2535,33 @@ get('/:static/:sub', function ($static, $sub) {
|
||||||
if (!login()) {
|
if (!login()) {
|
||||||
file_cache($_SERVER['REQUEST_URI']);
|
file_cache($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--' . strtolower($static) . '--' . strtolower($sub) . '.html.php';
|
||||||
|
$ls = $vroot . '/layout--' . strtolower($static) . '.html.php';
|
||||||
|
$lf = $vroot . '/layout--static.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--' . strtolower($static) . '--' . strtolower($sub);
|
||||||
|
} else if (file_exists($ls)) {
|
||||||
|
$layout = 'layout--' . strtolower($static);
|
||||||
|
} else if (file_exists($lf)) {
|
||||||
|
$layout = 'layout--static';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/static--' . strtolower($static) . '--' . strtolower($sub) . '.html.php';
|
||||||
|
$ps = $vroot . '/static--' . strtolower($static) . '.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'static--' . strtolower($static) . '--' . strtolower($sub);
|
||||||
|
} else if (file_exists($ps)) {
|
||||||
|
$pview = 'static--' . strtolower($static);
|
||||||
|
} else {
|
||||||
|
$pview = 'static';
|
||||||
|
}
|
||||||
|
|
||||||
render('static', array(
|
render($pview, array(
|
||||||
'title' => $post->title . ' - ' . blog_title(),
|
'title' => $post->title . ' - ' . blog_title(),
|
||||||
'description' => $post->description,
|
'description' => $post->description,
|
||||||
'canonical' => $post->url,
|
'canonical' => $post->url,
|
||||||
|
|
@ -2317,7 +2570,7 @@ get('/:static/:sub', function ($static, $sub) {
|
||||||
'p' => $post,
|
'p' => $post,
|
||||||
'type' => 'subPage',
|
'type' => 'subPage',
|
||||||
'is_subpage' => true,
|
'is_subpage' => true,
|
||||||
));
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edit the sub static page
|
// Edit the sub static page
|
||||||
|
|
@ -2462,6 +2715,12 @@ post('/:static/:sub/delete', function () {
|
||||||
|
|
||||||
// Show blog post with year-month
|
// Show blog post with year-month
|
||||||
get('/:year/:month/:name', function ($year, $month, $name) {
|
get('/:year/:month/:name', function ($year, $month, $name) {
|
||||||
|
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
$search = $_GET['search'];
|
||||||
|
$url = site_url() . 'search/' . remove_accent($search);
|
||||||
|
header("Location: $url");
|
||||||
|
}
|
||||||
|
|
||||||
if (config('permalink.type') == 'post') {
|
if (config('permalink.type') == 'post') {
|
||||||
$redir = site_url() . 'post/' . $name;
|
$redir = site_url() . 'post/' . $name;
|
||||||
|
|
@ -2529,8 +2788,27 @@ get('/:year/:month/:name', function ($year, $month, $name) {
|
||||||
} else {
|
} else {
|
||||||
$blog = '';
|
$blog = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
render('post', array(
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
|
$lt = $vroot . '/layout--post--' . $current->ct . '.html.php';
|
||||||
|
$ls = $vroot . '/layout--post.html.php';
|
||||||
|
if (file_exists($lt)) {
|
||||||
|
$layout = 'layout--post--' . $current->ct;
|
||||||
|
} else if (file_exists($ls)) {
|
||||||
|
$layout = 'layout--post';
|
||||||
|
} else {
|
||||||
|
$layout = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pv = $vroot . '/post--' . $current->ct . '.html.php';
|
||||||
|
if (file_exists($pv)) {
|
||||||
|
$pview = 'post--' . $current->ct;
|
||||||
|
} else {
|
||||||
|
$pview = 'post';
|
||||||
|
}
|
||||||
|
|
||||||
|
render($pview, array(
|
||||||
'title' => $current->title . ' - ' . blog_title(),
|
'title' => $current->title . ' - ' . blog_title(),
|
||||||
'description' => $current->description,
|
'description' => $current->description,
|
||||||
'canonical' => $current->url,
|
'canonical' => $current->url,
|
||||||
|
|
@ -2542,7 +2820,7 @@ get('/:year/:month/:name', function ($year, $month, $name) {
|
||||||
'next' => has_next($next),
|
'next' => has_next($next),
|
||||||
'type' => $var,
|
'type' => $var,
|
||||||
'is_post' => true,
|
'is_post' => true,
|
||||||
));
|
), $layout);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
||||||
$post->categoryb = '<a property="v:title" rel="v:url" href="' . $category[0]->url . '">' . $category[0]->title . '</a>';
|
$post->categoryb = '<a property="v:title" rel="v:url" href="' . $category[0]->url . '">' . $category[0]->title . '</a>';
|
||||||
}
|
}
|
||||||
$type = $str[count($str) - 2];
|
$type = $str[count($str) - 2];
|
||||||
|
$post->ct = $str[count($str) - 3];
|
||||||
|
|
||||||
// The post author + author url
|
// The post author + author url
|
||||||
$post->author = $author;
|
$post->author = $author;
|
||||||
|
|
@ -1775,7 +1776,7 @@ function menu($custom = null)
|
||||||
|
|
||||||
$links = explode('|', $menu);
|
$links = explode('|', $menu);
|
||||||
|
|
||||||
echo '<ul class="nav navbar-nav ' . $custom . '">';
|
echo '<ul class="nav ' . $custom . '">';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$len = count($links);
|
$len = count($links);
|
||||||
|
|
@ -1847,7 +1848,7 @@ function get_menu($custom)
|
||||||
|
|
||||||
krsort($posts);
|
krsort($posts);
|
||||||
|
|
||||||
echo '<ul class="nav navbar-nav ' . $custom . '">';
|
echo '<ul class="nav ' . $custom . '">';
|
||||||
if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) {
|
if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) {
|
||||||
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1923,7 +1924,7 @@ function get_menu($custom)
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
echo '<ul class="nav navbar-nav ' . $custom . '">';
|
echo '<ul class="nav ' . $custom . '">';
|
||||||
if ($req == site_path() . '/') {
|
if ($req == site_path() . '/') {
|
||||||
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2533,12 +2534,23 @@ function file_cache($request)
|
||||||
{
|
{
|
||||||
if (config('cache.off') == 'true') return;
|
if (config('cache.off') == 'true') return;
|
||||||
|
|
||||||
|
$hour = str_replace(',', '.', config('cache.expiration'));
|
||||||
|
if (empty($hour)) {
|
||||||
|
$hour = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
|
||||||
$c = str_replace('/', '#', str_replace('?', '~', $request));
|
$c = str_replace('/', '#', str_replace('?', '~', $request));
|
||||||
$cachefile = 'cache/page/' . $c . '.cache';
|
$cachefile = 'cache/page/' . $c . '.cache';
|
||||||
if (file_exists($cachefile)) {
|
if (file_exists($cachefile)) {
|
||||||
header('Content-type: text/html; charset=utf-8');
|
if ($now - filemtime($cachefile) >= 60 * 60 * $hour) {
|
||||||
readfile($cachefile);
|
unlink($cachefile);
|
||||||
die;
|
} else {
|
||||||
|
header('Content-type: text/html; charset=utf-8');
|
||||||
|
readfile($cachefile);
|
||||||
|
die;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
</div>
|
</div>
|
||||||
</li><!-- /.searchbox -->
|
</li><!-- /.searchbox -->
|
||||||
</ul>
|
</ul>
|
||||||
<?php echo menu('navbar-right');?>
|
<?php echo menu('navbar-nav navbar-right');?>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div><!--//container-->
|
</div><!--//container-->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue