1
0

AdventOfCode

This commit is contained in:
Mike Schwörer 2020-01-17 00:36:37 +01:00
parent b5f8543da2
commit 81e129effa
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 39 additions and 33 deletions

View File

@ -1,8 +1,17 @@
<?php
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/adventofcode.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'];
$year = $post['extras']['aoc:year'];
@ -11,7 +20,7 @@ $year = $post['extras']['aoc:year'];
<div class="boxedcontent blogcontent_plain">
<div style="position: relative;">
<a href="<?php echo AdventOfCode::getGithubLink($year); ?>" style="position: absolute; top: 0; right: 0; border: 0;">
<a href="<?php echo $SITE->modules->AdventOfCode()->getGithubLink($year); ?>" style="position: absolute; top: 0; right: 0; border: 0;">
<img src="/data/images/blog/github_band.png" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
</div>
@ -21,16 +30,8 @@ $year = $post['extras']['aoc:year'];
</div>
<div class="bc_data">
<?php
$pd = new ParsedownCustom();
echo $pd->text(Blog::getPostFragment($post));
?>
<?php $SITE->renderMarkdown($SITE->modules->Blog()->getPostFragment($post)); ?>
<br/>
<?php
global $PARAM_AOCCALENDAR;
$PARAM_AOCCALENDAR = ['year' => $year, 'nav'=>true, 'linkheader'=>false, 'ajax'=>false];
require (__DIR__ . '/../fragments/panel_aoc_calendar.php')
?>
<?php echo $SITE->fragments->PanelAdventOfCodeCalendar($year, true, false, false); ?>
</div>
</div>

View File

@ -1,23 +1,28 @@
<?php
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/blog.php');
require_once (__DIR__ . '/../internals/adventofcode.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'];
$subview = $parameter['subview'];
$year = $post['extras']['aoc:year'];
$subview = $OPTIONS['subview'];
$day = AdventOfCode::getDayFromStrIdent($year, $subview);
if ($day === NULL) httpError(404, 'AdventOfCode entry not found');
$pd = new ParsedownCustom();
$day = $SITE->modules->AdventOfCode()->getDayFromStrIdent($year, $subview);
if ($day === NULL) { $FRAME_OPTIONS->forceResult(404, 'AdventOfCode entry not found'); return; }
?>
<div class="boxedcontent base_markdown">
<div style="position: relative;">
<a href="<?php echo AdventOfCode::getGithubLink($year); ?>" style="position: absolute; top: 0; right: 0; border: 0;">
<a href="<?php echo $SITE->modules->AdventOfCode()->getGithubLink($year); ?>" style="position: absolute; top: 0; right: 0; border: 0;">
<img src="/data/images/blog/github_band.png" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
</div>
@ -43,7 +48,7 @@ $pd = new ParsedownCustom();
<b>Part <?php echo $i; ?>:</b>
<div class="bc_aoc_solution_parent">
<div class="bc_aoc_solution_code">
<pre><code class="<?php echo AdventOfCode::getLanguageCSS($day) ?>"><?php echo htmlspecialchars(AdventOfCode::getSolutionCode($day, $i-1)); ?></code></pre>
<pre><code class="<?php echo $SITE->modules->AdventOfCode()->getLanguageCSS($day) ?>"><?php echo htmlspecialchars($SITE->modules->AdventOfCode()->getSolutionCode($day, $i-1)); ?></code></pre>
</div>
<div class="bc_aoc_solution_value"><b>Result:</b> <?php echo $day['solutions'][$i-1]; ?></div>
</div>
@ -51,12 +56,12 @@ $pd = new ParsedownCustom();
<?php endfor; ?>
<?php includeAdditionalScript("/data/javascript/prism.js", 'defer'); ?>
<?php includeAdditionalStylesheet("/data/rawcss/prism.css"); ?>
<?php $FRAME_OPTIONS->addScript("/data/javascript/prism.js", true); ?>
<?php $FRAME_OPTIONS->addStylesheet("/data/rawcss/prism.css"); ?>
<div class="pagination">
<?php
$assocdays = AdventOfCode::listSingleYearAssociative($year);
$assocdays = $SITE->modules->AdventOfCode()->listSingleYearAssociative($year);
echo "<div class='pagAny'>";
for($i=0; $i < 25; $i++)

View File

@ -81,8 +81,8 @@ class AdventOfCode
$a['url_aoc'] = $yeardata['url-aoc'] . $a['day']; // adventofcode.com/{year}/day/{day}
$a['file_challenge'] = (__DIR__ . '/../statics/aoc/'.$year.'/'.$n2p.'_challenge.txt');
$a['file_input'] = (__DIR__ . '/../statics/aoc/'.$year.'/'.$n2p.'_input.txt');
$a['file_challenge'] = (__DIR__ . '/../../statics/aoc/'.$year.'/'.$n2p.'_challenge.txt');
$a['file_input'] = (__DIR__ . '/../../statics/aoc/'.$year.'/'.$n2p.'_input.txt');
$a['date'] = $year . '-' . 12 . '-' . $n2p;
@ -90,7 +90,7 @@ class AdventOfCode
for ($i=1; $i <= $a['parts']; $i++)
{
$solutionfiles []= (__DIR__ . '/../statics/aoc/' . $year . '/' . $n2p . '_solution-' . $i . '.' . self::LANGUAGES[$a['language']]['ext']);
$solutionfiles []= (__DIR__ . '/../../statics/aoc/' . $year . '/' . $n2p . '_solution-' . $i . '.' . self::LANGUAGES[$a['language']]['ext']);
}
$a['file_solutions'] = $solutionfiles;