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

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);
}
}
/**