Add warnings pointing to latest manual version on all old manual pages

This commit is contained in:
Alex Cabal 2020-11-24 12:43:22 -06:00
parent e56c6b4642
commit 8deafc7543
4 changed files with 36 additions and 5 deletions

23
lib/Manual.php Normal file
View file

@ -0,0 +1,23 @@
<?
class Manual{
public static function GetLatestVersion(){
$dirs = glob(MANUAL_PATH . '/*', GLOB_ONLYDIR);
sort($dirs);
return str_replace(MANUAL_PATH . '/', '', $dirs[sizeof($dirs) - 1]);
}
public static function GetRequestedVersion(){
try{
if(preg_match_all('|/manual/([0-9]+\.[0-9]+\.[0-9]+)|ius', $_SERVER['REQUEST_URI'], $matches)){
return($matches[1][0]);
}
else{
return null;
}
}
catch(\Exception $ex){
return null;
}
}
}

View file

@ -0,0 +1,7 @@
<? if(Manual::GetRequestedVersion() !== Manual::GetLatestVersion()){ ?>
<aside class="alert">
<p>This is an outdated version of the manual that is no longer current.</p>
<p><a href="/manual/latest">Read the latest version instead.</a></p>
</aside>
<? } ?>

View file

@ -643,6 +643,10 @@ figure code.css{
overflow-x: auto; overflow-x: auto;
} }
main.manual aside.alert p{
text-align: center;
}
@media(max-width: 1700px){ @media(max-width: 1700px){
main.manual > article{ main.manual > article{
margin-left: 10rem; margin-left: 10rem;

View file

@ -6,10 +6,7 @@ use function Safe\sort;
// Redirect to the latest version of the manual // Redirect to the latest version of the manual
$dirs = glob(MANUAL_PATH . '/*', GLOB_ONLYDIR); $currentManual = Manual::GetLatestVersion();
sort($dirs);
$currentManual = str_replace(WEB_ROOT, '', $dirs[sizeof($dirs) - 1]);
$url = HttpInput::GetString('url', true, ''); $url = HttpInput::GetString('url', true, '');
$url = preg_replace('|^/|ius', '', $url); $url = preg_replace('|^/|ius', '', $url);
@ -21,4 +18,4 @@ if($url != ''){
} }
http_response_code(302); http_response_code(302);
header('Location: ' . $currentManual . $url); header('Location: /manual/' . $currentManual . $url);