mirror of
https://github.com/danpros/htmly.git
synced 2026-04-23 14:06:23 +05:30
Basic Support for SubPages Ready to use.
Must Add CMS Funktions Add/Edit/delete to it. if Rename a Static page the subFolder must be renamed as well.
This commit is contained in:
parent
f7502b95b5
commit
fa77cc805b
3 changed files with 79 additions and 17 deletions
|
|
@ -374,7 +374,7 @@ function get_recent_pages() {
|
|||
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
|
||||
if (config("views.counter") == "true")
|
||||
echo '<td>' . $p->views . '</td>';
|
||||
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
|
||||
echo '<td><a href="' . $p->url . '/add?destination=admin">Add Sub</a> <a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
|
||||
echo '</tr>';
|
||||
|
||||
$shortUrl = substr($p->url,strrpos($p->url, "/") + 1);
|
||||
|
|
@ -384,8 +384,8 @@ function get_recent_pages() {
|
|||
{
|
||||
echo '<tr class="' . $class . '">';
|
||||
echo '<td> »<a target="_blank" href="' . $sp->url . '">' . $sp->title . '</a></td>';
|
||||
if (config("views.counter") == "true")
|
||||
echo '<td>' . $sp->views . '</td>';
|
||||
if (config("views.counter") == "true")
|
||||
echo '<td>' . $sp->views . '</td>';
|
||||
echo '<td><a href="' . $sp->url . '/edit?destination=admin">Edit</a> <a href="' . $sp->url . '/delete?destination=admin">Delete</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,24 @@ post('/login', function() {
|
|||
}
|
||||
});
|
||||
|
||||
get("/:static/:sub/edit", function($static,$sub){
|
||||
echo $static,$sub,"edit";
|
||||
die();
|
||||
});
|
||||
post("/:static/:sub/edit", function($static,$sub){
|
||||
echo $static,$sub,"edit.";
|
||||
die();
|
||||
});
|
||||
|
||||
get("/:static/:sub/delete", function($static,$sub){
|
||||
echo $static,$sub,"delete";
|
||||
die();
|
||||
});
|
||||
post("/:static/:sub/delete", function($static,$sub){
|
||||
echo $static,$sub,"delete.";
|
||||
die();
|
||||
});
|
||||
|
||||
// The blog post page
|
||||
get('/:year/:month/:name', function($year, $month, $name) {
|
||||
|
||||
|
|
@ -1098,6 +1116,14 @@ get('/admin/update/now/:csrf', function($CSRF) {
|
|||
}
|
||||
});
|
||||
|
||||
get('/:static/add', function($static){
|
||||
echo $static,"add";
|
||||
die();
|
||||
});
|
||||
post('/:static/add', function($static){
|
||||
echo $static,"add.";
|
||||
die();
|
||||
});
|
||||
|
||||
get('/:static/:sub', function($static,$sub) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1082,6 +1082,22 @@ function menu() {
|
|||
}
|
||||
}
|
||||
|
||||
function get_title_from_file($v)
|
||||
{
|
||||
// Get the contents and convert it to HTML
|
||||
$content = MarkdownExtra::defaultTransform(file_get_contents($v));
|
||||
|
||||
// Extract the title and body
|
||||
$arr = explode('t-->', $content);
|
||||
if (isset($arr[1])) {
|
||||
$title = str_replace('<!--t', '', $arr[0]);
|
||||
$title = rtrim(ltrim($title, ' '), ' ');
|
||||
} else {
|
||||
$title = str_replace('-', ' ', str_replace('.md', '', $base));
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
// Auto generate menu from static page
|
||||
function get_menu() {
|
||||
|
||||
|
|
@ -1116,23 +1132,43 @@ function get_menu() {
|
|||
$base = str_replace($replaced, '', $v);
|
||||
$url = site_url() . str_replace('.md', '', $base);
|
||||
|
||||
// Get the contents and convert it to HTML
|
||||
$content = MarkdownExtra::defaultTransform(file_get_contents($v));
|
||||
|
||||
// Extract the title and body
|
||||
$arr = explode('t-->', $content);
|
||||
if (isset($arr[1])) {
|
||||
$title = str_replace('<!--t', '', $arr[0]);
|
||||
$title = rtrim(ltrim($title, ' '), ' ');
|
||||
} else {
|
||||
$title = str_replace('-', ' ', str_replace('.md', '', $base));
|
||||
}
|
||||
|
||||
$title = get_title_from_file($v);
|
||||
|
||||
if (strpos($req, str_replace('.md', '', $base)) !== false) {
|
||||
echo '<li class="' . $class . ' active"><a href="' . $url . '">' . ucwords($title) . '</a></li>';
|
||||
$active = ' active';
|
||||
} else {
|
||||
echo '<li class="' . $class . '"><a href="' . $url . '">' . ucwords($title) . '</a></li>';
|
||||
$active = '';
|
||||
}
|
||||
echo '<li class="' . $class . '"' . $active . '>';
|
||||
|
||||
$subPages = get_static_sub_pages(str_replace('.md', '', $base));
|
||||
echo '<a href="' . $url . '">' . ucwords($title) . '</a><br/>';
|
||||
if(!empty($subPages))
|
||||
{
|
||||
echo '<ul>';
|
||||
|
||||
$iSub = 0;
|
||||
$countSub = count($subPages);
|
||||
foreach($subPages as $index => $sp)
|
||||
{
|
||||
$classSub = "item";
|
||||
if($iSub == 0)
|
||||
{
|
||||
$classSub .= " first";
|
||||
}
|
||||
if($iSub == $countSub -1)
|
||||
{
|
||||
$classSub .= " last";
|
||||
}
|
||||
$replacedSub = substr($sp, 0, strrpos($sp, '/')) . '/';
|
||||
$baseSub = str_replace($replacedSub, '', $sp);
|
||||
$urlSub = $url . "/" . str_replace('.md', '', $baseSub);
|
||||
echo '<li class="' . $classSub . '"><a href="' . $urlSub . '">» ' . get_title_from_file($sp) . '</a></li>';
|
||||
$iSub++;
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue