support redirects

This commit is contained in:
mappu 2015-04-05 16:35:54 +12:00
parent 0303019641
commit 092efca34d
3 changed files with 24 additions and 0 deletions

View File

@ -452,6 +452,18 @@ function buildcommon() {
// Done // Done
} }
function buildredirects($redirects) {
foreach($redirects as $oldname => $newname) {
ob_start();
?>
<meta http-equiv="refresh" content="0; url=<?=hesc($newname)?>.html">
<a href="<?=hesc($newname)?>.html">Moved &raquo;</a>
<?php
$page = ob_get_clean();
file_put_contents(BASEDIR.'wwwroot/'.$oldname.'.html', $page);
}
}
function main($args) { function main($args) {
$basedir = './'; $basedir = './';
$total = $args[0]; $total = $args[0];
@ -480,6 +492,9 @@ function main($args) {
if ($pos == 0) { if ($pos == 0) {
buildcommon(); buildcommon();
if (array_key_exists('redirect', $config)) {
buildredirects( $config['redirect'] );
}
} else { } else {
buildprojects($pos, array_decimate(listprojects(), $total, $pos)); buildprojects($pos, array_decimate(listprojects(), $total, $pos));
} }

View File

@ -6,3 +6,7 @@ index_thumb_w=90
index_thumb_h=32 index_thumb_h=32
; n.b. Recommend a multiple of the JPEG iDCT block size for index_thumb_h ; n.b. Recommend a multiple of the JPEG iDCT block size for index_thumb_h
[redirect]
; old project name = new project name
code.ivysaur.me=codesite

View File

@ -6,3 +6,8 @@ index_thumb_w=90
index_thumb_h=32 index_thumb_h=32
; n.b. Recommend a multiple of the JPEG iDCT block size for index_thumb_h ; n.b. Recommend a multiple of the JPEG iDCT block size for index_thumb_h
[redirect]
; old project name = new project name
old-project-name=example-project