1
0
This commit is contained in:
Mike Schwörer 2020-01-16 10:50:18 +01:00
parent 76b4709d1a
commit 987a0a3c12
13 changed files with 156 additions and 103 deletions

View File

@ -34,7 +34,7 @@
<array /> <array />
</option> </option>
<option name="outputFromStdout" value="false" /> <option name="outputFromStdout" value="false" />
<option name="program" value="python" /> <option name="program" value="python3" />
<option name="runOnExternalChanges" value="true" /> <option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Project Files" /> <option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="true" /> <option name="trackOnlyRoot" value="true" />

View File

@ -1,7 +1,17 @@
<?php <?php
require_once (__DIR__ . '/../internals/base.php'); require_once (__DIR__ . '/../internals/website.php');
require_once (__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/ParsedownCustom.php'); /** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$post = $parameter['blogpost'];
?> ?>
<div class="boxedcontent blogcontent_markdown base_markdown"> <div class="boxedcontent blogcontent_markdown base_markdown">
@ -11,10 +21,7 @@ require_once (__DIR__ . '/../internals/ParsedownCustom.php');
</div> </div>
<div class="bc_data"> <div class="bc_data">
<?php <?php echo $SITE->renderMarkdown($SITE->modules->Blog()->getPostFragment($post)); ?>
$pd = new ParsedownCustom();
echo $pd->text(Blog::getPostFragment($post));
?>
</div> </div>
</div> </div>

View File

@ -1,6 +1,17 @@
<?php <?php
require_once (__DIR__ . '/../internals/base.php'); require_once (__DIR__ . '/../internals/website.php');
require_once (__DIR__ . '/../internals/blog.php');
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
global $FRAGMENT_PARAM;
/** @var array $parameter */
$parameter = $FRAGMENT_PARAM;
?>
<?php
$post = $parameter['blogpost'];
?> ?>
<div class="boxedcontent blogcontent_plain"> <div class="boxedcontent blogcontent_plain">
@ -10,7 +21,7 @@ require_once (__DIR__ . '/../internals/blog.php');
</div> </div>
<div class="bc_data"> <div class="bc_data">
<?php echo nl2br(htmlspecialchars(Blog::getPostFragment($post))); ?> <?php echo nl2br(htmlspecialchars($SITE->modules->Blog()->getPostFragment($post))); ?>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@ require_once (__DIR__ . '/../internals/website.php');
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $FRAME_OPTIONS->title; ?></title> <title><?php echo htmlspecialchars($FRAME_OPTIONS->title); ?></title>
<meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/> <meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/> <link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php <?php

View File

@ -12,7 +12,7 @@ require_once (__DIR__ . '/../internals/website.php');
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $FRAME_OPTIONS->title; ?></title> <title><?php echo htmlspecialchars($FRAME_OPTIONS->title); ?></title>
<meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/> <meta name="google-site-verification" content="pZOhmjeJcQbRMNa8xRLam4dwJ2oYwMwISY1lRKreSSs"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/> <link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<link rel="stylesheet" href="/data/css/styles.css" /> <link rel="stylesheet" href="/data/css/styles.css" />

View File

@ -45,4 +45,46 @@ class Fragments
$FRAGMENT_PARAM = [ 'year' => $year, 'nav'=>$shownav, 'linkheader'=>$linkheader, 'ajax'=>$ajax, 'frame'=>$frame, 'frameid'=>$frameid ]; $FRAGMENT_PARAM = [ 'year' => $year, 'nav'=>$shownav, 'linkheader'=>$linkheader, 'ajax'=>$ajax, 'frame'=>$frame, 'frameid'=>$frameid ];
include (__DIR__ . '/../fragments/panel_aoc_calendar.php'); include (__DIR__ . '/../fragments/panel_aoc_calendar.php');
} }
public function BlogviewPlain(array $blogpost)
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
include (__DIR__ . '/../fragments/blogview_plain.php');
}
public function BlogviewMarkdown(array $blogpost)
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
include (__DIR__ . '/../fragments/blogview_markdown.php');
}
public function BlogviewEulerList(array $blogpost)
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
include (__DIR__ . '/../fragments/blogview_euler_list.php');
}
public function BlogviewEulerSingle(array $blogpost, string $subview)
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost, 'subview' => $subview ];
include (__DIR__ . '/../fragments/blogview_euler_single.php');
}
public function BlogviewAdventOfCodeList(array $blogpost)
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
include (__DIR__ . '/../fragments/blogview_aoc_list.php');
}
public function BlogviewAdventOfCodeSingle(array $blogpost, string $subview)
{
global $FRAGMENT_PARAM;
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost, 'subview' => $subview ];
include (__DIR__ . '/../fragments/blogview_aoc_single.php');
}
} }

