mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-10 13:08:41 +00:00
2156cdffef
We add a new way to access blog page. Now there are 3. The switch now uses number to choose the way. 1 is for subdomain and 3 is for subfolder. 2 is for separated blog domain with its subfolder. For example, mike's link is blog.xxx.xxx/mike. Blog list page link on navbar will change by domain mode.
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
call_user_func(function() { // to prevent variable scope leak
|
|
|
|
Route::pattern('id', '[1-9][0-9]{0,9}');
|
|
Route::pattern('blog_username', '[a-zA-Z0-9_\-]{1,20}');
|
|
|
|
switch (UOJConfig::$data['switch']['blog-domain-mode']) {
|
|
case 1:
|
|
$domain = '{blog_username}.'.UOJConfig::$data['web']['blog']['host'];
|
|
$prefix = '';
|
|
break;
|
|
case 2:
|
|
$domain = UOJConfig::$data['web']['blog']['host'];
|
|
$prefix = '/{blog_username}';
|
|
break;
|
|
case 3:
|
|
$domain = UOJConfig::$data['web']['main']['host'];
|
|
$prefix = '/blog/{blog_username}';
|
|
break;
|
|
}
|
|
|
|
Route::group([
|
|
'domain' => UOJConfig::$data['web']['blog']['host']
|
|
], function() {
|
|
Route::any("/", '/blogs.php');
|
|
Route::any("/blogs/{id}", '/blog_show.php');
|
|
Route::any("/post/{id}", '/blog_show.php');
|
|
}
|
|
);
|
|
Route::group([
|
|
'domain' => $domain,
|
|
'onload' => function() {
|
|
UOJContext::setupBlog();
|
|
}
|
|
], function() use ($prefix) {
|
|
Route::any("$prefix/", '/subdomain/blog/index.php');
|
|
Route::any("$prefix/archive", '/subdomain/blog/archive.php');
|
|
Route::any("$prefix/aboutme", '/subdomain/blog/aboutme.php');
|
|
Route::any("$prefix/click-zan", '/click_zan.php');
|
|
Route::any("$prefix/post/{id}", '/subdomain/blog/blog.php');
|
|
Route::any("$prefix/slide/{id}", '/subdomain/blog/slide.php');
|
|
Route::any("$prefix/post/(?:{id}|new)/write", '/subdomain/blog/blog_write.php');
|
|
Route::any("$prefix/slide/(?:{id}|new)/write", '/subdomain/blog/slide_write.php');
|
|
Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php');
|
|
}
|
|
);
|
|
|
|
});
|