ProjectEuler
This commit is contained in:
@@ -2,89 +2,131 @@
|
||||
|
||||
class Fragments
|
||||
{
|
||||
private function evalFragment($name, $url, $params)
|
||||
{
|
||||
try
|
||||
{
|
||||
ob_start();
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = $params;
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include (__DIR__ . '/../fragments/' . $url);
|
||||
}
|
||||
return ob_get_contents();
|
||||
}
|
||||
finally
|
||||
{
|
||||
ob_end_clean();
|
||||
}
|
||||
}
|
||||
|
||||
public function PanelEuler()
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ ];
|
||||
include (__DIR__ . '/../fragments/panel_euler.php');
|
||||
return $this->evalFragment('PanelEuler', 'panel_euler.php', [ ]);
|
||||
}
|
||||
|
||||
public function PanelPrograms()
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ ];
|
||||
include (__DIR__ . '/../fragments/panel_programs.php');
|
||||
return $this->evalFragment('PanelPrograms', 'panel_programs.php', [ ]);
|
||||
}
|
||||
|
||||
public function PanelBlog()
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ ];
|
||||
include (__DIR__ . '/../fragments/panel_blog.php');
|
||||
return $this->evalFragment('PanelBlog', 'panel_blog.php', [ ]);
|
||||
}
|
||||
|
||||
public function PanelBooks()
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ ];
|
||||
include (__DIR__ . '/../fragments/panel_books.php');
|
||||
return $this->evalFragment('PanelBooks', 'panel_books.php', [ ]);
|
||||
}
|
||||
|
||||
public function PanelAdventOfCode()
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ ];
|
||||
include (__DIR__ . '/../fragments/panel_aoc.php');
|
||||
return $this->evalFragment('PanelAdventOfCode', 'panel_aoc.php', [ ]);
|
||||
}
|
||||
|
||||
public function PanelAdventOfCodeCalendar(int $year, bool $shownav, bool $linkheader, bool $ajax, bool $frame=true, $frameid=null)
|
||||
{
|
||||
if ($frameid == null) $frameid = 'aoc_frame_' . getRandomToken(16);
|
||||
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'year' => $year, 'nav'=>$shownav, 'linkheader'=>$linkheader, 'ajax'=>$ajax, 'frame'=>$frame, 'frameid'=>$frameid ];
|
||||
include (__DIR__ . '/../fragments/panel_aoc_calendar.php');
|
||||
return $this->evalFragment('PanelAdventOfCodeCalendar', 'panel_aoc_calendar.php',
|
||||
[
|
||||
'year' => $year,
|
||||
'nav' => $shownav,
|
||||
'linkheader' => $linkheader,
|
||||
'ajax' => $ajax,
|
||||
'frame' => $frame,
|
||||
'frameid' => ($frameid == null) ? ('aoc_frame_' . getRandomToken(16)) : $frameid,
|
||||
]);
|
||||
}
|
||||
|
||||
public function BlogviewPlain(array $blogpost)
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
|
||||
include (__DIR__ . '/../fragments/blogview_plain.php');
|
||||
return $this->evalFragment('BlogviewPlain', 'blogview_plain.php',
|
||||
[
|
||||
'blogpost' => $blogpost,
|
||||
]);
|
||||
}
|
||||
|
||||
public function BlogviewMarkdown(array $blogpost)
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
|
||||
include (__DIR__ . '/../fragments/blogview_markdown.php');
|
||||
return $this->evalFragment('BlogviewMarkdown', 'blogview_markdown.php',
|
||||
[
|
||||
'blogpost' => $blogpost,
|
||||
]);
|
||||
}
|
||||
|
||||
public function BlogviewEulerList(array $blogpost)
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
|
||||
include (__DIR__ . '/../fragments/blogview_euler_list.php');
|
||||
return $this->evalFragment('BlogviewEulerList', 'blogview_euler_list.php',
|
||||
[
|
||||
'blogpost' => $blogpost,
|
||||
]);
|
||||
}
|
||||
|
||||
public function BlogviewEulerSingle(array $blogpost, string $subview)
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost, 'subview' => $subview ];
|
||||
include (__DIR__ . '/../fragments/blogview_euler_single.php');
|
||||
return $this->evalFragment('BlogviewEulerSingle', 'blogview_euler_single.php',
|
||||
[
|
||||
'blogpost' => $blogpost,
|
||||
'subview' => $subview,
|
||||
]);
|
||||
}
|
||||
|
||||
public function BlogviewAdventOfCodeList(array $blogpost)
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost ];
|
||||
include (__DIR__ . '/../fragments/blogview_aoc_list.php');
|
||||
return $this->evalFragment('BlogviewAdventOfCodeList', 'blogview_aoc_list.php',
|
||||
[
|
||||
'blogpost' => $blogpost,
|
||||
]);
|
||||
}
|
||||
|
||||
public function BlogviewAdventOfCodeSingle(array $blogpost, string $subview)
|
||||
{
|
||||
global $FRAGMENT_PARAM;
|
||||
$FRAGMENT_PARAM = [ 'blogpost' => $blogpost, 'subview' => $subview ];
|
||||
include (__DIR__ . '/../fragments/blogview_aoc_single.php');
|
||||
return $this->evalFragment('BlogviewAdventOfCodeSingle', 'blogview_aoc_single.php',
|
||||
[
|
||||
'blogpost' => $blogpost,
|
||||
'subview' => $subview,
|
||||
]);
|
||||
}
|
||||
|
||||
public function WidgetBefunge93(string $code, string $url, bool $interactive, int $speed, bool $editable)
|
||||
{
|
||||
return $this->evalFragment('WidgetBefunge93', 'widget_befunge93.php',
|
||||
[
|
||||
'code' => $code,
|
||||
'url' => $url,
|
||||
'interactive' => $interactive,
|
||||
'speed' => $speed,
|
||||
'editable' => $editable,
|
||||
]);
|
||||
}
|
||||
|
||||
public function WidgetBFJoust(string $codeLeft, string $codeRight)
|
||||
{
|
||||
return $this->evalFragment('WidgetBFJoust', 'widget_bfjoust.php',
|
||||
[
|
||||
'code_left' => $codeLeft,
|
||||
'code_right' => $codeRight,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,9 @@ class Euler
|
||||
$a['url_raw'] = 'https://raw.githubusercontent.com/Mikescher/Project-Euler_Befunge/master/processed/Euler_Problem-' . $n3p . '.b93';
|
||||
$a['url_github'] = 'https://github.com/Mikescher/Project-Euler_Befunge';
|
||||
|
||||
$a['file_description'] = (__DIR__ . '/../statics/euler/Euler_Problem-'.$n3p.'_description.md');
|
||||
$a['file_code'] = (__DIR__ . '/../statics/euler/Euler_Problem-'.$n3p.'.b93');
|
||||
$a['file_explanation'] = (__DIR__ . '/../statics/euler/Euler_Problem-'.$n3p.'_explanation.md');
|
||||
$a['file_description'] = (__DIR__ . '/../../statics/euler/Euler_Problem-'.$n3p.'_description.md');
|
||||
$a['file_code'] = (__DIR__ . '/../../statics/euler/Euler_Problem-'.$n3p.'.b93');
|
||||
$a['file_explanation'] = (__DIR__ . '/../../statics/euler/Euler_Problem-'.$n3p.'_explanation.md');
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
@@ -67,29 +67,14 @@ class ParsedownCustom extends ParsedownExtra
|
||||
|
||||
protected function handleBFJoust(array $Element)
|
||||
{
|
||||
global $PARAM_CODE_LEFT;
|
||||
global $PARAM_CODE_RIGHT;
|
||||
|
||||
$split = preg_split("/-{16,}/", $Element['text']);
|
||||
|
||||
$PARAM_CODE_LEFT = trim($split[0]);
|
||||
$PARAM_CODE_RIGHT = trim($split[1]);
|
||||
|
||||
return require (__DIR__ . '/../fragments/widget_bfjoust.php');
|
||||
return Website::inst()->fragments->WidgetBFJoust(trim($split[0]), trim($split[1]));
|
||||
}
|
||||
|
||||
protected function handleBef93(array $Element)
|
||||
{
|
||||
global $PARAM_BEFUNGE93RUNNER;
|
||||
$PARAM_BEFUNGE93RUNNER =
|
||||
[
|
||||
'code' => $Element['text'],
|
||||
'url' => '',
|
||||
'interactive' => $Element['b93_interactive'],
|
||||
'speed' => $Element['b93_speed'],
|
||||
'editable' => $Element['b93_editable'],
|
||||
];
|
||||
return require (__DIR__ . '/../fragments/widget_befunge93.php');
|
||||
return Website::inst()->fragments->WidgetBefunge93($Element['text'], '', $Element['b93_interactive'], $Element['b93_speed'], $Element['b93_editable']);
|
||||
}
|
||||
|
||||
protected function blockTable($Line, array $Block = null)
|
||||
|
||||
Reference in New Issue
Block a user