View File

@ -26,7 +26,7 @@ class Blog
$d['canonical'] = "https://www.mikescher.com" . $d['url']; $d['canonical'] = "https://www.mikescher.com" . $d['url'];
$d['file_fragment'] = __DIR__ . '/../statics/blog/' . $d['fragment']; $d['file_fragment'] = __DIR__ . '/../../statics/blog/' . $d['fragment'];
if (!array_key_exists('extras', $d)) $d['extras'] = []; if (!array_key_exists('extras', $d)) $d['extras'] = [];
@ -53,6 +53,12 @@ class Blog
return null; return null;
} }
/**
* @param string $id
* @param string $subview
* @param string $error
* @return array|null
*/
public function getFullBlogpost($id, $subview, &$error) public function getFullBlogpost($id, $subview, &$error)
{ {
$post = $this->getBlogpost($id); $post = $this->getBlogpost($id);

View File

@ -58,4 +58,10 @@ class PageFrameOptions
$this->scripts []= [ $url, $defer ]; $this->scripts []= [ $url, $defer ];
} }
public function setForced404(string $err)
{
$this->force_404 = true;
$this->force_404_message = $err;
}
} }

View File

@ -1,6 +1,5 @@
<?php <?php
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../extern/Parsedown.php'); require_once (__DIR__ . '/../extern/Parsedown.php');
require_once (__DIR__ . '/../extern/ParsedownExtra.php'); require_once (__DIR__ . '/../extern/ParsedownExtra.php');
@ -71,7 +70,7 @@ class ParsedownCustom extends ParsedownExtra
global $PARAM_CODE_LEFT; global $PARAM_CODE_LEFT;
global $PARAM_CODE_RIGHT; global $PARAM_CODE_RIGHT;
$split = preg_split("/\-{16,}/", $Element['text']); $split = preg_split("/-{16,}/", $Element['text']);
$PARAM_CODE_LEFT = trim($split[0]); $PARAM_CODE_LEFT = trim($split[0]);
$PARAM_CODE_RIGHT = trim($split[1]); $PARAM_CODE_RIGHT = trim($split[1]);

View File

@ -67,7 +67,7 @@ class Website
if ($result->force_404) if ($result->force_404)
{ {
$this->serveCustom404($route->full_url, $result); $this->serveCustom404($route->full_url, $result, $result->force_404_message);
exit(); exit();
} }
@ -79,7 +79,7 @@ class Website
} }
} }
private function serveCustom404(string $uri, PageFrameOptions $frameOpt) private function serveCustom404(string $uri, PageFrameOptions $frameOpt, string $message)
{ {
try try
{ {
@ -88,6 +88,8 @@ class Website
$route = URLRoute::getNotFoundRoute($uri); $route = URLRoute::getNotFoundRoute($uri);
$route->parameter['message'] = $message;
$result = $route->getDirect($this, $frameOpt); $result = $route->getDirect($this, $frameOpt);
$this->output($result, $route); $this->output($result, $route);
@ -184,6 +186,13 @@ class Website
setcookie("mikescher_auth", "", time()+30); setcookie("mikescher_auth", "", time()+30);
} }
public function renderMarkdown(string $txt)
{
require_once 'parsedowncustom.php';
$pd = new ParsedownCustom();
return $pd->text($txt);
}
} }
/** /**

View File

@ -1,36 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<?php <?php
require_once (__DIR__ . '/../internals/base.php'); require_once (__DIR__ . '/../internals/website.php');
require_once (__DIR__ . '/../internals/blog.php');
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
$id = $OPTIONS['id']; /** @var URLRoute $ROUTE */ global $ROUTE;
$subview = $OPTIONS['subview']; /** @var Website $SITE */ global $SITE;
?>
$post = Blog::getFullBlogpost($id, $subview, $err);
if ($post === null) httpError(404, $err); <?php
$id = $ROUTE->parameter['id'];
?> $subview = $ROUTE->parameter['subview'];
<head>
<meta charset="utf-8"> $post = $SITE->modules->Blog()->getFullBlogpost($id, $subview, $err);
<title>Mikescher.com - <?php echo htmlspecialchars($post['title']); ?></title> if ($post === null) { $FRAME_OPTIONS->setForced404($err); return; }
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php printHeaderCSS(); ?> $FRAME_OPTIONS->title = 'Mikescher.com - ' . $post['title'];
<?php echo '<link rel="canonical" href="' . $post['canonical'] . '"/>'; ?> $FRAME_OPTIONS->canonical_url = $post['canonical'];
</head>
<body> if ($post['type'] == 'euler')
<div id="mastercontainer"> $FRAME_OPTIONS->activeHeader = 'euler';
else if ($post['type'] == 'euler' && $post['issubview'])
<?php $FRAME_OPTIONS->activeHeader = 'aoc';
if ($post['type'] == 'euler') $HEADER_ACTIVE = 'euler'; else
else if ($post['type'] == 'euler' && $post['issubview']) $HEADER_ACTIVE = 'aoc'; $FRAME_OPTIONS->activeHeader = 'blog';
else $HEADER_ACTIVE = 'blog';
include (__DIR__ . '/../fragments/header.php');
?> ?>
<div id="content" class="content-responsive">
<div class="blockcontent"> <div class="blockcontent">
@ -38,35 +31,25 @@ include (__DIR__ . '/../fragments/header.php');
<?php <?php
if ($post['type'] === 'plain') { if ($post['type'] === 'plain')
{
include (__DIR__ . '/../fragments/blogview_plain.php'); $SITE->fragments->BlogviewPlain($post);
}
} elseif ($post['type'] === 'markdown') { elseif ($post['type'] === 'markdown')
{
include (__DIR__ . '/../fragments/blogview_markdown.php'); $SITE->fragments->BlogviewMarkdown($post);
}
} elseif ($post['type'] === 'euler') { elseif ($post['type'] === 'euler')
{
if ($subview === '') include (__DIR__ . '/../fragments/blogview_euler_list.php'); if ($subview === '') $SITE->fragments->BlogviewEulerList($post);
else include (__DIR__ . '/../fragments/blogview_euler_single.php'); else $SITE->fragments->BlogviewEulerSingle($post, $subview);
}
} elseif ($post['type'] === 'aoc') { elseif ($post['type'] === 'aoc')
{
if ($subview === '') include (__DIR__ . '/../fragments/blogview_aoc_list.php'); if ($subview === '') $SITE->fragments->BlogviewAdventOfCodeList($post);
else include (__DIR__ . '/../fragments/blogview_aoc_single.php'); else $SITE->fragments->BlogviewAdventOfCodeSingle($post, $subview);
} }
?> ?>
</div> </div>
</div>
<?php include (__DIR__ . '/../fragments/footer.php'); ?>
</div>
<?php printAdditionalScripts(); ?>
<?php printAdditionalStylesheets(); ?>
</body>
</html>

View File

@ -1,34 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<?php <?php
require_once (__DIR__ . '/../internals/base.php'); require_once (__DIR__ . '/../internals/website.php');
global $OPTIONS;
$errorcode = $OPTIONS['code']; /** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
$errormsg = $OPTIONS['message']; /** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
?> ?>
<head>
<meta charset="utf-8">
<title>Mikescher.com - <?php echo $errormsg; ?></title>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php printHeaderCSS(); ?>
</head>
<body>
<div id="mastercontainer">
<?php $HEADER_ACTIVE='none'; include (__DIR__ . '/../fragments/header.php'); ?> <?php
$message = isset($ROUTE->parameter['message']) ? $ROUTE->parameter['message'] : '';
$FRAME_OPTIONS->title = 'Mikescher.com - ' . $message;
$FRAME_OPTIONS->canonical_url = null;
$FRAME_OPTIONS->activeHeader = null;
$FRAME_OPTIONS->contentCSSClasses []= 'content-fullheight';
?>
<div id="content" class="content-responsive content-fullheight">
<div class="ev_master"> <div class="ev_master">
<div class="ev_code"><?php echo $errorcode; ?></div> <div class="ev_code">404</div>
<div class="ev_msg"><?php echo $errormsg; ?></div> <?php if ($message !== ''): ?>
<div class="ev_msg"><?php echo $message; ?></div>
<?php endif; ?>
</div> </div>
</div>
</div>
<?php printAdditionalScripts(); ?>
<?php printAdditionalStylesheets(); ?>
</body>
</html>

View File

@ -19,7 +19,7 @@ $debuginfo = $ROUTE->parameter['debuginfo'];
<div class="ev_master"> <div class="ev_master">
<div class="ev_code">500</div> <div class="ev_code">500</div>
<div class="ev_msg">asdasd<?php echo $message; ?></div> <div class="ev_msg"><?php echo $message; ?></div>
<?php if ($debuginfo !== null && strlen($debuginfo)>0 && ($SITE != null && !$SITE->isProd())): ?> <?php if ($debuginfo !== null && strlen($debuginfo)>0 && ($SITE != null && !$SITE->isProd())): ?>
<p class="ev_statusmore"><?php echo nl2br($debuginfo); ?></p> <p class="ev_statusmore"><?php echo nl2br($debuginfo); ?></p>
<?php endif; ?> <?php endif; ?>