mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 01:22:23 -04:00
Add warnings pointing to latest manual version on all old manual pages
This commit is contained in:
parent
e56c6b4642
commit
8deafc7543
4 changed files with 36 additions and 5 deletions
23
lib/Manual.php
Normal file
23
lib/Manual.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
7
templates/OldManualVersionWarning.php
Normal file
7
templates/OldManualVersionWarning.php
Normal 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>
|
||||
<? } ?>
|
||||
|
|
@ -643,6 +643,10 @@ figure code.css{
|
|||
overflow-x: auto;
|
||||
}
|
||||
|
||||
main.manual aside.alert p{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media(max-width: 1700px){
|
||||
main.manual > article{
|
||||
margin-left: 10rem;
|
||||
|
|
|
@ -6,10 +6,7 @@ use function Safe\sort;
|
|||
|
||||
// Redirect to the latest version of the manual
|
||||
|
||||
$dirs = glob(MANUAL_PATH . '/*', GLOB_ONLYDIR);
|
||||
sort($dirs);
|
||||
|
||||
$currentManual = str_replace(WEB_ROOT, '', $dirs[sizeof($dirs) - 1]);
|
||||
$currentManual = Manual::GetLatestVersion();
|
||||
|
||||
$url = HttpInput::GetString('url', true, '');
|
||||
$url = preg_replace('|^/|ius', '', $url);
|
||||
|
@ -21,4 +18,4 @@ if($url != ''){
|
|||
}
|
||||
|
||||
http_response_code(302);
|
||||
header('Location: ' . $currentManual . $url);
|
||||
header('Location: /manual/' . $currentManual . $url);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue