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 />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="python" />
<option name="program" value="python3" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="true" />

View File

@ -1,7 +1,17 @@
<?php
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/ParsedownCustom.php');
require_once (__DIR__ . '/../internals/website.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">
@ -11,10 +21,7 @@ require_once (__DIR__ . '/../internals/ParsedownCustom.php');
</div>
<div class="bc_data">
<?php
$pd = new ParsedownCustom();
echo $pd->text(Blog::getPostFragment($post));
?>
<?php echo $SITE->renderMarkdown($SITE->modules->Blog()->getPostFragment($post)); ?>
</div>
</div>

View File

@ -1,6 +1,17 @@
<?php
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/website.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">
@ -10,7 +21,7 @@ require_once (__DIR__ . '/../internals/blog.php');
</div>
<div class="bc_data">
<?php echo nl2br(htmlspecialchars(Blog::getPostFragment($post))); ?>
<?php echo nl2br(htmlspecialchars($SITE->modules->Blog()->getPostFragment($post))); ?>
</div>
</div>

View File

@ -12,7 +12,7 @@ require_once (__DIR__ . '/../internals/website.php');
<html lang="en">
<head>
<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"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<?php

View File

@ -12,7 +12,7 @@ require_once (__DIR__ . '/../internals/website.php');
<html lang="en">
<head>
<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"/>
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
<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 ];
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['file_fragment'] = __DIR__ . '/../statics/blog/' . $d['fragment'];
$d['file_fragment'] = __DIR__ . '/../../statics/blog/' . $d['fragment'];
if (!array_key_exists('extras', $d)) $d['extras'] = [];
@ -53,6 +53,12 @@ class Blog
return null;
}
/**
* @param string $id
* @param string $subview
* @param string $error
* @return array|null
*/
public function getFullBlogpost($id, $subview, &$error)
{
$post = $this->getBlogpost($id);

View File

@ -58,4 +58,10 @@ class PageFrameOptions
$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
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../extern/Parsedown.php');
require_once (__DIR__ . '/../extern/ParsedownExtra.php');
@ -71,7 +70,7 @@ class ParsedownCustom extends ParsedownExtra
global $PARAM_CODE_LEFT;
global $PARAM_CODE_RIGHT;
$split = preg_split("/\-{16,}/", $Element['text']);
$split = preg_split("/-{16,}/", $Element['text']);
$PARAM_CODE_LEFT = trim($split[0]);
$PARAM_CODE_RIGHT = trim($split[1]);

View File

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

View File

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

View File

@ -19,7 +19,7 @@ $debuginfo = $ROUTE->parameter['debuginfo'];
<div class="ev_master">
<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())): ?>
<p class="ev_statusmore"><?php echo nl2br($debuginfo); ?></p>
<?php endif; ?>