Changes
This commit is contained in:
parent
450299e95a
commit
7a2272a263
2 changed files with 96 additions and 109 deletions
66
mkht.php
66
mkht.php
|
@ -23,12 +23,6 @@ else
|
||||||
if (file_exists(SITE . "/config.ini"))
|
if (file_exists(SITE . "/config.ini"))
|
||||||
$config = parse_ini_file(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']))
|
if (!isset($config['css']))
|
||||||
$config['css'] = true;
|
$config['css'] = true;
|
||||||
|
|
||||||
|
@ -52,18 +46,11 @@ require ROOT . "/less.php/lib/Less/Autoloader.php";
|
||||||
Less_Autoloader::register();
|
Less_Autoloader::register();
|
||||||
|
|
||||||
$colorScheme = array(
|
$colorScheme = array(
|
||||||
"darkColor" => "#2a2a2a",
|
"darkColor" => "black",
|
||||||
"darkerColor" => "#222222",
|
|
||||||
"lightColor" => "white",
|
"lightColor" => "white",
|
||||||
"lightlessColor" => "#eeeeee",
|
|
||||||
"mainColor" => "red",
|
"mainColor" => "red",
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($config['trueBlack']) {
|
|
||||||
$colorScheme['darkColor'] = "#000000";
|
|
||||||
$colorScheme['darkerColor'] = "#000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
'cache_dir' => SITE . '/css',
|
'cache_dir' => SITE . '/css',
|
||||||
'compress' => true,
|
'compress' => true,
|
||||||
|
@ -114,21 +101,11 @@ foreach ($pages as $page) {
|
||||||
if ($pathParts['extension'] === "gmi") {
|
if ($pathParts['extension'] === "gmi") {
|
||||||
$gmilines = explode("\n", file_get_contents($pathParts['dirname'] . "/" . $pathParts['basename']));
|
$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) {
|
foreach ($gmilines as $key => $line) {
|
||||||
if (substr($line, 0, 2) === "=>") {
|
if (substr($line, 0, 2) === "=>") {
|
||||||
preg_match("/=> +(.[^ ]+)/", $line, $lnUrl);
|
preg_match("/=> +(.[^ ]+)/", $line, $lnUrl);
|
||||||
preg_match("/=> +.[^ ]+ +(.+)/", $line, $lnTitle);
|
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));
|
$urlPathParts = pathinfo(parse_url($lnUrl[1], PHP_URL_PATH));
|
||||||
|
|
||||||
// .gmi > .md for local links
|
// .gmi > .md for local links
|
||||||
|
@ -136,7 +113,6 @@ foreach ($pages as $page) {
|
||||||
$lnUrl[1] = $urlPathParts['dirname'] . "/" . $urlPathParts['filename'] . ".md";
|
$lnUrl[1] = $urlPathParts['dirname'] . "/" . $urlPathParts['filename'] . ".md";
|
||||||
|
|
||||||
if (isset($lnTitle[1])) {
|
if (isset($lnTitle[1])) {
|
||||||
$lnTitle[1] = str_replace($mdSpecial, $htmlEntities, $lnTitle[1]);
|
|
||||||
$gmilines[$key] = "[" . $lnTitle[1] . "](" . $lnUrl[1] . ")";
|
$gmilines[$key] = "[" . $lnTitle[1] . "](" . $lnUrl[1] . ")";
|
||||||
} else {
|
} else {
|
||||||
$gmilines[$key] = "[" . $lnUrl[1] . "](" . $lnUrl[1] . ")";
|
$gmilines[$key] = "[" . $lnUrl[1] . "](" . $lnUrl[1] . ")";
|
||||||
|
@ -152,13 +128,18 @@ foreach ($pages as $page) {
|
||||||
|
|
||||||
|
|
||||||
// Compile Markdown to HTML with Parsedown
|
// 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/Parsedown.php";
|
||||||
require_once ROOT . "/parsedown-extra/ParsedownExtra.php";
|
require_once ROOT . "/parsedown-extra/ParsedownExtra.php";
|
||||||
$Parsedown = new ParsedownExtra;
|
$Parsedown = new ParsedownExtra;
|
||||||
$Parsedown = $Parsedown->setUrlsLinked(false);
|
$Parsedown = $Parsedown->setUrlsLinked(false);
|
||||||
$Parsedown = $Parsedown->setMarkupEscaped(false);
|
$Parsedown = $Parsedown->setMarkupEscaped(false);
|
||||||
$Parsedown = $Parsedown->setBreaksEnabled(true);
|
$Parsedown = $Parsedown->setBreaksEnabled(true);
|
||||||
$pageContent = $Parsedown->text(file_get_contents($pathParts['dirname'] . "/" . $pathParts['filename'] . ".md"));
|
$pageContent = $Parsedown->text($markdown);
|
||||||
|
|
||||||
|
|
||||||
// .md > .html for local links
|
// .md > .html for local links
|
||||||
|
@ -167,31 +148,38 @@ foreach ($pages as $page) {
|
||||||
|
|
||||||
// Add header and footer to HTML
|
// Add header and footer to HTML
|
||||||
|
|
||||||
|
$urlPath = str_replace(SITE, "", $pathParts['dirname']);
|
||||||
|
$relativePathToRoot = "";
|
||||||
|
for ($i = substr_count($urlPath, "/") ; $i > 0 ; $i--)
|
||||||
|
$relativePathToRoot .= "../";
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<?php
|
<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]))
|
if (isset($lang[1]))
|
||||||
echo $lang[1];
|
echo $lang[1];
|
||||||
else
|
else
|
||||||
echo $config['defaultLang'];
|
echo $config['defaultLang'];
|
||||||
|
|
||||||
?>">
|
?>">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title><?php
|
<?php
|
||||||
if (isset($title) AND !is_null($title))
|
if (isset($title) AND !is_null($title) AND isset($config['siteTitle']))
|
||||||
echo $title . " · " . $config['siteTitle'];
|
echo "<title>" . $title . " · " . $config['siteTitle'] . "</title>";
|
||||||
else
|
else if (isset($title) AND !is_null($title))
|
||||||
echo $config['siteTitle'];
|
echo "<title>" . $title . "</title>";
|
||||||
?></title>
|
else if (isset($config['siteTitle']))
|
||||||
|
echo "<title>" . $config['siteTitle'] . "</title>";
|
||||||
|
?>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<?php if ($config['css']) { ?>
|
<?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 } ?>
|
||||||
<?php
|
<?php
|
||||||
if (file_exists(SITE . "/head.inc.html"))
|
if (file_exists(SITE . "/head.inc.html"))
|
||||||
|
@ -204,7 +192,7 @@ else
|
||||||
if ($config['header']) {
|
if ($config['header']) {
|
||||||
?>
|
?>
|
||||||
<header>
|
<header>
|
||||||
<a id="lienHeader" href="/">
|
<a id="lienHeader" href="./<?= $relativePathToRoot ?>">
|
||||||
<?php
|
<?php
|
||||||
if (file_exists(SITE . "/img/logo.webp"))
|
if (file_exists(SITE . "/img/logo.webp"))
|
||||||
echo '<img src="img/logo.webp" ' . getimagesize(SITE . "/img/logo.webp")[3] . ' alt="' . $config['siteTitle'] . '" />';
|
echo '<img src="img/logo.webp" ' . getimagesize(SITE . "/img/logo.webp")[3] . ' alt="' . $config['siteTitle'] . '" />';
|
||||||
|
|
139
style.less
139
style.less
|
@ -1,30 +1,6 @@
|
||||||
@light: ~"(prefers-color-scheme: light)";
|
@light: ~"(prefers-color-scheme: light)";
|
||||||
@dark: ~"(prefers-color-scheme: dark)";
|
@dark: ~"(prefers-color-scheme: dark)";
|
||||||
@fontSize: 30px;
|
@smallWidthScreen: ~"(max-width: 420px)";
|
||||||
|
|
||||||
* {
|
|
||||||
padding: 0px;
|
|
||||||
margin: 0px;
|
|
||||||
font-family: system-ui, sans-serif;
|
|
||||||
font-size: @fontSize;
|
|
||||||
line-height: 42px;
|
|
||||||
|
|
||||||
&:hover, &:focus {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media @light {
|
|
||||||
background-color: @lightColor;
|
|
||||||
color: @darkColor;
|
|
||||||
scrollbar-color: @darkColor @lightColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media @dark {
|
|
||||||
background-color: @darkColor;
|
|
||||||
color: @lightColor;
|
|
||||||
scrollbar-color: @lightColor @darkColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
@media @light {
|
@media @light {
|
||||||
|
@ -37,18 +13,42 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
|
||||||
|
@media @light {
|
||||||
|
scrollbar-color: @darkColor @lightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media @dark {
|
||||||
|
scrollbar-color: @lightColor @darkColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
font-family: system-ui, sans-serif;
|
||||||
|
font-size: 30px;
|
||||||
|
line-height: 42px;
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
|
|
||||||
|
@media @light {
|
||||||
|
background-color: @lightColor;
|
||||||
|
color: @darkColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media @dark {
|
||||||
|
background-color: @darkColor;
|
||||||
|
color: @lightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media @smallWidthScreen {
|
||||||
|
font-size: 26px;
|
||||||
|
line-height: 38px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
padding: 15px;
|
|
||||||
|
|
||||||
@media (max-width: 500px) {
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
margin-left: 20%;
|
margin-left: 20%;
|
||||||
margin-right: 20%;
|
margin-right: 20%;
|
||||||
|
|
||||||
|
@ -60,16 +60,28 @@ main {
|
||||||
@media (max-width: 800px) {
|
@media (max-width: 800px) {
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a, a:visited {
|
a, a:visited {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
transition-property: color, border-color;
|
transition-property: color, border-color;
|
||||||
transition-duration: 0.1s;
|
transition-duration: 0.05s;
|
||||||
transition-timing-function: linear;
|
transition-timing-function: linear;
|
||||||
|
|
||||||
&:hover, &:focus {
|
@media @light {
|
||||||
|
background-color: @lightColor;
|
||||||
|
color: @darkColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media @dark {
|
||||||
|
background-color: @darkColor;
|
||||||
|
color: @lightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover, &:focus {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: @mainColor;
|
color: @mainColor;
|
||||||
}
|
}
|
||||||
|
@ -134,22 +146,12 @@ strong {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre, *:not(pre) > code, var, samp {
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre, code, var, samp {
|
pre, code, var, samp {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
border-radius: 10px;
|
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
@media @dark {
|
border-radius: 15px;
|
||||||
background-color: @darkerColor;
|
word-break: break-all;
|
||||||
}
|
|
||||||
|
|
||||||
@media @light {
|
|
||||||
background-color: @lightlessColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abbr[title] {
|
abbr[title] {
|
||||||
|
@ -183,6 +185,11 @@ header, footer, .centered {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
// ----- TITLES -----
|
// ----- TITLES -----
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
@ -190,41 +197,33 @@ h1, h2, h3, h4, h5, h6 {
|
||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h1 > * {
|
|
||||||
font-size: @fontSize + 40;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
font-size: 70px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
}
|
margin-bottom: 20px;
|
||||||
|
|
||||||
h2, h2 > * {
|
@media @smallWidthScreen {
|
||||||
font-size: @fontSize + 30;
|
font-size: 45px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
margin-top: 50px;
|
font-size: 60px;
|
||||||
margin-bottom: 20px;
|
margin-top: 30px;
|
||||||
}
|
margin-bottom: 15px;
|
||||||
|
|
||||||
h3, h3 > * {
|
@media @smallWidthScreen {
|
||||||
font-size: @fontSize + 25;
|
font-size: 40px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
|
font-size: 42px;
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 15px;
|
||||||
}
|
|
||||||
|
|
||||||
h4, h4 > * {
|
@media @smallWidthScreen {
|
||||||
font-size: @fontSize + 18;
|
font-size: 35px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h5, h5 > * {
|
|
||||||
font-size: @fontSize + 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
h6, h6 > * {
|
|
||||||
font-size: @fontSize + 6;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue