|
|
|
@ -23,12 +23,6 @@ else |
|
|
|
|
if (file_exists(SITE . "/config.ini")) |
|
|
|
|
$config = parse_ini_file(SITE . "/config.ini"); |
|
|
|
|
|
|
|
|
|
if (!isset($config['trueBlack'])) |
|
|
|
|
$config['trueBlack'] = false; |
|
|
|
|
|
|
|
|
|
if (!isset($config['siteTitle'])) |
|
|
|
|
$config['siteTitle'] = "Site"; |
|
|
|
|
|
|
|
|
|
if (!isset($config['css'])) |
|
|
|
|
$config['css'] = true; |
|
|
|
|
|
|
|
|
@ -52,18 +46,11 @@ require ROOT . "/less.php/lib/Less/Autoloader.php"; |
|
|
|
|
Less_Autoloader::register(); |
|
|
|
|
|
|
|
|
|
$colorScheme = array( |
|
|
|
|
"darkColor" => "#2a2a2a", |
|
|
|
|
"darkerColor" => "#222222", |
|
|
|
|
"darkColor" => "black", |
|
|
|
|
"lightColor" => "white", |
|
|
|
|
"lightlessColor" => "#eeeeee", |
|
|
|
|
"mainColor" => "red", |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($config['trueBlack']) { |
|
|
|
|
$colorScheme['darkColor'] = "#000000"; |
|
|
|
|
$colorScheme['darkerColor'] = "#000000"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$options = array( |
|
|
|
|
'cache_dir' => SITE . '/css', |
|
|
|
|
'compress' => true, |
|
|
|
@ -114,21 +101,11 @@ foreach ($pages as $page) { |
|
|
|
|
if ($pathParts['extension'] === "gmi") { |
|
|
|
|
$gmilines = explode("\n", file_get_contents($pathParts['dirname'] . "/" . $pathParts['basename'])); |
|
|
|
|
|
|
|
|
|
if (substr($gmilines[0], 0, 2) === "# ") |
|
|
|
|
$title = substr($gmilines[0], 2); |
|
|
|
|
else |
|
|
|
|
$title = NULL; |
|
|
|
|
|
|
|
|
|
foreach ($gmilines as $key => $line) { |
|
|
|
|
if (substr($line, 0, 2) === "=>") { |
|
|
|
|
preg_match("/=> +(.[^ ]+)/", $line, $lnUrl); |
|
|
|
|
preg_match("/=> +.[^ ]+ +(.+)/", $line, $lnTitle); |
|
|
|
|
|
|
|
|
|
// Escape Markdown special characters |
|
|
|
|
$mdSpecial = array("[", "]", "(", ")"); |
|
|
|
|
$htmlEntities = array("[", "]", "(", ")"); |
|
|
|
|
$lnUrl[1] = str_replace($mdSpecial, $htmlEntities, $lnUrl[1]); |
|
|
|
|
|
|
|
|
|
$urlPathParts = pathinfo(parse_url($lnUrl[1], PHP_URL_PATH)); |
|
|
|
|
|
|
|
|
|
// .gmi > .md for local links |
|
|
|
@ -136,7 +113,6 @@ foreach ($pages as $page) { |
|
|
|
|
$lnUrl[1] = $urlPathParts['dirname'] . "/" . $urlPathParts['filename'] . ".md"; |
|
|
|
|
|
|
|
|
|
if (isset($lnTitle[1])) { |
|
|
|
|
$lnTitle[1] = str_replace($mdSpecial, $htmlEntities, $lnTitle[1]); |
|
|
|
|
$gmilines[$key] = "[" . $lnTitle[1] . "](" . $lnUrl[1] . ")"; |
|
|
|
|
} else { |
|
|
|
|
$gmilines[$key] = "[" . $lnUrl[1] . "](" . $lnUrl[1] . ")"; |
|
|
|
@ -152,13 +128,18 @@ foreach ($pages as $page) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Compile Markdown to HTML with Parsedown |
|
|
|
|
$markdown = file_get_contents($pathParts['dirname'] . "/" . $pathParts['filename'] . ".md"); |
|
|
|
|
if (preg_match("/# (.*)\\n/", $markdown, $matches)) // If a main heading is found |
|
|
|
|
$title = $matches[1]; // Then it will be the HTML page <title> |
|
|
|
|
else |
|
|
|
|
$title = NULL; |
|
|
|
|
require_once ROOT . "/parsedown/Parsedown.php"; |
|
|
|
|
require_once ROOT . "/parsedown-extra/ParsedownExtra.php"; |
|
|
|
|
$Parsedown = new ParsedownExtra; |
|
|
|
|
$Parsedown = $Parsedown->setUrlsLinked(false); |
|
|
|
|
$Parsedown = $Parsedown->setMarkupEscaped(false); |
|
|
|
|
$Parsedown = $Parsedown->setBreaksEnabled(true); |
|
|
|
|
$pageContent = $Parsedown->text(file_get_contents($pathParts['dirname'] . "/" . $pathParts['filename'] . ".md")); |
|
|
|
|
$pageContent = $Parsedown->text($markdown); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// .md > .html for local links |
|
|
|
@ -167,31 +148,38 @@ foreach ($pages as $page) { |
|
|
|
|
|
|
|
|
|
// Add header and footer to HTML |
|
|
|
|
|
|
|
|
|
$urlPath = str_replace(SITE, "", $pathParts['dirname']); |
|
|
|
|
$relativePathToRoot = ""; |
|
|
|
|
for ($i = substr_count($urlPath, "/") ; $i > 0 ; $i--) |
|
|
|
|
$relativePathToRoot .= "../"; |
|
|
|
|
|
|
|
|
|
ob_start(); |
|
|
|
|
|
|
|
|
|
?> |
|
|
|
|
<!DOCTYPE html> |
|
|
|
|
<html lang="<?php |
|
|
|
|
|
|
|
|
|
preg_match("#\.([a-zA-Z-]{2,5})\.#", $pathParts['basename'], $lang); |
|
|
|
|
preg_match("#\.([a-zA-Z-]{2,5})\.#", $pathParts['basename'], $lang); |
|
|
|
|
|
|
|
|
|
if (isset($lang[1])) |
|
|
|
|
echo $lang[1]; |
|
|
|
|
else |
|
|
|
|
echo $config['defaultLang']; |
|
|
|
|
if (isset($lang[1])) |
|
|
|
|
echo $lang[1]; |
|
|
|
|
else |
|
|
|
|
echo $config['defaultLang']; |
|
|
|
|
|
|
|
|
|
?>"> |
|
|
|
|
<head> |
|
|
|
|
<meta charset="UTF-8"> |
|
|
|
|
<title><?php |
|
|
|
|
if (isset($title) AND !is_null($title)) |
|
|
|
|
echo $title . " · " . $config['siteTitle']; |
|
|
|
|
else |
|
|
|
|
echo $config['siteTitle']; |
|
|
|
|
?></title> |
|
|
|
|
<?php |
|
|
|
|
if (isset($title) AND !is_null($title) AND isset($config['siteTitle'])) |
|
|
|
|
echo "<title>" . $title . " · " . $config['siteTitle'] . "</title>"; |
|
|
|
|
else if (isset($title) AND !is_null($title)) |
|
|
|
|
echo "<title>" . $title . "</title>"; |
|
|
|
|
else if (isset($config['siteTitle'])) |
|
|
|
|
echo "<title>" . $config['siteTitle'] . "</title>"; |
|
|
|
|
?> |
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
|
|
|
<?php if ($config['css']) { ?> |
|
|
|
|
<link type="text/css" rel="stylesheet" media="screen" href="/css/<?= CSS_FILENAME ?>">
|
|
|
|
|
<link rel="stylesheet" media="screen" href="<?= $relativePathToRoot ?>css/<?= CSS_FILENAME ?>">
|
|
|
|
|
<?php } ?> |
|
|
|
|
<?php |
|
|
|
|
if (file_exists(SITE . "/head.inc.html")) |
|
|
|
@ -204,7 +192,7 @@ else |
|
|
|
|
if ($config['header']) { |
|
|
|
|
?> |
|
|
|
|
<header> |
|
|
|
|
<a id="lienHeader" href="/"> |
|
|
|
|
<a id="lienHeader" href="./<?= $relativePathToRoot ?>">
|
|
|
|
|
<?php |
|
|
|
|
if (file_exists(SITE . "/img/logo.webp")) |
|
|
|
|
echo '<img src="img/logo.webp" ' . getimagesize(SITE . "/img/logo.webp")[3] . ' alt="' . $config['siteTitle'] . '" />'; |
|
|
|
|