more dynamic header
This commit is contained in:
parent
cf6c496b34
commit
6f90fb912b
@ -15,6 +15,8 @@ $post = $parameter['blogpost'];
|
||||
|
||||
$year = $post['extras']['aoc:year'];
|
||||
|
||||
$FRAME_OPTIONS->alternative_url = "/adventofcode/$year";
|
||||
|
||||
?>
|
||||
|
||||
<div class="boxedcontent blogcontent_plain">
|
||||
|
@ -17,6 +17,8 @@ $year = $post['extras']['aoc:year'];
|
||||
|
||||
$day = $SITE->modules->AdventOfCode()->getDayFromStrIdent($year, $subview);
|
||||
if ($day === NULL) { $FRAME_OPTIONS->forceResult(404, 'AdventOfCode entry not found'); return; }
|
||||
|
||||
$FRAME_OPTIONS->alternative_url = $day['url-alternative'];
|
||||
?>
|
||||
|
||||
<div class="boxedcontent base_markdown">
|
||||
|
@ -24,6 +24,8 @@ require_once (__DIR__ . '/../internals/website.php');
|
||||
<link rel="icon" type="image/png" href="/data/images/favicon.png"/>
|
||||
<?php
|
||||
if ($FRAME_OPTIONS->canonical_url !== null) echo '<link rel="canonical" href="'.$FRAME_OPTIONS->canonical_url.'"/>' . "\n";
|
||||
if ($FRAME_OPTIONS->alternative_url !== null) echo '<link rel="alternate" href="'.$FRAME_OPTIONS->alternative_url.'"/>' . "\n";
|
||||
|
||||
foreach ($FRAME_OPTIONS->stylesheets as $cssfile) echo '<link rel="stylesheet" href="' . $cssfile . '"/>' . "\n";
|
||||
foreach ($FRAME_OPTIONS->scripts as $scriptfile)
|
||||
{
|
||||
@ -41,15 +43,37 @@ require_once (__DIR__ . '/../internals/website.php');
|
||||
</div>
|
||||
|
||||
<div class="tabrow">
|
||||
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'home') echo 'tab_active'; ?>" href="/">Home</a>
|
||||
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'euler') echo 'tab_active'; ?>" href="/blog/1/Project_Euler_with_Befunge">Project Euler</a>
|
||||
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'blog') echo 'tab_active'; ?>" href="/blog">Blog</a>
|
||||
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'programs') echo 'tab_active'; ?>" href="/programs">Programs</a>
|
||||
|
||||
<?php if ($FRAME_OPTIONS->activeHeader === 'aoc' || intval(date('m')) === 12): ?>
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'aoc') echo 'tab_active'; ?>" href="/adventofcode">Advent of Code</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($FRAME_OPTIONS->activeHeader === 'books'): ?>
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'books') echo 'tab_active'; ?>" href="/books">Books</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'webapps') echo 'tab_active'; ?>" href="/webapps">Tools</a>
|
||||
<?php if ($SITE->isLoggedInByCookie()): ?><a class="tab tab_admin" href="/admin">Admin</a><?php endif; ?>
|
||||
|
||||
<?php if ($SITE->isLoggedInByCookie()): ?>
|
||||
<a class="tab tab_admin" href="/admin">Admin</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<a class="tab <?php if ($FRAME_OPTIONS->activeHeader === 'about') echo 'tab_active'; ?>" href="/about">About</a>
|
||||
|
||||
<div class="tab_split" ></div>
|
||||
<?php if ($SITE->isLoggedInByCookie()): ?><a class="tab tab_logout" href="/logout"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-8 0 40 32"><path d="m 18,24 0,4 -14,0 0,-24 14,0 0,4 4,0 0,-8 -22,0 0,32 22,0 0,-8 z m -6,-4.003 0,-8 12,0 0,-4 8,8 -8,8 0,-4 z"></path></svg></a><?php endif; ?>
|
||||
|
||||
<?php if ($SITE->isLoggedInByCookie()): ?>
|
||||
<a class="tab tab_logout" href="/logout"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-8 0 40 32"><path d="m 18,24 0,4 -14,0 0,-24 14,0 0,4 4,0 0,-8 -22,0 0,32 22,0 0,-8 z m -6,-4.003 0,-8 12,0 0,-4 8,8 -8,8 0,-4 z"></path></svg></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<a class="tab tab_github" href="https://github.com/Mikescher/">Github</a>
|
||||
</div>
|
||||
|
||||
|
@ -60,6 +60,10 @@ $URL_RULES =
|
||||
[ 'url' => ['log', '?{id}', '?{name}', '?{subview}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ],
|
||||
[ 'url' => ['blogpost', 'view'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%GET%', 'subview' => '' ], ],
|
||||
|
||||
[ 'url' => ['adventofcode'], 'target' => 'adventofcode_year.php', 'options' => [ ], 'parameter' => [ 'year' => '' ], ],
|
||||
[ 'url' => ['adventofcode', '?{year}'], 'target' => 'adventofcode_year.php', 'options' => [ ], 'parameter' => [ 'year' => '%URL%' ], ],
|
||||
[ 'url' => ['adventofcode', '?{year}', '?{day}'], 'target' => 'adventofcode_day.php', 'options' => [ ], 'parameter' => [ 'year' => '%URL%', 'day' => '%URL%' ], ],
|
||||
|
||||
[ 'url' => ['webapps'], 'target' => 'webapps_list.php', 'options' => [ ], 'parameter' => [ ], ],
|
||||
|
||||
[ 'url' => ['highscores', 'list.php'], 'target' => 'highscores_listentries.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ],
|
||||
|
@ -84,6 +84,7 @@ class AdventOfCode implements IWebsiteModule
|
||||
$a['day-padded'] = $n2p;
|
||||
|
||||
$a['url'] = '/blog/' . $yeardata['blog-id'] . '/Advent_of_Code_' . $year . '/day-' . $n2p;
|
||||
$a['url-alternative'] = '/adventofcode/' . $year . '/' . $n2p;
|
||||
$a['canonical'] = "https://www.mikescher.com" . $a['url'];
|
||||
|
||||
$a['url_aoc'] = $yeardata['url-aoc'] . $a['day']; // adventofcode.com/{year}/day/{day}
|
||||
|
@ -102,6 +102,8 @@ class SelfTest implements IWebsiteModule
|
||||
$this->addMethodPathStatus( "web::aoc::aoc-404-1", 404, '/blog/25/Advent_of_Code_2017/day-26');
|
||||
$this->addMethodPathStatus( "web::aoc::aoc-404-2", 404, '/blog/23/Advent_of_Code_2018/day-27');
|
||||
$this->addMethodPathStatus( "web::aoc::aoc-404-3", 404, '/blog/24/Advent_of_Code_2019/day-28');
|
||||
$this->addMethodMultiPathStatus("web::aoc::aoc-redirect-1", 302, '{0}', function(){ return array_key_map(Website::inst()->modules->AdventOfCode()->listAllDays(), 'url-alternative'); });
|
||||
$this->addMethodMultiPathStatus("web::aoc::aoc-redirect-1", 302, '/adventofcode/{0}', function(){ return Website::inst()->modules->AdventOfCode()->listYears(); });
|
||||
|
||||
$this->addCheckConsistency("modules::database::database-check-consistency", function(){ return Website::inst()->modules->Database(); });
|
||||
$this->addCheckConsistency("modules::blog::blog-check-consistency", function(){ return Website::inst()->modules->Blog(); });
|
||||
|
@ -36,6 +36,9 @@ class PageFrameOptions
|
||||
/** @var string */
|
||||
public $canonical_url = null;
|
||||
|
||||
/** @var string */
|
||||
public $alternative_url = null;
|
||||
|
||||
/** @var string[] */
|
||||
public $contentCSSClasses = [ 'content-responsive' ];
|
||||
|
||||
|
@ -283,4 +283,8 @@ function curl_http_request($url)
|
||||
return [ 'output'=>$output, 'statuscode'=>$httpcode, 'redirect'=>$redirect, 'errnum'=>$errnum, 'errstr'=>$errmsg ];
|
||||
}
|
||||
|
||||
function array_last(array $arr)
|
||||
{
|
||||
return $arr[count($arr)-1];
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Website
|
||||
|
||||
if ($result->force_redirect)
|
||||
{
|
||||
header('Location: ' . $result->force_redirect_url);
|
||||
header('Location: ' . $result->force_redirect_url); // http 302: Found
|
||||
exit();
|
||||
}
|
||||
|
||||
|
21
www/pages/adventofcode_day.php
Normal file
21
www/pages/adventofcode_day.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require_once (__DIR__ . '/../internals/website.php');
|
||||
|
||||
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||
/** @var Website $SITE */ global $SITE;
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
$year = intval($ROUTE->parameter['year']);
|
||||
$day = intval($ROUTE->parameter['day']);
|
||||
|
||||
if ($SITE->modules->AdventOfCode()->getSingleDay($year, $day) === null)
|
||||
{
|
||||
$FRAME_OPTIONS->setForced404('Advent of Code not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$FRAME_OPTIONS->setForcedRedirect($SITE->modules->AdventOfCode()->getSingleDay($year, $day)['url']);
|
||||
?>
|
32
www/pages/adventofcode_year.php
Normal file
32
www/pages/adventofcode_year.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once (__DIR__ . '/../internals/website.php');
|
||||
|
||||
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||
/** @var Website $SITE */ global $SITE;
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
if ($ROUTE->parameter['year'] === '')
|
||||
{
|
||||
$year = array_last($SITE->modules->AdventOfCode()->listYears());
|
||||
$FRAME_OPTIONS->setForcedRedirect($SITE->modules->AdventOfCode()->getURLForYear($year));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$year = intval($ROUTE->parameter['year']);
|
||||
|
||||
if (in_array($year, $SITE->modules->AdventOfCode()->listYears()))
|
||||
{
|
||||
$FRAME_OPTIONS->setForcedRedirect($SITE->modules->AdventOfCode()->getURLForYear($year));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$FRAME_OPTIONS->setForced404('Advent of Code not found');
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
@ -18,7 +18,7 @@ $FRAME_OPTIONS->canonical_url = $post['canonical'];
|
||||
|
||||
if ($post['type'] == 'euler')
|
||||
$FRAME_OPTIONS->activeHeader = 'euler';
|
||||
else if ($post['type'] == 'euler' && $post['issubview'])
|
||||
else if ($post['type'] == 'aoc')
|
||||
$FRAME_OPTIONS->activeHeader = 'aoc';
|
||||
else
|
||||
$FRAME_OPTIONS->activeHeader = 'blog';
|
||||
|
@ -14,7 +14,7 @@ if ($book === null) { $FRAME_OPTIONS->setForced404("Books not found"); return; }
|
||||
|
||||
$FRAME_OPTIONS->title = $book['title'];
|
||||
$FRAME_OPTIONS->canonical_url = $book['url'];
|
||||
$FRAME_OPTIONS->activeHeader = 'book';
|
||||
$FRAME_OPTIONS->activeHeader = 'books';
|
||||
|
||||
$FRAME_OPTIONS->addScript('/data/javascript/ms_basic.js', true);
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user