MyNoVi/index.php

44 lines
1.2 KiB
PHP

<?php
require 'vendor/autoload.php';
require 'apps/apps.php';
$dir = $_GET['dir'] ?? '';
$file = $_GET['file'] ?? '';
if (!empty($dir)) {
$dir = filter_input(INPUT_GET, 'dir', FILTER_SANITIZE_STRING);
}
if (isset($file)) {
$file = filter_input(INPUT_GET, 'file', FILTER_SANITIZE_STRING);
}
if (empty($file) || !file_exists('content/' . urldecode($dir) . '/' . urldecode($file) . '.md')) {
$dir = '';
if (file_exists('content/index.md')) {
$file = 'index';
} else {
$file = 'default';
}
}
$Parsedown = new ParsedownToc();
$content = file_get_contents('content/' . urldecode($dir) . '/' . urldecode($file) . '.md');
$options = array('selectors' => array('h2', 'h3'));
$Parsedown = new ParsedownToc($options);
$body = $Parsedown->text($content);
$toc = $Parsedown->contentsList();
$body = str_replace("[ ]", '<input type="checkbox" disabled>', $body);
$body = str_replace("[x]", '<input type="checkbox" checked disabled>', $body);
$body = str_replace("</h2>", ' <a href="#" class="backTop">⬆️</a></h2>', $body);
$body = str_replace("</h3>", ' <a href="#" class="backTop">⬆️</a></h3>', $body);
require 'tpl/header.html';
require 'tpl/aside.html';
require 'tpl/main.html';
require 'tpl/footer.html';