2016-07-18 16:39:37 +00:00
|
|
|
<?php
|
|
|
|
|
2017-11-25 04:00:00 +00:00
|
|
|
call_user_func(function() { // to prevent variable scope leak
|
2016-07-18 16:39:37 +00:00
|
|
|
|
2019-07-12 06:30:00 +00:00
|
|
|
Route::pattern('id', '[1-9][0-9]{0,9}');
|
2017-11-25 04:00:00 +00:00
|
|
|
Route::pattern('blog_username', '[a-zA-Z0-9_\-]{1,20}');
|
|
|
|
|
2019-07-12 06:30:00 +00:00
|
|
|
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;
|
2016-07-18 16:39:37 +00:00
|
|
|
}
|
2017-11-25 04:00:00 +00:00
|
|
|
|
2019-07-12 06:30:00 +00:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
);
|
2017-11-25 04:00:00 +00:00
|
|
|
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');
|
style(web): change link location of blog functions
When using sub-directory blog, the 'blogof' not looks so good.
And, there are duplicate 'blog' characters, which making people uncomfortable.
So, for sub-directory blog, use 'blog' instead of 'blogof'.
'blog' is not as a sub folder or type anymore, use 'post' instead.
BREAKING CHANGE: Due to the conflict of 'blog' sub-directory, when go to blog post,
now should use 'blogs/{id}'; but when subdomain mode is on, you can still use 'blog'
to access these blog posts. 'blogof' is no longer used, and you need to inform users
that blog link is changed, to avoid the inaccessbility.
2019-07-12 04:13:30 +00:00
|
|
|
Route::any("$prefix/post/{id}", '/subdomain/blog/blog.php');
|
2017-11-25 04:00:00 +00:00
|
|
|
Route::any("$prefix/slide/{id}", '/subdomain/blog/slide.php');
|
style(web): change link location of blog functions
When using sub-directory blog, the 'blogof' not looks so good.
And, there are duplicate 'blog' characters, which making people uncomfortable.
So, for sub-directory blog, use 'blog' instead of 'blogof'.
'blog' is not as a sub folder or type anymore, use 'post' instead.
BREAKING CHANGE: Due to the conflict of 'blog' sub-directory, when go to blog post,
now should use 'blogs/{id}'; but when subdomain mode is on, you can still use 'blog'
to access these blog posts. 'blogof' is no longer used, and you need to inform users
that blog link is changed, to avoid the inaccessbility.
2019-07-12 04:13:30 +00:00
|
|
|
Route::any("$prefix/post/(?:{id}|new)/write", '/subdomain/blog/blog_write.php');
|
2017-11-25 04:00:00 +00:00
|
|
|
Route::any("$prefix/slide/(?:{id}|new)/write", '/subdomain/blog/slide_write.php');
|
style(web): change link location of blog functions
When using sub-directory blog, the 'blogof' not looks so good.
And, there are duplicate 'blog' characters, which making people uncomfortable.
So, for sub-directory blog, use 'blog' instead of 'blogof'.
'blog' is not as a sub folder or type anymore, use 'post' instead.
BREAKING CHANGE: Due to the conflict of 'blog' sub-directory, when go to blog post,
now should use 'blogs/{id}'; but when subdomain mode is on, you can still use 'blog'
to access these blog posts. 'blogof' is no longer used, and you need to inform users
that blog link is changed, to avoid the inaccessbility.
2019-07-12 04:13:30 +00:00
|
|
|
Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php');
|
2017-11-25 04:00:00 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|