AoC single + prism + better additional css/js handling
This commit is contained in:
@@ -5,11 +5,6 @@ require_once (__DIR__ . '/../internals/adventofcode.php');
|
||||
|
||||
$year = $post['extras']['aoc:year'];
|
||||
|
||||
$assocdays = AdventOfCode::listSingleYearAssociative($year);
|
||||
|
||||
$prev_year = AdventOfCode::getPrevYear($year);
|
||||
$next_year = AdventOfCode::getNextYear($year);
|
||||
|
||||
?>
|
||||
|
||||
<div class="boxedcontent blogcontent_plain">
|
||||
@@ -26,37 +21,14 @@ $next_year = AdventOfCode::getNextYear($year);
|
||||
|
||||
<div class="bc_data">
|
||||
|
||||
<?php echo nl2br(Blog::getPostFragment($post)); ?>
|
||||
<?php echo nl2br(htmlspecialchars(Blog::getPostFragment($post))); ?>
|
||||
|
||||
<div class="aoc_calendar_parent">
|
||||
<div class="aoc_calendar">
|
||||
<div class="aoc_calendar_header">
|
||||
<?php
|
||||
if ($prev_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" ><</a>';
|
||||
else echo '<a href="#" class="aoc_calendar_header_link aoc_prev aoc_link_hidden" ><</a>';
|
||||
|
||||
echo '<span class="aoc_calendar_header_title">'.$year.'</span>';
|
||||
|
||||
if ($next_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >></a>';
|
||||
else echo '<a href="" class="aoc_calendar_header_link aoc_next aoc_link_hidden" >></a>';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
for ($i=0; $i<5; $i++)
|
||||
{
|
||||
echo '<div class="aoc_calendar_row">'."\n";
|
||||
for ($j=0; $j<5; $j++)
|
||||
{
|
||||
$day = $assocdays[$i*5+$j];
|
||||
if ($day === null) echo '<span class="aoc_calendar_field aoc_disabled">'.($i*5+$j+1).'</span>'."\n";
|
||||
else echo '<a href="'.$day['url'].'" class="aoc_calendar_field aoc_enabled" >'.($i*5+$j+1).'</a>'."\n";
|
||||
}
|
||||
echo '</div>'."\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
global $PARAM_AOCCALENDAR;
|
||||
$PARAM_AOCCALENDAR = ['year' => $year];
|
||||
require (__DIR__ . '/../fragments/panel_aoc_calendar.php')
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
67
www/fragments/blogview_aoc_single.php
Normal file
67
www/fragments/blogview_aoc_single.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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');
|
||||
|
||||
$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();
|
||||
|
||||
?>
|
||||
|
||||
<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;">
|
||||
<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>
|
||||
|
||||
<div class="bc_header">
|
||||
<?php echo $day['date']; ?>
|
||||
</div>
|
||||
|
||||
<div class="bc_data">
|
||||
|
||||
<div class="bce_header"><h1><a href="<?php echo $day['url_aoc']; ?>">Day <?php echo $day['day-padded']; ?></a>: <?php echo htmlspecialchars($day['title']); ?></h1></div>
|
||||
|
||||
<b>Description:</b>
|
||||
<div class="bc_aoc_description"><?php echo nl2br(htmlspecialchars(file_get_contents($day['file_challenge']))); ?></div>
|
||||
<br/>
|
||||
|
||||
<b>Input:</b>
|
||||
<div class="bc_aoc_input"><?php echo nl2br(htmlspecialchars(file_get_contents($day['file_input']))); ?></div>
|
||||
<br/>
|
||||
|
||||
<?php for ($i=1; $i<=$day['parts']; $i++): ?>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<div class="bc_aoc_solution_value"><b>Result:</b> <?php echo $day['solutions'][$i-1]; ?></div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php includeAdditionalScript("/data/javascript/prism.js", 'defer'); ?>
|
||||
<?php includeAdditionalStylesheet("/data/rawcss/prism.css"); ?>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<?php
|
||||
global $PARAM_AOCCALENDAR;
|
||||
$PARAM_AOCCALENDAR = ['year' => $year];
|
||||
require (__DIR__ . '/../fragments/panel_aoc_calendar.php')
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -10,7 +10,7 @@ require_once (__DIR__ . '/../internals/blog.php');
|
||||
</div>
|
||||
|
||||
<div class="bc_data">
|
||||
<?php echo nl2br(Blog::getPostFragment($post)); ?>
|
||||
<?php echo nl2br(htmlspecialchars(Blog::getPostFragment($post))); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
41
www/fragments/panel_aoc_calendar.php
Normal file
41
www/fragments/panel_aoc_calendar.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
global $PARAM_AOCCALENDAR;
|
||||
|
||||
$year = $PARAM_AOCCALENDAR['year'];
|
||||
|
||||
$assocdays = AdventOfCode::listSingleYearAssociative($year);
|
||||
$prev_year = AdventOfCode::getPrevYear($year);
|
||||
$next_year = AdventOfCode::getNextYear($year);
|
||||
|
||||
?>
|
||||
|
||||
<div class="aoc_calendar_parent">
|
||||
<div class="aoc_calendar">
|
||||
<div class="aoc_calendar_header">
|
||||
<?php
|
||||
if ($prev_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" ><</a>';
|
||||
else echo '<a href="#" class="aoc_calendar_header_link aoc_prev aoc_link_hidden" ><</a>';
|
||||
|
||||
echo '<span class="aoc_calendar_header_title">'.$year.'</span>';
|
||||
|
||||
if ($next_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >></a>';
|
||||
else echo '<a href="" class="aoc_calendar_header_link aoc_next aoc_link_hidden" >></a>';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
for ($i=0; $i<5; $i++)
|
||||
{
|
||||
echo '<div class="aoc_calendar_row">'."\n";
|
||||
for ($j=0; $j<5; $j++)
|
||||
{
|
||||
$day = $assocdays[$i*5+$j];
|
||||
if ($day === null) echo '<span class="aoc_calendar_field aoc_disabled">'.($i*5+$j+1).'</span>'."\n";
|
||||
else echo '<a href="'.$day['url'].'" class="aoc_calendar_field aoc_enabled" >'.($i*5+$j+1).'</a>'."\n";
|
||||
}
|
||||
echo '</div>'."\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,7 +58,7 @@ if ($interactive) {
|
||||
$result .= ' </div>' . "\n";
|
||||
$result .= '</div>' . "\n";
|
||||
|
||||
$result .= includeScriptOnce("/data/javascript/blogpost_bef93runner.js", false, '') . "\n";
|
||||
includeAdditionalScript("/data/javascript/blogpost_bef93runner.js");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -35,6 +35,6 @@ $result .= '</div>' . "\n";
|
||||
|
||||
$result .= '' . "\n";
|
||||
|
||||
$result .= includeScriptOnce("/data/javascript/blogpost_BFJoustBot_script.js", false, '') . "\n";
|
||||
includeAdditionalScript("/data/javascript/blogpost_BFJoustBot_script.js");
|
||||
|
||||
return $result;
|
||||
Reference in New Issue
Block a user