mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 20:16:22 +05:30
Improve pages/subpages
Allow to reorder the pages and subpages position. Added doks theme
This commit is contained in:
parent
672aec1278
commit
8d142b7f37
46 changed files with 4860 additions and 94 deletions
|
|
@ -380,7 +380,7 @@ function render($view, $locals = null, $layout = null)
|
|||
|
||||
if (($view_root = config('views.root')) == null)
|
||||
error(500, "[views.root] is not set");
|
||||
|
||||
|
||||
$fnc = "{$view_root}/functions.php";
|
||||
|
||||
ob_start();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function get_static_subpages($static = null)
|
|||
$stringLen = strlen($static);
|
||||
return array_filter($_sub_page, function ($sub_page) use ($static, $stringLen) {
|
||||
$x = explode("/", $sub_page['dirname']);
|
||||
if ($x[2] == $static) {
|
||||
if (strpos($x[2], $static) !== false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -126,7 +126,7 @@ function get_draft_subpages($static = null)
|
|||
$stringLen = strlen($static);
|
||||
return array_filter($_draftSubpage, function ($sub_page) use ($static, $stringLen) {
|
||||
$x = explode("/", $sub_page['dirname']);
|
||||
if ($x[2] == $static) {
|
||||
if (strpos($x[2], $static) !== false) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -544,14 +544,20 @@ function get_pages($pages, $page = 1, $perpage = 0)
|
|||
$post = new stdClass;
|
||||
|
||||
// The static page URL
|
||||
$url= $v['filename'];
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$url = $fn[1];
|
||||
} else {
|
||||
$url= $v['filename'];
|
||||
}
|
||||
|
||||
$post->url = site_url() . $url;
|
||||
|
||||
$post->file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
|
||||
|
||||
$post->md = $url;
|
||||
$post->md = $v['basename'];
|
||||
$post->slug = $url;
|
||||
$post->parent = null;
|
||||
|
||||
|
|
@ -597,18 +603,32 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
|
|||
|
||||
$post = new stdClass;
|
||||
|
||||
$static = str_replace(dirname($v['dirname']) . '/', '', $v['dirname']);
|
||||
$fd = str_replace(dirname($v['dirname']) . '/', '', $v['dirname']);
|
||||
|
||||
$st = explode('.', $fd);
|
||||
if (isset($st[1])) {
|
||||
$static = $st[1];
|
||||
} else {
|
||||
$static = $fd;
|
||||
}
|
||||
|
||||
// The static page URL
|
||||
$url= $v['filename'];
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$url = $fn[1];
|
||||
} else {
|
||||
$url= $v['filename'];
|
||||
}
|
||||
|
||||
$post->url = site_url() . $static . "/" . $url;
|
||||
|
||||
$post->file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
|
||||
|
||||
$post->md = $url;
|
||||
$post->md = $v['basename'];
|
||||
$post->slug = $url;
|
||||
$post->parent = $static;
|
||||
$post->parent = $fd;
|
||||
|
||||
// Get the contents and convert it to HTML
|
||||
$content = file_get_contents($post->file);
|
||||
|
|
@ -877,7 +897,7 @@ function read_category_info($category)
|
|||
|
||||
$desc->url = site_url() . 'category/' . $url;
|
||||
|
||||
$desc->md = $url;
|
||||
$desc->md = $v['basename'];
|
||||
|
||||
$desc->slug = $url;
|
||||
|
||||
|
|
@ -914,16 +934,16 @@ function default_category($category = null)
|
|||
$desc->url = site_url() . 'category/uncategorized';
|
||||
$desc->slug = 'uncategorized';
|
||||
$desc->body = '<p>' . i18n('Uncategorized_comment') . '</p>';
|
||||
$desc->md = 'uncategorized';
|
||||
$desc->md = 'uncategorized.md';
|
||||
$desc->description = i18n('Uncategorized_comment');
|
||||
$desc->file = '';
|
||||
$desc->count = get_categorycount($desc->md);
|
||||
$desc->count = get_categorycount($desc->slug);
|
||||
} else {
|
||||
$desc->title = $category;
|
||||
$desc->url = site_url() . 'category/' . $category;
|
||||
$desc->slug = $category;
|
||||
$desc->body = '<p>' . i18n('All_blog_posts') . ': ' . $category . '</p>';
|
||||
$desc->md = $category;
|
||||
$desc->md = $category . '.md';
|
||||
$desc->description = i18n('All_blog_posts') . ': ' . $category;
|
||||
$desc->file = '';
|
||||
$desc->count = get_categorycount($category);
|
||||
|
|
@ -950,7 +970,7 @@ function category_list($custom = null) {
|
|||
} else {
|
||||
$arr = get_category_info(null);
|
||||
foreach ($arr as $i => $a) {
|
||||
$cat[] = array($a->md, $a->title, $a->count, $a->description);
|
||||
$cat[] = array($a->slug, $a->title, $a->count, $a->description);
|
||||
}
|
||||
|
||||
$tmp = serialize($cat);
|
||||
|
|
@ -2447,7 +2467,7 @@ function get_title_from_file($v)
|
|||
}
|
||||
|
||||
// Auto generate menu from static page
|
||||
function get_menu($custom)
|
||||
function get_menu($custom = null, $auto = null)
|
||||
{
|
||||
$posts = get_static_pages();
|
||||
$req = $_SERVER['REQUEST_URI'];
|
||||
|
|
@ -2457,17 +2477,20 @@ function get_menu($custom)
|
|||
asort($posts);
|
||||
|
||||
echo '<ul class="nav ' . $custom . '">';
|
||||
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>';
|
||||
} else {
|
||||
echo '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||
}
|
||||
|
||||
if (config('blog.enable') == 'true' ) {
|
||||
if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) {
|
||||
echo '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
|
||||
if (is_null($auto)) {
|
||||
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>';
|
||||
} else {
|
||||
echo '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
echo '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
|
||||
}
|
||||
|
||||
if (config('blog.enable') == 'true' ) {
|
||||
if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) {
|
||||
echo '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
} else {
|
||||
echo '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2484,7 +2507,15 @@ function get_menu($custom)
|
|||
$i++;
|
||||
|
||||
// Filename string
|
||||
$filename= $v['filename'];
|
||||
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$filename= $fn[1];
|
||||
} else {
|
||||
$filename= $v['filename'];
|
||||
}
|
||||
|
||||
$url = site_url() . $filename;
|
||||
$parent_file = $v['dirname'] . '/' . $v['basename'];
|
||||
|
||||
|
|
@ -2514,7 +2545,13 @@ function get_menu($custom)
|
|||
$classSub .= " last";
|
||||
}
|
||||
|
||||
$baseSub= $sp['filename'];
|
||||
$bs = explode('.', $sp['filename']);
|
||||
if (isset($bs[1])) {
|
||||
$baseSub = $bs[1];
|
||||
} else {
|
||||
$baseSub= $sp['filename'];
|
||||
}
|
||||
|
||||
$child_file = $sp['dirname'] . '/' . $sp['basename'];
|
||||
if ($req == site_path() . "/" . $filename . "/" . $baseSub) {
|
||||
$classSub .= ' active';
|
||||
|
|
@ -2721,9 +2758,15 @@ function sitemap_page_path()
|
|||
foreach ($posts as $index => $v) {
|
||||
|
||||
$post = new stdClass;
|
||||
|
||||
$fn = explode('.', $v['filename']);
|
||||
|
||||
if (isset($fn[1])) {
|
||||
$filename = $fn[1];
|
||||
} else {
|
||||
$filename= $v['filename'];
|
||||
}
|
||||
|
||||
// Filename
|
||||
$filename= $v['filename'];
|
||||
$file = $v['dirname'] . '/' . $v['basename'];
|
||||
$post->url = site_url() . $filename;
|
||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($file)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue